프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 7e2d682c

이력 | 보기 | 이력해설 | 다운로드 (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

    
561
           ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
562
            ScaleImage(pageWidth,pageHeight);
563

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

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

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

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

    
576
            #endregion
577

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

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

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

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

    
634
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
635

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

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

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

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

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

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

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

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

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

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

    
729

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

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

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

    
747
            SetCommentPages(true);
748
        }
749

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

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

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

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

    
814
        #region ZoomIn & ZoomOut
815

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

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

    
828

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

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

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

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

    
864
        }
865

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

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

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

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

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

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

    
918
        #endregion
919

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

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

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

    
932
        }
933

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

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

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

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

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

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

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

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

    
1100

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

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

    
1113

    
1114
               CreateDragDropWindow2(img);
1115
              
1116
    }
1117

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1544
                    e.Handled = true;
1545
                }
1546

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

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

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

    
1596
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1597

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

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

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

    
1611
        private EllipseGeometry hitArea = new EllipseGeometry();
1612

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

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

    
1623
                    SetCursor();
1624

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

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

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

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

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

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

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

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

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

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

    
1713
                zoomAndPanControl.ReleaseMouseCapture();
1714

    
1715

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

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

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

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

    
1741
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1742

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

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

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

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

    
1784
            //GC.Collect();
1785

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

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

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

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

    
1812
        }
1813

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1964
            zoomAndPanControl.RotationAngle = rotate.Angle;
1965

    
1966

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2127
            ConvertInkControlToPolygon();
2128

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

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

    
2139
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2140
            {
2141
                if (item as ArrowTextControl != null)
2142
                {
2143
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2144
                }
2145
            }
2146

    
2147
            //if (currentControl != null)
2148
            {
2149
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2150
                if (text_item_ != null)
2151
                {
2152
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2153
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2154
                    (text_item_ as TextControl).IsEditingMode = false;
2155
                    (text_item_ as TextControl).Base_TextBox.Focusable = false;
2156
                    currentControl = null;
2157
                }
2158

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

    
2168
            double Ang = 0;                                          
2169
            if (rotate.Angle != 0)
2170
            {
2171
                Ang = 360 - rotate.Angle;
2172
            }
2173

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

    
2188
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2189
            {
2190
                if (this._dragdropWindow != null)
2191
                {
2192
                    this._dragdropWindow.Close();
2193
                    this._dragdropWindow = null;
2194
                    symbol_id = null;
2195
                }
2196
            }
2197
            */
2198

    
2199
            if (e.LeftButton == MouseButtonState.Pressed)
2200
            {
2201
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2202
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2203

    
2204
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2205
                SetCursor();
2206

    
2207
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2208
            }
2209

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

    
2229
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2230

    
2231
            }
2232
            else if (e.XButton2 == MouseButtonState.Pressed)
2233
            {
2234
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2235
                {
2236
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2237
                }
2238
            }
2239

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

    
2250
                    if (controlType == ControlType.None)
2251
                    {
2252
                        isLeftMouseButtonDownOnWindow = true;
2253
                    }
2254
                }
2255

    
2256
                /// 캡쳐 모드 설정
2257
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2258
                {
2259
                    dragCaptureBorder.Visibility = Visibility.Visible;
2260
                    isLeftMouseButtonDownOnWindow = true;
2261
                }
2262

    
2263
                /// 줌 모드 설정
2264
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2265
                {
2266
                    isLeftMouseButtonDownOnWindow = true;
2267
                }
2268

    
2269
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2270
                if (control != null)
2271
                {
2272
                    AdornerFinal final = null;
2273

    
2274
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2275
                    {
2276
                        /// 기존 selection 해제
2277
                        SelectionSet.Instance.UnSelect(this);
2278

    
2279
                        final = new AdornerFinal(control);
2280

    
2281
                        this.Control_Style(control);
2282

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

    
2308
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2309

    
2310
                        if ((control as TextControl) != null)
2311
                        {
2312
                            if(!((control as TextControl).EnableEditing)) {
2313
                                (control as TextControl).EnableEditing = true;
2314
                            }
2315
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2316
                            {
2317
                                ViewerDataModel.Instance.checkTextStyle = true;
2318
                            }
2319
                            else
2320
                            {
2321
                                ViewerDataModel.Instance.checkTextStyle = false;
2322
                            }
2323
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2324
                            {
2325
                                ViewerDataModel.Instance.checkTextWeight = true;
2326
                            }
2327
                            else
2328
                            {
2329
                                ViewerDataModel.Instance.checkTextWeight = false;
2330
                            }
2331
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2332
                            {
2333
                                ViewerDataModel.Instance.checkUnderLine = true;
2334
                            }
2335
                            else
2336
                            {
2337
                                ViewerDataModel.Instance.checkUnderLine = false;
2338
                            }
2339
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2340
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2341

    
2342
                        }
2343
                        else if ((control as ArrowTextControl) != null)
2344
                        {
2345
                            if (!((control as ArrowTextControl).EnableEditing))
2346
                            {
2347
                                (control as ArrowTextControl).EnableEditing = true;
2348
                            }
2349
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2350
                            {
2351
                                ViewerDataModel.Instance.checkTextStyle = true;
2352
                            }
2353
                            else
2354
                            {
2355
                                ViewerDataModel.Instance.checkTextStyle = false;
2356
                            }
2357
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2358
                            {
2359
                                ViewerDataModel.Instance.checkTextWeight = true;
2360
                            }
2361
                            else
2362
                            {
2363
                                ViewerDataModel.Instance.checkTextWeight = false;
2364
                            }
2365
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2366
                            {
2367
                                ViewerDataModel.Instance.checkUnderLine = true;
2368
                            }
2369
                            else
2370
                            {
2371
                                ViewerDataModel.Instance.checkUnderLine = false;
2372
                            }
2373
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2374
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2375
                        }
2376
                        else if ((control as RectCloudControl) != null)
2377
                        {
2378
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2379
                        }
2380
                        else if ((control as CloudControl) != null)
2381
                        {
2382
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2383
                        }
2384
                    }
2385
                    else
2386
                    {
2387
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2388
                        SelectionSet.Instance.UnSelect(this);
2389
                        comment.Add(control);
2390

    
2391
                        Control_Style(control);
2392

    
2393
                        final = new AdornerFinal(comment);
2394
                    }
2395

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

    
2439
                switch (controlType)
2440
                {
2441
                    case ControlType.Coordinate:
2442
                        {
2443
                            if (e.LeftButton == MouseButtonState.Pressed)
2444
                            {
2445
                                if (currentControl is CoordinateControl)
2446
                                {
2447
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2448
                                    {
2449
                                        return;
2450
                                    }
2451

    
2452
                                    CreateCommand.Instance.Execute(currentControl);
2453

    
2454
                                    currentControl = null;
2455
                                    this.cursor = Cursors.Arrow;
2456
                                }
2457
                                else
2458
                                {
2459
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2460
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2461
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2462
                                    {
2463
                                        currentControl = null;
2464
                                        this.cursor = Cursors.Arrow;
2465
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2466
                                        return;
2467
                                    }
2468
                                    else
2469
                                    {
2470
                                        currentControl = new CoordinateControl
2471
                                        {
2472
                                            Background = new SolidColorBrush(Colors.Black),
2473
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2474
                                            ControlType = ControlType.Coordinate
2475
                                        };
2476

    
2477
                                        currentControl.CommentID = Commons.shortGuid();
2478
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2479
                                        currentControl.IsNew = true;
2480

    
2481
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2482

    
2483
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2484
                                    }
2485
                                }
2486
                            }
2487
                        }
2488
                        break;
2489
                    case ControlType.InsideWhite:
2490
                        {
2491
                            if (e.LeftButton == MouseButtonState.Pressed)
2492
                            {
2493
                                if (currentControl is InsideWhiteControl)
2494
                                {
2495
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2496
                                    {
2497
                                        return;
2498
                                    }
2499

    
2500
                                    CreateCommand.Instance.Execute(currentControl);
2501

    
2502
                                    currentControl = null;
2503
                                    this.cursor = Cursors.Arrow;
2504
                                }
2505
                                else
2506
                                {
2507
                                    currentControl = new InsideWhiteControl
2508
                                    {
2509
                                        Background = new SolidColorBrush(Colors.Black),
2510
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2511
                                        ControlType = ControlType.InsideWhite
2512
                                    };
2513

    
2514
                                    currentControl.CommentID = Commons.shortGuid();
2515
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2516
                                    currentControl.IsNew = true;
2517
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2518

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

    
2535
                                    CreateCommand.Instance.Execute(currentControl);
2536

    
2537
                                    currentControl = null;
2538
                                    this.cursor = Cursors.Arrow;
2539
                                }
2540
                                else
2541
                                {
2542
                                    currentControl = new OverlapWhiteControl
2543
                                    {
2544
                                        Background = new SolidColorBrush(Colors.Black),
2545
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2546
                                        ControlType = ControlType.OverlapWhite
2547
                                    };
2548

    
2549
                                    currentControl.CommentID = Commons.shortGuid();
2550
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2551
                                    currentControl.IsNew = true;
2552
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2553

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

    
2570
                                    CreateCommand.Instance.Execute(currentControl);
2571

    
2572
                                    currentControl = null;
2573
                                    this.cursor = Cursors.Arrow;
2574
                                }
2575
                                else
2576
                                {
2577
                                    currentControl = new ClipWhiteControl
2578
                                    {
2579
                                        Background = new SolidColorBrush(Colors.Black),
2580
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2581
                                        ControlType = ControlType.ClipWhite
2582
                                    };
2583

    
2584
                                    currentControl.CommentID = Commons.shortGuid();
2585
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2586
                                    currentControl.IsNew = true;
2587
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2588

    
2589
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2590
                                }
2591
                            }
2592
                        }
2593
                        break;
2594
                    case ControlType.Rectangle:
2595
                        {
2596
                            if (e.LeftButton == MouseButtonState.Pressed)
2597
                            {
2598
                                if (currentControl is RectangleControl)
2599
                                {
2600
                                    //20180906 LJY TEST IsRotationDrawingEnable
2601
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2602
                                    {
2603
                                        return;
2604
                                    }
2605

    
2606
                                    CreateCommand.Instance.Execute(currentControl);
2607
                                    currentControl = null;
2608
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2609
                                }
2610
                                else
2611
                                {
2612
                                    currentControl = new RectangleControl
2613
                                    {
2614
                                        Background = new SolidColorBrush(Colors.Black),
2615
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2616
                                        ControlType = ControlType.Rectangle
2617
                                    };
2618

    
2619
                                    currentControl.CommentID = Commons.shortGuid();
2620
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2621
                                    currentControl.IsNew = true;
2622
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2623

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

    
2641
                                    CreateCommand.Instance.Execute(currentControl);
2642

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

    
2656
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2657
                                    currentControl.CommentID = Commons.shortGuid();
2658
                                    currentControl.IsNew = true;
2659
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2660
                                }
2661
                            }
2662
                        }
2663
                        break;
2664
                    case ControlType.Circle:
2665
                        {
2666
                            if (e.LeftButton == MouseButtonState.Pressed)
2667
                            {
2668
                                if (currentControl is CircleControl)
2669
                                {
2670
                                    //20180906 LJY TEST IsRotationDrawingEnable
2671
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2672
                                    {
2673
                                        return;
2674
                                    }
2675

    
2676
                                    CreateCommand.Instance.Execute(currentControl);
2677

    
2678
                                    currentControl = null;
2679
                                }
2680
                                else
2681
                                {
2682
                                    currentControl = new CircleControl
2683
                                    {
2684
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2685
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2686
                                        Background = new SolidColorBrush(Colors.Black)
2687
                                    };
2688

    
2689
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2690
                                    currentControl.CommentID = Commons.shortGuid();
2691
                                    currentControl.IsNew = true;
2692
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2693
                                }
2694
                            }
2695
                        }
2696
                        break;
2697
                    case ControlType.Triangle:
2698
                        {
2699
                            if (e.LeftButton == MouseButtonState.Pressed)
2700
                            {
2701
                                if (currentControl is TriControl)
2702
                                {
2703
                                    var content = currentControl as TriControl;
2704
                                    if (content.MidPoint == new Point(0, 0))
2705
                                    {
2706
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2707
                                    }
2708
                                    else
2709
                                    {
2710
                                        //20180906 LJY TEST IsRotationDrawingEnable
2711
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2712
                                        {
2713
                                            return;
2714
                                        }
2715

    
2716
                                        CreateCommand.Instance.Execute(currentControl);
2717

    
2718
                                        currentControl = null;
2719
                                    }
2720
                                }
2721
                                else
2722
                                {
2723
                                    currentControl = new TriControl
2724
                                    {
2725
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2726
                                        Background = new SolidColorBrush(Colors.Black),
2727
                                    };
2728

    
2729
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2730
                                    currentControl.CommentID = Commons.shortGuid();
2731
                                    currentControl.IsNew = true;
2732
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2733
                                }
2734
                            }
2735
                        }
2736
                        break;
2737
                    case ControlType.CancelLine:
2738
                    case ControlType.SingleLine:
2739
                    case ControlType.ArrowLine:
2740
                    case ControlType.TwinLine:
2741
                    case ControlType.DimLine:
2742
                        {
2743
                            if (e.LeftButton == MouseButtonState.Pressed)
2744
                            {
2745
                                if (currentControl is LineControl)
2746
                                {
2747
                                    //20180906 LJY TEST IsRotationDrawingEnable
2748
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2749
                                    {
2750
                                        return;
2751
                                    }
2752

    
2753
                                    CreateCommand.Instance.Execute(currentControl);
2754
                                    currentControl = null;
2755
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2756
                                }
2757
                                else
2758
                                {
2759
                                    currentControl = new LineControl
2760
                                    {
2761
                                        ControlType = this.controlType,
2762
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2763
                                        Background = new SolidColorBrush(Colors.Black)
2764
                                    };
2765

    
2766
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2767
                                    currentControl.CommentID = Commons.shortGuid();
2768
                                    currentControl.IsNew = true;
2769
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2770
                                    this.MainAngle.Visibility = Visibility.Visible;
2771
                                }
2772
                            }
2773
                        }
2774
                        break;
2775
                    case ControlType.PolygonControl:
2776
                        {
2777
                            if (currentControl is PolygonControl)
2778
                            {
2779
                                var control = currentControl as PolygonControl;
2780

    
2781
                                if (e.RightButton == MouseButtonState.Pressed)
2782
                                {
2783
                                    control.IsCompleted = true;
2784
                                }
2785

    
2786
                                if (!control.IsCompleted)
2787
                                {
2788
                                    control.PointSet.Add(control.EndPoint);
2789
                                }
2790
                                else
2791
                                {
2792
                                    //20180906 LJY TEST IsRotationDrawingEnable
2793
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2794
                                    {
2795
                                        return;
2796
                                    }
2797

    
2798
                                    var firstPoint = control.PointSet.First();
2799
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2800
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2801
                                    control.PointSet.Add(firstPoint);
2802

    
2803
                                    control.ApplyOverViewData();
2804

    
2805
                                    CreateCommand.Instance.Execute(currentControl);
2806
                                    control.UpdateControl();
2807
                                    currentControl = null;
2808
                                }
2809
                            }
2810
                            else
2811
                            {
2812
                                if (e.LeftButton == MouseButtonState.Pressed)
2813
                                {
2814
                                    currentControl = new PolygonControl
2815
                                    {
2816
                                        PointSet = new List<Point>(),
2817
                                    };
2818

    
2819
                                    var polygonControl = (currentControl as PolygonControl);
2820
                                    currentControl.CommentID = Commons.shortGuid();
2821
                                    currentControl.IsNew = true;
2822
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2823
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2824
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2825
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2826
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2827
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2828
                                    polygonControl.ApplyTemplate();
2829
                                    polygonControl.Visibility = Visibility.Visible;
2830
                                }
2831
                            }
2832
                        }
2833
                        break;
2834
                    case ControlType.ChainLine:
2835
                        {
2836
                            if (currentControl is PolygonControl)
2837
                            {
2838
                                var control = currentControl as PolygonControl;
2839

    
2840
                                if (e.RightButton == MouseButtonState.Pressed)
2841
                                {
2842
                                    //20180906 LJY TEST IsRotationDrawingEnable
2843
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2844
                                    {
2845
                                        return;
2846
                                    }
2847

    
2848
                                    CreateCommand.Instance.Execute(currentControl);
2849

    
2850
                                    currentControl = null;
2851
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2852
                                    return;
2853
                                }
2854

    
2855
                                if (!control.IsCompleted)
2856
                                {
2857
                                    control.PointSet.Add(control.EndPoint);
2858
                                    this.MainAngle.Visibility = Visibility.Visible;
2859
                                }
2860
                            }
2861
                            else
2862
                            {
2863
                                if (e.LeftButton == MouseButtonState.Pressed)
2864
                                {
2865
                                    MainAngle.Visibility = Visibility.Visible;
2866
                                    currentControl = new PolygonControl
2867
                                    {
2868
                                        PointSet = new List<Point>(),
2869
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2870
                                        ControlType = ControlType.ChainLine,
2871
                                        DashSize = ViewerDataModel.Instance.DashSize,
2872
                                        LineSize = ViewerDataModel.Instance.LineSize,
2873
                                        //PointC = new StylusPointSet()
2874
                                    };
2875

    
2876
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2877
                                    //{
2878
                                        var polygonControl = (currentControl as PolygonControl);
2879
                                        currentControl.CommentID = Commons.shortGuid();
2880
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2881
                                        currentControl.IsNew = true;
2882
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2883
                                        //currentControl.OnApplyTemplate();
2884
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2885
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2886
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2887
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2888
                                    //}
2889
                                }
2890
                            }
2891
                        }
2892
                        break;
2893
                    case ControlType.ArcLine:
2894
                        {
2895
                            if (e.LeftButton == MouseButtonState.Pressed)
2896
                            {
2897
                                if (currentControl is ArcControl)
2898
                                {
2899
                                    //20180906 LJY TEST IsRotationDrawingEnable
2900
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2901
                                    {
2902
                                        return;
2903
                                    }
2904

    
2905
                                    CreateCommand.Instance.Execute(currentControl);
2906

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

    
2948
                                    CreateCommand.Instance.Execute(currentControl);
2949

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

    
2986
                                    if (currentControl is ArrowControl_Multi)
2987
                                    {
2988
                                        var content = currentControl as ArrowControl_Multi;
2989
                                        if (content.MiddlePoint == new Point(0, 0))
2990
                                        {
2991
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2992
                                            {
2993
                                                content.MiddlePoint = content.EndPoint;
2994
                                            }
2995
                                            else
2996
                                            {
2997
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2998
                                            }
2999
                                        }
3000
                                        else
3001
                                        {
3002
                                            //20180906 LJY TEST IsRotationDrawingEnable
3003
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3004
                                            {
3005
                                                return;
3006
                                            }
3007

    
3008
                                            CreateCommand.Instance.Execute(currentControl);
3009

    
3010
                                            currentControl = null;
3011
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3012
                                        }
3013
                                    }
3014
                                    else
3015
                                    {
3016
                                        currentControl = new ArrowControl_Multi
3017
                                        {
3018
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3019
                                            Background = new SolidColorBrush(Colors.Black)
3020
                                        };
3021
                                        currentControl.CommentID = Commons.shortGuid();
3022
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3023
                                        currentControl.IsNew = true;
3024
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3025
                                        this.MainAngle.Visibility = Visibility.Visible;
3026
                                    }
3027
                                //}
3028
                            }
3029
                        }
3030
                        break;
3031
                    case ControlType.PolygonCloud:
3032
                        {
3033
                            if (currentControl is CloudControl)
3034
                            {
3035
                                var control = currentControl as CloudControl;
3036
                                if (e.RightButton == MouseButtonState.Pressed)
3037
                                {
3038
                                    control.IsCompleted = true;
3039
                                }
3040

    
3041
                                if (!control.IsCompleted)
3042
                                {
3043
                                    control.PointSet.Add(control.EndPoint);
3044
                                }
3045
                                else
3046
                                {
3047
                                    //20180906 LJY TEST IsRotationDrawingEnable
3048
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3049
                                    {
3050
                                        return;
3051
                                    }
3052

    
3053
                                    CreateCommand.Instance.Execute(currentControl);
3054

    
3055
                                    control.isTransOn = true;
3056
                                    var firstPoint = control.PointSet.First();
3057

    
3058
                                    control.PointSet.Add(firstPoint);
3059
                                    control.DrawingCloud();
3060
                                    control.ApplyOverViewData();
3061

    
3062
                                    currentControl = null;
3063
                                }
3064
                            }
3065
                            else
3066
                            {
3067
                                if (e.LeftButton == MouseButtonState.Pressed)
3068
                                {
3069
                                    currentControl = new CloudControl
3070
                                    {
3071
                                        PointSet = new List<Point>(),
3072
                                        PointC = new StylusPointSet()
3073
                                    };
3074

    
3075
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3076
                                    //{
3077
                                        var polygonControl = (currentControl as CloudControl);
3078
                                        currentControl.CommentID = Commons.shortGuid();
3079
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3080
                                        currentControl.IsNew = true;
3081
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3082

    
3083
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3084
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3085
                                    
3086
                                    //}
3087
                                }
3088
                            }
3089
                        }
3090
                        break;
3091
                    case ControlType.ImgControl:
3092
                        {
3093
                            if (e.LeftButton == MouseButtonState.Pressed)
3094
                            {
3095
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3096
                                //{
3097
                                    if (currentControl is ImgControl)
3098
                                    {
3099
                                        //20180906 LJY TEST IsRotationDrawingEnable
3100
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3101
                                        {
3102
                                            return;
3103
                                        }
3104

    
3105
                                        CreateCommand.Instance.Execute(currentControl);
3106
                                        controlType = ControlType.ImgControl;
3107
                                        currentControl = null;
3108
                                    }
3109
                                    else
3110
                                    {
3111
                                        
3112
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3113
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3114
                                        {
3115
                                            Image img = new Image();
3116
                                            if (filename.Contains(".svg"))
3117
                                            {
3118
                                                byte[] imageData = null;
3119
                                                DrawingImage image = null;
3120
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3121
                                                {
3122
                                                    imageData = web.DownloadData(new Uri(filename));
3123
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3124
                                                    image = SvgReader.Load(stream);
3125
                                                }
3126
                                                img.Source = image;
3127
                                            }
3128
                                            else
3129
                                            {
3130
                                                img.Source = new BitmapImage(new Uri(filename));
3131
                                            }
3132

    
3133
                                            currentControl = new ImgControl
3134
                                            {
3135
                                                    Background = new SolidColorBrush(Colors.Black),
3136
                                                    PointSet = new List<Point>(),
3137
                                                    FilePath = filename,
3138
                                                    ImageData = img.Source,
3139
                                                    StartPoint = canvasDrawingMouseDownPoint,
3140
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3141
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3142
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3143
                                                    ControlType = ControlType.ImgControl
3144
                                                };
3145

    
3146
                                        
3147
                                                currentControl.CommentID = Commons.shortGuid();                                            
3148
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3149
                                                currentControl.IsNew = true;
3150
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3151

    
3152
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3153
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3154
                                        }
3155
                                    }
3156
                                //}
3157
                            }
3158
                        }
3159
                        break;
3160
                    case ControlType.Date:
3161
                        {
3162
                            if (e.LeftButton == MouseButtonState.Pressed)
3163
                            {
3164
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3165
                                //{
3166
                                    if (currentControl is DateControl)
3167
                                    {
3168
                                        //20180906 LJY TEST IsRotationDrawingEnable
3169
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3170
                                        {
3171
                                            return;
3172
                                        }
3173

    
3174
                                        CreateCommand.Instance.Execute(currentControl);
3175
                                        currentControl = null;
3176

    
3177
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3178
                                        {
3179
                                            controlType = ControlType.None;
3180
                                            IsSwingMode = false;
3181
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3182
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3183
                                            mouseHandlingMode = MouseHandlingMode.None;
3184
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3185
                                            txtBatch.Visibility = Visibility.Collapsed;
3186

    
3187
                                        }
3188
                                    }
3189
                                    else
3190
                                    {
3191
                                        currentControl = new DateControl
3192
                                        {
3193
                                            StartPoint = canvasDrawingMouseDownPoint,
3194
                                            Background = new SolidColorBrush(Colors.Black)
3195
                                        };
3196
                                        currentControl.CommentID = Commons.shortGuid();
3197
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3198
                                        currentControl.IsNew = true;
3199
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3200

    
3201
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3202
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3203
                                }
3204
                                //}
3205
                            }
3206
                        }
3207
                        break;
3208
                    case ControlType.TextControl:
3209
                        {
3210
                            if (e.LeftButton == MouseButtonState.Pressed)
3211
                            {
3212
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3213
                                {
3214
                                    currentControl = new TextControl
3215
                                    {
3216
                                        ControlType = controlType
3217
                                    };
3218
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3219
                                    currentControl.CommentID = Commons.shortGuid();
3220
                                    currentControl.IsNew = true;
3221
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3222
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3223
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3224

    
3225
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3226
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3227
                                    
3228
                                    (currentControl as TextControl).ControlType_No = 0;
3229
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3230
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3231
                                    (currentControl as TextControl).ApplyTemplate();
3232
                                    (currentControl as TextControl).Base_TextBox.Focus();
3233

    
3234
                                    CreateCommand.Instance.Execute(currentControl);
3235
                                }
3236
                            }
3237
                        }
3238
                        break;
3239
                    case ControlType.TextBorder:
3240
                        {
3241
                            if (e.LeftButton == MouseButtonState.Pressed)
3242
                            {
3243
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3244
                                {
3245
                                    currentControl = new TextControl
3246
                                    {
3247
                                        ControlType = controlType
3248
                                    };
3249

    
3250
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3251
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3252
                                    currentControl.CommentID = Commons.shortGuid();
3253
                                    currentControl.IsNew = true;
3254
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3255
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3256
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3257
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3258
                                    
3259
                                    (currentControl as TextControl).ControlType_No = 1;
3260
                                    (currentControl as TextControl).Angle = Ang;
3261
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3262
                                    (currentControl as TextControl).ApplyTemplate();
3263
                                    (currentControl as TextControl).Base_TextBox.Focus();
3264
                                    CreateCommand.Instance.Execute(currentControl);
3265
                                }
3266
                            }
3267
                        }
3268
                        break;
3269
                    case ControlType.TextCloud:
3270
                        {
3271
                            if (e.LeftButton == MouseButtonState.Pressed)
3272
                            {
3273
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3274
                                {
3275
                                    currentControl = new TextControl
3276
                                    {
3277
                                        ControlType = controlType
3278
                                    };
3279

    
3280
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3281
                                    currentControl.CommentID = Commons.shortGuid();
3282
                                    currentControl.IsNew = true;
3283
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3284
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3285

    
3286
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3287
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3288
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3289

    
3290
                                    (currentControl as TextControl).Angle = Ang;
3291
                                    (currentControl as TextControl).ControlType_No = 2;
3292
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3293
                                    (currentControl as TextControl).ApplyTemplate();
3294
                                    (currentControl as TextControl).Base_TextBox.Focus();
3295
                                    CreateCommand.Instance.Execute(currentControl);
3296
                                    //currentControl = null;
3297
                                }
3298
                            }
3299
                        }
3300
                        break;
3301
                    case ControlType.ArrowTextControl:
3302
                         {
3303
                            if (e.LeftButton == MouseButtonState.Pressed)
3304
                            {
3305
                                if (currentControl is ArrowTextControl)
3306
                                {
3307
                                    //20180906 LJY TEST IsRotationDrawingEnable
3308
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3309
                                    {
3310
                                        return;
3311
                                    }
3312

    
3313
                                    CreateCommand.Instance.Execute(currentControl);
3314

    
3315
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3316
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3317
                                    (currentControl as ArrowTextControl).IsNew = false;
3318
                                    currentControl = null;
3319
                                }
3320
                                else
3321
                                {
3322
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3323
                                    //{
3324
                                        currentControl = new ArrowTextControl();
3325
                                        currentControl.CommentID = Commons.shortGuid();
3326
                                        currentControl.IsNew = true;
3327
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3328
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3329

    
3330
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3331
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3332
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3333
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3334
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3335

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

    
3339
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3340
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3341
                                        this.MainAngle.Visibility = Visibility.Visible;
3342

    
3343
                                    
3344
                                    //}
3345
                                }
3346
                            }
3347
                        }
3348
                        break;
3349
                    case ControlType.ArrowTransTextControl:
3350
                        {
3351
                            if (e.LeftButton == MouseButtonState.Pressed)
3352
                            {
3353
                                if (currentControl is ArrowTextControl)
3354
                                {
3355
                                    //20180906 LJY TEST IsRotationDrawingEnable
3356
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3357
                                    {
3358
                                        return;
3359
                                    }
3360

    
3361
                                    CreateCommand.Instance.Execute(currentControl);
3362
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3363
                                    currentControl.IsNew = false;
3364
                                    currentControl = null;
3365
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3366
                                }
3367
                                else
3368
                                {
3369
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3370
                                    //{
3371
                                    currentControl = new ArrowTextControl()
3372
                                    {
3373
                                        ControlType = ControlType.ArrowTransTextControl
3374
                                    };
3375
                                    currentControl.CommentID = Commons.shortGuid();
3376
                                    currentControl.IsNew = true;
3377
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3378
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3379
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3380
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3381
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3382
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3383
                                    (currentControl as ArrowTextControl).isFixed = true;
3384
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3385

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

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

    
3408
                                    CreateCommand.Instance.Execute(currentControl);
3409
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3410
                                    currentControl.IsNew = false;
3411
                                    currentControl = null;
3412
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3413
                                }
3414
                                else
3415
                                {
3416
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3417
                                    //{
3418
                                        currentControl = new ArrowTextControl()
3419
                                        {
3420
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3421
                                        };
3422
                                        currentControl.CommentID = Commons.shortGuid();
3423
                                        currentControl.IsNew = true;
3424
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3425
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3426

    
3427
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3428

    
3429
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3430

    
3431
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3432
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3433
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3434

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

    
3468
                                    currentControl = new ArrowTextControl()
3469
                                    {
3470
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3471
                                        ControlType = ControlType.ArrowTransTextBorderControl
3472

    
3473
                                    };
3474
                                        currentControl.CommentID = Commons.shortGuid();
3475
                                        currentControl.IsNew = true;
3476
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3477
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3478

    
3479
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3480

    
3481
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3482
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3483
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3484
                                        (currentControl as ArrowTextControl).isFixed = true;
3485
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3486
                                     
3487
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3488
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3489
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3490

    
3491
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3492
                                        this.MainAngle.Visibility = Visibility.Visible;
3493
                                    
3494
                                    //20180911 LJY
3495
                                        (currentControl as ArrowTextControl).isTrans = true;
3496
                                    
3497

    
3498
                                    //}
3499
                                }
3500
                            }
3501
                        }
3502
                        break;
3503
                    case ControlType.ArrowTextCloudControl:
3504
                        {
3505
                            if (e.LeftButton == MouseButtonState.Pressed)
3506
                            {
3507
                                if (currentControl is ArrowTextControl)
3508
                                {
3509
                                    //20180906 LJY TEST IsRotationDrawingEnable
3510
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3511
                                    {
3512
                                        return;
3513
                                    }
3514
                                    CreateCommand.Instance.Execute(currentControl);
3515
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3516
                                    currentControl.IsNew = false;
3517
                                    currentControl = null;
3518
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3519
                                }
3520
                                else
3521
                                {
3522
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3523
                                    //{
3524
                                        currentControl = new ArrowTextControl()
3525
                                        {
3526
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3527
                                        };
3528
                                        currentControl.CommentID = Commons.shortGuid();
3529
                                        currentControl.IsNew = true;
3530
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3531
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3532

    
3533
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3534
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3535
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3536
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3537
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3538

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

    
3576
                                        };
3577
                                        currentControl.CommentID = Commons.shortGuid();
3578
                                        currentControl.IsNew = true; 
3579
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3580
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3581
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3582

    
3583
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3584
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3585
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3586
                                        (currentControl as ArrowTextControl).isFixed = true;
3587
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3588

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

    
3592
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3593
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3594
                                        this.MainAngle.Visibility = Visibility.Visible;  
3595
                                    
3596
                                    //20180911 LJY
3597
                                        (currentControl as ArrowTextControl).isTrans = true;
3598
                                    //}
3599
                                }
3600
                            }
3601
                        }
3602
                        break;
3603
                    //강인구 추가
3604
                    case ControlType.Sign:
3605
                        {
3606
                            if (e.LeftButton == MouseButtonState.Pressed)
3607
                            {
3608
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3609
                                //{
3610
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3611

    
3612
                                    if (_sign == null)
3613
                                    {
3614
                                        txtBatch.Visibility = Visibility.Collapsed;
3615
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3616
                                        controlType = ControlType.None;
3617

    
3618
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3619
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3620
                                        return;
3621
                                    }
3622

    
3623
                                    if (currentControl is SignControl)
3624
                                    {
3625
                                        //20180906 LJY TEST IsRotationDrawingEnable
3626
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3627
                                        {
3628
                                            return;
3629
                                        }
3630

    
3631
                                        CreateCommand.Instance.Execute(currentControl);
3632
                                        currentControl = null;
3633
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3634
                                        {
3635
                                            txtBatch.Text = "Place Date";
3636
                                            controlType = ControlType.Date;
3637
                                        }
3638
                                    }
3639
                                    else
3640
                                    {
3641
                                        currentControl = new SignControl
3642
                                        {
3643
                                            Background = new SolidColorBrush(Colors.Black),
3644
                                            UserNumber = App.ViewInfo.UserID,
3645
                                            ProjectNO = App.ViewInfo.ProjectNO,
3646
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3647
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3648
                                            ControlType = ControlType.Sign
3649
                                        };
3650

    
3651
                                        currentControl.CommentID = Commons.shortGuid();
3652
                                        currentControl.IsNew = true;
3653
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3654
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3655

    
3656
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3657
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3658
                                }
3659
                                //}
3660
                            }
3661
                        }
3662
                        break;
3663
                    case ControlType.Mark:
3664
                        {
3665
                            if (e.LeftButton == MouseButtonState.Pressed)
3666
                            {
3667
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3668
                                //{
3669
                                    if (currentControl is RectangleControl)
3670
                                    {
3671
                                        //20180906 LJY TEST IsRotationDrawingEnable
3672
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3673
                                        {
3674
                                            return;
3675
                                        }
3676

    
3677
                                        CreateCommand.Instance.Execute(currentControl);
3678
                                        (currentControl as RectangleControl).ApplyOverViewData();
3679
                                        currentControl = null;
3680
                                    
3681
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3682

    
3683
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3684
                                        {
3685
                                            txtBatch.Text = "Place Signature";
3686
                                            controlType = ControlType.Sign;
3687
                                        }
3688
                                    }
3689
                                    else
3690
                                    {
3691
                                        currentControl = new RectangleControl
3692
                                        {
3693
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3694
                                            Background = new SolidColorBrush(Colors.Black),
3695
                                            ControlType = ControlType.Mark ,
3696
                                            Paint = PaintSet.Fill
3697
                                        };
3698

    
3699
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3700
                                        currentControl.CommentID = Commons.shortGuid();
3701
                                        currentControl.IsNew = true;
3702
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3703
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3704
                                    }
3705
                                //}
3706
                            }
3707
                        }
3708
                        break;
3709
                    case ControlType.Symbol:
3710
                        {
3711
                            if (e.LeftButton == MouseButtonState.Pressed)
3712
                            {
3713
                                if (currentControl is SymControl)
3714
                                {
3715
                                    //20180906 LJY TEST IsRotationDrawingEnable
3716
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3717
                                    {
3718
                                        return;
3719
                                    }
3720
                                    CreateCommand.Instance.Execute(currentControl);
3721
                                    currentControl = null;
3722
                                
3723
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3724
                                }
3725
                                else
3726
                                {
3727
                                    currentControl = new SymControl
3728
                                    {
3729
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3730
                                        Background = new SolidColorBrush(Colors.Black),
3731
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3732
                                        ControlType = ControlType.Symbol
3733
                                    };
3734

    
3735
                                    currentControl.IsNew = true;
3736
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3737
                                    currentControl.CommentID = Commons.shortGuid();
3738
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3739

    
3740
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3741
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3742
                                }
3743
                                //}
3744
                            }
3745
                        }
3746
                        break;
3747
                    case ControlType.Stamp:
3748
                        {
3749
                            if (e.LeftButton == MouseButtonState.Pressed)
3750
                            {
3751
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3752
                                //{
3753
                                    if (currentControl is SymControlN)
3754
                                    {
3755
                                        //20180906 LJY TEST IsRotationDrawingEnable
3756
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3757
                                        {
3758
                                            return;
3759
                                        }
3760

    
3761
                                        CreateCommand.Instance.Execute(currentControl);
3762
                                        currentControl = null;
3763
                                   
3764

    
3765
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3766
                                    }
3767
                                    else
3768
                                    {
3769
                                        currentControl = new SymControlN
3770
                                        {
3771
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3772
                                            Background = new SolidColorBrush(Colors.Black),
3773
                                            STAMP = App.SystemInfo.STAMP,                                            
3774
                                            ControlType = ControlType.Stamp
3775
                                        };
3776

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

    
3825
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3826
                            if (over != null)
3827
                            {
3828
                                mouseOff = true;
3829
                            }
3830
                        }
3831
                    }
3832

    
3833
                    if (!mouseOff)
3834
                    {
3835
                        SelectionSet.Instance.UnSelect(this);
3836
                    }
3837
                }
3838
                zoomAndPanControl.CaptureMouse();
3839
                e.Handled = true;
3840
            }
3841
          
3842
        }
3843

    
3844
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3845
        {
3846
            ///mouseButtonDown = e.ChangedButton;
3847
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3848
        }
3849

    
3850
        private void RemoveLineStroke(Point P)
3851
        {
3852
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3853
            if (control != null)
3854
            {
3855
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3856
            }
3857
        }
3858

    
3859
        private void RemovePointStroke(Point P)
3860
        {
3861
            foreach (Stroke hits in inkBoard.Strokes)
3862
            {
3863
                foreach (StylusPoint sty in hits.StylusPoints)
3864
                {
3865

    
3866
                }
3867
                if (hits.HitTest(P))
3868
                {
3869
                    inkBoard.Strokes.Remove(hits);
3870
                    return;
3871
                }
3872
            }
3873
        }
3874

    
3875
        private void StartNewStroke(Point P)
3876
        {
3877
            strokePoints = new StylusPointCollection();
3878
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3879
            strokePoints.Add(segment1Start);
3880
            stroke = new Stroke(strokePoints);
3881

    
3882
            stroke.DrawingAttributes.Color = Colors.Red;
3883
            stroke.DrawingAttributes.Width = 4;
3884
            stroke.DrawingAttributes.Height = 4;
3885

    
3886
            inkBoard.Strokes.Add(stroke);
3887
        }
3888

    
3889
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3890
        {
3891
            ConsolidationMethod();
3892
        }
3893

    
3894
        /// <summary>
3895
        /// execute TeamConsolidationCommand
3896
        /// </summary>
3897
        public void TeamConsolidationMethod()
3898
        {
3899
            this.UpdateMyMarkupList();
3900
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3901
            {
3902
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3903
            }
3904
            else
3905
            {
3906

    
3907
                ViewerDataModel.Instance.IsConsolidate = true;
3908
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3909

    
3910
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3911
                {
3912
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3913
                    {
3914
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3915
                        return;
3916
                    }                    
3917
                }
3918
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3919
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3920
                {
3921
                    MarkupInfoList.Add(item);
3922
                }
3923
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3924
            }
3925
        }
3926

    
3927
        public void ConsolidationMethod()
3928
        {
3929
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3930
            {
3931
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3932
            }
3933
            else
3934
            {
3935
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3936
                foreach (var item in this.gridViewMarkup.SelectedItems)
3937
                {
3938
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3939
                }
3940
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3941
                
3942
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3943
            }
3944
        }
3945

    
3946
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3947
        {
3948
            if (App.ViewInfo != null)
3949
            {
3950
                btnConsolidate = (sender as RadRibbonButton);
3951
                if (!App.ViewInfo.NewCommentPermission)
3952
                {
3953
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3954
                }
3955
            }
3956
        }
3957

    
3958
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3959
        {
3960
            TeamConsolidationMethod();
3961
        }
3962

    
3963
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3964
        {
3965
            btnTeamConsolidate = sender as RadRibbonButton;
3966
            if (App.ViewInfo != null)
3967
            {
3968
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3969
                {
3970
                    if (btnConsolidate != null)
3971
                    {
3972
                        btnConsolidate.Visibility = Visibility.Collapsed;
3973
                    }
3974

    
3975
                    if (!App.ViewInfo.NewCommentPermission)
3976
                    {
3977
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3978
                    }
3979
                }
3980
                else
3981
                {
3982
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3983
                }
3984
            }
3985
        }
3986

    
3987
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3988
        {
3989
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3990
            if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
3991
            {
3992
                if (item != null)
3993
                {
3994
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3995
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3996
                }
3997
                else
3998
                {
3999
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4000
                }
4001
            }
4002
            else
4003
            {
4004
                DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4005
            }
4006
        }
4007

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

    
4024
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4025
        {
4026
            UpdateMyMarkupList();
4027

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

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

    
4051
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4052
                if (item2 != null)
4053
                {
4054
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4055

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

    
4066
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4067
        {
4068
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4069

    
4070
            if (App.ViewInfo != null)
4071
            {
4072
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4073
                {
4074
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4075
                }
4076
            }
4077
        }
4078

    
4079
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4080
        {
4081
            if (CompareMode.IsChecked)
4082
            {
4083
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4084
                {
4085
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4086
                }
4087
                if (ViewerDataModel.Instance.PageNumber == 0)
4088
                {
4089
                    ViewerDataModel.Instance.PageNumber = 1;
4090
                }
4091

    
4092
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4093
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4094
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4095

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

    
4109
        private void Sync_Click(object sender, RoutedEventArgs e)
4110
        {
4111
            if (Sync.IsChecked)
4112
            {
4113
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4114
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4115
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4116
            }
4117
        }
4118

    
4119
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4120
        {
4121
            if (UserList.IsChecked)
4122
            {
4123
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4124
            }
4125
            else
4126
            {
4127
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4128
            }
4129
        }
4130

    
4131
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4132
        {
4133

    
4134
            if (BalanceMode.IsChecked)
4135
            {
4136
                ViewerDataModel.Instance.PageBalanceMode = true;
4137
            }
4138
            else
4139
            {
4140
                ViewerDataModel.Instance.PageBalanceMode = false;
4141
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4142
            }
4143
        }
4144

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

    
4158
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4159
        {
4160
            if ((sender as System.Windows.Controls.Control).Tag != null)
4161
            {
4162
                //Compare 초기화
4163
                CompareMode.IsChecked = false;
4164
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4165

    
4166
                if (ViewerDataModel.Instance.PageNumber == 0)
4167
                {
4168
                    ViewerDataModel.Instance.PageNumber = 1;
4169
                }
4170

    
4171
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4172
                {
4173
                }
4174
                else
4175
                {
4176
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4177
                }
4178

    
4179
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4180
                {
4181

    
4182
                }
4183
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4184
                {
4185
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4186
                }
4187

    
4188
                if (!testPanel2.IsHidden)
4189
                {
4190
                    if (IsSyncPDFMode)
4191
                    {
4192
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4193
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4194

    
4195
                        if (pdfpath.IsDownloading)
4196
                        {
4197
                            pdfpath.DownloadCompleted += (ex, arg) =>
4198
                            {
4199
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4200
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4201
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4202
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4203
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4204
                            };
4205
                        }
4206
                        else
4207
                        {
4208
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4209
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4210
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4211

    
4212
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4213
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4214
                        }
4215

    
4216
                    }
4217
                    else
4218
                    {
4219
                        string uri = "";
4220

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

    
4230
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4231

    
4232
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4233
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4234
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4235

    
4236
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4237
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4238

    
4239
                        if (defaultBitmapImage_Compare.IsDownloading)
4240
                        {
4241
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4242
                            {
4243
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4244
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4245
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4246

    
4247
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4248
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4249
                            };
4250
                        }
4251
                    }
4252

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

    
4257
                    foreach (var item in gridSelectionRevItem)
4258
                    {
4259
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4260
                        {
4261
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4262
                        });
4263
                    }
4264

    
4265
                    //강인구 추가
4266
                    zoomAndPanControl2.ZoomTo(new Rect
4267
                    {
4268
                        X = 0,
4269
                        Y = 0,
4270
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4271
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4272
                    });
4273

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

    
4276
                }
4277
            }
4278
        }
4279

    
4280
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4281
        {
4282
            if (MarkupMode.IsChecked)
4283
            {
4284
                IsSyncPDFMode = true;
4285

    
4286
                var uri = CurrentRev.TO_VENDOR;
4287

    
4288
                if (ViewerDataModel.Instance.PageNumber == 0)
4289
                {
4290
                    ViewerDataModel.Instance.PageNumber = 1;
4291
                }
4292

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

    
4297
                if (pdfpath.IsDownloading)
4298
                {
4299
                    pdfpath.DownloadCompleted += (ex, arg) =>
4300
                    {
4301
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4302
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4303
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4304
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4305
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4306
                    };
4307
                }
4308
                else
4309
                {
4310
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4311
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4312
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4313

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

    
4331
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4332

    
4333
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4334
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4335
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4336

    
4337
                if (defaultBitmapImage_Compare.IsDownloading)
4338
                {
4339
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                }
4346
                zoomAndPanControl2.ApplyTemplate();
4347
                zoomAndPanControl2.UpdateLayout();
4348
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4349
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4350
            }
4351
        }
4352

    
4353
        private void RadButton_Click(object sender, RoutedEventArgs e)
4354
        {
4355
            gridViewHistory_Busy.IsBusy = true;
4356

    
4357
            RadButton instance = sender as RadButton;
4358
            if (instance.CommandParameter != null)
4359
            {
4360
                CurrentRev = instance.CommandParameter as VPRevision;
4361
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4362
                {
4363
                    if (ea.Error == null && ea.Result != null)
4364
                    {
4365
                        testPanel2.IsHidden = false;
4366

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

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

    
4393
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4394

    
4395
                        var defaultBitmapImage_Compare = new BitmapImage();
4396
                        defaultBitmapImage_Compare.BeginInit();
4397
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4398
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4399
                        defaultBitmapImage_Compare.EndInit();
4400

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

    
4422
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4423
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4424
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4425

    
4426
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4427
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4428
                        gridViewHistory_Busy.IsBusy = false;
4429
                    }
4430

    
4431
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4432
                };
4433
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4434
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4435
            }
4436
        }
4437

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

    
4461
        public void Sync_Event(VPRevision Currnet_Rev)
4462
        {
4463
            CurrentRev = Currnet_Rev;
4464

    
4465
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4466
            {
4467
                if (ea.Error == null && ea.Result != null)
4468
                {
4469
                    testPanel2.IsHidden = false;
4470

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

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

    
4497
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4498

    
4499
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4500

    
4501
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4502
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4503
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4504

    
4505
                    if (defaultBitmapImage_Compare.IsDownloading)
4506
                    {
4507
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                    }
4514

    
4515

    
4516
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4517
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4518
                    zoomAndPanControl2.ApplyTemplate();
4519
                    zoomAndPanControl2.UpdateLayout();
4520

    
4521
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4522
                    {
4523
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4524
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4525
                    }
4526
                    //}
4527

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

    
4534
            };
4535
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4536
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4537
        }
4538

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

    
4555
        private void Create_Symbol(object sender, RoutedEventArgs e)
4556
        {
4557
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4558

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

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

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

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

    
4632
                            if (symbolsvg == true)
4633
                            {
4634
                                try
4635
                                {
4636
                                    var defaultBitmapImage = new BitmapImage();
4637
                                    defaultBitmapImage.BeginInit();
4638
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4639
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4640
                                    Check_Uri.UriCheck(filename);
4641
                                    defaultBitmapImage.UriSource = new Uri(filename);
4642
                                    defaultBitmapImage.EndInit();
4643

    
4644
                                    System.Drawing.Bitmap image;
4645

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

    
4668
                                            StringBuilder svgBuilder = new StringBuilder();
4669
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4670
                                            {
4671
                                                svgBuilder.AppendLine(e2.Data);
4672
                                            };
4673

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

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

    
4715
        public void SymbolSave(string Name, string Url, string Data)
4716
        {
4717
            try
4718
            {
4719
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4720
                {
4721
                    ID = Commons.shortGuid(),
4722
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4723
                    NAME = Name,
4724
                    IMAGE_URL = Url,
4725
                    DATA = Data
4726
                };
4727

    
4728
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4729
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4730
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4731
            }
4732
            catch (Exception)
4733
            {
4734
                throw;
4735
            }
4736
        }
4737

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

    
4760
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4761
        {           
4762
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4763
            DataBind();
4764
        }
4765

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

    
4792
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4793

    
4794
                List<SYMBOL_PUBLIC> symbol_Public;
4795

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

    
4831
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4832
                        _Encoder.Save(fs);
4833
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4834

    
4835
                        byte[] Img_byte = fs.ToArray();
4836

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

    
4858
        public PngBitmapEncoder symImage(string data)
4859
        {
4860

    
4861
            Canvas _canvas = new Canvas();
4862
            _canvas.Background = Brushes.White;
4863
            _canvas.Width = adorner_.BorderSize.Width;
4864
            _canvas.Height = adorner_.BorderSize.Height;
4865
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4866

    
4867
            BitmapEncoder encoder = new PngBitmapEncoder();
4868

    
4869

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

    
4872
            DrawingVisual dv = new DrawingVisual();
4873

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

    
4877
            using (DrawingContext ctx = dv.RenderOpen())
4878
            {
4879
                VisualBrush vb = new VisualBrush(_canvas);
4880
                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)));
4881
            }
4882

    
4883
            try
4884
            {
4885
                renderBitmap.Render(dv);
4886

    
4887
                //GC.Collect();
4888
                GC.WaitForPendingFinalizers();
4889
                //GC.Collect();
4890
                // encode png data
4891
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4892
                // puch rendered bitmap into it
4893
                pngEncoder.Interlace = PngInterlaceOption.Off;
4894
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4895
                return pngEncoder;
4896

    
4897
            }
4898
            catch //(Exception ex)
4899
            {
4900
                return null;
4901
            }
4902

    
4903
        }
4904

    
4905
        public void DialogMessage_Alert(string content, string header)
4906
        {
4907
            DialogParameters parameters = new DialogParameters()
4908
            {
4909
                Owner = Application.Current.MainWindow,
4910
                Content = new TextBlock()
4911
                { 
4912
                    MinWidth = 400,
4913
                    FontSize = 11,
4914
                    Text = content,
4915
                    TextWrapping = System.Windows.TextWrapping.Wrap
4916
                },
4917
                Header = header,
4918
                Theme = new VisualStudio2013Theme(),
4919
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4920
            };            
4921
            RadWindow.Alert(parameters);
4922
        }
4923

    
4924
        #region 캡쳐 기능
4925

    
4926
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4927
        {
4928
            if (x < 0)
4929
            {
4930
                width += x;
4931
                x = 0;
4932
            }
4933
            if (y < 0)
4934
            {
4935
                height += y;
4936
                y = 0;
4937

    
4938
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4939
            }
4940
            if (x + width > zoomAndPanCanvas.ActualWidth)
4941
            {
4942
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4943
            }
4944
            if (y + height > zoomAndPanCanvas.ActualHeight)
4945
            {
4946
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4947
            }
4948

    
4949
            byte[] pixels = CopyPixels(x, y, width, height);
4950

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

    
4953
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4954
        }
4955

    
4956
        public byte[] CopyPixels(int x, int y, int width, int height)
4957
        {
4958
            byte[] pixels = new byte[width * height * 4];
4959
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4960

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

    
4964
            return pixels;
4965
        }
4966

    
4967
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4968
        {
4969
            DrawingVisual drawingVisual = new DrawingVisual();
4970
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4971

    
4972
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4973
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4974
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4975
            drawingContext.Close();
4976

    
4977
            // 비트맵으로 변환합니다.
4978
            RenderTargetBitmap target =
4979
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4980
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4981

    
4982
            target.Render(drawingVisual);
4983
            return target;
4984
        }
4985

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

    
4998
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4999
        {
5000
            System.Drawing.Bitmap image = GetBitmap(source);
5001
            //흰색 제거
5002
            //image.MakeTransparent(System.Drawing.Color.White);
5003

    
5004
            var imageStream = new System.IO.MemoryStream();
5005
            byte[] imageBytes = null;
5006
            using (imageStream)
5007
            {
5008
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5009
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5010
                imageStream.Position = 0;
5011
                imageBytes = imageStream.ToArray();
5012
            }
5013

    
5014
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5015

    
5016
            RadWindow CheckPop = new RadWindow();
5017
            //Alert check = new Alert(Msg);
5018

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

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

    
5050
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5051
        {
5052
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5053
            KCOMDataModel.DataModel.CHECK_LIST check_;
5054
            string Result = streamToBase64.ImageToBase64(source);
5055
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5056
            string projectno = App.ViewInfo.ProjectNO;
5057
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5058

    
5059
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5060
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5061
            if (Item != null)
5062
            {
5063
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5064
            }
5065
            else
5066
            {
5067
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5068
            }
5069

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

    
5102
        }
5103

    
5104
        public void Set_Capture()
5105
        {
5106
            double x = canvasDrawingMouseDownPoint.X;
5107
            double y = canvasDrawingMouseDownPoint.Y;
5108
            double width = dragCaptureBorder.Width;
5109
            double height = dragCaptureBorder.Height;
5110

    
5111
            if (width > 5 || height > 5)
5112
            {
5113
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5114
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5115
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5116
            }
5117
        }
5118
        #endregion
5119

    
5120
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5121
        {
5122
            multi_Undo_Data = new Multi_Undo_data();
5123

    
5124
            multi_Undo_Data.Markup = control;
5125

    
5126
            if ((control as IShapeControl) != null)
5127
            {
5128
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5129
            }
5130
            if ((control as IDashControl) != null)
5131
            {
5132
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5133
            }
5134
            if ((control as IPath) != null)
5135
            {
5136
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5137
            }
5138
            if ((control as UIElement) != null)
5139
            {
5140
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5141
            }
5142

    
5143
            return multi_Undo_Data;
5144
        }
5145

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

    
5165
        /// <summary>
5166
        /// convert inkcontrol to polygoncontrol
5167
        /// </summary>
5168
        public void ConvertInkControlToPolygon()
5169
        {
5170
            if (inkBoard.Strokes.Count > 0)
5171
            {
5172
                inkBoard.Strokes.ToList().ForEach(stroke =>
5173
                {
5174
                    InkToPath ip = new InkToPath();
5175

    
5176
                    List<Point> inkPointSet = new List<Point>();
5177
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5178

    
5179
                    PolygonControl pc = new PolygonControl()
5180
                    {
5181
                        Angle = 0,
5182
                        PointSet = inkPointSet,
5183
                        ControlType = ControlType.Ink
5184
                    };
5185
                    pc.StartPoint = inkPointSet[0];
5186
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5187
                    pc.LineSize = 3;
5188
                    pc.CommentID = Commons.shortGuid();
5189
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5190

    
5191
                    if (pc.PointSet.Count > 0)
5192
                    {
5193
                        CreateCommand.Instance.Execute(pc);
5194
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5195
                    }
5196
                });
5197
                inkBoard.Strokes.Clear();
5198
            }
5199
        }
5200

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

    
5217
            return false;
5218
        }
5219

    
5220
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5221
        {
5222
            e.Effects = DragDropEffects.Copy;
5223
        }
5224

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

    
5230
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5231
        {
5232
            e.Effects = DragDropEffects.None;
5233
        }
5234

    
5235
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5236
        {
5237
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5238
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5239

    
5240
            ScaleImage(pageWidth, pageHeight);
5241
        }
5242

    
5243
        /// <summary>
5244
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5245
        /// </summary>
5246
        /// <param name="pageWidth">원본 사이즈</param>
5247
        /// <param name="pageHeight">원본 사이즈</param>
5248
        /// <returns></returns>
5249
        private void ScaleImage(double pageWidth,double pageHeight)
5250
        {
5251
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5252
        }
5253

    
5254
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5255
        {
5256
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5257
        }
5258

    
5259

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