프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

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

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

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

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

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

    
272
            return false;
273
        }
274

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

    
298
            return false;
299
        }
300

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
433
        
434

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

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

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

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

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

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

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

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

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

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

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

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

    
545
            #endregion
546

    
547
            ViewerDataModel.Instance.PageNumber = BalancePoint;
548

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

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

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

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

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

    
594

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

    
600

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

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

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

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

    
657
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
658

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

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

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

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

    
698
        }
699

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

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

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

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

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

    
751

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

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

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

    
769
            SetCommentPages(true);
770
        }
771

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

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

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

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

    
836
        #region ZoomIn & ZoomOut
837

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

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

    
850

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

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

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

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

    
886
        }
887

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

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

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

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

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

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

    
940
        #endregion
941

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

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

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

    
954
        }
955

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

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

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

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

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

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

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

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

    
1122

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

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

    
1135

    
1136
               CreateDragDropWindow2(img);
1137
              
1138
    }
1139

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1340
                        case ControlType.ArcLine:
1341
                            {
1342
                                var control = currentControl as ArcControl;
1343
                                if (control != null)
1344
                                {
1345
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1346
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1347
                                }
1348
                            }
1349
                            break;
1350

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

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

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

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

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

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

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

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

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

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

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

    
1566
                    e.Handled = true;
1567
                }
1568

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

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

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

    
1618
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1619

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

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

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

    
1633
        private EllipseGeometry hitArea = new EllipseGeometry();
1634

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

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

    
1645
                    SetCursor();
1646

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

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

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

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

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

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

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

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

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

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

    
1735
                zoomAndPanControl.ReleaseMouseCapture();
1736

    
1737

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

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

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

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

    
1763
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1764

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

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

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

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

    
1806
            //GC.Collect();
1807

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

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

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

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

    
1834
        }
1835

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1986
            zoomAndPanControl.RotationAngle = rotate.Angle;
1987

    
1988

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2147
            ConvertInkControlToPolygon();
2148

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2298
                        final = new AdornerFinal(control);
2299

    
2300
                        this.Control_Style(control);
2301

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

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

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

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

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

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

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

    
2429
                        Control_Style(control);
2430

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

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

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

    
2490
                                    CreateCommand.Instance.Execute(currentControl);
2491

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

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

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

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

    
2538
                                    CreateCommand.Instance.Execute(currentControl);
2539

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

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

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

    
2573
                                    CreateCommand.Instance.Execute(currentControl);
2574

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

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

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

    
2608
                                    CreateCommand.Instance.Execute(currentControl);
2609

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

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

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

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

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

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

    
2679
                                    CreateCommand.Instance.Execute(currentControl);
2680

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

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

    
2714
                                    CreateCommand.Instance.Execute(currentControl);
2715

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

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

    
2754
                                        CreateCommand.Instance.Execute(currentControl);
2755

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

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

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

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

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

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

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

    
2841
                                    control.ApplyOverViewData();
2842

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

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

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

    
2886
                                    CreateCommand.Instance.Execute(currentControl);
2887

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

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

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

    
2943
                                    CreateCommand.Instance.Execute(currentControl);
2944

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

    
2986
                                    CreateCommand.Instance.Execute(currentControl);
2987

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

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

    
3046
                                            CreateCommand.Instance.Execute(currentControl);
3047

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

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

    
3091
                                    CreateCommand.Instance.Execute(currentControl);
3092

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3351
                                    CreateCommand.Instance.Execute(currentControl);
3352

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3773
                                    currentControl.IsNew = true;
3774
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3775
                                    currentControl.CommentID = Commons.shortGuid();
3776
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3777

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4031
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4032
            }
4033
            else
4034
            {
4035
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4036
            }
4037
        }
4038

    
4039
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4040
        {
4041
            btnFinalPDF = sender as RadRibbonButton;
4042
            if (App.ViewInfo != null)
4043
            {
4044
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4045
                {
4046
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4047
                    if (btnConsolidate != null)
4048
                    {
4049
                        btnConsolidate.Visibility = Visibility.Collapsed;
4050
                    }
4051
                }
4052
            }
4053
        }
4054

    
4055
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4056
        {
4057
            UpdateMyMarkupList();
4058

    
4059
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4060
            {
4061
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4062
            }
4063
            else
4064
            {
4065
                ViewerDataModel.Instance.IsConsolidate = true;
4066
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4067
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4068

    
4069
                string project_no = App.ViewInfo.ProjectNO;
4070
                string doc_id = _DocInfo.ID;
4071
                string user_id = App.ViewInfo.UserID;
4072
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4073
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4074
                {
4075
                    markupInfoItems.Add(item);
4076
                }
4077
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4078
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4079
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4080
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4081

    
4082
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4083
                if (item2 != null)
4084
                {
4085
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4086

    
4087
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4088
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4089
                }
4090
                else
4091
                {
4092
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4093
                }
4094
            }
4095
        }
4096

    
4097
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4098
        {
4099
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4100

    
4101
            if (App.ViewInfo != null)
4102
            {
4103
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4104
                {
4105
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4106
                }
4107
            }
4108
        }
4109

    
4110
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4111
        {
4112
            if (CompareMode.IsChecked)
4113
            {
4114
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4115
                {
4116
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4117
                }
4118
                if (ViewerDataModel.Instance.PageNumber == 0)
4119
                {
4120
                    ViewerDataModel.Instance.PageNumber = 1;
4121
                }
4122

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

    
4127
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4128
            }
4129
            else
4130
            {
4131
                da.From = 1;
4132
                da.To = 1;
4133
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4134
                da.AutoReverse = false;
4135
                canvas_compareBorder.Children.Clear();
4136
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4137
            }
4138
        }
4139

    
4140
        private void Sync_Click(object sender, RoutedEventArgs e)
4141
        {
4142
            if (Sync.IsChecked)
4143
            {
4144
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4145
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4146
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4147
            }
4148
        }
4149

    
4150
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4151
        {
4152
            if (UserList.IsChecked)
4153
            {
4154
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4155
            }
4156
            else
4157
            {
4158
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4159
            }
4160
        }
4161

    
4162
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4163
        {
4164

    
4165
            if (BalanceMode.IsChecked)
4166
            {
4167
                ViewerDataModel.Instance.PageBalanceMode = true;
4168
            }
4169
            else
4170
            {
4171
                ViewerDataModel.Instance.PageBalanceMode = false;
4172
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4173
            }
4174
        }
4175

    
4176
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4177
        {
4178
            //초기화
4179
            testPanel2.IsHidden = true;
4180
            ViewerDataModel.Instance.PageBalanceMode = false;
4181
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4182
            ViewerDataModel.Instance.PageNumber = 0;
4183
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4184
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4185
            UserList.IsChecked = false;
4186
            BalanceMode.IsChecked = false;
4187
        }
4188

    
4189
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4190
        {
4191
            if ((sender as System.Windows.Controls.Control).Tag != null)
4192
            {
4193
                //Compare 초기화
4194
                CompareMode.IsChecked = false;
4195
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4196

    
4197
                if (ViewerDataModel.Instance.PageNumber == 0)
4198
                {
4199
                    ViewerDataModel.Instance.PageNumber = 1;
4200
                }
4201

    
4202
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4203
                {
4204
                }
4205
                else
4206
                {
4207
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4208
                }
4209

    
4210
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4211
                {
4212

    
4213
                }
4214
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4215
                {
4216
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4217
                }
4218

    
4219
                if (!testPanel2.IsHidden)
4220
                {
4221
                    if (IsSyncPDFMode)
4222
                    {
4223
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4224
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4225

    
4226
                        if (pdfpath.IsDownloading)
4227
                        {
4228
                            pdfpath.DownloadCompleted += (ex, arg) =>
4229
                            {
4230
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4231
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4232
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4233
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4234
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4235
                            };
4236
                        }
4237
                        else
4238
                        {
4239
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4240
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4241
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4242

    
4243
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4244
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4245
                        }
4246

    
4247
                    }
4248
                    else
4249
                    {
4250
                        string uri = "";
4251

    
4252
                        if (userData.COMPANY != "EXT")
4253
                        {
4254
                            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);
4255
                        }
4256
                        else
4257
                        {
4258
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4259
                        }
4260

    
4261
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4262

    
4263
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4264
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4265
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4266

    
4267
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4268
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4269

    
4270
                        if (defaultBitmapImage_Compare.IsDownloading)
4271
                        {
4272
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4273
                            {
4274
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4275
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4276
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4277

    
4278
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4279
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4280
                            };
4281
                        }
4282
                    }
4283

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

    
4288
                    foreach (var item in gridSelectionRevItem)
4289
                    {
4290
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4291
                        {
4292
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4293
                        });
4294
                    }
4295

    
4296
                    //강인구 추가
4297
                    zoomAndPanControl2.ZoomTo(new Rect
4298
                    {
4299
                        X = 0,
4300
                        Y = 0,
4301
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4302
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4303
                    });
4304

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

    
4307
                }
4308
            }
4309
        }
4310

    
4311
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4312
        {
4313
            if (MarkupMode.IsChecked)
4314
            {
4315
                IsSyncPDFMode = true;
4316

    
4317
                var uri = CurrentRev.TO_VENDOR;
4318

    
4319
                if (ViewerDataModel.Instance.PageNumber == 0)
4320
                {
4321
                    ViewerDataModel.Instance.PageNumber = 1;
4322
                }
4323

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

    
4328
                if (pdfpath.IsDownloading)
4329
                {
4330
                    pdfpath.DownloadCompleted += (ex, arg) =>
4331
                    {
4332
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4333
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4334
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4335
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4336
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4337
                    };
4338
                }
4339
                else
4340
                {
4341
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4342
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4343
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4344

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

    
4362
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4363

    
4364
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4365
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4366
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4367

    
4368
                if (defaultBitmapImage_Compare.IsDownloading)
4369
                {
4370
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4371
                    {
4372
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4373
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4374
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4375
                    };
4376
                }
4377
                zoomAndPanControl2.ApplyTemplate();
4378
                zoomAndPanControl2.UpdateLayout();
4379
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4380
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4381
            }
4382
        }
4383

    
4384
        private void RadButton_Click(object sender, RoutedEventArgs e)
4385
        {
4386
            gridViewHistory_Busy.IsBusy = true;
4387

    
4388
            RadButton instance = sender as RadButton;
4389
            if (instance.CommandParameter != null)
4390
            {
4391
                CurrentRev = instance.CommandParameter as VPRevision;
4392
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4393
                {
4394
                    if (ea.Error == null && ea.Result != null)
4395
                    {
4396
                        testPanel2.IsHidden = false;
4397

    
4398
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4399
                        foreach(var info in ea.Result)
4400
                        {
4401
                            if(info.UserID == App.ViewInfo.UserID)
4402
                            {
4403
                                info.userDelete = true;
4404
                                info.DisplayColor = "FFFF0000";
4405
                            }
4406
                            else
4407
                            {
4408
                                info.userDelete = false;
4409
                            }
4410
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4411
                        }
4412
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4413

    
4414
                        string uri = "";
4415
                        if (userData.COMPANY != "EXT")
4416
                        {
4417
                            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);
4418
                        }
4419
                        else
4420
                        {
4421
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4422
                        }
4423

    
4424
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4425

    
4426
                        var defaultBitmapImage_Compare = new BitmapImage();
4427
                        defaultBitmapImage_Compare.BeginInit();
4428
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4429
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4430
                        defaultBitmapImage_Compare.EndInit();
4431

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

    
4453
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4454
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4455
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4456

    
4457
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4458
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4459
                        gridViewHistory_Busy.IsBusy = false;
4460
                    }
4461

    
4462
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4463
                };
4464
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4465
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4466
            }
4467
        }
4468

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

    
4492
        public void Sync_Event(VPRevision Currnet_Rev)
4493
        {
4494
            CurrentRev = Currnet_Rev;
4495

    
4496
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4497
            {
4498
                if (ea.Error == null && ea.Result != null)
4499
                {
4500
                    testPanel2.IsHidden = false;
4501

    
4502
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4503
                    foreach(var info in ea.Result)
4504
                    {
4505
                        if(info.UserID == App.ViewInfo.UserID)
4506
                        {
4507
                            info.userDelete = true;
4508
                            info.DisplayColor = "FFFF0000";
4509
                        }
4510
                        else
4511
                        {
4512
                            info.userDelete = false;
4513
                        }
4514
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4515
                    }
4516
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4517

    
4518
                    string uri = "";
4519
                    if (userData.COMPANY != "EXT")
4520
                    {
4521
                        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);
4522
                    }
4523
                    else
4524
                    {
4525
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4526
                    }
4527

    
4528
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4529

    
4530
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4531

    
4532
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4533
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4534
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4535

    
4536
                    if (defaultBitmapImage_Compare.IsDownloading)
4537
                    {
4538
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4539
                        {
4540
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4541
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4542
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4543
                        };
4544
                    }
4545

    
4546

    
4547
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4548
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4549
                    zoomAndPanControl2.ApplyTemplate();
4550
                    zoomAndPanControl2.UpdateLayout();
4551

    
4552
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4553
                    {
4554
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4555
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4556
                    }
4557
                    //}
4558

    
4559
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4560
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4561
                    gridViewHistory_Busy.IsBusy = false;
4562
                }
4563
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4564

    
4565
            };
4566
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4567
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4568
        }
4569

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

    
4586
        private void Create_Symbol(object sender, RoutedEventArgs e)
4587
        {
4588
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4589

    
4590
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4591
            {
4592
                DialogMessage_Alert("Please Select Controls", "Alert");
4593
            }
4594
            else //선택된 것이 있으면
4595
            {
4596
                string MarkupData = "";
4597
                adorner_ = new AdornerFinal();
4598

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

    
4627
        }
4628
        public int symbolselectindex = 0;
4629
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4630
        {
4631
            //Save save = new Save();
4632
            try
4633
            {
4634
                string svgfilename = null;
4635
                if (symbolname != null)
4636
                {
4637
                    if (symbolpng == true || symbolsvg == true)
4638
                    {
4639
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4640
                        string guid = Commons.shortGuid();
4641

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

    
4663
                            if (symbolsvg == true)
4664
                            {
4665
                                try
4666
                                {
4667
                                    var defaultBitmapImage = new BitmapImage();
4668
                                    defaultBitmapImage.BeginInit();
4669
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4670
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4671
                                    Check_Uri.UriCheck(filename);
4672
                                    defaultBitmapImage.UriSource = new Uri(filename);
4673
                                    defaultBitmapImage.EndInit();
4674

    
4675
                                    System.Drawing.Bitmap image;
4676

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

    
4699
                                            StringBuilder svgBuilder = new StringBuilder();
4700
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4701
                                            {
4702
                                                svgBuilder.AppendLine(e2.Data);
4703
                                            };
4704

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

    
4721
                                                DataBind();
4722
                                            };
4723
                                            potrace.WaitForExit();
4724
                                        };
4725
                                    }
4726
                                    else
4727
                                    {
4728
                                        //GC.Collect();
4729
                                    }
4730
                                }
4731
                                catch(Exception ee)
4732
                                {
4733
                                    DialogMessage_Alert("" + ee, "Alert");
4734
                                }
4735
                            }
4736
                        };                                             
4737
                    }
4738
                }
4739
            }
4740
            catch (Exception e)
4741
            {
4742
                //DialogMessage_Alert(e + "", "Alert");
4743
            }            
4744
        }
4745

    
4746
        public void SymbolSave(string Name, string Url, string Data)
4747
        {
4748
            try
4749
            {
4750
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4751
                {
4752
                    ID = Commons.shortGuid(),
4753
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4754
                    NAME = Name,
4755
                    IMAGE_URL = Url,
4756
                    DATA = Data
4757
                };
4758

    
4759
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4760
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4761
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4762
            }
4763
            catch (Exception)
4764
            {
4765
                throw;
4766
            }
4767
        }
4768

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

    
4791
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4792
        {           
4793
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4794
            DataBind();
4795
        }
4796

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

    
4823
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4824

    
4825
                List<SYMBOL_PUBLIC> symbol_Public;
4826

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

    
4862
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4863
                        _Encoder.Save(fs);
4864
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4865

    
4866
                        byte[] Img_byte = fs.ToArray();
4867

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

    
4889
        public PngBitmapEncoder symImage(string data)
4890
        {
4891

    
4892
            Canvas _canvas = new Canvas();
4893
            _canvas.Background = Brushes.White;
4894
            _canvas.Width = adorner_.BorderSize.Width;
4895
            _canvas.Height = adorner_.BorderSize.Height;
4896
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4897

    
4898
            BitmapEncoder encoder = new PngBitmapEncoder();
4899

    
4900

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

    
4903
            DrawingVisual dv = new DrawingVisual();
4904

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

    
4908
            using (DrawingContext ctx = dv.RenderOpen())
4909
            {
4910
                VisualBrush vb = new VisualBrush(_canvas);
4911
                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)));
4912
            }
4913

    
4914
            try
4915
            {
4916
                renderBitmap.Render(dv);
4917

    
4918
                //GC.Collect();
4919
                GC.WaitForPendingFinalizers();
4920
                //GC.Collect();
4921
                // encode png data
4922
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4923
                // puch rendered bitmap into it
4924
                pngEncoder.Interlace = PngInterlaceOption.Off;
4925
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4926
                return pngEncoder;
4927

    
4928
            }
4929
            catch //(Exception ex)
4930
            {
4931
                return null;
4932
            }
4933

    
4934
        }
4935

    
4936
        public void DialogMessage_Alert(string content, string header)
4937
        {
4938
            var box = new TextBlock();
4939
            box.MinWidth = 400;
4940
            box.FontSize = 11;
4941
            //box.FontSize = 12;
4942
            box.Text = content;
4943
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4944

    
4945
            DialogParameters parameters = new DialogParameters()
4946
            {
4947
                Owner = Application.Current.MainWindow,
4948
                Content = box,
4949
                Header = header,
4950
                Theme = new VisualStudio2013Theme(),
4951
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4952
            };            
4953
            RadWindow.Alert(parameters);
4954
        }
4955

    
4956
        #region 캡쳐 기능
4957

    
4958
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4959
        {
4960
            if (x < 0)
4961
            {
4962
                width += x;
4963
                x = 0;
4964
            }
4965
            if (y < 0)
4966
            {
4967
                height += y;
4968
                y = 0;
4969

    
4970
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4971
            }
4972
            if (x + width > zoomAndPanCanvas.ActualWidth)
4973
            {
4974
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4975
            }
4976
            if (y + height > zoomAndPanCanvas.ActualHeight)
4977
            {
4978
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4979
            }
4980

    
4981
            byte[] pixels = CopyPixels(x, y, width, height);
4982

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

    
4985
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4986
        }
4987

    
4988
        public byte[] CopyPixels(int x, int y, int width, int height)
4989
        {
4990
            byte[] pixels = new byte[width * height * 4];
4991
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4992

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

    
4996
            return pixels;
4997
        }
4998

    
4999
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5000
        {
5001
            DrawingVisual drawingVisual = new DrawingVisual();
5002
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5003

    
5004
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5005
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5006
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5007
            drawingContext.Close();
5008

    
5009
            // 비트맵으로 변환합니다.
5010
            RenderTargetBitmap target =
5011
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5012
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5013

    
5014
            target.Render(drawingVisual);
5015
            return target;
5016
        }
5017

    
5018
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5019
        {
5020
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5021
            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);
5022
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5023
            bmp.UnlockBits(data);
5024
            return bmp;
5025
        }
5026
        public string symbolname = null;
5027
        public bool symbolsvg = true;
5028
        public bool symbolpng = true;
5029

    
5030
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5031
        {
5032
            System.Drawing.Bitmap image = GetBitmap(source);
5033
            //흰색 제거
5034
            //image.MakeTransparent(System.Drawing.Color.White);
5035

    
5036
            var imageStream = new System.IO.MemoryStream();
5037
            byte[] imageBytes = null;
5038
            using (imageStream)
5039
            {
5040
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5041
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5042
                imageStream.Position = 0;
5043
                imageBytes = imageStream.ToArray();
5044
            }
5045

    
5046
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5047

    
5048
            RadWindow CheckPop = new RadWindow();
5049
            //Alert check = new Alert(Msg);
5050

    
5051
            CheckPop = new RadWindow
5052
            {
5053
                MinWidth = 400,
5054
                MinHeight = 100,
5055
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5056
                Header = "Alert",
5057
                Content = symbolPrompt,
5058
                //DialogResult = 
5059
                ResizeMode = System.Windows.ResizeMode.NoResize,
5060
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5061
                IsTopmost = true,
5062
            };
5063
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5064
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5065
            CheckPop.ShowDialog();
5066

    
5067
            /*
5068
            DialogParameters parameters = new DialogParameters()
5069
            {
5070
                Owner = Application.Current.MainWindow,
5071
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5072
                DefaultPromptResultValue = "Custom State",
5073
                Content = "Name :",
5074
                Header = "Insert Custom Symbol Name",
5075
                Theme = new VisualStudio2013Theme(),
5076
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5077
            };            
5078
            RadWindow.Prompt(parameters);
5079
            */
5080
        }
5081

    
5082
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5083
        {
5084
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5085
            KCOMDataModel.DataModel.CHECK_LIST check_;
5086
            string Result = streamToBase64.ImageToBase64(source);
5087
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5088
            string projectno = App.ViewInfo.ProjectNO;
5089
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5090

    
5091
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5092
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5093
            if (Item != null)
5094
            {
5095
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5096
            }
5097
            else
5098
            {
5099
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5100
            }
5101

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

    
5134
        }
5135

    
5136
        public void Set_Capture()
5137
        {
5138
            double x = canvasDrawingMouseDownPoint.X;
5139
            double y = canvasDrawingMouseDownPoint.Y;
5140
            double width = dragCaptureBorder.Width;
5141
            double height = dragCaptureBorder.Height;
5142

    
5143
            if (width > 5 || height > 5)
5144
            {
5145
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5146
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5147
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5148
            }
5149
        }
5150
        #endregion
5151

    
5152
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5153
        {
5154
            multi_Undo_Data = new Multi_Undo_data();
5155

    
5156
            multi_Undo_Data.Markup = control;
5157

    
5158
            if ((control as IShapeControl) != null)
5159
            {
5160
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5161
            }
5162
            if ((control as IDashControl) != null)
5163
            {
5164
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5165
            }
5166
            if ((control as IPath) != null)
5167
            {
5168
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5169
            }
5170
            if ((control as UIElement) != null)
5171
            {
5172
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5173
            }
5174

    
5175
            return multi_Undo_Data;
5176
        }
5177

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

    
5197
        /// <summary>
5198
        /// convert inkcontrol to polygoncontrol
5199
        /// </summary>
5200
        public void ConvertInkControlToPolygon()
5201
        {
5202
            if (inkBoard.Strokes.Count > 0)
5203
            {
5204
                inkBoard.Strokes.ToList().ForEach(stroke =>
5205
                {
5206
                    InkToPath ip = new InkToPath();
5207

    
5208
                    List<Point> inkPointSet = new List<Point>();
5209
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5210

    
5211
                    PolygonControl pc = new PolygonControl()
5212
                    {
5213
                        Angle = 0,
5214
                        PointSet = inkPointSet,
5215
                        ControlType = ControlType.Ink
5216
                    };
5217
                    pc.StartPoint = inkPointSet[0];
5218
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5219
                    pc.LineSize = 3;
5220
                    pc.CommentID = Commons.shortGuid();
5221
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5222

    
5223
                    if (pc.PointSet.Count > 0)
5224
                    {
5225
                        CreateCommand.Instance.Execute(pc);
5226
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5227
                    }
5228
                });
5229
                inkBoard.Strokes.Clear();
5230
            }
5231
        }
5232

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

    
5249
            return false;
5250
        }
5251

    
5252
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5253
        {
5254
            e.Effects = DragDropEffects.Copy;
5255
        }
5256

    
5257
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5258
        {
5259
            e.Effects = DragDropEffects.Copy;
5260
        }
5261

    
5262
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5263
        {
5264
            e.Effects = DragDropEffects.None;
5265
        }
5266

    
5267
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5268
        {
5269
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5270
        }
5271

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