프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 92442e4a

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

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

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

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

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

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

    
272
            return false;
273
        }
274

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

    
298
            return false;
299
        }
300

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
434
        
435

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

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

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

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

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

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

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

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

    
520
        DispatcherTimer renderTesttimer;
521

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

    
534
            #region 페이지가 벗어난 경우
535

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

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

    
548
            #endregion
549

    
550
            ViewerDataModel.Instance.PageNumber = BalancePoint;
551

    
552
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
553
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
554
            var pageUri = pageNavigator.CurrentPage.PageUri;
555
            var contentScale = zoomAndPanControl.ContentScale;
556

    
557
            #region 페이지 이미지 로딩 수정
558

    
559
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
560
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
561
            ScaleImage(pageWidth,pageHeight);
562

    
563
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
564
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
565

    
566
            zoomAndPanCanvas.Width = pageWidth;
567
            zoomAndPanCanvas.Height = pageHeight;
568

    
569
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
570
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
571

    
572
            inkBoard.Width = pageWidth;
573
            inkBoard.Height = pageHeight;
574

    
575
            #endregion
576

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

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

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

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

    
633
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
634

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

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

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

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

    
674
            this.pageNavigator.ChangePage(e.PageNumber);
675
        }
676

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

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

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

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

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

    
728

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

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

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

    
746
            SetCommentPages(true);
747
        }
748

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

    
779
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
780
        {
781
            if (e.MiddleButton == MouseButtonState.Pressed)
782
            {
783

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

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

    
813
        #region ZoomIn & ZoomOut
814

    
815
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
816
        {
817
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
818
                zoomAndPanControl.ContentZoomFocusY));
819
        }
820

    
821
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
822
        {
823
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
824
                zoomAndPanControl.ContentZoomFocusY));
825
        }
826

    
827

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

    
841
            if (zoomAndPanControl2 != null && Sync.IsChecked)
842
            {
843
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
844
            }
845
        }
846

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

    
858
            if (zoomAndPanControl2 != null && Sync.IsChecked)
859
            {
860
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
861
            }
862

    
863
        }
864

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

    
876
            if (Sync.IsChecked)
877
            {
878
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
879
            }
880
        }
881

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

    
893
            if (Sync.IsChecked)
894
            {
895
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
896
            }
897
        }
898

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

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

    
917
        #endregion
918

    
919
        private void init()
920
        {
921
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
922
            {
923

    
924
                ControlList.Clear();
925
                listBox.Items.Clear();
926
                selected_item.Clear();
927

    
928
                (item as IMarkupCommonData).IsSelected = false;
929
            }
930

    
931
        }
932

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

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

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

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

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

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

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

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

    
1099

    
1100
               if (this._dragdropWindow != null)
1101
               {
1102
                   this._dragdropWindow.Close();
1103
                   this._dragdropWindow = null;
1104
               }
1105

    
1106
               symbol_id = id;
1107
               symbol_group_id = group_id;
1108
               symbol_SelectedIndex = SelectedIndex;
1109
               symbol_Data = Data_;
1110
               symbol_img = img;
1111

    
1112

    
1113
               CreateDragDropWindow2(img);
1114
              
1115
    }
1116

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

    
1137
            Win32Point w32Mouse = new Win32Point();
1138
            GetCursorPos(ref w32Mouse);
1139

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

    
1152
                Point currentPos = e.GetPosition(rect);
1153

    
1154
                floatingTip.HorizontalOffset = currentPos.X + 20;
1155
                floatingTip.VerticalOffset = currentPos.Y;
1156
            }
1157

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

    
1166
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1167
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1168
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1169

    
1170
                if (Sync.IsChecked)
1171
                {
1172
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1173
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1174
                }
1175
            }
1176

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1537
                    if (dragDistance > DragThreshold)
1538
                    {
1539
                        isDraggingSelectionRect = true;
1540
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1541
                    }
1542

    
1543
                    e.Handled = true;
1544
                }
1545

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

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

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

    
1595
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1596

    
1597
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1598
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1599

    
1600
                if (Sync.IsChecked)
1601
                {
1602
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1603
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1604
                }
1605
            }
1606
        }
1607

    
1608
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1609

    
1610
        private EllipseGeometry hitArea = new EllipseGeometry();
1611

    
1612
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1613
        {
1614
            IsDrawing = false;
1615

    
1616
            if (mouseHandlingMode != MouseHandlingMode.None)
1617
            {
1618
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1619
                {
1620
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1621

    
1622
                    SetCursor();
1623

    
1624
                    switch (controlType)
1625
                    {
1626
                        case ControlType.None:
1627
                            break;
1628
                        case ControlType.Rectangle:
1629
                            {
1630

    
1631
                            }
1632
                            break;
1633
                        case ControlType.PenControl:
1634
                            {
1635

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

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

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

    
1683
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1684

    
1685
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1686
                            }
1687

    
1688
                            isDraggingSelectionRect = false;
1689
                            e.Handled = true;
1690
                            wasDragSelectionApplied = true;
1691
                        }
1692

    
1693
                        if (isLeftMouseButtonDownOnWindow)
1694
                        {
1695
                            isLeftMouseButtonDownOnWindow = false;
1696
                            this.ReleaseMouseCapture();
1697
                            e.Handled = true;
1698
                        }
1699

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

    
1712
                zoomAndPanControl.ReleaseMouseCapture();
1713

    
1714

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

    
1723
            ///mouseButtonDown = MouseButton.Left;
1724
            //controlType = ControlType.SingleLine;
1725
        }
1726

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

    
1737
            double width = dragCaptureBorder.Width;
1738
            double height = dragCaptureBorder.Height;
1739

    
1740
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1741

    
1742
            if (x < 0)
1743
            {
1744
                width += x;
1745
                x = 0;
1746
            }
1747
            if (y < 0)
1748
            {
1749
                height += y;
1750
                y = 0;
1751

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

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

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

    
1783
            //GC.Collect();
1784

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

    
1797
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1798
        {
1799
            ///mouseButtonDown = MouseButton.Left;
1800
        }
1801

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

    
1808
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1809
        {
1810

    
1811
        }
1812

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

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

    
1828
            Rect dragRect = new Rect(x, y, width, height);
1829
            ///dragRect.Inflate(width / 10, height / 10);
1830

    
1831
            foreach (var item in Items)
1832
            {
1833
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1834

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

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

    
1860
                dragSelectionBorder.Visibility = Visibility.Visible;
1861
            }
1862
            else
1863
            {
1864
                dragZoomBorder.Visibility = Visibility.Visible;
1865
            }
1866
            UpdateDragSelectionRect(pt1, pt2);
1867
        }
1868

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

    
1876
            //
1877
            // Determine x,y,width and height of the rect inverting the points if necessary.
1878
            // 
1879

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

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

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

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

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

    
1963
            zoomAndPanControl.RotationAngle = rotate.Angle;
1964

    
1965

    
1966
            if (!testPanel2.IsHidden)
1967
            {
1968
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1969
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1970
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1971
            }
1972

    
1973
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1974
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1975
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1976
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1977
            ViewerDataModel.Instance.Angle = rotate.Angle;
1978
        }
1979

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

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

    
2013
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2014
        }
2015

    
2016
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2017
        {
2018
            string Data_ = "";
2019

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

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

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

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

    
2093
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2094
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2095
                    UndoData.Markup_List.Add(multi_Undo_Data);
2096
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2097

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

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

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

    
2124
            ConvertInkControlToPolygon();
2125

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

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

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

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

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

    
2164
            double Ang = 0;                                          
2165
            if (rotate.Angle != 0)
2166
            {
2167
                Ang = 360 - rotate.Angle;
2168
            }
2169

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

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

    
2195
            if (e.LeftButton == MouseButtonState.Pressed)
2196
            {
2197
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2198
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2199

    
2200
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2201
                SetCursor();
2202

    
2203
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2204
            }
2205

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

    
2225
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2226

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

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

    
2246
                    if (controlType == ControlType.None)
2247
                    {
2248
                        isLeftMouseButtonDownOnWindow = true;
2249
                    }
2250
                }
2251

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

    
2259
                /// 줌 모드 설정
2260
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2261
                {
2262
                    isLeftMouseButtonDownOnWindow = true;
2263
                }
2264

    
2265
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2266
                if (control != null)
2267
                {
2268
                    AdornerFinal final = null;
2269

    
2270
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2271
                    {
2272
                        /// 기존 selection 해제
2273
                        SelectionSet.Instance.UnSelect(this);
2274

    
2275
                        final = new AdornerFinal(control);
2276

    
2277
                        this.Control_Style(control);
2278

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

    
2304
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2305

    
2306
                        if ((control as TextControl) != null)
2307
                        {
2308
                            if(!((control as TextControl).EnableEditing)) {
2309
                                (control as TextControl).EnableEditing = true;
2310
                            }
2311

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

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

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

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

    
2406
                        Control_Style(control);
2407

    
2408
                        final = new AdornerFinal(comment);
2409
                    }
2410

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

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

    
2467
                                    CreateCommand.Instance.Execute(currentControl);
2468

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

    
2492
                                        currentControl.CommentID = Commons.shortGuid();
2493
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2494
                                        currentControl.IsNew = true;
2495

    
2496
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2497

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

    
2515
                                    CreateCommand.Instance.Execute(currentControl);
2516

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

    
2529
                                    currentControl.CommentID = Commons.shortGuid();
2530
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2531
                                    currentControl.IsNew = true;
2532
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2533

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

    
2550
                                    CreateCommand.Instance.Execute(currentControl);
2551

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

    
2564
                                    currentControl.CommentID = Commons.shortGuid();
2565
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2566
                                    currentControl.IsNew = true;
2567
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2568

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

    
2585
                                    CreateCommand.Instance.Execute(currentControl);
2586

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

    
2599
                                    currentControl.CommentID = Commons.shortGuid();
2600
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2601
                                    currentControl.IsNew = true;
2602
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2603

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

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

    
2634
                                    currentControl.CommentID = Commons.shortGuid();
2635
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2636
                                    currentControl.IsNew = true;
2637
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2638

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

    
2656
                                    CreateCommand.Instance.Execute(currentControl);
2657

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

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

    
2691
                                    CreateCommand.Instance.Execute(currentControl);
2692

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

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

    
2731
                                        CreateCommand.Instance.Execute(currentControl);
2732

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

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

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

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

    
2796
                                if (e.RightButton == MouseButtonState.Pressed)
2797
                                {
2798
                                    control.IsCompleted = true;
2799
                                }
2800

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

    
2813
                                    var firstPoint = control.PointSet.First();
2814
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2815
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2816
                                    control.PointSet.Add(firstPoint);
2817

    
2818
                                    control.ApplyOverViewData();
2819

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

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

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

    
2863
                                    CreateCommand.Instance.Execute(currentControl);
2864

    
2865
                                    currentControl = null;
2866
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2867
                                    return;
2868
                                }
2869

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

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

    
2920
                                    CreateCommand.Instance.Execute(currentControl);
2921

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

    
2963
                                    CreateCommand.Instance.Execute(currentControl);
2964

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

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

    
3023
                                            CreateCommand.Instance.Execute(currentControl);
3024

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

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

    
3068
                                    CreateCommand.Instance.Execute(currentControl);
3069

    
3070
                                    control.isTransOn = true;
3071
                                    var firstPoint = control.PointSet.First();
3072

    
3073
                                    control.PointSet.Add(firstPoint);
3074
                                    control.DrawingCloud();
3075
                                    control.ApplyOverViewData();
3076

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

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

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

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

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

    
3161
                                        
3162
                                                currentControl.CommentID = Commons.shortGuid();                                            
3163
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3164
                                                currentControl.IsNew = true;
3165
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3166

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

    
3189
                                        CreateCommand.Instance.Execute(currentControl);
3190
                                        currentControl = null;
3191

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

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

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

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

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

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

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

    
3301
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3302
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3303
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3304

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

    
3328
                                    CreateCommand.Instance.Execute(currentControl);
3329

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

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

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

    
3354
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3355
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3356
                                        this.MainAngle.Visibility = Visibility.Visible;
3357

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

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

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

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

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

    
3442
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3443

    
3444
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3445

    
3446
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3447
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3448
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3449

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

    
3483
                                    currentControl = new ArrowTextControl()
3484
                                    {
3485
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3486
                                        ControlType = ControlType.ArrowTransTextBorderControl
3487

    
3488
                                    };
3489
                                        currentControl.CommentID = Commons.shortGuid();
3490
                                        currentControl.IsNew = true;
3491
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3492
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3493

    
3494
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3495

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

    
3506
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3507
                                        this.MainAngle.Visibility = Visibility.Visible;
3508
                                    
3509
                                    //20180911 LJY
3510
                                        (currentControl as ArrowTextControl).isTrans = true;
3511
                                    
3512

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

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

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

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

    
3598
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3599
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3600
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3601
                                        (currentControl as ArrowTextControl).isFixed = true;
3602
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3603

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

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

    
3627
                                    if (_sign == null)
3628
                                    {
3629
                                        txtBatch.Visibility = Visibility.Collapsed;
3630
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3631
                                        controlType = ControlType.None;
3632

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

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

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

    
3666
                                        currentControl.CommentID = Commons.shortGuid();
3667
                                        currentControl.IsNew = true;
3668
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3669
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3670

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

    
3692
                                        CreateCommand.Instance.Execute(currentControl);
3693
                                        (currentControl as RectangleControl).ApplyOverViewData();
3694
                                        currentControl = null;
3695
                                    
3696
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3697

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

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

    
3750
                                    currentControl.IsNew = true;
3751
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3752
                                    currentControl.CommentID = Commons.shortGuid();
3753
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3754

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

    
3776
                                        CreateCommand.Instance.Execute(currentControl);
3777
                                        currentControl = null;
3778
                                   
3779

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

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

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

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

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

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

    
3873
        private void RemovePointStroke(Point P)
3874
        {
3875
            foreach (Stroke hits in inkBoard.Strokes)
3876
            {
3877
                foreach (StylusPoint sty in hits.StylusPoints)
3878
                {
3879

    
3880
                }
3881
                if (hits.HitTest(P))
3882
                {
3883
                    inkBoard.Strokes.Remove(hits);
3884
                    return;
3885
                }
3886
            }
3887
        }
3888

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

    
3896
            stroke.DrawingAttributes.Color = Colors.Red;
3897
            stroke.DrawingAttributes.Width = 4;
3898
            stroke.DrawingAttributes.Height = 4;
3899

    
3900
            inkBoard.Strokes.Add(stroke);
3901
        }
3902

    
3903
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3904
        {
3905
            ConsolidationMethod();
3906
        }
3907

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

    
3921
                ViewerDataModel.Instance.IsConsolidate = true;
3922
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3923

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

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

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

    
3972
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3973
        {
3974
            TeamConsolidationMethod();
3975
        }
3976

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

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

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

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

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

    
4032
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4033
        {
4034
            UpdateMyMarkupList();
4035

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

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

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

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

    
4074
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4075
        {
4076
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4077

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

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

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

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

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

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

    
4139
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4140
        {
4141

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

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

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

    
4174
                if (ViewerDataModel.Instance.PageNumber == 0)
4175
                {
4176
                    ViewerDataModel.Instance.PageNumber = 1;
4177
                }
4178

    
4179
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4180
                {
4181
                }
4182
                else
4183
                {
4184
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4185
                }
4186

    
4187
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4188
                {
4189

    
4190
                }
4191
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4192
                {
4193
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4194
                }
4195

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

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

    
4220
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4221
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4222
                        }
4223

    
4224
                    }
4225
                    else
4226
                    {
4227
                        string uri = "";
4228

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

    
4238
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4239

    
4240
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4241
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4242
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4243

    
4244
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4245
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4246

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

    
4255
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4256
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4257
                            };
4258
                        }
4259
                    }
4260

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

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

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

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

    
4284
                }
4285
            }
4286
        }
4287

    
4288
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4289
        {
4290
            if (MarkupMode.IsChecked)
4291
            {
4292
                IsSyncPDFMode = true;
4293

    
4294
                var uri = CurrentRev.TO_VENDOR;
4295

    
4296
                if (ViewerDataModel.Instance.PageNumber == 0)
4297
                {
4298
                    ViewerDataModel.Instance.PageNumber = 1;
4299
                }
4300

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

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

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

    
4339
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4340

    
4341
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4342
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4343
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4344

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

    
4361
        private void RadButton_Click(object sender, RoutedEventArgs e)
4362
        {
4363
            gridViewHistory_Busy.IsBusy = true;
4364

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

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

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

    
4401
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4402

    
4403
                        var defaultBitmapImage_Compare = new BitmapImage();
4404
                        defaultBitmapImage_Compare.BeginInit();
4405
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4406
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4407
                        defaultBitmapImage_Compare.EndInit();
4408

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

    
4430
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4431
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4432
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4433

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

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

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

    
4469
        public void Sync_Event(VPRevision Currnet_Rev)
4470
        {
4471
            CurrentRev = Currnet_Rev;
4472

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

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

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

    
4505
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4506

    
4507
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4508

    
4509
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4510
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4511
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4512

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

    
4523

    
4524
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4525
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4526
                    zoomAndPanControl2.ApplyTemplate();
4527
                    zoomAndPanControl2.UpdateLayout();
4528

    
4529
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4530
                    {
4531
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4532
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4533
                    }
4534
                    //}
4535

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

    
4542
            };
4543
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4544
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4545
        }
4546

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

    
4563
        private void Create_Symbol(object sender, RoutedEventArgs e)
4564
        {
4565
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4566

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

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

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

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

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

    
4652
                                    System.Drawing.Bitmap image;
4653

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

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

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

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

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

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

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

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

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

    
4800
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4801

    
4802
                List<SYMBOL_PUBLIC> symbol_Public;
4803

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

    
4839
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4840
                        _Encoder.Save(fs);
4841
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4842

    
4843
                        byte[] Img_byte = fs.ToArray();
4844

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

    
4866
        public PngBitmapEncoder symImage(string data)
4867
        {
4868

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

    
4875
            BitmapEncoder encoder = new PngBitmapEncoder();
4876

    
4877

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

    
4880
            DrawingVisual dv = new DrawingVisual();
4881

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

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

    
4891
            try
4892
            {
4893
                renderBitmap.Render(dv);
4894

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

    
4905
            }
4906
            catch //(Exception ex)
4907
            {
4908
                return null;
4909
            }
4910

    
4911
        }
4912

    
4913
        public void DialogMessage_Alert(string content, string header)
4914
        {
4915
            DialogParameters parameters = new DialogParameters()
4916
            {
4917
                Owner = Application.Current.MainWindow,
4918
                Content = new TextBlock()
4919
                { 
4920
                    MinWidth = 400,
4921
                    FontSize = 11,
4922
                    Text = content,
4923
                    TextWrapping = System.Windows.TextWrapping.Wrap
4924
                },
4925
                Header = header,
4926
                Theme = new VisualStudio2013Theme(),
4927
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4928
            };            
4929
            RadWindow.Alert(parameters);
4930
        }
4931

    
4932
        #region 캡쳐 기능
4933

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

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

    
4957
            byte[] pixels = CopyPixels(x, y, width, height);
4958

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

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

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

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

    
4972
            return pixels;
4973
        }
4974

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

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

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

    
4990
            target.Render(drawingVisual);
4991
            return target;
4992
        }
4993

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

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

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

    
5022
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5023

    
5024
            RadWindow CheckPop = new RadWindow();
5025
            //Alert check = new Alert(Msg);
5026

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

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

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

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

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

    
5110
        }
5111

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

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

    
5128
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5129
        {
5130
            multi_Undo_Data = new Multi_Undo_data();
5131

    
5132
            multi_Undo_Data.Markup = control;
5133

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

    
5151
            return multi_Undo_Data;
5152
        }
5153

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

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

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

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

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

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

    
5225
            return false;
5226
        }
5227

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

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

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

    
5243
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5244
        {
5245
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5246
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5247

    
5248
            ScaleImage(pageWidth, pageHeight);
5249
        }
5250

    
5251
        /// <summary>
5252
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5253
        /// </summary>
5254
        /// <param name="pageWidth">원본 사이즈</param>
5255
        /// <param name="pageHeight">원본 사이즈</param>
5256
        /// <returns></returns>
5257
        private void ScaleImage(double pageWidth,double pageHeight)
5258
        {
5259
            mainPanel.Scale = (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5260
        }
5261

    
5262
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5263
        {
5264
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5265
        }
5266

    
5267

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