프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (252 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
        DispatcherTimer renderTesttimer;
498

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

    
511
            #region 페이지가 벗어난 경우
512

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

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

    
525
            #endregion
526

    
527
            ViewerDataModel.Instance.PageNumber = BalancePoint;
528

    
529
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
530
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
531
            var pageUri = pageNavigator.CurrentPage.PageUri;
532
            var contentScale = zoomAndPanControl.ContentScale;
533

    
534
            #region 이미지 로딩 수정
535

    
536
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
537

    
538
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
539
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
540

    
541
            zoomAndPanCanvas.Width = pageWidth;
542
            zoomAndPanCanvas.Height = pageHeight;
543

    
544
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
545
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
546

    
547
            inkBoard.Width = pageWidth;
548
            inkBoard.Height = pageHeight;
549

    
550
            #endregion
551

    
552
            if (!testPanel2.IsHidden)
553
            {
554
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
555
                //PDF모드일때 잠시 대기(강인구)
556
                if (IsSyncPDFMode)
557
                {
558
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
559
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
560

    
561
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
562
                    if (pdfpath.IsDownloading)
563
                    {
564
                        pdfpath.DownloadCompleted += (ex, arg) =>
565
                        {
566
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
567
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
568
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
569
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
570
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
571
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
572
                        };
573
                    }
574
                    else
575
                    {
576
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
577
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
578
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
579
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
580

    
581
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
582
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
583
                    }
584
                }
585
                else
586
                {
587
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
588
                    string uri2 = "";
589
                    if (userData.COMPANY != "EXT")
590
                    {
591
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
592
                    }
593
                    else
594
                    {
595
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
596
                    }
597

    
598
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
599
                    var defaultBitmapImage_Compare = new BitmapImage();
600
                    defaultBitmapImage_Compare.BeginInit();
601
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
602
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
603
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
604
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
605
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
606
                    defaultBitmapImage_Compare.EndInit();
607

    
608
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
609

    
610
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
611
                    zoomAndPanControl.ZoomTo(new Rect
612
                    {
613
                        X = 0,
614
                        Y = 0,
615
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
616
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
617
                    });
618

    
619
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
620
                    if (defaultBitmapImage_Compare.IsDownloading)
621
                    {
622
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
623
                        {
624
                            defaultBitmapImage_Compare.Freeze();
625
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
626
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
627
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
628
                            ComparePanel.UpdateLayout();
629
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
630
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
631

    
632
                            zoomAndPanControl.ZoomTo(new Rect
633
                            {
634
                                X = 0,
635
                                Y = 0,
636
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
637
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
638
                            });
639

    
640
                            //defaultBitmapImage_Compare dispose
641
                            defaultBitmapImage_Compare = null;
642
                            GC.Collect();
643
                        };
644
                    }
645
                }
646
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
647
            }
648

    
649
            this.pageNavigator.ChangePage(e.PageNumber);
650
        }
651

    
652
        public async System.Threading.Tasks.Task<BitmapImage> GetDownloadImageAsync2(Uri uri,double pageWidth,double pageHeight)
653
        {
654
            BitmapImage defaultBitmapImage = new BitmapImage();
655

    
656
            using (System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient())
657
            {
658
                using (var responseStream = await httpClient.GetStreamAsync(uri))
659
                {
660
                    using (var memoryStream = new System.IO.MemoryStream())
661
                    {
662
                        await responseStream.CopyToAsync(memoryStream);
663

    
664
                        defaultBitmapImage.BeginInit();
665
                        defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
666
                        defaultBitmapImage.StreamSource = memoryStream;
667
                        defaultBitmapImage.DecodePixelWidth = (int)(pageWidth * (zoomAndPanControl.ContentScale * 10));
668
                        defaultBitmapImage.DecodePixelHeight = (int)(pageHeight * (zoomAndPanControl.ContentScale * 10));
669
                        defaultBitmapImage.EndInit();
670
                        defaultBitmapImage.Freeze();
671
                    }
672
                }
673
            }
674
            //defaultBitmapImage.Dispatcher.Invoke(() => { 
675
            //    defaultBitmapImage.BeginInit();
676
            //    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
677
            //    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
678
            //    defaultBitmapImage.UriSource = uri;
679
            //    defaultBitmapImage.DecodePixelWidth = Convert.ToInt32(pageWidth);
680
            //    defaultBitmapImage.DecodePixelHeight = Convert.ToInt32(pageHeight);// * zoomAndPanControl.ContentScale
681
            //    defaultBitmapImage.EndInit();
682

    
683
            //    ViewerDataModel.Instance.ImageViewPath = null;
684
            //    Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
685
            //    if (defaultBitmapImage.IsDownloading)
686
            //    {
687
            //        Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
688
            //        defaultBitmapImage.DownloadCompleted += (ex, arg) =>
689
            //        {
690
            //            defaultBitmapImage.Freeze();
691
            //            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
692
            //            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
693
            //            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
694

    
695
            //            //image dispose
696
            //            defaultBitmapImage = null;
697

    
698
            //            GC.Collect();
699
            //        };
700
            //    }
701
            //});
702

    
703
            System.Diagnostics.Debug.WriteLine("이미지 다운로드");
704
            return defaultBitmapImage;
705
        }
706

    
707
        /// <summary>
708
        /// called after page is changed
709
        /// </summary>
710
        /// <param name="sender"></param>
711
        /// <param name="e"></param>
712
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
713
        {
714
            if (zoomAndPanCanvas2.Width.IsNaN())
715
            {
716
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
717
            }
718

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

    
744
            /// fire selection event
745
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
746
            this.gridViewMarkup.UnselectAll();
747
            this.gridViewMarkup.Select(gridSelectionItem);
748

    
749
            if (!testPanel2.IsHidden)
750
            {
751
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
752
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
753
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
754

    
755
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
756
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
757

    
758

    
759
                foreach (var item in gridSelectionRevItem)
760
                {
761
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
762
                    {
763
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
764
                    });
765
                }
766
            }
767

    
768
            var instanceMain = this.ParentOfType<MainWindow>();
769
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
770
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
771

    
772
            instanceMain.dzTopMenu.rotateOffSet = 0;
773
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
774
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
775

    
776
            SetCommentPages(true);
777
        }
778

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

    
809
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
810
        {
811
            if (e.MiddleButton == MouseButtonState.Pressed)
812
            {
813

    
814
            }
815
            e.Handled = true;
816
            if (e.Delta > 0)
817
            {
818
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
819
                ZoomIn(currentContentMousePoint);
820
            }
821
            else
822
            {
823
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
824
                ZoomOut(currentContentMousePoint);
825
            }
826
        }
827

    
828
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
829
        {
830
            e.Handled = true;
831
            if (e.Delta > 0)
832
            {
833
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
834
                ZoomIn_Sync(currentContentMousePoint);
835
            }
836
            else
837
            {
838
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
839
                ZoomOut_Sync(currentContentMousePoint);
840
            }
841
        }
842

    
843
        #region ZoomIn & ZoomOut
844

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

    
851
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
852
        {
853
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
854
                zoomAndPanControl.ContentZoomFocusY));
855
        }
856

    
857

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

    
871
            if (zoomAndPanControl2 != null && Sync.IsChecked)
872
            {
873
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
874
            }
875
        }
876

    
877
        private void ZoomIn(Point contentZoomCenter)
878
        {
879
            if (zoomAndPanControl.ContentScale > 0.19)
880
            {
881
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
882
            }
883
            else
884
            {
885
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
886
            }
887

    
888
            if (zoomAndPanControl2 != null && Sync.IsChecked)
889
            {
890
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
891
            }
892

    
893
        }
894

    
895
        private void ZoomOut_Sync(Point contentZoomCenter)
896
        {
897
            if (zoomAndPanControl2.ContentScale > 0.39)
898
            {
899
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
900
            }
901
            else
902
            {
903
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
904
            }
905

    
906
            if (Sync.IsChecked)
907
            {
908
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
909
            }
910
        }
911

    
912
        private void ZoomIn_Sync(Point contentZoomCenter)
913
        {
914
            if (zoomAndPanControl2.ContentScale > 0.19)
915
            {
916
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
917
            }
918
            else
919
            {
920
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
921
            }
922

    
923
            if (Sync.IsChecked)
924
            {
925
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
926
            }
927
        }
928

    
929
        private void ZoomOut()
930
        {
931
            zoomAndPanControl.ContentScale -= 0.1;
932
            //if (zoomAndPanControl2 != null)
933
            //{
934
            //    zoomAndPanControl2.ContentScale -= 0.1;
935
            //}
936
        }
937

    
938
        private void ZoomIn()
939
        {
940
            zoomAndPanControl.ContentScale += 0.1;
941
            //if (zoomAndPanControl2 != null)
942
            //{
943
            //    zoomAndPanControl2.ContentScale += 0.1;
944
            //}
945
        }
946

    
947
        #endregion
948

    
949
        private void init()
950
        {
951
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
952
            {
953

    
954
                ControlList.Clear();
955
                listBox.Items.Clear();
956
                selected_item.Clear();
957

    
958
                (item as IMarkupCommonData).IsSelected = false;
959
            }
960

    
961
        }
962

    
963
        private HitTestResultBehavior MyCallback(HitTestResult result)
964
        {
965
            //this.cursor = Cursors.UpArrow;
966
            var element = result.VisualHit;
967
            while (element != null && !(element is CommentUserInfo))
968
                element = VisualTreeHelper.GetParent(element);
969

    
970
            if (element == null)
971
            {
972
                return HitTestResultBehavior.Stop;
973
            }
974
            else
975
            {
976
                if (element is CommentUserInfo)
977
                {
978
                    if (!hitList.Contains(element))
979
                    {
980
                        hitList.Add((CommentUserInfo)element);
981
                    }
982
                    else
983
                    {
984
                        return HitTestResultBehavior.Stop;
985
                    }
986
                }
987
            }
988
            return HitTestResultBehavior.Continue;
989
        }
990

    
991
        public void ReleaseSelectPath()
992
        {
993
            if (SelectionPath == null)
994
            {
995
                SelectionPath = new Path();
996
                SelectionPath.Name = "";
997
            }
998
            if (SelectionPath.Name != "")
999
            {
1000
                SelectionPath.Name = "None";
1001
            }
1002
            SelectionPath.Opacity = 0.01;
1003
            SelectionPath.RenderTransform = null;
1004
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1005
        }
1006

    
1007
        #region 컨트롤 초기화 
1008
        public void Control_Init(object control)
1009
        {
1010
            if (L_Size != 0 && (control as IPath) != null)
1011
            {
1012
                (control as IPath).LineSize = L_Size;
1013
                L_Size = 0;
1014
            }
1015

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

    
1102
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1103
        {
1104
            //Control_Init(e.Source);
1105
        }
1106
        //private Window _dragdropWindow = null;
1107

    
1108
        [DllImport("user32.dll")]
1109
        [return: MarshalAs(UnmanagedType.Bool)]
1110
        internal static extern bool GetCursorPos(ref Win32Point pt);
1111

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

    
1129

    
1130
               if (this._dragdropWindow != null)
1131
               {
1132
                   this._dragdropWindow.Close();
1133
                   this._dragdropWindow = null;
1134
               }
1135

    
1136
               symbol_id = id;
1137
               symbol_group_id = group_id;
1138
               symbol_SelectedIndex = SelectedIndex;
1139
               symbol_Data = Data_;
1140
               symbol_img = img;
1141

    
1142

    
1143
               CreateDragDropWindow2(img);
1144
              
1145
    }
1146

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

    
1167
            Win32Point w32Mouse = new Win32Point();
1168
            GetCursorPos(ref w32Mouse);
1169

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

    
1182
                Point currentPos = e.GetPosition(rect);
1183

    
1184
                floatingTip.HorizontalOffset = currentPos.X + 20;
1185
                floatingTip.VerticalOffset = currentPos.Y;
1186
            }
1187

    
1188
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1189
            
1190
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1191
            {
1192
                SetCursor();
1193
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1194
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1195

    
1196
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1197
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1198
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1199

    
1200
                if (Sync.IsChecked)
1201
                {
1202
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1203
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1204
                }
1205
            }
1206

    
1207
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1208
            {
1209
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1210
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1211
                SetCursor();
1212

    
1213
                if (currentControl != null)
1214
                {
1215
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1216
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1217
                    //강인구 추가
1218
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1219

    
1220
                    if ((currentControl as IPath) != null)
1221
                    {
1222
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1223
                    }
1224
                    if ((currentControl as LineControl) != null)
1225
                    {
1226
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1227
                    }
1228

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

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

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

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

    
1380
                        case ControlType.Circle:
1381
                            {
1382
                                if (currentControl != null)
1383
                                {
1384
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1385
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1386
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1387
                                }
1388
                            }
1389
                            break;
1390

    
1391
                        case ControlType.PolygonCloud:
1392
                            {
1393
                                var control = currentControl as CloudControl;
1394
                                if (control != null)
1395
                                {
1396
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1397
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1398
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1399
                                }
1400
                            }
1401
                            break;
1402

    
1403
                        case ControlType.Triangle:
1404
                            {
1405
                                var control = currentControl as TriControl;
1406
                                if (control != null)
1407
                                {
1408
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1409
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1410
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1411
                                }
1412
                            }
1413
                            break;
1414

    
1415
                        case ControlType.ImgControl:
1416
                            {
1417
                                var control = currentControl as ImgControl;
1418
                                if (control != null)
1419
                                {
1420
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1421
                                }
1422
                            }
1423
                            break;
1424

    
1425
                        case ControlType.Date:
1426
                            {
1427
                                var control = currentControl as DateControl;
1428
                                if (control != null)
1429
                                {
1430
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1431
                                }
1432
                            }
1433
                            break;
1434

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

    
1544
                                //inkBoard.Strokes.Add(stroke);
1545
                            }
1546
                            break;
1547
                    }
1548
                    return;
1549
                }
1550
            }
1551
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1552
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1553
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1554
            {
1555
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1556

    
1557
                if (isDraggingSelectionRect)
1558
                {
1559
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1560
                    e.Handled = true;
1561
                }
1562
                else if (isLeftMouseButtonDownOnWindow)
1563
                {
1564
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1565
                    double dragDistance = Math.Abs(dragDelta.Length);
1566

    
1567
                    if (dragDistance > DragThreshold)
1568
                    {
1569
                        isDraggingSelectionRect = true;
1570
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1571
                    }
1572

    
1573
                    e.Handled = true;
1574
                }
1575

    
1576
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1577
                {
1578
                }
1579
                else
1580
                {
1581
                    e.Handled = true;
1582
                }
1583
            }
1584
            /*
1585
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1586
            { //symbol      
1587
                if(_dragdropWindow != null)
1588
                {
1589
                    Win32Point w32Mouse = new Win32Point();
1590
                    GetCursorPos(ref w32Mouse);
1591

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

    
1617
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1618
        {
1619
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1620
            {
1621
                SetCursor();
1622
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1623
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1624

    
1625
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1626

    
1627
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1628
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1629

    
1630
                if (Sync.IsChecked)
1631
                {
1632
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1633
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1634
                }
1635
            }
1636
        }
1637

    
1638
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1639

    
1640
        private EllipseGeometry hitArea = new EllipseGeometry();
1641

    
1642
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1643
        {
1644
            IsDrawing = false;
1645

    
1646
            if (mouseHandlingMode != MouseHandlingMode.None)
1647
            {
1648
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1649
                {
1650
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1651

    
1652
                    SetCursor();
1653

    
1654
                    switch (controlType)
1655
                    {
1656
                        case ControlType.None:
1657
                            break;
1658
                        case ControlType.Rectangle:
1659
                            {
1660

    
1661
                            }
1662
                            break;
1663
                        case ControlType.PenControl:
1664
                            {
1665

    
1666
                            }
1667
                            break;
1668
                        default:
1669
                            break;
1670
                    }                    
1671
                }
1672
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1673
                {
1674
                    if (isLeftMouseButtonDownOnWindow)
1675
                    {
1676
                        bool wasDragSelectionApplied = false;
1677

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

    
1697
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1698
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1699
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1700
                            }
1701
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1702
                            {
1703
                                ApplyDragSelectionRect();
1704
                            }
1705
                            else
1706
                            {
1707
                                double x = Canvas.GetLeft(dragZoomBorder);
1708
                                double y = Canvas.GetTop(dragZoomBorder);
1709
                                double width = dragZoomBorder.Width;
1710
                                double height = dragZoomBorder.Height;
1711
                                Rect dragRect = new Rect(x, y, width, height);
1712

    
1713
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1714

    
1715
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1716
                            }
1717

    
1718
                            isDraggingSelectionRect = false;
1719
                            e.Handled = true;
1720
                            wasDragSelectionApplied = true;
1721
                        }
1722

    
1723
                        if (isLeftMouseButtonDownOnWindow)
1724
                        {
1725
                            isLeftMouseButtonDownOnWindow = false;
1726
                            this.ReleaseMouseCapture();
1727
                            e.Handled = true;
1728
                        }
1729

    
1730
                        if (!wasDragSelectionApplied)
1731
                        {
1732
                            init();
1733
                        }
1734
                    }
1735
                }
1736
                else if (e.RightButton == MouseButtonState.Pressed)
1737
                {
1738
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1739
                    SetCursor();
1740
                }
1741

    
1742
                zoomAndPanControl.ReleaseMouseCapture();
1743

    
1744

    
1745
                e.Handled = true;
1746
            }
1747
            else
1748
            {
1749
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1750
                SetCursor();
1751
            }
1752

    
1753
            ///mouseButtonDown = MouseButton.Left;
1754
            //controlType = ControlType.SingleLine;
1755
        }
1756

    
1757
        public void Set_Symbol_Capture(Point endPoint)
1758
        {       
1759
            double x = canvasDrawingMouseDownPoint.X;
1760
            double y = canvasDrawingMouseDownPoint.Y;
1761
            if(x > endPoint.X)
1762
            {
1763
                x = endPoint.X;
1764
                y = endPoint.Y;
1765
            }
1766

    
1767
            double width = dragCaptureBorder.Width;
1768
            double height = dragCaptureBorder.Height;
1769

    
1770
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1771

    
1772
            if (x < 0)
1773
            {
1774
                width += x;
1775
                x = 0;
1776
            }
1777
            if (y < 0)
1778
            {
1779
                height += y;
1780
                y = 0;
1781

    
1782
                width = (int)canvasImage.PixelWidth - x;
1783
            }
1784
            if (x + width > canvasImage.PixelWidth)
1785
            {
1786
                width = (int)canvasImage.PixelWidth - x;
1787
            }
1788
            if (y + height > canvasImage.PixelHeight)
1789
            {
1790
                height = (int)canvasImage.PixelHeight - y;
1791
            }
1792
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1793

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

    
1806
            var defaultBitmapImage = new BitmapImage();
1807
            defaultBitmapImage.BeginInit();
1808
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1809
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1810
            defaultBitmapImage.UriSource = new Uri(uri);
1811
            defaultBitmapImage.EndInit();
1812

    
1813
            //GC.Collect();
1814

    
1815
            if (defaultBitmapImage.IsDownloading)
1816
            {
1817
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1818
                {
1819
                    defaultBitmapImage.Freeze();
1820
                    //GC.Collect();
1821
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1822
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1823
                };
1824
            }
1825
        }
1826

    
1827
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1828
        {
1829
            ///mouseButtonDown = MouseButton.Left;
1830
        }
1831

    
1832
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1833
        {
1834
            ///mouseButtonDown = MouseButton.Left;
1835
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1836
        }
1837

    
1838
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1839
        {
1840

    
1841
        }
1842

    
1843
        /// <summary>
1844
        /// select items by dragging
1845
        /// </summary>
1846
        private void ApplyDragSelectionRect()
1847
        {
1848
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1849

    
1850
            double x = Canvas.GetLeft(dragSelectionBorder);
1851
            double y = Canvas.GetTop(dragSelectionBorder);
1852
            double width = dragSelectionBorder.Width;
1853
            double height = dragSelectionBorder.Height;
1854
            Boolean Flag = false;
1855
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1856
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1857

    
1858
            Rect dragRect = new Rect(x, y, width, height);
1859
            ///dragRect.Inflate(width / 10, height / 10);
1860

    
1861
            foreach (var item in Items)
1862
            {
1863
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1864

    
1865
                if (Flag)
1866
                {
1867
                    adornerSet.Add(item);
1868
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1869
                    Control_Style(item);
1870
                }
1871
            }
1872
            if (adornerSet.Count > 0)
1873
            {
1874
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1875
                SelectLayer.Children.Add(final);
1876
            }
1877
        }
1878

    
1879
        private void InitDragSelectionRect(Point pt1, Point pt2)
1880
        {
1881
            //캡쳐 중
1882
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1883
            {
1884
                dragCaptureBorder.Visibility = Visibility.Visible;
1885
            }
1886
            //선택 중
1887
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1888
            {
1889

    
1890
                dragSelectionBorder.Visibility = Visibility.Visible;
1891
            }
1892
            else
1893
            {
1894
                dragZoomBorder.Visibility = Visibility.Visible;
1895
            }
1896
            UpdateDragSelectionRect(pt1, pt2);
1897
        }
1898

    
1899
        /// <summary>
1900
        /// Update the position and size of the rectangle used for drag selection.
1901
        /// </summary>
1902
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1903
        {
1904
            double x, y, width, height;
1905

    
1906
            //
1907
            // Determine x,y,width and height of the rect inverting the points if necessary.
1908
            // 
1909

    
1910
            if (pt2.X < pt1.X)
1911
            {
1912
                x = pt2.X;
1913
                width = pt1.X - pt2.X;
1914
            }
1915
            else
1916
            {
1917
                x = pt1.X;
1918
                width = pt2.X - pt1.X;
1919
            }
1920

    
1921
            if (pt2.Y < pt1.Y)
1922
            {
1923
                y = pt2.Y;
1924
                height = pt1.Y - pt2.Y;
1925
            }
1926
            else
1927
            {
1928
                y = pt1.Y;
1929
                height = pt2.Y - pt1.Y;
1930
            }
1931

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

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

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

    
1993
            zoomAndPanControl.RotationAngle = rotate.Angle;
1994

    
1995

    
1996
            if (!testPanel2.IsHidden)
1997
            {
1998
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1999
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2000
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2001
            }
2002

    
2003
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2004
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2005
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2006
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2007
            ViewerDataModel.Instance.Angle = rotate.Angle;
2008
        }
2009

    
2010
        private void syncPannelRotate(double angle)
2011
        {
2012
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2013
            rotate.Angle = angle;
2014
            var rotationNum = Math.Abs((rotate.Angle / 90));
2015

    
2016
            if (angle == 90 || angle == 270)
2017
            {
2018
                double emptySize = zoomAndPanCanvas2.Width;
2019
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2020
                zoomAndPanCanvas2.Height = emptySize;
2021
            }
2022
            if (angle == 0)
2023
            {
2024
                translate2.X = 0;
2025
                translate2.Y = 0;
2026
            }
2027
            else if (angle == 90)
2028
            {
2029
                translate2.X = zoomAndPanCanvas2.Width;
2030
                translate2.Y = 0;
2031
            }
2032
            else if (angle == 180)
2033
            {
2034
                translate2.X = zoomAndPanCanvas2.Width;
2035
                translate2.Y = zoomAndPanCanvas2.Height;
2036
            }
2037
            else
2038
            {
2039
                translate2.X = 0;
2040
                translate2.Y = zoomAndPanCanvas2.Height;
2041
            }
2042

    
2043
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2044
        }
2045

    
2046
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2047
        {
2048
            string Data_ = "";
2049

    
2050
            try
2051
            {
2052
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2053
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2054
                if (Data_ != null || Data_ != "")
2055
                {
2056
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2057
                }
2058
                else
2059
                {
2060
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2061
                }
2062

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

    
2089
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2090
                    {
2091
                        PointSet = new List<Point>(),
2092
                        FilePath = Data_,
2093
                        ImageData = img.Source,
2094
                        StartPoint = canvasZoomPanningMouseDownPoint,
2095
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2096
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2097
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2098
                        canvasZoomPanningMouseDownPoint.Y),
2099
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2100
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2101
                    };
2102

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

    
2123
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2124
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2125
                    UndoData.Markup_List.Add(multi_Undo_Data);
2126
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2127

    
2128
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2129
                    currentControl.CommentID = Commons.shortGuid();
2130
                    currentControl.SymbolID = id;
2131
                    currentControl.GroupID = group_id;
2132
                    currentControl.ApplyTemplate();
2133
                    currentControl.SetImage();
2134

    
2135
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2136
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2137
                    SelectLayer.Children.Add(final);
2138
                }
2139
            }
2140
            catch (Exception ex)
2141
            {
2142
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2143
            }
2144
        }
2145

    
2146
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2147
        {            
2148
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2149
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2150
            {
2151
                set_option.Value = double.Parse(set_option.ContentText);
2152
            }
2153

    
2154
            ConvertInkControlToPolygon();
2155

    
2156
            ///TODO:
2157
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2158
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2159

    
2160
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2161
            {
2162
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2163
            }
2164
            /// up to here
2165

    
2166
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2167
            {
2168
                if (arrow_text as ArrowTextControl != null)
2169
                {
2170
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2171
                }
2172
            }
2173

    
2174
            //if (currentControl != null)
2175
            {
2176
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2177
                if (text_item_ != null)
2178
                {
2179
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2180
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2181
                    (text_item_ as TextControl).EnableEditing = false;
2182
                    currentControl = null;
2183
                }
2184

    
2185
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2186
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2187
                {
2188
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2189
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2190
                    currentControl = null;
2191
                }
2192
            }
2193

    
2194
            double Ang = 0;                                          
2195
            if (rotate.Angle != 0)
2196
            {
2197
                Ang = 360 - rotate.Angle;
2198
            }
2199

    
2200
            if (e.OriginalSource is System.Windows.Controls.Image)
2201
            {
2202
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2203
            }
2204
            /*
2205
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2206
            {                
2207
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2208
                if(symbol_id != null)
2209
                {
2210
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2211
                }                
2212
            }
2213

    
2214
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2215
            {
2216
                if (this._dragdropWindow != null)
2217
                {
2218
                    this._dragdropWindow.Close();
2219
                    this._dragdropWindow = null;
2220
                    symbol_id = null;
2221
                }
2222
            }
2223
            */
2224

    
2225
            if (e.LeftButton == MouseButtonState.Pressed)
2226
            {
2227
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2228
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2229

    
2230
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2231
                SetCursor();
2232

    
2233
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2234
            }
2235

    
2236
            if (e.MiddleButton == MouseButtonState.Pressed)
2237
            {
2238
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2239
                cursor = Cursors.SizeAll;
2240
                SetCursor();
2241
            }
2242
            if (e.RightButton == MouseButtonState.Pressed)
2243
            {
2244
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2245
                cursor = Cursors.SizeAll;
2246
                SetCursor();
2247
            }
2248
            else if (e.XButton1 == MouseButtonState.Pressed)
2249
            {
2250
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2251
                {
2252
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2253
                }
2254

    
2255
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2256

    
2257
            }
2258
            else if (e.XButton2 == MouseButtonState.Pressed)
2259
            {
2260
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2261
                {
2262
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2263
                }
2264
            }
2265

    
2266
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2267
            {
2268
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2269
                {
2270
                    if (SelectLayer.Children.Count == 0)
2271
                    {
2272
                        isLeftMouseButtonDownOnWindow = true;
2273
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2274
                    }
2275

    
2276
                    if (controlType == ControlType.None)
2277
                    {
2278
                        isLeftMouseButtonDownOnWindow = true;
2279
                    }
2280
                }
2281

    
2282
                /// 캡쳐 모드 설정
2283
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2284
                {
2285
                    dragCaptureBorder.Visibility = Visibility.Visible;
2286
                    isLeftMouseButtonDownOnWindow = true;
2287
                }
2288

    
2289
                /// 줌 모드 설정
2290
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2291
                {
2292
                    isLeftMouseButtonDownOnWindow = true;
2293
                }
2294

    
2295
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2296
                if (control != null)
2297
                {
2298
                    AdornerFinal final = null;
2299

    
2300
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2301
                    {
2302
                        /// 기존 selection 해제
2303
                        SelectionSet.Instance.UnSelect(this);
2304

    
2305
                        final = new AdornerFinal(control);
2306

    
2307
                        this.Control_Style(control);
2308

    
2309
                        if ((control as IPath) != null)
2310
                        {
2311
                            if ((control as IPath).LineSize != 0)
2312
                            {
2313
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2314
                            }
2315
                        }
2316
                        if ((control as IShapeControl) != null)
2317
                        {
2318
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2319
                            {
2320
                                ViewerDataModel.Instance.checkHatchShape = true;
2321
                            }
2322
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2323
                            {
2324
                                ViewerDataModel.Instance.checkFillShape = true;
2325
                            }
2326
                            else
2327
                            {
2328
                                ViewerDataModel.Instance.checkHatchShape = false;
2329
                                ViewerDataModel.Instance.checkFillShape = false;
2330
                            }
2331
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2332
                        }
2333

    
2334
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2335

    
2336
                        if ((control as TextControl) != null)
2337
                        {
2338
                            if(!((control as TextControl).EnableEditing)) {
2339
                                (control as TextControl).EnableEditing = true;
2340
                            }
2341

    
2342
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2343
                            {
2344
                                ViewerDataModel.Instance.checkTextStyle = true;
2345
                            }
2346
                            else
2347
                            {
2348
                                ViewerDataModel.Instance.checkTextStyle = false;
2349
                            }
2350

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

    
2378
                        }
2379
                        else if ((control as ArrowTextControl) != null)
2380
                        {
2381
                            if (!((control as ArrowTextControl).EnableEditing))
2382
                            {
2383
                                (control as ArrowTextControl).EnableEditing = true;
2384
                            }
2385
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2386
                            {
2387
                                ViewerDataModel.Instance.checkTextStyle = true;
2388
                            }
2389
                            else
2390
                            {
2391
                                ViewerDataModel.Instance.checkTextStyle = false;
2392
                            }
2393

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

    
2436
                        Control_Style(control);
2437

    
2438
                        final = new AdornerFinal(comment);
2439
                    }
2440

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

    
2484
                switch (controlType)
2485
                {
2486
                    case ControlType.Coordinate:
2487
                        {
2488
                            if (e.LeftButton == MouseButtonState.Pressed)
2489
                            {
2490
                                if (currentControl is CoordinateControl)
2491
                                {
2492
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2493
                                    {
2494
                                        return;
2495
                                    }
2496

    
2497
                                    CreateCommand.Instance.Execute(currentControl);
2498

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

    
2522
                                        currentControl.CommentID = Commons.shortGuid();
2523
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2524
                                        currentControl.IsNew = true;
2525

    
2526
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2527

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

    
2545
                                    CreateCommand.Instance.Execute(currentControl);
2546

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

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

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

    
2580
                                    CreateCommand.Instance.Execute(currentControl);
2581

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

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

    
2599
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2600
                                }
2601
                            }
2602
                        }
2603
                        break;
2604
                    case ControlType.ClipWhite:
2605
                        {
2606
                            if (e.LeftButton == MouseButtonState.Pressed)
2607
                            {
2608
                                if (currentControl is ClipWhiteControl)
2609
                                {
2610
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2611
                                    {
2612
                                        return;
2613
                                    }
2614

    
2615
                                    CreateCommand.Instance.Execute(currentControl);
2616

    
2617
                                    currentControl = null;
2618
                                    this.cursor = Cursors.Arrow;
2619
                                }
2620
                                else
2621
                                {
2622
                                    currentControl = new ClipWhiteControl
2623
                                    {
2624
                                        Background = new SolidColorBrush(Colors.Black),
2625
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2626
                                        ControlType = ControlType.ClipWhite
2627
                                    };
2628

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

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

    
2651
                                    CreateCommand.Instance.Execute(currentControl);
2652
                                    currentControl = null;
2653
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2654
                                }
2655
                                else
2656
                                {
2657
                                    currentControl = new RectangleControl
2658
                                    {
2659
                                        Background = new SolidColorBrush(Colors.Black),
2660
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2661
                                        ControlType = ControlType.Rectangle
2662
                                    };
2663

    
2664
                                    currentControl.CommentID = Commons.shortGuid();
2665
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2666
                                    currentControl.IsNew = true;
2667
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2668

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

    
2686
                                    CreateCommand.Instance.Execute(currentControl);
2687

    
2688
                                    currentControl = null;
2689
                                
2690
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2691
                                }
2692
                                else
2693
                                {
2694
                                    currentControl = new RectCloudControl
2695
                                    {
2696
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2697
                                        ControlType = ControlType.RectCloud,
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.Circle:
2710
                        {
2711
                            if (e.LeftButton == MouseButtonState.Pressed)
2712
                            {
2713
                                if (currentControl is CircleControl)
2714
                                {
2715
                                    //20180906 LJY TEST IsRotationDrawingEnable
2716
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2717
                                    {
2718
                                        return;
2719
                                    }
2720

    
2721
                                    CreateCommand.Instance.Execute(currentControl);
2722

    
2723
                                    currentControl = null;
2724
                                }
2725
                                else
2726
                                {
2727
                                    currentControl = new CircleControl
2728
                                    {
2729
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2730
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2731
                                        Background = new SolidColorBrush(Colors.Black)
2732
                                    };
2733

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

    
2761
                                        CreateCommand.Instance.Execute(currentControl);
2762

    
2763
                                        currentControl = null;
2764
                                    }
2765
                                }
2766
                                else
2767
                                {
2768
                                    currentControl = new TriControl
2769
                                    {
2770
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2771
                                        Background = new SolidColorBrush(Colors.Black),
2772
                                    };
2773

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

    
2798
                                    CreateCommand.Instance.Execute(currentControl);
2799
                                    currentControl = null;
2800
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2801
                                }
2802
                                else
2803
                                {
2804
                                    currentControl = new LineControl
2805
                                    {
2806
                                        ControlType = this.controlType,
2807
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2808
                                        Background = new SolidColorBrush(Colors.Black)
2809
                                    };
2810

    
2811
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2812
                                    currentControl.CommentID = Commons.shortGuid();
2813
                                    currentControl.IsNew = true;
2814
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2815
                                    this.MainAngle.Visibility = Visibility.Visible;
2816
                                }
2817
                            }
2818
                        }
2819
                        break;
2820
                    case ControlType.PolygonControl:
2821
                        {
2822
                            if (currentControl is PolygonControl)
2823
                            {
2824
                                var control = currentControl as PolygonControl;
2825

    
2826
                                if (e.RightButton == MouseButtonState.Pressed)
2827
                                {
2828
                                    control.IsCompleted = true;
2829
                                }
2830

    
2831
                                if (!control.IsCompleted)
2832
                                {
2833
                                    control.PointSet.Add(control.EndPoint);
2834
                                }
2835
                                else
2836
                                {
2837
                                    //20180906 LJY TEST IsRotationDrawingEnable
2838
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2839
                                    {
2840
                                        return;
2841
                                    }
2842

    
2843
                                    var firstPoint = control.PointSet.First();
2844
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2845
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2846
                                    control.PointSet.Add(firstPoint);
2847

    
2848
                                    control.ApplyOverViewData();
2849

    
2850
                                    CreateCommand.Instance.Execute(currentControl);
2851
                                    control.UpdateControl();
2852
                                    currentControl = null;
2853
                                }
2854
                            }
2855
                            else
2856
                            {
2857
                                if (e.LeftButton == MouseButtonState.Pressed)
2858
                                {
2859
                                    currentControl = new PolygonControl
2860
                                    {
2861
                                        PointSet = new List<Point>(),
2862
                                    };
2863

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

    
2885
                                if (e.RightButton == MouseButtonState.Pressed)
2886
                                {
2887
                                    //20180906 LJY TEST IsRotationDrawingEnable
2888
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2889
                                    {
2890
                                        return;
2891
                                    }
2892

    
2893
                                    CreateCommand.Instance.Execute(currentControl);
2894

    
2895
                                    currentControl = null;
2896
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2897
                                    return;
2898
                                }
2899

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

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

    
2950
                                    CreateCommand.Instance.Execute(currentControl);
2951

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

    
2993
                                    CreateCommand.Instance.Execute(currentControl);
2994

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

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

    
3053
                                            CreateCommand.Instance.Execute(currentControl);
3054

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

    
3086
                                if (!control.IsCompleted)
3087
                                {
3088
                                    control.PointSet.Add(control.EndPoint);
3089
                                }
3090
                                else
3091
                                {
3092
                                    //20180906 LJY TEST IsRotationDrawingEnable
3093
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3094
                                    {
3095
                                        return;
3096
                                    }
3097

    
3098
                                    CreateCommand.Instance.Execute(currentControl);
3099

    
3100
                                    control.isTransOn = true;
3101
                                    var firstPoint = control.PointSet.First();
3102

    
3103
                                    control.PointSet.Add(firstPoint);
3104
                                    control.DrawingCloud();
3105
                                    control.ApplyOverViewData();
3106

    
3107
                                    currentControl = null;
3108
                                }
3109
                            }
3110
                            else
3111
                            {
3112
                                if (e.LeftButton == MouseButtonState.Pressed)
3113
                                {
3114
                                    currentControl = new CloudControl
3115
                                    {
3116
                                        PointSet = new List<Point>(),
3117
                                        PointC = new StylusPointSet()
3118
                                    };
3119

    
3120
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3121
                                    //{
3122
                                        var polygonControl = (currentControl as CloudControl);
3123
                                        currentControl.CommentID = Commons.shortGuid();
3124
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3125
                                        currentControl.IsNew = true;
3126
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3127

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

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

    
3178
                                            currentControl = new ImgControl
3179
                                            {
3180
                                                    Background = new SolidColorBrush(Colors.Black),
3181
                                                    PointSet = new List<Point>(),
3182
                                                    FilePath = filename,
3183
                                                    ImageData = img.Source,
3184
                                                    StartPoint = canvasDrawingMouseDownPoint,
3185
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3186
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3187
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3188
                                                    ControlType = ControlType.ImgControl
3189
                                                };
3190

    
3191
                                        
3192
                                                currentControl.CommentID = Commons.shortGuid();                                            
3193
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3194
                                                currentControl.IsNew = true;
3195
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3196

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

    
3219
                                        CreateCommand.Instance.Execute(currentControl);
3220
                                        currentControl = null;
3221

    
3222
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3223
                                        {
3224
                                            controlType = ControlType.None;
3225
                                            IsSwingMode = false;
3226
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3227
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3228
                                            mouseHandlingMode = MouseHandlingMode.None;
3229
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3230
                                            txtBatch.Visibility = Visibility.Collapsed;
3231

    
3232
                                        }
3233
                                    }
3234
                                    else
3235
                                    {
3236
                                        currentControl = new DateControl
3237
                                        {
3238
                                            StartPoint = canvasDrawingMouseDownPoint,
3239
                                            Background = new SolidColorBrush(Colors.Black)
3240
                                        };
3241
                                        currentControl.CommentID = Commons.shortGuid();
3242
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3243
                                        currentControl.IsNew = true;
3244
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3245

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

    
3270
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3271
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3272
                                    
3273
                                    (currentControl as TextControl).ControlType_No = 0;
3274
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3275
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3276
                                    (currentControl as TextControl).ApplyTemplate();
3277
                                    (currentControl as TextControl).Base_TextBox.Focus();
3278

    
3279
                                    CreateCommand.Instance.Execute(currentControl);
3280
                                }
3281
                            }
3282
                        }
3283
                        break;
3284
                    case ControlType.TextBorder:
3285
                        {
3286
                            if (e.LeftButton == MouseButtonState.Pressed)
3287
                            {
3288
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3289
                                {
3290
                                    currentControl = new TextControl
3291
                                    {
3292
                                        ControlType = controlType
3293
                                    };
3294

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

    
3325
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3326
                                    currentControl.CommentID = Commons.shortGuid();
3327
                                    currentControl.IsNew = true;
3328
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3329
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3330

    
3331
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3332
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3333
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3334

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

    
3358
                                    CreateCommand.Instance.Execute(currentControl);
3359

    
3360
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3361
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3362
                                    (currentControl as ArrowTextControl).IsNew = false;
3363
                                    currentControl = null;
3364
                                }
3365
                                else
3366
                                {
3367
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3368
                                    //{
3369
                                        currentControl = new ArrowTextControl();
3370
                                        currentControl.CommentID = Commons.shortGuid();
3371
                                        currentControl.IsNew = true;
3372
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3373
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3374

    
3375
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3376
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3377
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3378
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3379
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3380

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

    
3384
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3385
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3386
                                        this.MainAngle.Visibility = Visibility.Visible;
3387

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

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

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

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

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

    
3472
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3473

    
3474
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3475

    
3476
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3477
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3478
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3479

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

    
3513
                                    currentControl = new ArrowTextControl()
3514
                                    {
3515
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3516
                                        ControlType = ControlType.ArrowTransTextBorderControl
3517

    
3518
                                    };
3519
                                        currentControl.CommentID = Commons.shortGuid();
3520
                                        currentControl.IsNew = true;
3521
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3522
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3523

    
3524
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3525

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

    
3536
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3537
                                        this.MainAngle.Visibility = Visibility.Visible;
3538
                                    
3539
                                    //20180911 LJY
3540
                                        (currentControl as ArrowTextControl).isTrans = true;
3541
                                    
3542

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

    
3578
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3579
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3580
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3581
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3582
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3583

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

    
3621
                                        };
3622
                                        currentControl.CommentID = Commons.shortGuid();
3623
                                        currentControl.IsNew = true; 
3624
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3625
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3626
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3627

    
3628
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3629
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3630
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3631
                                        (currentControl as ArrowTextControl).isFixed = true;
3632
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3633

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

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

    
3657
                                    if (_sign == null)
3658
                                    {
3659
                                        txtBatch.Visibility = Visibility.Collapsed;
3660
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3661
                                        controlType = ControlType.None;
3662

    
3663
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3664
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3665
                                        return;
3666
                                    }
3667

    
3668
                                    if (currentControl is SignControl)
3669
                                    {
3670
                                        //20180906 LJY TEST IsRotationDrawingEnable
3671
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3672
                                        {
3673
                                            return;
3674
                                        }
3675

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

    
3696
                                        currentControl.CommentID = Commons.shortGuid();
3697
                                        currentControl.IsNew = true;
3698
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3699
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3700

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

    
3722
                                        CreateCommand.Instance.Execute(currentControl);
3723
                                        (currentControl as RectangleControl).ApplyOverViewData();
3724
                                        currentControl = null;
3725
                                    
3726
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3727

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

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

    
3780
                                    currentControl.IsNew = true;
3781
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3782
                                    currentControl.CommentID = Commons.shortGuid();
3783
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3784

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

    
3806
                                        CreateCommand.Instance.Execute(currentControl);
3807
                                        currentControl = null;
3808
                                   
3809

    
3810
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3811
                                    }
3812
                                    else
3813
                                    {
3814
                                        currentControl = new SymControlN
3815
                                        {
3816
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3817
                                            Background = new SolidColorBrush(Colors.Black),
3818
                                            STAMP = App.SystemInfo.STAMP,                                            
3819
                                            ControlType = ControlType.Stamp
3820
                                        };
3821

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

    
3870
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3871
                            if (over != null)
3872
                            {
3873
                                mouseOff = true;
3874
                            }
3875
                        }
3876
                    }
3877

    
3878
                    if (!mouseOff)
3879
                    {
3880
                        SelectionSet.Instance.UnSelect(this);
3881
                    }
3882
                }
3883
                zoomAndPanControl.CaptureMouse();
3884
                e.Handled = true;
3885
            }
3886
        }
3887

    
3888
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3889
        {
3890
            ///mouseButtonDown = e.ChangedButton;
3891
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3892
        }
3893

    
3894
        private void RemoveLineStroke(Point P)
3895
        {
3896
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3897
            if (control != null)
3898
            {
3899
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3900
            }
3901
        }
3902

    
3903
        private void RemovePointStroke(Point P)
3904
        {
3905
            foreach (Stroke hits in inkBoard.Strokes)
3906
            {
3907
                foreach (StylusPoint sty in hits.StylusPoints)
3908
                {
3909

    
3910
                }
3911
                if (hits.HitTest(P))
3912
                {
3913
                    inkBoard.Strokes.Remove(hits);
3914
                    return;
3915
                }
3916
            }
3917
        }
3918

    
3919
        private void StartNewStroke(Point P)
3920
        {
3921
            strokePoints = new StylusPointCollection();
3922
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3923
            strokePoints.Add(segment1Start);
3924
            stroke = new Stroke(strokePoints);
3925

    
3926
            stroke.DrawingAttributes.Color = Colors.Red;
3927
            stroke.DrawingAttributes.Width = 4;
3928
            stroke.DrawingAttributes.Height = 4;
3929

    
3930
            inkBoard.Strokes.Add(stroke);
3931
        }
3932

    
3933
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3934
        {
3935
            ConsolidationMethod();
3936
        }
3937

    
3938
        /// <summary>
3939
        /// execute TeamConsolidationCommand
3940
        /// </summary>
3941
        public void TeamConsolidationMethod()
3942
        {
3943
            this.UpdateMyMarkupList();
3944
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3945
            {
3946
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3947
            }
3948
            else
3949
            {
3950

    
3951
                ViewerDataModel.Instance.IsConsolidate = true;
3952
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3953

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

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

    
3990
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3991
        {
3992
            if (App.ViewInfo != null)
3993
            {
3994
                btnConsolidate = (sender as RadRibbonButton);
3995
                if (!App.ViewInfo.NewCommentPermission)
3996
                {
3997
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3998
                }
3999
            }
4000
        }
4001

    
4002
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4003
        {
4004
            TeamConsolidationMethod();
4005
        }
4006

    
4007
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4008
        {
4009
            btnTeamConsolidate = sender as RadRibbonButton;
4010
            if (App.ViewInfo != null)
4011
            {
4012
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4013
                {
4014
                    if (btnConsolidate != null)
4015
                    {
4016
                        btnConsolidate.Visibility = Visibility.Collapsed;
4017
                    }
4018

    
4019
                    if (!App.ViewInfo.NewCommentPermission)
4020
                    {
4021
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4022
                    }
4023
                }
4024
                else
4025
                {
4026
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4027
                }
4028
            }
4029
        }
4030

    
4031
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4032
        {
4033
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4034
            if (item != null)
4035
            {
4036
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4037

    
4038
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4039
            }
4040
            else
4041
            {
4042
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4043
            }
4044
        }
4045

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

    
4062
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4063
        {
4064
            UpdateMyMarkupList();
4065

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

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

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

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

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

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

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

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

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

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

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

    
4169
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4170
        {
4171

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

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

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

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

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

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

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

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

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

    
4250
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4251
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4252
                        }
4253

    
4254
                    }
4255
                    else
4256
                    {
4257
                        string uri = "";
4258

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

    
4268
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4269

    
4270
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4271
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4272
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4273

    
4274
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4275
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4276

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

    
4285
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4286
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4287
                            };
4288
                        }
4289
                    }
4290

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

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

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

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

    
4314
                }
4315
            }
4316
        }
4317

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

    
4324
                var uri = CurrentRev.TO_VENDOR;
4325

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

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

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

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

    
4369
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4370

    
4371
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4372
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4373
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4374

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

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

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

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

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

    
4431
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4432

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

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

    
4460
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4461
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4462
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4463

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

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

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

    
4499
        public void Sync_Event(VPRevision Currnet_Rev)
4500
        {
4501
            CurrentRev = Currnet_Rev;
4502

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

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

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

    
4535
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4536

    
4537
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4538

    
4539
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4540
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4541
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4542

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

    
4553

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

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

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

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

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

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

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

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

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

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

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

    
4682
                                    System.Drawing.Bitmap image;
4683

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

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

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

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

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

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

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

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

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

    
4830
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4831

    
4832
                List<SYMBOL_PUBLIC> symbol_Public;
4833

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

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

    
4873
                        byte[] Img_byte = fs.ToArray();
4874

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

    
4896
        public PngBitmapEncoder symImage(string data)
4897
        {
4898

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

    
4905
            BitmapEncoder encoder = new PngBitmapEncoder();
4906

    
4907

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

    
4910
            DrawingVisual dv = new DrawingVisual();
4911

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

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

    
4921
            try
4922
            {
4923
                renderBitmap.Render(dv);
4924

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

    
4935
            }
4936
            catch //(Exception ex)
4937
            {
4938
                return null;
4939
            }
4940

    
4941
        }
4942

    
4943
        public void DialogMessage_Alert(string content, string header)
4944
        {
4945
            var box = new TextBlock();
4946
            box.MinWidth = 400;
4947
            box.FontSize = 11;
4948
            //box.FontSize = 12;
4949
            box.Text = content;
4950
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4951

    
4952
            DialogParameters parameters = new DialogParameters()
4953
            {
4954
                Owner = Application.Current.MainWindow,
4955
                Content = box,
4956
                Header = header,
4957
                Theme = new VisualStudio2013Theme(),
4958
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4959
            };            
4960
            RadWindow.Alert(parameters);
4961
        }
4962

    
4963
        #region 캡쳐 기능
4964

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

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

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

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

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

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

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

    
5003
            return pixels;
5004
        }
5005

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

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

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

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

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

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

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

    
5053
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5054

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

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

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

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

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

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

    
5141
        }
5142

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

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

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

    
5163
            multi_Undo_Data.Markup = control;
5164

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

    
5182
            return multi_Undo_Data;
5183
        }
5184

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

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

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

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

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

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

    
5256
            return false;
5257
        }
5258

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

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

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

    
5274
        private async void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5275
        {
5276
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5277
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5278
            var pageUri = pageNavigator.CurrentPage.PageUri;
5279
            var contentScale = zoomAndPanControl.ContentScale;
5280

    
5281
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
5282
        }
5283

    
5284
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5285
        {
5286
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5287
        }
5288

    
5289

    
5290
        /*
5291
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5292
        {
5293
            try
5294
            {
5295
                if (e.Data.GetDataPresent(typeof(string)))
5296
                {
5297
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5298
                    string dragData = e.Data.GetData(typeof(string)) as string;
5299
                    Move_Symbol(sender, dragData);
5300
                }
5301
            }
5302
            catch (Exception ex)
5303
            {
5304
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5305
            }            
5306
        }
5307
        */
5308
    }
5309
}
클립보드 이미지 추가 (최대 크기: 500 MB)