프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 8614f701

이력 | 보기 | 이력해설 | 다운로드 (250 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
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
370
            SelectionSet.Instance.UnSelect(this);
371

    
372
            Button content = (sender as Button);
373
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
374

    
375
            DeleteItem(item);
376
        }
377

    
378
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
379

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

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

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

    
411
        
412

    
413
        private void timercallback(Object o)
414
        {
415
            Stopwatch sw = new Stopwatch();
416
            sw.Start();
417
            TempFile.TempFileAdd();
418
            sw.Stop();
419

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

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

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

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

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

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

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

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

    
509
            #region 페이지가 벗어난 경우
510

    
511
            if (BalancePoint < 1)
512
            {
513
                BalancePoint = 1;
514
                ViewerDataModel.Instance.PageBalanceNumber = 0;
515
            }
516

    
517
            if (pageNavigator.PageCount < BalancePoint)
518
            {
519
                BalancePoint = pageNavigator.PageCount;
520
                ViewerDataModel.Instance.PageBalanceNumber = 0;
521
            }
522

    
523
            #endregion
524

    
525
            ViewerDataModel.Instance.PageNumber = BalancePoint;
526

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

    
537
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
538
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
539

    
540
            var defaultBitmapImage = new BitmapImage();
541
            defaultBitmapImage.BeginInit();
542
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
543
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
544
            defaultBitmapImage.UriSource = new Uri(uri);
545
            defaultBitmapImage.DecodePixelWidth = Convert.ToInt32(pageWidth * zoomAndPanControl.ContentScale);
546
            defaultBitmapImage.DecodePixelHeight = Convert.ToInt32(pageHeight * zoomAndPanControl.ContentScale);
547
            defaultBitmapImage.EndInit();
548

    
549
            ViewerDataModel.Instance.ImageViewPath = null;
550
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
551
            if (defaultBitmapImage.IsDownloading)
552
            {
553
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
554
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
555
                {                   
556
                    defaultBitmapImage.Freeze();                                        
557
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
558
                    ViewerDataModel.Instance.ImageViewWidth = pageWidth;
559
                    ViewerDataModel.Instance.ImageViewHeight = pageHeight;
560
                    mainPanel.UpdateLayout();
561
                    this.pageNavigator.ChangePage(e.PageNumber); 
562
                    
563
                    //image dispose
564
                    defaultBitmapImage = null;
565
                    GC.Collect();
566
                };
567
            }
568

    
569
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
570
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
571

    
572

    
573
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
574
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
575
            inkBoard.Width = zoomAndPanCanvas.Width;
576
            inkBoard.Height = zoomAndPanCanvas.Height;
577

    
578

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

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

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

    
625
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
626
                    var defaultBitmapImage_Compare = new BitmapImage();
627
                    defaultBitmapImage_Compare.BeginInit();
628
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
629
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
630
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
631
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
632
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
633
                    defaultBitmapImage_Compare.EndInit();
634

    
635
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
636

    
637
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
638
                    zoomAndPanControl.ZoomTo(new Rect
639
                    {
640
                        X = 0,
641
                        Y = 0,
642
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
643
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
644
                    });
645

    
646
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
647
                    if (defaultBitmapImage_Compare.IsDownloading)
648
                    {
649
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
650
                        {
651
                            defaultBitmapImage_Compare.Freeze();
652
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
653
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
654
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
655
                            ComparePanel.UpdateLayout();
656
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
657
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
658

    
659
                            zoomAndPanControl.ZoomTo(new Rect
660
                            {
661
                                X = 0,
662
                                Y = 0,
663
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
664
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
665
                            });
666

    
667
                            //defaultBitmapImage_Compare dispose
668
                            defaultBitmapImage_Compare = null;
669
                            GC.Collect();
670
                        };
671
                    }
672
                }
673
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
674
            }
675

    
676
        }
677

    
678
        /// <summary>
679
        /// called after page is changed
680
        /// </summary>
681
        /// <param name="sender"></param>
682
        /// <param name="e"></param>
683
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
684
        {
685
            if (zoomAndPanCanvas2.Width.IsNaN())
686
            {
687
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
688
            }
689

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

    
715
            /// fire selection event
716
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
717
            this.gridViewMarkup.UnselectAll();
718
            this.gridViewMarkup.Select(gridSelectionItem);
719

    
720
            if (!testPanel2.IsHidden)
721
            {
722
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
723
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
724
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
725

    
726
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
727
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
728

    
729

    
730
                foreach (var item in gridSelectionRevItem)
731
                {
732
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
733
                    {
734
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
735
                    });
736
                }
737
            }
738

    
739
            var instanceMain = this.ParentOfType<MainWindow>();
740
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
741
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
742

    
743
            instanceMain.dzTopMenu.rotateOffSet = 0;
744
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
745
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
746

    
747
            SetCommentPages(true);
748
        }
749

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

    
776
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
777
        {
778
            if (e.MiddleButton == MouseButtonState.Pressed)
779
            {
780

    
781
            }
782
            e.Handled = true;
783
            if (e.Delta > 0)
784
            {
785
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
786
                ZoomIn(currentContentMousePoint);
787
            }
788
            else
789
            {
790
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
791
                ZoomOut(currentContentMousePoint);
792
            }
793
        }
794

    
795
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
796
        {
797
            e.Handled = true;
798
            if (e.Delta > 0)
799
            {
800
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
801
                ZoomIn_Sync(currentContentMousePoint);
802
            }
803
            else
804
            {
805
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
806
                ZoomOut_Sync(currentContentMousePoint);
807
            }
808
        }
809

    
810
        #region ZoomIn & ZoomOut
811

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

    
818
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
819
        {
820
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
821
                zoomAndPanControl.ContentZoomFocusY));
822
        }
823

    
824

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

    
838
            if (zoomAndPanControl2 != null && Sync.IsChecked)
839
            {
840
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
841
            }
842
        }
843

    
844
        private void ZoomIn(Point contentZoomCenter)
845
        {
846
            if (zoomAndPanControl.ContentScale > 0.19)
847
            {
848
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
849
            }
850
            else
851
            {
852
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
853
            }
854

    
855
            if (zoomAndPanControl2 != null && Sync.IsChecked)
856
            {
857
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
858
            }
859

    
860
        }
861

    
862
        private void ZoomOut_Sync(Point contentZoomCenter)
863
        {
864
            if (zoomAndPanControl2.ContentScale > 0.39)
865
            {
866
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
867
            }
868
            else
869
            {
870
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
871
            }
872

    
873
            if (Sync.IsChecked)
874
            {
875
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
876
            }
877
        }
878

    
879
        private void ZoomIn_Sync(Point contentZoomCenter)
880
        {
881
            if (zoomAndPanControl2.ContentScale > 0.19)
882
            {
883
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
884
            }
885
            else
886
            {
887
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
888
            }
889

    
890
            if (Sync.IsChecked)
891
            {
892
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
893
            }
894
        }
895

    
896
        private void ZoomOut()
897
        {
898
            zoomAndPanControl.ContentScale -= 0.1;
899
            //if (zoomAndPanControl2 != null)
900
            //{
901
            //    zoomAndPanControl2.ContentScale -= 0.1;
902
            //}
903
        }
904

    
905
        private void ZoomIn()
906
        {
907
            zoomAndPanControl.ContentScale += 0.1;
908
            //if (zoomAndPanControl2 != null)
909
            //{
910
            //    zoomAndPanControl2.ContentScale += 0.1;
911
            //}
912
        }
913

    
914
        #endregion
915

    
916
        private void init()
917
        {
918
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
919
            {
920

    
921
                ControlList.Clear();
922
                listBox.Items.Clear();
923
                selected_item.Clear();
924

    
925
                (item as IMarkupCommonData).IsSelected = false;
926
            }
927

    
928
        }
929

    
930
        private HitTestResultBehavior MyCallback(HitTestResult result)
931
        {
932
            //this.cursor = Cursors.UpArrow;
933
            var element = result.VisualHit;
934
            while (element != null && !(element is CommentUserInfo))
935
                element = VisualTreeHelper.GetParent(element);
936

    
937
            if (element == null)
938
            {
939
                return HitTestResultBehavior.Stop;
940
            }
941
            else
942
            {
943
                if (element is CommentUserInfo)
944
                {
945
                    if (!hitList.Contains(element))
946
                    {
947
                        hitList.Add((CommentUserInfo)element);
948
                    }
949
                    else
950
                    {
951
                        return HitTestResultBehavior.Stop;
952
                    }
953
                }
954
            }
955
            return HitTestResultBehavior.Continue;
956
        }
957

    
958
        public void ReleaseSelectPath()
959
        {
960
            if (SelectionPath == null)
961
            {
962
                SelectionPath = new Path();
963
                SelectionPath.Name = "";
964
            }
965
            if (SelectionPath.Name != "")
966
            {
967
                SelectionPath.Name = "None";
968
            }
969
            SelectionPath.Opacity = 0.01;
970
            SelectionPath.RenderTransform = null;
971
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
972
        }
973

    
974
        #region 컨트롤 초기화 
975
        public void Control_Init(object control)
976
        {
977
            if (L_Size != 0 && (control as IPath) != null)
978
            {
979
                (control as IPath).LineSize = L_Size;
980
                L_Size = 0;
981
            }
982

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

    
1069
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1070
        {
1071
            //Control_Init(e.Source);
1072
        }
1073
        //private Window _dragdropWindow = null;
1074

    
1075
        [DllImport("user32.dll")]
1076
        [return: MarshalAs(UnmanagedType.Bool)]
1077
        internal static extern bool GetCursorPos(ref Win32Point pt);
1078

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

    
1096

    
1097
               if (this._dragdropWindow != null)
1098
               {
1099
                   this._dragdropWindow.Close();
1100
                   this._dragdropWindow = null;
1101
               }
1102

    
1103
               symbol_id = id;
1104
               symbol_group_id = group_id;
1105
               symbol_SelectedIndex = SelectedIndex;
1106
               symbol_Data = Data_;
1107
               symbol_img = img;
1108

    
1109

    
1110
               CreateDragDropWindow2(img);
1111
              
1112
    }
1113

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

    
1134
            Win32Point w32Mouse = new Win32Point();
1135
            GetCursorPos(ref w32Mouse);
1136

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

    
1149
                Point currentPos = e.GetPosition(rect);
1150

    
1151
                floatingTip.HorizontalOffset = currentPos.X + 20;
1152
                floatingTip.VerticalOffset = currentPos.Y;
1153
            }
1154

    
1155
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1156
            
1157
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1158
            {
1159
                SetCursor();
1160
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1161
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1162

    
1163
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1164
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1165
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1166

    
1167
                if (Sync.IsChecked)
1168
                {
1169
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1170
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1171
                }
1172
            }
1173

    
1174
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1175
            {
1176
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1177
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1178
                SetCursor();
1179

    
1180
                if (currentControl != null)
1181
                {
1182
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1183
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1184
                    //강인구 추가
1185
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1186

    
1187
                    if ((currentControl as IPath) != null)
1188
                    {
1189
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1190
                    }
1191
                    if ((currentControl as LineControl) != null)
1192
                    {
1193
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1194
                    }
1195

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

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

    
1314
                        case ControlType.ArcLine:
1315
                            {
1316
                                var control = currentControl as ArcControl;
1317
                                if (control != null)
1318
                                {
1319
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1320
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1321
                                }
1322
                            }
1323
                            break;
1324

    
1325
                        case ControlType.ArcArrow:
1326
                            {
1327
                                var control = currentControl as ArrowArcControl;
1328
                                if (control != null)
1329
                                {
1330
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1331
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1332
                                }
1333
                            }
1334
                            break;
1335

    
1336
                        case ControlType.ArrowMultiLine:
1337
                            {
1338
                                var control = currentControl as ArrowControl_Multi;
1339
                                if (control != null)
1340
                                {
1341
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1342
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1343
                                }
1344
                            }
1345
                            break;
1346

    
1347
                        case ControlType.Circle:
1348
                            {
1349
                                if (currentControl != null)
1350
                                {
1351
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1352
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1353
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1354
                                }
1355
                            }
1356
                            break;
1357

    
1358
                        case ControlType.PolygonCloud:
1359
                            {
1360
                                var control = currentControl as CloudControl;
1361
                                if (control != null)
1362
                                {
1363
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1364
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1365
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1366
                                }
1367
                            }
1368
                            break;
1369

    
1370
                        case ControlType.Triangle:
1371
                            {
1372
                                var control = currentControl as TriControl;
1373
                                if (control != null)
1374
                                {
1375
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1376
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1377
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1378
                                }
1379
                            }
1380
                            break;
1381

    
1382
                        case ControlType.ImgControl:
1383
                            {
1384
                                var control = currentControl as ImgControl;
1385
                                if (control != null)
1386
                                {
1387
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1388
                                }
1389
                            }
1390
                            break;
1391

    
1392
                        case ControlType.Date:
1393
                            {
1394
                                var control = currentControl as DateControl;
1395
                                if (control != null)
1396
                                {
1397
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1398
                                }
1399
                            }
1400
                            break;
1401

    
1402
                        case ControlType.ArrowTextControl:
1403
                        case ControlType.ArrowTransTextControl:
1404
                        case ControlType.ArrowTextBorderControl:
1405
                        case ControlType.ArrowTransTextBorderControl:
1406
                        case ControlType.ArrowTextCloudControl:
1407
                        case ControlType.ArrowTransTextCloudControl:
1408
                            {
1409
                                var control = currentControl as ArrowTextControl;
1410
                                if (control != null)
1411
                                {
1412
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1413
                                }
1414
                            }
1415
                            break;
1416
                        case ControlType.PolygonControl:
1417
                        case ControlType.ChainLine:
1418
                            {
1419
                                var control = currentControl as PolygonControl;
1420
                                if (control != null)
1421
                                {
1422
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1423
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1424
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1425
                                }
1426
                            }
1427
                            break;
1428
                        case ControlType.Sign:
1429
                            {
1430
                                var control = currentControl as SignControl;
1431
                                if (control != null)
1432
                                {
1433
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1434
                                }
1435
                            }
1436
                            break;
1437
                        case ControlType.Symbol:
1438
                            {
1439
                                var control = currentControl as SymControl;
1440
                                if (control != null)
1441
                                {
1442
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1443
                                }
1444
                            }
1445
                            break;
1446
                        case ControlType.Stamp:
1447
                            {
1448
                                var control = currentControl as SymControlN;
1449
                                if (control != null)
1450
                                {
1451
                                    if (control.STAMP != null)
1452
                                    {
1453
                                        control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1454
                                    }
1455
                                    else
1456
                                    {
1457
                                        currentControl = null;
1458
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1459
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1460
                                    }
1461
                                }                                    
1462
                            }
1463
                            break;
1464
                        case ControlType.Rectangle:
1465
                        case ControlType.Mark:
1466
                            {
1467
                                var control = currentControl as RectangleControl;
1468
                                if (control != null)
1469
                                {
1470
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1471
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1472
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1473
                                }
1474
                            }
1475
                            break;
1476
                        case ControlType.PenControl:
1477
                            {
1478
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1479
                                //inkBoard.Strokes.Add(stroke);
1480
                            }
1481
                            break;
1482
                        default:
1483
                            break;
1484
                    }
1485
                }
1486
            }
1487
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1488
            {
1489
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1490
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1491
                SetCursor();
1492
                if (currentControl == null)
1493
                {
1494
                    switch (controlType)
1495
                    {
1496
                        case ControlType.PenControl:
1497
                            {
1498
                                if (inkBoard.Tag.ToString() == "Ink")
1499
                                {
1500
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1501
                                }
1502
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1503
                                {
1504
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1505
                                }
1506
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1507
                                {
1508
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1509
                                }
1510

    
1511
                                //inkBoard.Strokes.Add(stroke);
1512
                            }
1513
                            break;
1514
                    }
1515
                    return;
1516
                }
1517
            }
1518
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1519
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1520
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1521
            {
1522
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1523

    
1524
                if (isDraggingSelectionRect)
1525
                {
1526
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1527
                    e.Handled = true;
1528
                }
1529
                else if (isLeftMouseButtonDownOnWindow)
1530
                {
1531
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1532
                    double dragDistance = Math.Abs(dragDelta.Length);
1533

    
1534
                    if (dragDistance > DragThreshold)
1535
                    {
1536
                        isDraggingSelectionRect = true;
1537
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1538
                    }
1539

    
1540
                    e.Handled = true;
1541
                }
1542

    
1543
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1544
                {
1545
                }
1546
                else
1547
                {
1548
                    e.Handled = true;
1549
                }
1550
            }
1551
            /*
1552
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1553
            { //symbol      
1554
                if(_dragdropWindow != null)
1555
                {
1556
                    Win32Point w32Mouse = new Win32Point();
1557
                    GetCursorPos(ref w32Mouse);
1558

    
1559
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1560
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1561
                }                
1562
            }
1563
            */
1564
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1565
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1566
            {
1567
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1568
                if(control != null)
1569
                {
1570
                    this.cursor = Cursors.Hand;
1571
                    SetCursor();
1572
                }
1573
                else
1574
                {
1575
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1576
                    SetCursor();
1577
                }
1578
            }
1579
            else
1580
            {
1581
            }
1582
        }
1583

    
1584
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1585
        {
1586
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1587
            {
1588
                SetCursor();
1589
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1590
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1591

    
1592
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1593

    
1594
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1595
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1596

    
1597
                if (Sync.IsChecked)
1598
                {
1599
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1600
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1601
                }
1602
            }
1603
        }
1604

    
1605
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1606

    
1607
        private EllipseGeometry hitArea = new EllipseGeometry();
1608

    
1609
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1610
        {
1611
            IsDrawing = false;
1612

    
1613
            if (mouseHandlingMode != MouseHandlingMode.None)
1614
            {
1615
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1616
                {
1617
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1618

    
1619
                    SetCursor();
1620

    
1621
                    switch (controlType)
1622
                    {
1623
                        case ControlType.None:
1624
                            break;
1625
                        case ControlType.Rectangle:
1626
                            {
1627

    
1628
                            }
1629
                            break;
1630
                        case ControlType.PenControl:
1631
                            {
1632

    
1633
                            }
1634
                            break;
1635
                        default:
1636
                            break;
1637
                    }                    
1638
                }
1639
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1640
                {
1641
                    if (isLeftMouseButtonDownOnWindow)
1642
                    {
1643
                        bool wasDragSelectionApplied = false;
1644

    
1645
                        if (isDraggingSelectionRect)
1646
                        {
1647
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1648
                            {
1649
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1650
                                mouseHandlingMode = MouseHandlingMode.None;
1651
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1652
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1653
                                Set_Symbol_Capture(endPoint);
1654
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1655
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1656
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1657
                            }
1658
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1659
                            {
1660
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1661
                                mouseHandlingMode = MouseHandlingMode.None;
1662
                                Set_Capture();
1663

    
1664
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1665
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1666
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1667
                            }
1668
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1669
                            {
1670
                                ApplyDragSelectionRect();
1671
                            }
1672
                            else
1673
                            {
1674
                                double x = Canvas.GetLeft(dragZoomBorder);
1675
                                double y = Canvas.GetTop(dragZoomBorder);
1676
                                double width = dragZoomBorder.Width;
1677
                                double height = dragZoomBorder.Height;
1678
                                Rect dragRect = new Rect(x, y, width, height);
1679

    
1680
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1681

    
1682
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1683
                            }
1684

    
1685
                            isDraggingSelectionRect = false;
1686
                            e.Handled = true;
1687
                            wasDragSelectionApplied = true;
1688
                        }
1689

    
1690
                        if (isLeftMouseButtonDownOnWindow)
1691
                        {
1692
                            isLeftMouseButtonDownOnWindow = false;
1693
                            this.ReleaseMouseCapture();
1694
                            e.Handled = true;
1695
                        }
1696

    
1697
                        if (!wasDragSelectionApplied)
1698
                        {
1699
                            init();
1700
                        }
1701
                    }
1702
                }
1703
                else if (e.RightButton == MouseButtonState.Pressed)
1704
                {
1705
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1706
                    SetCursor();
1707
                }
1708

    
1709
                zoomAndPanControl.ReleaseMouseCapture();
1710

    
1711

    
1712
                e.Handled = true;
1713
            }
1714
            else
1715
            {
1716
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1717
                SetCursor();
1718
            }
1719

    
1720
            ///mouseButtonDown = MouseButton.Left;
1721
            //controlType = ControlType.SingleLine;
1722
        }
1723

    
1724
        public void Set_Symbol_Capture(Point endPoint)
1725
        {       
1726
            double x = canvasDrawingMouseDownPoint.X;
1727
            double y = canvasDrawingMouseDownPoint.Y;
1728
            if(x > endPoint.X)
1729
            {
1730
                x = endPoint.X;
1731
                y = endPoint.Y;
1732
            }
1733

    
1734
            double width = dragCaptureBorder.Width;
1735
            double height = dragCaptureBorder.Height;
1736

    
1737
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1738

    
1739
            if (x < 0)
1740
            {
1741
                width += x;
1742
                x = 0;
1743
            }
1744
            if (y < 0)
1745
            {
1746
                height += y;
1747
                y = 0;
1748

    
1749
                width = (int)canvasImage.PixelWidth - x;
1750
            }
1751
            if (x + width > canvasImage.PixelWidth)
1752
            {
1753
                width = (int)canvasImage.PixelWidth - x;
1754
            }
1755
            if (y + height > canvasImage.PixelHeight)
1756
            {
1757
                height = (int)canvasImage.PixelHeight - y;
1758
            }
1759
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1760

    
1761
            string uri = "";
1762
            if (userData.COMPANY != "EXT")
1763
            {
1764
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1765
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1766
            }
1767
            else
1768
            {
1769
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1770
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1771
            }
1772

    
1773
            var defaultBitmapImage = new BitmapImage();
1774
            defaultBitmapImage.BeginInit();
1775
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1776
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1777
            defaultBitmapImage.UriSource = new Uri(uri);
1778
            defaultBitmapImage.EndInit();
1779

    
1780
            //GC.Collect();
1781

    
1782
            if (defaultBitmapImage.IsDownloading)
1783
            {
1784
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1785
                {
1786
                    defaultBitmapImage.Freeze();
1787
                    //GC.Collect();
1788
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1789
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1790
                };
1791
            }
1792
        }
1793

    
1794
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1795
        {
1796
            ///mouseButtonDown = MouseButton.Left;
1797
        }
1798

    
1799
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1800
        {
1801
            ///mouseButtonDown = MouseButton.Left;
1802
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1803
        }
1804

    
1805
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1806
        {
1807

    
1808
        }
1809

    
1810
        /// <summary>
1811
        /// select items by dragging
1812
        /// </summary>
1813
        private void ApplyDragSelectionRect()
1814
        {
1815
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1816

    
1817
            double x = Canvas.GetLeft(dragSelectionBorder);
1818
            double y = Canvas.GetTop(dragSelectionBorder);
1819
            double width = dragSelectionBorder.Width;
1820
            double height = dragSelectionBorder.Height;
1821
            Boolean Flag = false;
1822
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1823
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1824

    
1825
            Rect dragRect = new Rect(x, y, width, height);
1826
            ///dragRect.Inflate(width / 10, height / 10);
1827

    
1828
            foreach (var item in Items)
1829
            {
1830
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1831

    
1832
                if (Flag)
1833
                {
1834
                    adornerSet.Add(item);
1835
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1836
                    Control_Style(item);
1837
                }
1838
            }
1839
            if (adornerSet.Count > 0)
1840
            {
1841
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1842
                SelectLayer.Children.Add(final);
1843
            }
1844
        }
1845

    
1846
        private void InitDragSelectionRect(Point pt1, Point pt2)
1847
        {
1848
            //캡쳐 중
1849
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1850
            {
1851
                dragCaptureBorder.Visibility = Visibility.Visible;
1852
            }
1853
            //선택 중
1854
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1855
            {
1856

    
1857
                dragSelectionBorder.Visibility = Visibility.Visible;
1858
            }
1859
            else
1860
            {
1861
                dragZoomBorder.Visibility = Visibility.Visible;
1862
            }
1863
            UpdateDragSelectionRect(pt1, pt2);
1864
        }
1865

    
1866
        /// <summary>
1867
        /// Update the position and size of the rectangle used for drag selection.
1868
        /// </summary>
1869
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1870
        {
1871
            double x, y, width, height;
1872

    
1873
            //
1874
            // Determine x,y,width and height of the rect inverting the points if necessary.
1875
            // 
1876

    
1877
            if (pt2.X < pt1.X)
1878
            {
1879
                x = pt2.X;
1880
                width = pt1.X - pt2.X;
1881
            }
1882
            else
1883
            {
1884
                x = pt1.X;
1885
                width = pt2.X - pt1.X;
1886
            }
1887

    
1888
            if (pt2.Y < pt1.Y)
1889
            {
1890
                y = pt2.Y;
1891
                height = pt1.Y - pt2.Y;
1892
            }
1893
            else
1894
            {
1895
                y = pt1.Y;
1896
                height = pt2.Y - pt1.Y;
1897
            }
1898

    
1899
            //
1900
            // Update the coordinates of the rectangle used for drag selection.
1901
            //
1902
            //캡쳐 중
1903
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1904
            {
1905
                Canvas.SetLeft(dragCaptureBorder, x);
1906
                Canvas.SetTop(dragCaptureBorder, y);
1907
                dragCaptureBorder.Width = width;
1908
                dragCaptureBorder.Height = height;
1909
            }
1910
            //선택 중
1911
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1912
            {
1913
                Canvas.SetLeft(dragSelectionBorder, x);
1914
                Canvas.SetTop(dragSelectionBorder, y);
1915
                dragSelectionBorder.Width = width;
1916
                dragSelectionBorder.Height = height;
1917
            }
1918
            else
1919
            {
1920
                Canvas.SetLeft(dragZoomBorder, x);
1921
                Canvas.SetTop(dragZoomBorder, y);
1922
                dragZoomBorder.Width = width;
1923
                dragZoomBorder.Height = height;
1924
            }
1925
        }
1926

    
1927
        private void drawingPannelRotate(double angle)
1928
        {
1929
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1930
            rotate.Angle = angle;
1931
            var rotationNum = Math.Abs((rotate.Angle / 90));
1932

    
1933
            if (angle == 90 || angle == 270)
1934
            {
1935
                double emptySize = zoomAndPanCanvas.Width;
1936
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1937
                zoomAndPanCanvas.Height = emptySize;
1938
            }
1939
            if (angle == 0)
1940
            {
1941
                translate.X = 0;
1942
                translate.Y = 0;
1943
            }
1944
            else if (angle == 90)
1945
            {
1946
                translate.X = zoomAndPanCanvas.Width;
1947
                translate.Y = 0;
1948
            }
1949
            else if (angle == 180)
1950
            {
1951
                translate.X = zoomAndPanCanvas.Width;
1952
                translate.Y = zoomAndPanCanvas.Height;
1953
            }
1954
            else
1955
            {
1956
                translate.X = 0;
1957
                translate.Y = zoomAndPanCanvas.Height;
1958
            }
1959

    
1960
            zoomAndPanControl.RotationAngle = rotate.Angle;
1961

    
1962

    
1963
            if (!testPanel2.IsHidden)
1964
            {
1965
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1966
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1967
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1968
            }
1969

    
1970
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1971
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1972
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1973
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1974
            ViewerDataModel.Instance.Angle = rotate.Angle;
1975
        }
1976

    
1977
        private void syncPannelRotate(double angle)
1978
        {
1979
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1980
            rotate.Angle = angle;
1981
            var rotationNum = Math.Abs((rotate.Angle / 90));
1982

    
1983
            if (angle == 90 || angle == 270)
1984
            {
1985
                double emptySize = zoomAndPanCanvas2.Width;
1986
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
1987
                zoomAndPanCanvas2.Height = emptySize;
1988
            }
1989
            if (angle == 0)
1990
            {
1991
                translate2.X = 0;
1992
                translate2.Y = 0;
1993
            }
1994
            else if (angle == 90)
1995
            {
1996
                translate2.X = zoomAndPanCanvas2.Width;
1997
                translate2.Y = 0;
1998
            }
1999
            else if (angle == 180)
2000
            {
2001
                translate2.X = zoomAndPanCanvas2.Width;
2002
                translate2.Y = zoomAndPanCanvas2.Height;
2003
            }
2004
            else
2005
            {
2006
                translate2.X = 0;
2007
                translate2.Y = zoomAndPanCanvas2.Height;
2008
            }
2009

    
2010
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2011
        }
2012

    
2013
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2014
        {
2015
            string Data_ = "";
2016

    
2017
            try
2018
            {
2019
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2020
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2021
                if (Data_ != null || Data_ != "")
2022
                {
2023
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2024
                }
2025
                else
2026
                {
2027
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2028
                }
2029

    
2030
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2031
                //{
2032
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2033
                //    STATE = 0,
2034
                //};
2035
                if (Data_ != null)
2036
                {
2037
                    Image img = new Image();
2038
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2039
                    if (Data_.Contains(".svg"))
2040
                    {
2041
                        byte[] imageData = null;
2042
                        DrawingImage image = null;
2043
                        using (System.Net.WebClient web = new System.Net.WebClient())
2044
                        {
2045
                            imageData = web.DownloadData(new Uri(Data_));
2046
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2047
                            image = SvgReader.Load(stream);
2048
                        }
2049
                        img.Source = image;
2050
                    }
2051
                    else
2052
                    {
2053
                        img.Source = new BitmapImage(new Uri(Data_));
2054
                    }
2055

    
2056
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2057
                    {
2058
                        PointSet = new List<Point>(),
2059
                        FilePath = Data_,
2060
                        ImageData = img.Source,
2061
                        StartPoint = canvasZoomPanningMouseDownPoint,
2062
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2063
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2064
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2065
                        canvasZoomPanningMouseDownPoint.Y),
2066
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2067
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2068
                    };
2069

    
2070
                    currentControl.PointSet = new List<Point>
2071
                                        {
2072
                                            currentControl.StartPoint,
2073
                                            currentControl.LeftBottomPoint,
2074
                                            currentControl.EndPoint,
2075
                                            currentControl.TopRightPoint,
2076
                                        };
2077
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2078
                    UndoData = new Undo_data()
2079
                    {
2080
                        IsUndo = false,
2081
                        Event = Event_Type.Create,
2082
                        EventTime = DateTime.Now,
2083
                        Markup_List = new List<Multi_Undo_data>()
2084
                    };
2085
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2086
                    {
2087
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2088
                    });
2089

    
2090
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2091
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2092
                    UndoData.Markup_List.Add(multi_Undo_Data);
2093
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2094

    
2095
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2096
                    currentControl.CommentID = Commons.shortGuid();
2097
                    currentControl.SymbolID = id;
2098
                    currentControl.GroupID = group_id;
2099
                    currentControl.ApplyTemplate();
2100
                    currentControl.SetImage();
2101

    
2102
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2103
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2104
                    SelectLayer.Children.Add(final);
2105
                }
2106
            }
2107
            catch (Exception ex)
2108
            {
2109
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2110
            }
2111
        }
2112

    
2113
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2114
        {            
2115
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2116
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2117
            {
2118
                set_option.Value = double.Parse(set_option.ContentText);
2119
            }
2120

    
2121
            ConvertInkControlToPolygon();
2122

    
2123
            ///TODO:
2124
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2125
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2126

    
2127
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2128
            {
2129
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2130
            }
2131
            /// up to here
2132

    
2133
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2134
            {
2135
                if (arrow_text as ArrowTextControl != null)
2136
                {
2137
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2138
                }
2139
            }
2140

    
2141
            //if (currentControl != null)
2142
            {
2143
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2144
                if (text_item_ != null)
2145
                {
2146
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2147
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2148
                    (text_item_ as TextControl).EnableEditing = false;
2149
                    currentControl = null;
2150
                }
2151

    
2152
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2153
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2154
                {
2155
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2156
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2157
                    currentControl = null;
2158
                }
2159
            }
2160

    
2161
            double Ang = 0;                                          
2162
            if (rotate.Angle != 0)
2163
            {
2164
                Ang = 360 - rotate.Angle;
2165
            }
2166

    
2167
            if (e.OriginalSource is System.Windows.Controls.Image)
2168
            {
2169
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2170
            }
2171
            /*
2172
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2173
            {                
2174
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2175
                if(symbol_id != null)
2176
                {
2177
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2178
                }                
2179
            }
2180

    
2181
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2182
            {
2183
                if (this._dragdropWindow != null)
2184
                {
2185
                    this._dragdropWindow.Close();
2186
                    this._dragdropWindow = null;
2187
                    symbol_id = null;
2188
                }
2189
            }
2190
            */
2191

    
2192
            if (e.LeftButton == MouseButtonState.Pressed)
2193
            {
2194
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2195
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2196

    
2197
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2198
                SetCursor();
2199

    
2200
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2201
            }
2202

    
2203
            if (e.MiddleButton == MouseButtonState.Pressed)
2204
            {
2205
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2206
                cursor = Cursors.SizeAll;
2207
                SetCursor();
2208
            }
2209
            if (e.RightButton == MouseButtonState.Pressed)
2210
            {
2211
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2212
                cursor = Cursors.SizeAll;
2213
                SetCursor();
2214
            }
2215
            else if (e.XButton1 == MouseButtonState.Pressed)
2216
            {
2217
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2218
                {
2219
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2220
                }
2221

    
2222
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2223

    
2224
            }
2225
            else if (e.XButton2 == MouseButtonState.Pressed)
2226
            {
2227
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2228
                {
2229
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2230
                }
2231
            }
2232

    
2233
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2234
            {
2235
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2236
                {
2237
                    if (SelectLayer.Children.Count == 0)
2238
                    {
2239
                        isLeftMouseButtonDownOnWindow = true;
2240
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2241
                    }
2242

    
2243
                    if (controlType == ControlType.None)
2244
                    {
2245
                        isLeftMouseButtonDownOnWindow = true;
2246
                    }
2247
                }
2248

    
2249
                /// 캡쳐 모드 설정
2250
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2251
                {
2252
                    dragCaptureBorder.Visibility = Visibility.Visible;
2253
                    isLeftMouseButtonDownOnWindow = true;
2254
                }
2255

    
2256
                /// 줌 모드 설정
2257
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2258
                {
2259
                    isLeftMouseButtonDownOnWindow = true;
2260
                }
2261

    
2262
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2263
                if (control != null)
2264
                {
2265
                    AdornerFinal final = null;
2266

    
2267
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2268
                    {
2269
                        /// 기존 selection 해제
2270
                        SelectionSet.Instance.UnSelect(this);
2271

    
2272
                        final = new AdornerFinal(control);
2273

    
2274
                        this.Control_Style(control);
2275

    
2276
                        if ((control as IPath) != null)
2277
                        {
2278
                            if ((control as IPath).LineSize != 0)
2279
                            {
2280
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2281
                            }
2282
                        }
2283
                        if ((control as IShapeControl) != null)
2284
                        {
2285
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2286
                            {
2287
                                ViewerDataModel.Instance.checkHatchShape = true;
2288
                            }
2289
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2290
                            {
2291
                                ViewerDataModel.Instance.checkFillShape = true;
2292
                            }
2293
                            else
2294
                            {
2295
                                ViewerDataModel.Instance.checkHatchShape = false;
2296
                                ViewerDataModel.Instance.checkFillShape = false;
2297
                            }
2298
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2299
                        }
2300

    
2301
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2302

    
2303
                        if ((control as TextControl) != null)
2304
                        {
2305
                            if(!((control as TextControl).EnableEditing)) {
2306
                                (control as TextControl).EnableEditing = true;
2307
                            }
2308

    
2309
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2310
                            {
2311
                                ViewerDataModel.Instance.checkTextStyle = true;
2312
                            }
2313
                            else
2314
                            {
2315
                                ViewerDataModel.Instance.checkTextStyle = false;
2316
                            }
2317

    
2318
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2319
                            {
2320
                                ViewerDataModel.Instance.checkTextStyle = true;
2321
                            }
2322
                            else
2323
                            {
2324
                                ViewerDataModel.Instance.checkTextStyle = false;
2325
                            }
2326
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2327
                            {
2328
                                ViewerDataModel.Instance.checkTextWeight = true;
2329
                            }
2330
                            else
2331
                            {
2332
                                ViewerDataModel.Instance.checkTextWeight = false;
2333
                            }
2334
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2335
                            {
2336
                                ViewerDataModel.Instance.checkUnderLine = true;
2337
                            }
2338
                            else
2339
                            {
2340
                                ViewerDataModel.Instance.checkUnderLine = false;
2341
                            }
2342
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2343
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2344

    
2345
                        }
2346
                        else if ((control as ArrowTextControl) != null)
2347
                        {
2348
                            if (!((control as ArrowTextControl).EnableEditing))
2349
                            {
2350
                                (control as ArrowTextControl).EnableEditing = true;
2351
                            }
2352
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2353
                            {
2354
                                ViewerDataModel.Instance.checkTextStyle = true;
2355
                            }
2356
                            else
2357
                            {
2358
                                ViewerDataModel.Instance.checkTextStyle = false;
2359
                            }
2360

    
2361
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2362
                            {
2363
                                ViewerDataModel.Instance.checkTextStyle = true;
2364
                            }
2365
                            else
2366
                            {
2367
                                ViewerDataModel.Instance.checkTextStyle = false;
2368
                            }
2369
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2370
                            {
2371
                                ViewerDataModel.Instance.checkTextWeight = true;
2372
                            }
2373
                            else
2374
                            {
2375
                                ViewerDataModel.Instance.checkTextWeight = false;
2376
                            }
2377
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2378
                            {
2379
                                ViewerDataModel.Instance.checkUnderLine = true;
2380
                            }
2381
                            else
2382
                            {
2383
                                ViewerDataModel.Instance.checkUnderLine = false;
2384
                            }
2385
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2386
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2387
                        }
2388
                        else if ((control as RectCloudControl) != null)
2389
                        {
2390
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2391
                        }
2392
                        else if ((control as CloudControl) != null)
2393
                        {
2394
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2395
                        }
2396
                    }
2397
                    else
2398
                    {
2399
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2400
                        SelectionSet.Instance.UnSelect(this);
2401
                        comment.Add(control);
2402

    
2403
                        Control_Style(control);
2404

    
2405
                        final = new AdornerFinal(comment);
2406
                    }
2407

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

    
2451
                switch (controlType)
2452
                {
2453
                    case ControlType.Coordinate:
2454
                        {
2455
                            if (e.LeftButton == MouseButtonState.Pressed)
2456
                            {
2457
                                if (currentControl is CoordinateControl)
2458
                                {
2459
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2460
                                    {
2461
                                        return;
2462
                                    }
2463

    
2464
                                    CreateCommand.Instance.Execute(currentControl);
2465

    
2466
                                    currentControl = null;
2467
                                    this.cursor = Cursors.Arrow;
2468
                                }
2469
                                else
2470
                                {
2471
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2472
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2473
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2474
                                    {
2475
                                        currentControl = null;
2476
                                        this.cursor = Cursors.Arrow;
2477
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2478
                                        return;
2479
                                    }
2480
                                    else
2481
                                    {
2482
                                        currentControl = new CoordinateControl
2483
                                        {
2484
                                            Background = new SolidColorBrush(Colors.Black),
2485
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2486
                                            ControlType = ControlType.Coordinate
2487
                                        };
2488

    
2489
                                        currentControl.CommentID = Commons.shortGuid();
2490
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2491
                                        currentControl.IsNew = true;
2492

    
2493
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2494

    
2495
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2496
                                    }
2497
                                }
2498
                            }
2499
                        }
2500
                        break;
2501
                    case ControlType.InsideWhite:
2502
                        {
2503
                            if (e.LeftButton == MouseButtonState.Pressed)
2504
                            {
2505
                                if (currentControl is InsideWhiteControl)
2506
                                {
2507
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2508
                                    {
2509
                                        return;
2510
                                    }
2511

    
2512
                                    CreateCommand.Instance.Execute(currentControl);
2513

    
2514
                                    currentControl = null;
2515
                                    this.cursor = Cursors.Arrow;
2516
                                }
2517
                                else
2518
                                {
2519
                                    currentControl = new InsideWhiteControl
2520
                                    {
2521
                                        Background = new SolidColorBrush(Colors.Black),
2522
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2523
                                        ControlType = ControlType.InsideWhite
2524
                                    };
2525

    
2526
                                    currentControl.CommentID = Commons.shortGuid();
2527
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2528
                                    currentControl.IsNew = true;
2529
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2530

    
2531
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2532
                                }
2533
                            }
2534
                        }
2535
                        break;
2536
                    case ControlType.OverlapWhite:
2537
                        {
2538
                            if (e.LeftButton == MouseButtonState.Pressed)
2539
                            {
2540
                                if (currentControl is OverlapWhiteControl)
2541
                                {
2542
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2543
                                    {
2544
                                        return;
2545
                                    }
2546

    
2547
                                    CreateCommand.Instance.Execute(currentControl);
2548

    
2549
                                    currentControl = null;
2550
                                    this.cursor = Cursors.Arrow;
2551
                                }
2552
                                else
2553
                                {
2554
                                    currentControl = new OverlapWhiteControl
2555
                                    {
2556
                                        Background = new SolidColorBrush(Colors.Black),
2557
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2558
                                        ControlType = ControlType.OverlapWhite
2559
                                    };
2560

    
2561
                                    currentControl.CommentID = Commons.shortGuid();
2562
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2563
                                    currentControl.IsNew = true;
2564
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2565

    
2566
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2567
                                }
2568
                            }
2569
                        }
2570
                        break;
2571
                    case ControlType.ClipWhite:
2572
                        {
2573
                            if (e.LeftButton == MouseButtonState.Pressed)
2574
                            {
2575
                                if (currentControl is ClipWhiteControl)
2576
                                {
2577
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2578
                                    {
2579
                                        return;
2580
                                    }
2581

    
2582
                                    CreateCommand.Instance.Execute(currentControl);
2583

    
2584
                                    currentControl = null;
2585
                                    this.cursor = Cursors.Arrow;
2586
                                }
2587
                                else
2588
                                {
2589
                                    currentControl = new ClipWhiteControl
2590
                                    {
2591
                                        Background = new SolidColorBrush(Colors.Black),
2592
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2593
                                        ControlType = ControlType.ClipWhite
2594
                                    };
2595

    
2596
                                    currentControl.CommentID = Commons.shortGuid();
2597
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2598
                                    currentControl.IsNew = true;
2599
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2600

    
2601
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2602
                                }
2603
                            }
2604
                        }
2605
                        break;
2606
                    case ControlType.Rectangle:
2607
                        {
2608
                            if (e.LeftButton == MouseButtonState.Pressed)
2609
                            {
2610
                                if (currentControl is RectangleControl)
2611
                                {
2612
                                    //20180906 LJY TEST IsRotationDrawingEnable
2613
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2614
                                    {
2615
                                        return;
2616
                                    }
2617

    
2618
                                    CreateCommand.Instance.Execute(currentControl);
2619
                                    currentControl = null;
2620
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2621
                                }
2622
                                else
2623
                                {
2624
                                    currentControl = new RectangleControl
2625
                                    {
2626
                                        Background = new SolidColorBrush(Colors.Black),
2627
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2628
                                        ControlType = ControlType.Rectangle
2629
                                    };
2630

    
2631
                                    currentControl.CommentID = Commons.shortGuid();
2632
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2633
                                    currentControl.IsNew = true;
2634
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2635

    
2636
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2637
                                }
2638
                            }
2639
                        }
2640
                        break;
2641
                    case ControlType.RectCloud:
2642
                        {
2643
                            if (e.LeftButton == MouseButtonState.Pressed)
2644
                            {
2645
                                if (currentControl is RectCloudControl)
2646
                                {
2647
                                    //20180906 LJY TEST IsRotationDrawingEnable
2648
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2649
                                    {
2650
                                        return;
2651
                                    }
2652

    
2653
                                    CreateCommand.Instance.Execute(currentControl);
2654

    
2655
                                    currentControl = null;
2656
                                
2657
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2658
                                }
2659
                                else
2660
                                {
2661
                                    currentControl = new RectCloudControl
2662
                                    {
2663
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2664
                                        ControlType = ControlType.RectCloud,
2665
                                        Background = new SolidColorBrush(Colors.Black)
2666
                                    };
2667

    
2668
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2669
                                    currentControl.CommentID = Commons.shortGuid();
2670
                                    currentControl.IsNew = true;
2671
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2672
                                }
2673
                            }
2674
                        }
2675
                        break;
2676
                    case ControlType.Circle:
2677
                        {
2678
                            if (e.LeftButton == MouseButtonState.Pressed)
2679
                            {
2680
                                if (currentControl is CircleControl)
2681
                                {
2682
                                    //20180906 LJY TEST IsRotationDrawingEnable
2683
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2684
                                    {
2685
                                        return;
2686
                                    }
2687

    
2688
                                    CreateCommand.Instance.Execute(currentControl);
2689

    
2690
                                    currentControl = null;
2691
                                }
2692
                                else
2693
                                {
2694
                                    currentControl = new CircleControl
2695
                                    {
2696
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2697
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2698
                                        Background = new SolidColorBrush(Colors.Black)
2699
                                    };
2700

    
2701
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2702
                                    currentControl.CommentID = Commons.shortGuid();
2703
                                    currentControl.IsNew = true;
2704
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2705
                                }
2706
                            }
2707
                        }
2708
                        break;
2709
                    case ControlType.Triangle:
2710
                        {
2711
                            if (e.LeftButton == MouseButtonState.Pressed)
2712
                            {
2713
                                if (currentControl is TriControl)
2714
                                {
2715
                                    var content = currentControl as TriControl;
2716
                                    if (content.MidPoint == new Point(0, 0))
2717
                                    {
2718
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2719
                                    }
2720
                                    else
2721
                                    {
2722
                                        //20180906 LJY TEST IsRotationDrawingEnable
2723
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2724
                                        {
2725
                                            return;
2726
                                        }
2727

    
2728
                                        CreateCommand.Instance.Execute(currentControl);
2729

    
2730
                                        currentControl = null;
2731
                                    }
2732
                                }
2733
                                else
2734
                                {
2735
                                    currentControl = new TriControl
2736
                                    {
2737
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2738
                                        Background = new SolidColorBrush(Colors.Black),
2739
                                    };
2740

    
2741
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2742
                                    currentControl.CommentID = Commons.shortGuid();
2743
                                    currentControl.IsNew = true;
2744
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2745
                                }
2746
                            }
2747
                        }
2748
                        break;
2749
                    case ControlType.CancelLine:
2750
                    case ControlType.SingleLine:
2751
                    case ControlType.ArrowLine:
2752
                    case ControlType.TwinLine:
2753
                    case ControlType.DimLine:
2754
                        {
2755
                            if (e.LeftButton == MouseButtonState.Pressed)
2756
                            {
2757
                                if (currentControl is LineControl)
2758
                                {
2759
                                    //20180906 LJY TEST IsRotationDrawingEnable
2760
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2761
                                    {
2762
                                        return;
2763
                                    }
2764

    
2765
                                    CreateCommand.Instance.Execute(currentControl);
2766
                                    currentControl = null;
2767
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2768
                                }
2769
                                else
2770
                                {
2771
                                    currentControl = new LineControl
2772
                                    {
2773
                                        ControlType = this.controlType,
2774
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2775
                                        Background = new SolidColorBrush(Colors.Black)
2776
                                    };
2777

    
2778
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2779
                                    currentControl.CommentID = Commons.shortGuid();
2780
                                    currentControl.IsNew = true;
2781
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2782
                                    this.MainAngle.Visibility = Visibility.Visible;
2783
                                }
2784
                            }
2785
                        }
2786
                        break;
2787
                    case ControlType.PolygonControl:
2788
                        {
2789
                            if (currentControl is PolygonControl)
2790
                            {
2791
                                var control = currentControl as PolygonControl;
2792

    
2793
                                if (e.RightButton == MouseButtonState.Pressed)
2794
                                {
2795
                                    control.IsCompleted = true;
2796
                                }
2797

    
2798
                                if (!control.IsCompleted)
2799
                                {
2800
                                    control.PointSet.Add(control.EndPoint);
2801
                                }
2802
                                else
2803
                                {
2804
                                    //20180906 LJY TEST IsRotationDrawingEnable
2805
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2806
                                    {
2807
                                        return;
2808
                                    }
2809

    
2810
                                    var firstPoint = control.PointSet.First();
2811
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2812
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2813
                                    control.PointSet.Add(firstPoint);
2814

    
2815
                                    control.ApplyOverViewData();
2816

    
2817
                                    CreateCommand.Instance.Execute(currentControl);
2818
                                    control.UpdateControl();
2819
                                    currentControl = null;
2820
                                }
2821
                            }
2822
                            else
2823
                            {
2824
                                if (e.LeftButton == MouseButtonState.Pressed)
2825
                                {
2826
                                    currentControl = new PolygonControl
2827
                                    {
2828
                                        PointSet = new List<Point>(),
2829
                                    };
2830

    
2831
                                    var polygonControl = (currentControl as PolygonControl);
2832
                                    currentControl.CommentID = Commons.shortGuid();
2833
                                    currentControl.IsNew = true;
2834
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2835
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2836
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2837
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2838
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2839
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2840
                                    polygonControl.ApplyTemplate();
2841
                                    polygonControl.Visibility = Visibility.Visible;
2842
                                }
2843
                            }
2844
                        }
2845
                        break;
2846
                    case ControlType.ChainLine:
2847
                        {
2848
                            if (currentControl is PolygonControl)
2849
                            {
2850
                                var control = currentControl as PolygonControl;
2851

    
2852
                                if (e.RightButton == MouseButtonState.Pressed)
2853
                                {
2854
                                    //20180906 LJY TEST IsRotationDrawingEnable
2855
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2856
                                    {
2857
                                        return;
2858
                                    }
2859

    
2860
                                    CreateCommand.Instance.Execute(currentControl);
2861

    
2862
                                    currentControl = null;
2863
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2864
                                    return;
2865
                                }
2866

    
2867
                                if (!control.IsCompleted)
2868
                                {
2869
                                    control.PointSet.Add(control.EndPoint);
2870
                                    this.MainAngle.Visibility = Visibility.Visible;
2871
                                }
2872
                            }
2873
                            else
2874
                            {
2875
                                if (e.LeftButton == MouseButtonState.Pressed)
2876
                                {
2877
                                    MainAngle.Visibility = Visibility.Visible;
2878
                                    currentControl = new PolygonControl
2879
                                    {
2880
                                        PointSet = new List<Point>(),
2881
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2882
                                        ControlType = ControlType.ChainLine,
2883
                                        DashSize = ViewerDataModel.Instance.DashSize,
2884
                                        LineSize = ViewerDataModel.Instance.LineSize,
2885
                                        //PointC = new StylusPointSet()
2886
                                    };
2887

    
2888
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2889
                                    //{
2890
                                        var polygonControl = (currentControl as PolygonControl);
2891
                                        currentControl.CommentID = Commons.shortGuid();
2892
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2893
                                        currentControl.IsNew = true;
2894
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2895
                                        //currentControl.OnApplyTemplate();
2896
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2897
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2898
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2899
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2900
                                    //}
2901
                                }
2902
                            }
2903
                        }
2904
                        break;
2905
                    case ControlType.ArcLine:
2906
                        {
2907
                            if (e.LeftButton == MouseButtonState.Pressed)
2908
                            {
2909
                                if (currentControl is ArcControl)
2910
                                {
2911
                                    //20180906 LJY TEST IsRotationDrawingEnable
2912
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2913
                                    {
2914
                                        return;
2915
                                    }
2916

    
2917
                                    CreateCommand.Instance.Execute(currentControl);
2918

    
2919
                                    currentControl = null;
2920
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2921
                                }
2922
                                else
2923
                                {
2924
                                    currentControl = new ArcControl
2925
                                    {
2926
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2927
                                        Background = new SolidColorBrush(Colors.Black)
2928
                                    };
2929
                                    currentControl.CommentID = Commons.shortGuid();
2930
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2931
                                    currentControl.IsNew = true;
2932
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2933
                                    this.MainAngle.Visibility = Visibility.Visible;
2934
                                }
2935
                            }
2936
                            else if (e.RightButton == MouseButtonState.Pressed)
2937
                            {
2938
                                if (currentControl != null)
2939
                                {
2940
                                    (currentControl as ArcControl).setClock();
2941
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2942
                                }
2943
                            }
2944
                        }
2945
                        break;
2946
                    case ControlType.ArcArrow:
2947
                        {
2948
                            if (e.LeftButton == MouseButtonState.Pressed)
2949
                            {
2950
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2951
                                //{
2952
                                if (currentControl is ArrowArcControl)
2953
                                {
2954
                                    //20180906 LJY TEST IsRotationDrawingEnable
2955
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2956
                                    {
2957
                                        return;
2958
                                    }
2959

    
2960
                                    CreateCommand.Instance.Execute(currentControl);
2961

    
2962
                                    currentControl = null;
2963
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2964
                                }
2965
                                else
2966
                                {
2967
                                    currentControl = new ArrowArcControl
2968
                                    {
2969
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2970
                                        Background = new SolidColorBrush(Colors.Black)
2971
                                    };
2972
                                    currentControl.CommentID = Commons.shortGuid();
2973
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2974
                                    currentControl.IsNew = true;
2975
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2976
                                    this.MainAngle.Visibility = Visibility.Visible;
2977
                                }
2978
                                //}
2979
                            }
2980
                            else if (e.RightButton == MouseButtonState.Pressed)
2981
                            {
2982
                                if (currentControl != null)
2983
                                {
2984
                                    (currentControl as ArrowArcControl).setClock();
2985
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2986
                                    //(currentControl as ArcControl).ApplyTemplate();
2987
                                }
2988
                            }
2989
                        }
2990
                        break;
2991
                    case ControlType.ArrowMultiLine:
2992
                        {
2993
                            if (e.LeftButton == MouseButtonState.Pressed)
2994
                            {
2995
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2996
                                //{
2997

    
2998
                                    if (currentControl is ArrowControl_Multi)
2999
                                    {
3000
                                        var content = currentControl as ArrowControl_Multi;
3001
                                        if (content.MiddlePoint == new Point(0, 0))
3002
                                        {
3003
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3004
                                            {
3005
                                                content.MiddlePoint = content.EndPoint;
3006
                                            }
3007
                                            else
3008
                                            {
3009
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3010
                                            }
3011
                                        }
3012
                                        else
3013
                                        {
3014
                                            //20180906 LJY TEST IsRotationDrawingEnable
3015
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3016
                                            {
3017
                                                return;
3018
                                            }
3019

    
3020
                                            CreateCommand.Instance.Execute(currentControl);
3021

    
3022
                                            currentControl = null;
3023
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3024
                                        }
3025
                                    }
3026
                                    else
3027
                                    {
3028
                                        currentControl = new ArrowControl_Multi
3029
                                        {
3030
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3031
                                            Background = new SolidColorBrush(Colors.Black)
3032
                                        };
3033
                                        currentControl.CommentID = Commons.shortGuid();
3034
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3035
                                        currentControl.IsNew = true;
3036
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3037
                                        this.MainAngle.Visibility = Visibility.Visible;
3038
                                    }
3039
                                //}
3040
                            }
3041
                        }
3042
                        break;
3043
                    case ControlType.PolygonCloud:
3044
                        {
3045
                            if (currentControl is CloudControl)
3046
                            {
3047
                                var control = currentControl as CloudControl;
3048
                                if (e.RightButton == MouseButtonState.Pressed)
3049
                                {
3050
                                    control.IsCompleted = true;
3051
                                }
3052

    
3053
                                if (!control.IsCompleted)
3054
                                {
3055
                                    control.PointSet.Add(control.EndPoint);
3056
                                }
3057
                                else
3058
                                {
3059
                                    //20180906 LJY TEST IsRotationDrawingEnable
3060
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3061
                                    {
3062
                                        return;
3063
                                    }
3064

    
3065
                                    CreateCommand.Instance.Execute(currentControl);
3066

    
3067
                                    control.isTransOn = true;
3068
                                    var firstPoint = control.PointSet.First();
3069

    
3070
                                    control.PointSet.Add(firstPoint);
3071
                                    control.DrawingCloud();
3072
                                    control.ApplyOverViewData();
3073

    
3074
                                    currentControl = null;
3075
                                }
3076
                            }
3077
                            else
3078
                            {
3079
                                if (e.LeftButton == MouseButtonState.Pressed)
3080
                                {
3081
                                    currentControl = new CloudControl
3082
                                    {
3083
                                        PointSet = new List<Point>(),
3084
                                        PointC = new StylusPointSet()
3085
                                    };
3086

    
3087
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3088
                                    //{
3089
                                        var polygonControl = (currentControl as CloudControl);
3090
                                        currentControl.CommentID = Commons.shortGuid();
3091
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3092
                                        currentControl.IsNew = true;
3093
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3094

    
3095
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3096
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3097
                                    
3098
                                    //}
3099
                                }
3100
                            }
3101
                        }
3102
                        break;
3103
                    case ControlType.ImgControl:
3104
                        {
3105
                            if (e.LeftButton == MouseButtonState.Pressed)
3106
                            {
3107
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3108
                                //{
3109
                                    if (currentControl is ImgControl)
3110
                                    {
3111
                                        //20180906 LJY TEST IsRotationDrawingEnable
3112
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3113
                                        {
3114
                                            return;
3115
                                        }
3116

    
3117
                                        CreateCommand.Instance.Execute(currentControl);
3118
                                        controlType = ControlType.ImgControl;
3119
                                        currentControl = null;
3120
                                    }
3121
                                    else
3122
                                    {
3123
                                        
3124
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3125
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3126
                                        {
3127
                                            Image img = new Image();
3128
                                            if (filename.Contains(".svg"))
3129
                                            {
3130
                                                byte[] imageData = null;
3131
                                                DrawingImage image = null;
3132
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3133
                                                {
3134
                                                    imageData = web.DownloadData(new Uri(filename));
3135
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3136
                                                    image = SvgReader.Load(stream);
3137
                                                }
3138
                                                img.Source = image;
3139
                                            }
3140
                                            else
3141
                                            {
3142
                                                img.Source = new BitmapImage(new Uri(filename));
3143
                                            }
3144

    
3145
                                            currentControl = new ImgControl
3146
                                            {
3147
                                                    Background = new SolidColorBrush(Colors.Black),
3148
                                                    PointSet = new List<Point>(),
3149
                                                    FilePath = filename,
3150
                                                    ImageData = img.Source,
3151
                                                    StartPoint = canvasDrawingMouseDownPoint,
3152
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3153
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3154
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3155
                                                    ControlType = ControlType.ImgControl
3156
                                                };
3157

    
3158
                                        
3159
                                                currentControl.CommentID = Commons.shortGuid();                                            
3160
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3161
                                                currentControl.IsNew = true;
3162
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3163

    
3164
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3165
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3166
                                        }
3167
                                    }
3168
                                //}
3169
                            }
3170
                        }
3171
                        break;
3172
                    case ControlType.Date:
3173
                        {
3174
                            if (e.LeftButton == MouseButtonState.Pressed)
3175
                            {
3176
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3177
                                //{
3178
                                    if (currentControl is DateControl)
3179
                                    {
3180
                                        //20180906 LJY TEST IsRotationDrawingEnable
3181
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3182
                                        {
3183
                                            return;
3184
                                        }
3185

    
3186
                                        CreateCommand.Instance.Execute(currentControl);
3187
                                        currentControl = null;
3188

    
3189
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3190
                                        {
3191
                                            controlType = ControlType.None;
3192
                                            IsSwingMode = false;
3193
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3194
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3195
                                            mouseHandlingMode = MouseHandlingMode.None;
3196
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3197
                                            txtBatch.Visibility = Visibility.Collapsed;
3198

    
3199
                                        }
3200
                                    }
3201
                                    else
3202
                                    {
3203
                                        currentControl = new DateControl
3204
                                        {
3205
                                            StartPoint = canvasDrawingMouseDownPoint,
3206
                                            Background = new SolidColorBrush(Colors.Black)
3207
                                        };
3208
                                        currentControl.CommentID = Commons.shortGuid();
3209
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3210
                                        currentControl.IsNew = true;
3211
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3212

    
3213
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3214
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3215
                                }
3216
                                //}
3217
                            }
3218
                        }
3219
                        break;
3220
                    case ControlType.TextControl:
3221
                        {
3222
                            if (e.LeftButton == MouseButtonState.Pressed)
3223
                            {
3224
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3225
                                {
3226
                                    currentControl = new TextControl
3227
                                    {
3228
                                        ControlType = controlType
3229
                                    };
3230
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3231
                                    currentControl.CommentID = Commons.shortGuid();
3232
                                    currentControl.IsNew = true;
3233
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3234
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3235
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3236

    
3237
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3238
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3239
                                    
3240
                                    (currentControl as TextControl).ControlType_No = 0;
3241
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3242
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3243
                                    (currentControl as TextControl).ApplyTemplate();
3244
                                    (currentControl as TextControl).Base_TextBox.Focus();
3245

    
3246
                                    CreateCommand.Instance.Execute(currentControl);
3247
                                }
3248
                            }
3249
                        }
3250
                        break;
3251
                    case ControlType.TextBorder:
3252
                        {
3253
                            if (e.LeftButton == MouseButtonState.Pressed)
3254
                            {
3255
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3256
                                {
3257
                                    currentControl = new TextControl
3258
                                    {
3259
                                        ControlType = controlType
3260
                                    };
3261

    
3262
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3263
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3264
                                    currentControl.CommentID = Commons.shortGuid();
3265
                                    currentControl.IsNew = true;
3266
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3267
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3268
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3269
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3270
                                    
3271
                                    (currentControl as TextControl).ControlType_No = 1;
3272
                                    (currentControl as TextControl).Angle = Ang;
3273
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3274
                                    (currentControl as TextControl).ApplyTemplate();
3275
                                    (currentControl as TextControl).Base_TextBox.Focus();
3276
                                    CreateCommand.Instance.Execute(currentControl);
3277
                                }
3278
                            }
3279
                        }
3280
                        break;
3281
                    case ControlType.TextCloud:
3282
                        {
3283
                            if (e.LeftButton == MouseButtonState.Pressed)
3284
                            {
3285
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3286
                                {
3287
                                    currentControl = new TextControl
3288
                                    {
3289
                                        ControlType = controlType
3290
                                    };
3291

    
3292
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3293
                                    currentControl.CommentID = Commons.shortGuid();
3294
                                    currentControl.IsNew = true;
3295
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3296
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3297

    
3298
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3299
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3300
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3301

    
3302
                                    (currentControl as TextControl).Angle = Ang;
3303
                                    (currentControl as TextControl).ControlType_No = 2;
3304
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3305
                                    (currentControl as TextControl).ApplyTemplate();
3306
                                    (currentControl as TextControl).Base_TextBox.Focus();
3307
                                    CreateCommand.Instance.Execute(currentControl);
3308
                                    //currentControl = null;
3309
                                }
3310
                            }
3311
                        }
3312
                        break;
3313
                    case ControlType.ArrowTextControl:
3314
                         {
3315
                            if (e.LeftButton == MouseButtonState.Pressed)
3316
                            {
3317
                                if (currentControl is ArrowTextControl)
3318
                                {
3319
                                    //20180906 LJY TEST IsRotationDrawingEnable
3320
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3321
                                    {
3322
                                        return;
3323
                                    }
3324

    
3325
                                    CreateCommand.Instance.Execute(currentControl);
3326

    
3327
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3328
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3329
                                    (currentControl as ArrowTextControl).IsNew = false;
3330
                                    currentControl = null;
3331
                                }
3332
                                else
3333
                                {
3334
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3335
                                    //{
3336
                                        currentControl = new ArrowTextControl();
3337
                                        currentControl.CommentID = Commons.shortGuid();
3338
                                        currentControl.IsNew = true;
3339
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3340
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3341

    
3342
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3343
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3344
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3345
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3346
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3347

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

    
3351
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3352
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3353
                                        this.MainAngle.Visibility = Visibility.Visible;
3354

    
3355
                                    
3356
                                    //}
3357
                                }
3358
                            }
3359
                        }
3360
                        break;
3361
                    case ControlType.ArrowTransTextControl:
3362
                        {
3363
                            if (e.LeftButton == MouseButtonState.Pressed)
3364
                            {
3365
                                if (currentControl is ArrowTextControl)
3366
                                {
3367
                                    //20180906 LJY TEST IsRotationDrawingEnable
3368
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3369
                                    {
3370
                                        return;
3371
                                    }
3372

    
3373
                                    CreateCommand.Instance.Execute(currentControl);
3374
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3375
                                    currentControl.IsNew = false;
3376
                                    currentControl = null;
3377
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3378
                                }
3379
                                else
3380
                                {
3381
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3382
                                    //{
3383
                                    currentControl = new ArrowTextControl()
3384
                                    {
3385
                                        ControlType = ControlType.ArrowTransTextControl
3386
                                    };
3387
                                    currentControl.CommentID = Commons.shortGuid();
3388
                                    currentControl.IsNew = true;
3389
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3390
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3391
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3392
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3393
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3394
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3395
                                    (currentControl as ArrowTextControl).isFixed = true;
3396
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3397

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

    
3401
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3402
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3403
                                    (currentControl as ArrowTextControl).isTrans = true;
3404
                                }
3405
                            }
3406
                        }
3407
                        break;
3408
                    case ControlType.ArrowTextBorderControl:
3409
                         {
3410
                            if (e.LeftButton == MouseButtonState.Pressed)
3411
                            {
3412
                                if (currentControl is ArrowTextControl)
3413
                                {
3414
                                    //20180906 LJY TEST IsRotationDrawingEnable
3415
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3416
                                    {
3417
                                        return;
3418
                                    }
3419

    
3420
                                    CreateCommand.Instance.Execute(currentControl);
3421
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3422
                                    currentControl.IsNew = false;
3423
                                    currentControl = null;
3424
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3425
                                }
3426
                                else
3427
                                {
3428
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3429
                                    //{
3430
                                        currentControl = new ArrowTextControl()
3431
                                        {
3432
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3433
                                        };
3434
                                        currentControl.CommentID = Commons.shortGuid();
3435
                                        currentControl.IsNew = true;
3436
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3437
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3438

    
3439
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3440

    
3441
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3442

    
3443
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3444
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3445
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3446

    
3447
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3448
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3449
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3450
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3451
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3452
                                    //}
3453
                                }
3454
                            }
3455
                        }
3456
                        break;
3457
                    case ControlType.ArrowTransTextBorderControl:
3458
                        {
3459
                            if (e.LeftButton == MouseButtonState.Pressed)
3460
                            {
3461
                                if (currentControl is ArrowTextControl)
3462
                                {
3463
                                    //20180906 LJY TEST IsRotationDrawingEnable
3464
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3465
                                    {
3466
                                        return;
3467
                                    }
3468
                                    CreateCommand.Instance.Execute(currentControl);
3469
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3470
                                    currentControl.IsNew = false;
3471
                                    currentControl = null;
3472
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3473
                                }
3474
                                else
3475
                                {
3476
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3477
                                    //{
3478
                                    
3479

    
3480
                                    currentControl = new ArrowTextControl()
3481
                                    {
3482
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3483
                                        ControlType = ControlType.ArrowTransTextBorderControl
3484

    
3485
                                    };
3486
                                        currentControl.CommentID = Commons.shortGuid();
3487
                                        currentControl.IsNew = true;
3488
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3489
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3490

    
3491
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3492

    
3493
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3494
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3495
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3496
                                        (currentControl as ArrowTextControl).isFixed = true;
3497
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3498
                                     
3499
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3500
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3501
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3502

    
3503
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3504
                                        this.MainAngle.Visibility = Visibility.Visible;
3505
                                    
3506
                                    //20180911 LJY
3507
                                        (currentControl as ArrowTextControl).isTrans = true;
3508
                                    
3509

    
3510
                                    //}
3511
                                }
3512
                            }
3513
                        }
3514
                        break;
3515
                    case ControlType.ArrowTextCloudControl:
3516
                        {
3517
                            if (e.LeftButton == MouseButtonState.Pressed)
3518
                            {
3519
                                if (currentControl is ArrowTextControl)
3520
                                {
3521
                                    //20180906 LJY TEST IsRotationDrawingEnable
3522
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3523
                                    {
3524
                                        return;
3525
                                    }
3526
                                    CreateCommand.Instance.Execute(currentControl);
3527
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3528
                                    currentControl.IsNew = false;
3529
                                    currentControl = null;
3530
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3531
                                }
3532
                                else
3533
                                {
3534
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3535
                                    //{
3536
                                        currentControl = new ArrowTextControl()
3537
                                        {
3538
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3539
                                        };
3540
                                        currentControl.CommentID = Commons.shortGuid();
3541
                                        currentControl.IsNew = true;
3542
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3543
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3544

    
3545
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3546
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3547
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3548
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3549
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3550

    
3551
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3552
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3553
                                    
3554
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3555
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3556
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3557
                                    //}
3558
                                }
3559
                            }
3560
                        }
3561
                        break;
3562
                    case ControlType.ArrowTransTextCloudControl:
3563
                        {
3564
                            if (e.LeftButton == MouseButtonState.Pressed)
3565
                            {
3566
                                if (currentControl is ArrowTextControl)
3567
                                {
3568
                                    //20180906 LJY TEST IsRotationDrawingEnable
3569
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3570
                                    {
3571
                                        return;
3572
                                    }
3573
                                    CreateCommand.Instance.Execute(currentControl);
3574
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3575
                                    currentControl.IsNew = false;
3576
                                    currentControl = null;
3577
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3578
                                }
3579
                                else
3580
                                {
3581
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3582
                                    //{
3583
                                        currentControl = new ArrowTextControl()
3584
                                        {
3585
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3586
                                            ControlType = ControlType.ArrowTransTextCloudControl
3587

    
3588
                                        };
3589
                                        currentControl.CommentID = Commons.shortGuid();
3590
                                        currentControl.IsNew = true; 
3591
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3592
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3593
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3594

    
3595
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3596
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3597
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3598
                                        (currentControl as ArrowTextControl).isFixed = true;
3599
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3600

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

    
3604
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3605
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3606
                                        this.MainAngle.Visibility = Visibility.Visible;  
3607
                                    
3608
                                    //20180911 LJY
3609
                                        (currentControl as ArrowTextControl).isTrans = true;
3610
                                    //}
3611
                                }
3612
                            }
3613
                        }
3614
                        break;
3615
                    //강인구 추가
3616
                    case ControlType.Sign:
3617
                        {
3618
                            if (e.LeftButton == MouseButtonState.Pressed)
3619
                            {
3620
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3621
                                //{
3622
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3623

    
3624
                                    if (_sign == null)
3625
                                    {
3626
                                        txtBatch.Visibility = Visibility.Collapsed;
3627
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3628
                                        controlType = ControlType.None;
3629

    
3630
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3631
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3632
                                        return;
3633
                                    }
3634

    
3635
                                    if (currentControl is SignControl)
3636
                                    {
3637
                                        //20180906 LJY TEST IsRotationDrawingEnable
3638
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3639
                                        {
3640
                                            return;
3641
                                        }
3642

    
3643
                                        CreateCommand.Instance.Execute(currentControl);
3644
                                        currentControl = null;
3645
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3646
                                        {
3647
                                            txtBatch.Text = "Place Date";
3648
                                            controlType = ControlType.Date;
3649
                                        }
3650
                                    }
3651
                                    else
3652
                                    {
3653
                                        currentControl = new SignControl
3654
                                        {
3655
                                            Background = new SolidColorBrush(Colors.Black),
3656
                                            UserNumber = App.ViewInfo.UserID,
3657
                                            ProjectNO = App.ViewInfo.ProjectNO,
3658
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3659
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3660
                                            ControlType = ControlType.Sign
3661
                                        };
3662

    
3663
                                        currentControl.CommentID = Commons.shortGuid();
3664
                                        currentControl.IsNew = true;
3665
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3666
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3667

    
3668
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3669
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3670
                                }
3671
                                //}
3672
                            }
3673
                        }
3674
                        break;
3675
                    case ControlType.Mark:
3676
                        {
3677
                            if (e.LeftButton == MouseButtonState.Pressed)
3678
                            {
3679
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3680
                                //{
3681
                                    if (currentControl is RectangleControl)
3682
                                    {
3683
                                        //20180906 LJY TEST IsRotationDrawingEnable
3684
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3685
                                        {
3686
                                            return;
3687
                                        }
3688

    
3689
                                        CreateCommand.Instance.Execute(currentControl);
3690
                                        (currentControl as RectangleControl).ApplyOverViewData();
3691
                                        currentControl = null;
3692
                                    
3693
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3694

    
3695
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3696
                                        {
3697
                                            txtBatch.Text = "Place Signature";
3698
                                            controlType = ControlType.Sign;
3699
                                        }
3700
                                    }
3701
                                    else
3702
                                    {
3703
                                        currentControl = new RectangleControl
3704
                                        {
3705
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3706
                                            Background = new SolidColorBrush(Colors.Black),
3707
                                            ControlType = ControlType.Mark ,
3708
                                            Paint = PaintSet.Fill
3709
                                        };
3710

    
3711
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3712
                                        currentControl.CommentID = Commons.shortGuid();
3713
                                        currentControl.IsNew = true;
3714
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3715
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3716
                                    }
3717
                                //}
3718
                            }
3719
                        }
3720
                        break;
3721
                    case ControlType.Symbol:
3722
                        {
3723
                            if (e.LeftButton == MouseButtonState.Pressed)
3724
                            {
3725
                                if (currentControl is SymControl)
3726
                                {
3727
                                    //20180906 LJY TEST IsRotationDrawingEnable
3728
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3729
                                    {
3730
                                        return;
3731
                                    }
3732
                                    CreateCommand.Instance.Execute(currentControl);
3733
                                    currentControl = null;
3734
                                
3735
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3736
                                }
3737
                                else
3738
                                {
3739
                                    currentControl = new SymControl
3740
                                    {
3741
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3742
                                        Background = new SolidColorBrush(Colors.Black),
3743
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3744
                                        ControlType = ControlType.Symbol
3745
                                    };
3746

    
3747
                                    currentControl.IsNew = true;
3748
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3749
                                    currentControl.CommentID = Commons.shortGuid();
3750
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3751

    
3752
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3753
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3754
                                }
3755
                                //}
3756
                            }
3757
                        }
3758
                        break;
3759
                    case ControlType.Stamp:
3760
                        {
3761
                            if (e.LeftButton == MouseButtonState.Pressed)
3762
                            {
3763
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3764
                                //{
3765
                                    if (currentControl is SymControlN)
3766
                                    {
3767
                                        //20180906 LJY TEST IsRotationDrawingEnable
3768
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3769
                                        {
3770
                                            return;
3771
                                        }
3772

    
3773
                                        CreateCommand.Instance.Execute(currentControl);
3774
                                        currentControl = null;
3775
                                   
3776

    
3777
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3778
                                    }
3779
                                    else
3780
                                    {
3781
                                        currentControl = new SymControlN
3782
                                        {
3783
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3784
                                            Background = new SolidColorBrush(Colors.Black),
3785
                                            STAMP = App.SystemInfo.STAMP,                                            
3786
                                            ControlType = ControlType.Stamp
3787
                                        };
3788

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

    
3837
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3838
                            if (over != null)
3839
                            {
3840
                                mouseOff = true;
3841
                            }
3842
                        }
3843
                    }
3844

    
3845
                    if (!mouseOff)
3846
                    {
3847
                        SelectionSet.Instance.UnSelect(this);
3848
                    }
3849
                }
3850
                zoomAndPanControl.CaptureMouse();
3851
                e.Handled = true;
3852
            }
3853
        }
3854

    
3855
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3856
        {
3857
            ///mouseButtonDown = e.ChangedButton;
3858
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3859
        }
3860

    
3861
        private void RemoveLineStroke(Point P)
3862
        {
3863
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3864
            if (control != null)
3865
            {
3866
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3867
            }
3868
        }
3869

    
3870
        private void RemovePointStroke(Point P)
3871
        {
3872
            foreach (Stroke hits in inkBoard.Strokes)
3873
            {
3874
                foreach (StylusPoint sty in hits.StylusPoints)
3875
                {
3876

    
3877
                }
3878
                if (hits.HitTest(P))
3879
                {
3880
                    inkBoard.Strokes.Remove(hits);
3881
                    return;
3882
                }
3883
            }
3884
        }
3885

    
3886
        private void StartNewStroke(Point P)
3887
        {
3888
            strokePoints = new StylusPointCollection();
3889
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3890
            strokePoints.Add(segment1Start);
3891
            stroke = new Stroke(strokePoints);
3892

    
3893
            stroke.DrawingAttributes.Color = Colors.Red;
3894
            stroke.DrawingAttributes.Width = 4;
3895
            stroke.DrawingAttributes.Height = 4;
3896

    
3897
            inkBoard.Strokes.Add(stroke);
3898
        }
3899

    
3900
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3901
        {
3902
            ConsolidationMethod();
3903
        }
3904

    
3905
        /// <summary>
3906
        /// execute TeamConsolidationCommand
3907
        /// </summary>
3908
        public void TeamConsolidationMethod()
3909
        {
3910
            this.UpdateMyMarkupList();
3911
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3912
            {
3913
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3914
            }
3915
            else
3916
            {
3917

    
3918
                ViewerDataModel.Instance.IsConsolidate = true;
3919
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3920

    
3921
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3922
                {
3923
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3924
                    {
3925
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3926
                        return;
3927
                    }                    
3928
                }
3929
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3930
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3931
                {
3932
                    MarkupInfoList.Add(item);
3933
                }
3934
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3935
            }
3936
        }
3937

    
3938
        public void ConsolidationMethod()
3939
        {
3940
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3941
            {
3942
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3943
            }
3944
            else
3945
            {
3946
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3947
                foreach (var item in this.gridViewMarkup.SelectedItems)
3948
                {
3949
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3950
                }
3951
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3952
                
3953
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3954
            }
3955
        }
3956

    
3957
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3958
        {
3959
            if (App.ViewInfo != null)
3960
            {
3961
                btnConsolidate = (sender as RadRibbonButton);
3962
                if (!App.ViewInfo.NewCommentPermission)
3963
                {
3964
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3965
                }
3966
            }
3967
        }
3968

    
3969
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3970
        {
3971
            TeamConsolidationMethod();
3972
        }
3973

    
3974
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3975
        {
3976
            btnTeamConsolidate = sender as RadRibbonButton;
3977
            if (App.ViewInfo != null)
3978
            {
3979
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3980
                {
3981
                    if (btnConsolidate != null)
3982
                    {
3983
                        btnConsolidate.Visibility = Visibility.Collapsed;
3984
                    }
3985

    
3986
                    if (!App.ViewInfo.NewCommentPermission)
3987
                    {
3988
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3989
                    }
3990
                }
3991
                else
3992
                {
3993
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3994
                }
3995
            }
3996
        }
3997

    
3998
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3999
        {
4000
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4001
            if (item != null)
4002
            {
4003
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4004

    
4005
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4006
            }
4007
            else
4008
            {
4009
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4010
            }
4011
        }
4012

    
4013
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4014
        {
4015
            btnFinalPDF = sender as RadRibbonButton;
4016
            if (App.ViewInfo != null)
4017
            {
4018
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4019
                {
4020
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4021
                    if (btnConsolidate != null)
4022
                    {
4023
                        btnConsolidate.Visibility = Visibility.Collapsed;
4024
                    }
4025
                }
4026
            }
4027
        }
4028

    
4029
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4030
        {
4031
            UpdateMyMarkupList();
4032

    
4033
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4034
            {
4035
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4036
            }
4037
            else
4038
            {
4039
                ViewerDataModel.Instance.IsConsolidate = true;
4040
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4041
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4042

    
4043
                string project_no = App.ViewInfo.ProjectNO;
4044
                string doc_id = _DocInfo.ID;
4045
                string user_id = App.ViewInfo.UserID;
4046
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4047
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4048
                {
4049
                    markupInfoItems.Add(item);
4050
                }
4051
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4052
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4053
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4054
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4055

    
4056
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4057
                if (item2 != null)
4058
                {
4059
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4060

    
4061
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4062
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4063
                }
4064
                else
4065
                {
4066
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4067
                }
4068
            }
4069
        }
4070

    
4071
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4072
        {
4073
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4074

    
4075
            if (App.ViewInfo != null)
4076
            {
4077
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4078
                {
4079
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4080
                }
4081
            }
4082
        }
4083

    
4084
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4085
        {
4086
            if (CompareMode.IsChecked)
4087
            {
4088
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4089
                {
4090
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4091
                }
4092
                if (ViewerDataModel.Instance.PageNumber == 0)
4093
                {
4094
                    ViewerDataModel.Instance.PageNumber = 1;
4095
                }
4096

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

    
4101
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4102
            }
4103
            else
4104
            {
4105
                da.From = 1;
4106
                da.To = 1;
4107
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4108
                da.AutoReverse = false;
4109
                canvas_compareBorder.Children.Clear();
4110
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4111
            }
4112
        }
4113

    
4114
        private void Sync_Click(object sender, RoutedEventArgs e)
4115
        {
4116
            if (Sync.IsChecked)
4117
            {
4118
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4119
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4120
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4121
            }
4122
        }
4123

    
4124
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4125
        {
4126
            if (UserList.IsChecked)
4127
            {
4128
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4129
            }
4130
            else
4131
            {
4132
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4133
            }
4134
        }
4135

    
4136
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4137
        {
4138

    
4139
            if (BalanceMode.IsChecked)
4140
            {
4141
                ViewerDataModel.Instance.PageBalanceMode = true;
4142
            }
4143
            else
4144
            {
4145
                ViewerDataModel.Instance.PageBalanceMode = false;
4146
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4147
            }
4148
        }
4149

    
4150
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4151
        {
4152
            //초기화
4153
            testPanel2.IsHidden = true;
4154
            ViewerDataModel.Instance.PageBalanceMode = false;
4155
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4156
            ViewerDataModel.Instance.PageNumber = 0;
4157
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4158
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4159
            UserList.IsChecked = false;
4160
            BalanceMode.IsChecked = false;
4161
        }
4162

    
4163
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4164
        {
4165
            if ((sender as System.Windows.Controls.Control).Tag != null)
4166
            {
4167
                //Compare 초기화
4168
                CompareMode.IsChecked = false;
4169
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4170

    
4171
                if (ViewerDataModel.Instance.PageNumber == 0)
4172
                {
4173
                    ViewerDataModel.Instance.PageNumber = 1;
4174
                }
4175

    
4176
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4177
                {
4178
                }
4179
                else
4180
                {
4181
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4182
                }
4183

    
4184
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4185
                {
4186

    
4187
                }
4188
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4189
                {
4190
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4191
                }
4192

    
4193
                if (!testPanel2.IsHidden)
4194
                {
4195
                    if (IsSyncPDFMode)
4196
                    {
4197
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4198
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4199

    
4200
                        if (pdfpath.IsDownloading)
4201
                        {
4202
                            pdfpath.DownloadCompleted += (ex, arg) =>
4203
                            {
4204
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4205
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4206
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4207
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4208
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4209
                            };
4210
                        }
4211
                        else
4212
                        {
4213
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4214
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4215
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4216

    
4217
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4218
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4219
                        }
4220

    
4221
                    }
4222
                    else
4223
                    {
4224
                        string uri = "";
4225

    
4226
                        if (userData.COMPANY != "EXT")
4227
                        {
4228
                            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);
4229
                        }
4230
                        else
4231
                        {
4232
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4233
                        }
4234

    
4235
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4236

    
4237
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4238
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4239
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4240

    
4241
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4242
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4243

    
4244
                        if (defaultBitmapImage_Compare.IsDownloading)
4245
                        {
4246
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4247
                            {
4248
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4249
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4250
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4251

    
4252
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4253
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4254
                            };
4255
                        }
4256
                    }
4257

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

    
4262
                    foreach (var item in gridSelectionRevItem)
4263
                    {
4264
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4265
                        {
4266
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4267
                        });
4268
                    }
4269

    
4270
                    //강인구 추가
4271
                    zoomAndPanControl2.ZoomTo(new Rect
4272
                    {
4273
                        X = 0,
4274
                        Y = 0,
4275
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4276
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4277
                    });
4278

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

    
4281
                }
4282
            }
4283
        }
4284

    
4285
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4286
        {
4287
            if (MarkupMode.IsChecked)
4288
            {
4289
                IsSyncPDFMode = true;
4290

    
4291
                var uri = CurrentRev.TO_VENDOR;
4292

    
4293
                if (ViewerDataModel.Instance.PageNumber == 0)
4294
                {
4295
                    ViewerDataModel.Instance.PageNumber = 1;
4296
                }
4297

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

    
4302
                if (pdfpath.IsDownloading)
4303
                {
4304
                    pdfpath.DownloadCompleted += (ex, arg) =>
4305
                    {
4306
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4307
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4308
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4309
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4310
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4311
                    };
4312
                }
4313
                else
4314
                {
4315
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4316
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4317
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4318

    
4319
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4320
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4321
                }
4322
            }
4323
            else
4324
            {
4325
                IsSyncPDFMode = false;
4326
                string uri = "";
4327
                if (userData.COMPANY != "EXT")
4328
                {
4329
                    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);
4330
                }
4331
                else
4332
                {
4333
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4334
                }
4335

    
4336
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4337

    
4338
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4339
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4340
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4341

    
4342
                if (defaultBitmapImage_Compare.IsDownloading)
4343
                {
4344
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4345
                    {
4346
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4347
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4348
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4349
                    };
4350
                }
4351
                zoomAndPanControl2.ApplyTemplate();
4352
                zoomAndPanControl2.UpdateLayout();
4353
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4354
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4355
            }
4356
        }
4357

    
4358
        private void RadButton_Click(object sender, RoutedEventArgs e)
4359
        {
4360
            gridViewHistory_Busy.IsBusy = true;
4361

    
4362
            RadButton instance = sender as RadButton;
4363
            if (instance.CommandParameter != null)
4364
            {
4365
                CurrentRev = instance.CommandParameter as VPRevision;
4366
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4367
                {
4368
                    if (ea.Error == null && ea.Result != null)
4369
                    {
4370
                        testPanel2.IsHidden = false;
4371

    
4372
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4373
                        foreach(var info in ea.Result)
4374
                        {
4375
                            if(info.UserID == App.ViewInfo.UserID)
4376
                            {
4377
                                info.userDelete = true;
4378
                                info.DisplayColor = "FFFF0000";
4379
                            }
4380
                            else
4381
                            {
4382
                                info.userDelete = false;
4383
                            }
4384
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4385
                        }
4386
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4387

    
4388
                        string uri = "";
4389
                        if (userData.COMPANY != "EXT")
4390
                        {
4391
                            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);
4392
                        }
4393
                        else
4394
                        {
4395
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4396
                        }
4397

    
4398
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4399

    
4400
                        var defaultBitmapImage_Compare = new BitmapImage();
4401
                        defaultBitmapImage_Compare.BeginInit();
4402
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4403
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4404
                        defaultBitmapImage_Compare.EndInit();
4405

    
4406
                        if (defaultBitmapImage_Compare.IsDownloading)
4407
                        {
4408
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4409
                            {
4410
                                defaultBitmapImage_Compare.Freeze();
4411
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4412
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4413
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4414
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4415
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4416
                            };
4417
                        }                        
4418
                        zoomAndPanControl2.ApplyTemplate();
4419
                        zoomAndPanControl2.UpdateLayout();
4420
                        //syncPannelRotate(zoomAndPanControl.RotationAngle);
4421
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4422
                        {
4423
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4424
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4425
                        }
4426

    
4427
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4428
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4429
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4430

    
4431
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4432
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4433
                        gridViewHistory_Busy.IsBusy = false;
4434
                    }
4435

    
4436
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4437
                };
4438
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4439
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4440
            }
4441
        }
4442

    
4443
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4444
        {
4445
            try
4446
            {
4447
                if (sender is RadButton)
4448
                {
4449
                    if ((sender as RadButton).Tag != null)
4450
                    {
4451
                        var url = (sender as RadButton).Tag.ToString();
4452
                        System.Diagnostics.Process.Start(url);
4453
                    }
4454
                    else
4455
                    {
4456
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4457
                    }
4458
                }
4459
            }
4460
            catch (Exception ex)
4461
            {
4462
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4463
            }
4464
        }
4465

    
4466
        public void Sync_Event(VPRevision Currnet_Rev)
4467
        {
4468
            CurrentRev = Currnet_Rev;
4469

    
4470
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4471
            {
4472
                if (ea.Error == null && ea.Result != null)
4473
                {
4474
                    testPanel2.IsHidden = false;
4475

    
4476
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4477
                    foreach(var info in ea.Result)
4478
                    {
4479
                        if(info.UserID == App.ViewInfo.UserID)
4480
                        {
4481
                            info.userDelete = true;
4482
                            info.DisplayColor = "FFFF0000";
4483
                        }
4484
                        else
4485
                        {
4486
                            info.userDelete = false;
4487
                        }
4488
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4489
                    }
4490
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4491

    
4492
                    string uri = "";
4493
                    if (userData.COMPANY != "EXT")
4494
                    {
4495
                        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);
4496
                    }
4497
                    else
4498
                    {
4499
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4500
                    }
4501

    
4502
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4503

    
4504
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4505

    
4506
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4507
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4508
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4509

    
4510
                    if (defaultBitmapImage_Compare.IsDownloading)
4511
                    {
4512
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4513
                        {
4514
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4515
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4516
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4517
                        };
4518
                    }
4519

    
4520

    
4521
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4522
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4523
                    zoomAndPanControl2.ApplyTemplate();
4524
                    zoomAndPanControl2.UpdateLayout();
4525

    
4526
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4527
                    {
4528
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4529
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4530
                    }
4531
                    //}
4532

    
4533
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4534
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4535
                    gridViewHistory_Busy.IsBusy = false;
4536
                }
4537
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4538

    
4539
            };
4540
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4541
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4542
        }
4543

    
4544
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4545
        {
4546
            if (sender is Image)
4547
            {
4548
                if ((sender as Image).Tag != null)
4549
                {
4550
                    var pdfUrl = (sender as Image).Tag.ToString();
4551
                    System.Diagnostics.Process.Start(pdfUrl);
4552
                }
4553
                else
4554
                {
4555
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4556
                }
4557
            }
4558
        }
4559

    
4560
        private void Create_Symbol(object sender, RoutedEventArgs e)
4561
        {
4562
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4563

    
4564
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4565
            {
4566
                DialogMessage_Alert("Please Select Controls", "Alert");
4567
            }
4568
            else //선택된 것이 있으면
4569
            {
4570
                string MarkupData = "";
4571
                adorner_ = new AdornerFinal();
4572

    
4573
                foreach (var item in SelectLayer.Children)
4574
                {
4575
                    if (item.GetType().Name == "AdornerFinal")
4576
                    {
4577
                        adorner_ = (item as Controls.AdornerFinal);
4578
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4579
                        {
4580
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4581
                            {
4582
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4583
                                MarkupData += markupReturn.ConvertData;
4584
                            }
4585
                        }
4586
                    }
4587
                }
4588
                DialogParameters parameters = new DialogParameters()
4589
                {
4590
                    Owner = Application.Current.MainWindow,
4591
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4592
                    DefaultPromptResultValue = "Custom State",
4593
                    Content = "Name :",
4594
                    Header = "Insert Custom Symbol Name",
4595
                    Theme = new VisualStudio2013Theme(),
4596
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4597
                };
4598
                RadWindow.Prompt(parameters);
4599
            }
4600

    
4601
        }
4602
        public int symbolselectindex = 0;
4603
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4604
        {
4605
            //Save save = new Save();
4606
            try
4607
            {
4608
                string svgfilename = null;
4609
                if (symbolname != null)
4610
                {
4611
                    if (symbolpng == true || symbolsvg == true)
4612
                    {
4613
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4614
                        string guid = Commons.shortGuid();
4615

    
4616
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4617
                        //Check_Uri.UriCheck();
4618
                        fileUploader.RunCompleted += (ex, arg) =>
4619
                        {
4620
                            filename = arg.Result;
4621
                            if (symbolpng == true)
4622
                            {
4623
                                if (filename != null)
4624
                                { 
4625
                                    if (symbolselectindex == 0)
4626
                                    {
4627
                                        SymbolSave(symbolname, filename, data);
4628
                                    }
4629
                                    else
4630
                                    {
4631
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4632
                                    }
4633
                                    DataBind();
4634
                                }                                
4635
                            }
4636

    
4637
                            if (symbolsvg == true)
4638
                            {
4639
                                try
4640
                                {
4641
                                    var defaultBitmapImage = new BitmapImage();
4642
                                    defaultBitmapImage.BeginInit();
4643
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4644
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4645
                                    Check_Uri.UriCheck(filename);
4646
                                    defaultBitmapImage.UriSource = new Uri(filename);
4647
                                    defaultBitmapImage.EndInit();
4648

    
4649
                                    System.Drawing.Bitmap image;
4650

    
4651
                                    if (defaultBitmapImage.IsDownloading)
4652
                                    {
4653
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4654
                                        {
4655
                                            defaultBitmapImage.Freeze();
4656
                                            image = GetBitmap(defaultBitmapImage);
4657
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4658
                                            Process potrace = new Process
4659
                                            {
4660
                                                StartInfo = new ProcessStartInfo
4661
                                                {
4662
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4663
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4664
                                                    RedirectStandardInput = true,
4665
                                                    RedirectStandardOutput = true,
4666
                                                    RedirectStandardError = true,
4667
                                                    UseShellExecute = false,
4668
                                                    CreateNoWindow = true,
4669
                                                    WindowStyle = ProcessWindowStyle.Hidden
4670
                                                },
4671
                                            };
4672

    
4673
                                            StringBuilder svgBuilder = new StringBuilder();
4674
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4675
                                            {
4676
                                                svgBuilder.AppendLine(e2.Data);
4677
                                            };
4678

    
4679
                                            potrace.EnableRaisingEvents = true;
4680
                                            potrace.Start();
4681
                                            potrace.Exited += (sender, e) =>
4682
                                            {
4683
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4684
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4685
                                                Check_Uri.UriCheck(svgfilename);
4686
                                                if (symbolselectindex == 0)
4687
                                                {
4688
                                                    SymbolSave(symbolname, svgfilename, data);
4689
                                                }
4690
                                                else
4691
                                                {
4692
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4693
                                                }
4694

    
4695
                                                DataBind();
4696
                                            };
4697
                                            potrace.WaitForExit();
4698
                                        };
4699
                                    }
4700
                                    else
4701
                                    {
4702
                                        //GC.Collect();
4703
                                    }
4704
                                }
4705
                                catch(Exception ee)
4706
                                {
4707
                                    DialogMessage_Alert("" + ee, "Alert");
4708
                                }
4709
                            }
4710
                        };                                             
4711
                    }
4712
                }
4713
            }
4714
            catch (Exception e)
4715
            {
4716
                //DialogMessage_Alert(e + "", "Alert");
4717
            }            
4718
        }
4719

    
4720
        public void SymbolSave(string Name, string Url, string Data)
4721
        {
4722
            try
4723
            {
4724
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4725
                {
4726
                    ID = Commons.shortGuid(),
4727
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4728
                    NAME = Name,
4729
                    IMAGE_URL = Url,
4730
                    DATA = Data
4731
                };
4732

    
4733
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4734
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4735
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4736
            }
4737
            catch (Exception)
4738
            {
4739
                throw;
4740
            }
4741
        }
4742

    
4743
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4744
        {
4745
            try
4746
            {
4747
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4748
                {
4749
                    ID = Commons.shortGuid(),
4750
                    DEPARTMENT = Department,
4751
                    NAME = Name,
4752
                    IMAGE_URL = Url,
4753
                    DATA = Data
4754
                };
4755
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4756
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4757
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4758
            }
4759
            catch (Exception)
4760
            {
4761
                throw;
4762
            }
4763
        }
4764

    
4765
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4766
        {           
4767
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4768
            DataBind();
4769
        }
4770

    
4771
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4772
        {
4773
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4774
            DataBind();
4775
        }
4776
        private void DataBind()
4777
        {
4778
            try
4779
            {
4780
                Symbol_Custom Custom = new Symbol_Custom();
4781
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4782
                
4783
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4784
                foreach (var item in symbol_Private)
4785
                {
4786
                    Custom.Name = item.NAME;
4787
                    Custom.ImageUri = item.IMAGE_URL;
4788
                    Custom.ID = item.ID;
4789
                    Custom_List.Add(Custom);
4790
                    Custom = new Symbol_Custom();
4791
                }
4792
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4793
                
4794
                Custom = new Symbol_Custom();
4795
                Custom_List = new List<Symbol_Custom>();
4796

    
4797
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4798

    
4799
                List<SYMBOL_PUBLIC> symbol_Public;
4800

    
4801
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4802
                {
4803
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4804
                }
4805
                else
4806
                {
4807
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4808
                }
4809
                foreach (var item in symbol_Public)
4810
                {
4811
                    Custom.Name = item.NAME;
4812
                    Custom.ImageUri = item.IMAGE_URL;
4813
                    Custom.ID = item.ID;
4814
                    Custom_List.Add(Custom);
4815
                    Custom = new Symbol_Custom();
4816
                }
4817
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4818
                BaseClient.Close();                
4819
            }
4820
            catch(Exception e)
4821
            {
4822
                //DialogMessage_Alert("DataBind", "Alert");
4823
            }
4824
            
4825
        }
4826
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4827
        {
4828
            try
4829
            {
4830
                if (args.PromptResult != null)
4831
                {
4832
                    if (args.DialogResult.Value)
4833
                    {
4834
                        PngBitmapEncoder _Encoder = symImage(data);
4835

    
4836
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4837
                        _Encoder.Save(fs);
4838
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4839

    
4840
                        byte[] Img_byte = fs.ToArray();
4841

    
4842
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4843
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4844
                        Check_Uri.UriCheck(filename);
4845
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4846
                        {
4847
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4848
                        }
4849
                        else
4850
                        {
4851
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4852
                        }
4853
                        DataBind();
4854
                    }
4855
                }
4856
            }
4857
            catch(Exception ex)
4858
            {
4859
                DialogMessage_Alert("" + ex, "Alert");
4860
            }
4861
        }
4862

    
4863
        public PngBitmapEncoder symImage(string data)
4864
        {
4865

    
4866
            Canvas _canvas = new Canvas();
4867
            _canvas.Background = Brushes.White;
4868
            _canvas.Width = adorner_.BorderSize.Width;
4869
            _canvas.Height = adorner_.BorderSize.Height;
4870
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4871

    
4872
            BitmapEncoder encoder = new PngBitmapEncoder();
4873

    
4874

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

    
4877
            DrawingVisual dv = new DrawingVisual();
4878

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

    
4882
            using (DrawingContext ctx = dv.RenderOpen())
4883
            {
4884
                VisualBrush vb = new VisualBrush(_canvas);
4885
                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)));
4886
            }
4887

    
4888
            try
4889
            {
4890
                renderBitmap.Render(dv);
4891

    
4892
                //GC.Collect();
4893
                GC.WaitForPendingFinalizers();
4894
                //GC.Collect();
4895
                // encode png data
4896
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4897
                // puch rendered bitmap into it
4898
                pngEncoder.Interlace = PngInterlaceOption.Off;
4899
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4900
                return pngEncoder;
4901

    
4902
            }
4903
            catch //(Exception ex)
4904
            {
4905
                return null;
4906
            }
4907

    
4908
        }
4909

    
4910
        public void DialogMessage_Alert(string content, string header)
4911
        {
4912
            var box = new TextBlock();
4913
            box.MinWidth = 400;
4914
            box.FontSize = 11;
4915
            //box.FontSize = 12;
4916
            box.Text = content;
4917
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4918

    
4919
            DialogParameters parameters = new DialogParameters()
4920
            {
4921
                Owner = Application.Current.MainWindow,
4922
                Content = box,
4923
                Header = header,
4924
                Theme = new VisualStudio2013Theme(),
4925
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4926
            };            
4927
            RadWindow.Alert(parameters);
4928
        }
4929

    
4930
        #region 캡쳐 기능
4931

    
4932
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4933
        {
4934
            if (x < 0)
4935
            {
4936
                width += x;
4937
                x = 0;
4938
            }
4939
            if (y < 0)
4940
            {
4941
                height += y;
4942
                y = 0;
4943

    
4944
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4945
            }
4946
            if (x + width > zoomAndPanCanvas.ActualWidth)
4947
            {
4948
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4949
            }
4950
            if (y + height > zoomAndPanCanvas.ActualHeight)
4951
            {
4952
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4953
            }
4954

    
4955
            byte[] pixels = CopyPixels(x, y, width, height);
4956

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

    
4959
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4960
        }
4961

    
4962
        public byte[] CopyPixels(int x, int y, int width, int height)
4963
        {
4964
            byte[] pixels = new byte[width * height * 4];
4965
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4966

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

    
4970
            return pixels;
4971
        }
4972

    
4973
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4974
        {
4975
            DrawingVisual drawingVisual = new DrawingVisual();
4976
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4977

    
4978
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4979
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4980
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4981
            drawingContext.Close();
4982

    
4983
            // 비트맵으로 변환합니다.
4984
            RenderTargetBitmap target =
4985
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4986
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4987

    
4988
            target.Render(drawingVisual);
4989
            return target;
4990
        }
4991

    
4992
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4993
        {
4994
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4995
            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);
4996
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4997
            bmp.UnlockBits(data);
4998
            return bmp;
4999
        }
5000
        public string symbolname = null;
5001
        public bool symbolsvg = true;
5002
        public bool symbolpng = true;
5003

    
5004
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5005
        {
5006
            System.Drawing.Bitmap image = GetBitmap(source);
5007
            //흰색 제거
5008
            //image.MakeTransparent(System.Drawing.Color.White);
5009

    
5010
            var imageStream = new System.IO.MemoryStream();
5011
            byte[] imageBytes = null;
5012
            using (imageStream)
5013
            {
5014
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5015
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5016
                imageStream.Position = 0;
5017
                imageBytes = imageStream.ToArray();
5018
            }
5019

    
5020
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5021

    
5022
            RadWindow CheckPop = new RadWindow();
5023
            //Alert check = new Alert(Msg);
5024

    
5025
            CheckPop = new RadWindow
5026
            {
5027
                MinWidth = 400,
5028
                MinHeight = 100,
5029
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5030
                Header = "Alert",
5031
                Content = symbolPrompt,
5032
                //DialogResult = 
5033
                ResizeMode = System.Windows.ResizeMode.NoResize,
5034
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5035
                IsTopmost = true,
5036
            };
5037
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5038
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5039
            CheckPop.ShowDialog();
5040

    
5041
            /*
5042
            DialogParameters parameters = new DialogParameters()
5043
            {
5044
                Owner = Application.Current.MainWindow,
5045
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5046
                DefaultPromptResultValue = "Custom State",
5047
                Content = "Name :",
5048
                Header = "Insert Custom Symbol Name",
5049
                Theme = new VisualStudio2013Theme(),
5050
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5051
            };            
5052
            RadWindow.Prompt(parameters);
5053
            */
5054
        }
5055

    
5056
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5057
        {
5058
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5059
            KCOMDataModel.DataModel.CHECK_LIST check_;
5060
            string Result = streamToBase64.ImageToBase64(source);
5061
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5062
            string projectno = App.ViewInfo.ProjectNO;
5063
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5064

    
5065
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5066
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5067
            if (Item != null)
5068
            {
5069
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5070
            }
5071
            else
5072
            {
5073
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5074
            }
5075

    
5076
            if (Item == null)
5077
            {
5078
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5079
                {
5080
                    ID = Commons.shortGuid(),
5081
                    USER_ID = App.ViewInfo.UserID,
5082
                    IMAGE_URL = Result,
5083
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5084
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5085
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5086
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5087
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5088
                    STATUS = "False",
5089
                    CREATE_TIME = DateTime.Now,
5090
                    UPDATE_TIME = DateTime.Now,
5091
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5092
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5093
                };
5094
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5095
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5096
                //this.BaseClient.AddCheckList(projectno, check_);
5097
            }
5098
            else
5099
            {
5100
                Item.IMAGE_URL = Result;
5101
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5102
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5103
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5104
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5105
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5106
            }
5107

    
5108
        }
5109

    
5110
        public void Set_Capture()
5111
        {
5112
            double x = canvasDrawingMouseDownPoint.X;
5113
            double y = canvasDrawingMouseDownPoint.Y;
5114
            double width = dragCaptureBorder.Width;
5115
            double height = dragCaptureBorder.Height;
5116

    
5117
            if (width > 5 || height > 5)
5118
            {
5119
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5120
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5121
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5122
            }
5123
        }
5124
        #endregion
5125

    
5126
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5127
        {
5128
            multi_Undo_Data = new Multi_Undo_data();
5129

    
5130
            multi_Undo_Data.Markup = control;
5131

    
5132
            if ((control as IShapeControl) != null)
5133
            {
5134
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5135
            }
5136
            if ((control as IDashControl) != null)
5137
            {
5138
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5139
            }
5140
            if ((control as IPath) != null)
5141
            {
5142
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5143
            }
5144
            if ((control as UIElement) != null)
5145
            {
5146
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5147
            }
5148

    
5149
            return multi_Undo_Data;
5150
        }
5151

    
5152
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5153
        {
5154
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5155
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5156
            {
5157
                if (items.UserID == Select_ID)
5158
                {
5159
                    foreach (var item in items.MarkupList)
5160
                    {
5161
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5162
                        {
5163
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5164
                                items.MarkupInfoID, Commons.shortGuid());
5165
                        }
5166
                    }
5167
                }
5168
            }
5169
        }
5170

    
5171
        /// <summary>
5172
        /// convert inkcontrol to polygoncontrol
5173
        /// </summary>
5174
        public void ConvertInkControlToPolygon()
5175
        {
5176
            if (inkBoard.Strokes.Count > 0)
5177
            {
5178
                inkBoard.Strokes.ToList().ForEach(stroke =>
5179
                {
5180
                    InkToPath ip = new InkToPath();
5181

    
5182
                    List<Point> inkPointSet = new List<Point>();
5183
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5184

    
5185
                    PolygonControl pc = new PolygonControl()
5186
                    {
5187
                        Angle = 0,
5188
                        PointSet = inkPointSet,
5189
                        ControlType = ControlType.Ink
5190
                    };
5191
                    pc.StartPoint = inkPointSet[0];
5192
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5193
                    pc.LineSize = 3;
5194
                    pc.CommentID = Commons.shortGuid();
5195
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5196

    
5197
                    if (pc.PointSet.Count > 0)
5198
                    {
5199
                        CreateCommand.Instance.Execute(pc);
5200
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5201
                    }
5202
                });
5203
                inkBoard.Strokes.Clear();
5204
            }
5205
        }
5206

    
5207
        /// <summary>
5208
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5209
        /// </summary>
5210
        /// <author>ingu</author>
5211
        /// <date>2018.06.05</date>
5212
        /// <param name="getPoint"></param>
5213
        /// <returns></returns>
5214
        private bool IsGetoutpoint(Point getPoint)
5215
        {
5216
            if (getPoint == new Point())
5217
            {
5218
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5219
                currentControl = null;
5220
                return true;
5221
            }
5222

    
5223
            return false;
5224
        }
5225

    
5226
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5227
        {
5228
            e.Effects = DragDropEffects.Copy;
5229
        }
5230

    
5231
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5232
        {
5233
            e.Effects = DragDropEffects.Copy;
5234
        }
5235

    
5236
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5237
        {
5238
            e.Effects = DragDropEffects.None;
5239
        }
5240

    
5241
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5242
        {
5243
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5244
        }
5245

    
5246
        /*
5247
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5248
        {
5249
            try
5250
            {
5251
                if (e.Data.GetDataPresent(typeof(string)))
5252
                {
5253
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5254
                    string dragData = e.Data.GetData(typeof(string)) as string;
5255
                    Move_Symbol(sender, dragData);
5256
                }
5257
            }
5258
            catch (Exception ex)
5259
            {
5260
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5261
            }            
5262
        }
5263
        */
5264
    }
5265
}
클립보드 이미지 추가 (최대 크기: 500 MB)