프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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
            try
561
            {
562
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
563
                ScaleImage(pageWidth, pageHeight);
564

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

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

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

    
574
                inkBoard.Width = pageWidth;
575
                inkBoard.Height = pageHeight;
576
            }
577
            catch (Exception)
578
            {
579
                throw;
580
            }
581
            
582

    
583
            #endregion
584

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

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

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

    
631
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
632
                    var defaultBitmapImage_Compare = new BitmapImage();
633
                    defaultBitmapImage_Compare.BeginInit();
634
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
635
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
636
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
637
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
638
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
639
                    defaultBitmapImage_Compare.EndInit();
640

    
641
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
642

    
643
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
644
                    zoomAndPanControl.ZoomTo(new Rect
645
                    {
646
                        X = 0,
647
                        Y = 0,
648
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
649
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
650
                    });
651

    
652
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
653
                    if (defaultBitmapImage_Compare.IsDownloading)
654
                    {
655
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
656
                        {
657
                            defaultBitmapImage_Compare.Freeze();
658
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
659
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
660
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
661
                            ComparePanel.UpdateLayout();
662
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
663
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
664

    
665
                            zoomAndPanControl.ZoomTo(new Rect
666
                            {
667
                                X = 0,
668
                                Y = 0,
669
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
670
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
671
                            });
672

    
673
                            //defaultBitmapImage_Compare dispose
674
                            defaultBitmapImage_Compare = null;
675
                            GC.Collect();
676
                        };
677
                    }
678
                }
679
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
680
            }
681

    
682
            this.pageNavigator.ChangePage(e.PageNumber);
683
        }
684

    
685
        /// <summary>
686
        /// called after page is changed
687
        /// </summary>
688
        /// <param name="sender"></param>
689
        /// <param name="e"></param>
690
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
691
        {
692
            if (zoomAndPanCanvas2.Width.IsNaN())
693
            {
694
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
695
            }
696

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

    
722
            /// fire selection event
723
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
724
            this.gridViewMarkup.UnselectAll();
725
            this.gridViewMarkup.Select(gridSelectionItem);
726

    
727
            if (!testPanel2.IsHidden)
728
            {
729
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
730
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
731
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
732

    
733
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
734
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
735

    
736

    
737
                foreach (var item in gridSelectionRevItem)
738
                {
739
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
740
                    {
741
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
742
                    });
743
                }
744
            }
745

    
746
            var instanceMain = this.ParentOfType<MainWindow>();
747
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
748
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
749

    
750
            instanceMain.dzTopMenu.rotateOffSet = 0;
751
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
752
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
753

    
754
            SetCommentPages(true);
755
        }
756

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

    
787
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
788
        {
789
            if (e.MiddleButton == MouseButtonState.Pressed)
790
            {
791

    
792
            }
793
            e.Handled = true;
794
            if (e.Delta > 0)
795
            {
796
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
797
                ZoomIn(currentContentMousePoint);
798
            }
799
            else
800
            {
801
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
802
                ZoomOut(currentContentMousePoint);
803
            }
804
        }
805

    
806
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
807
        {
808
            e.Handled = true;
809
            if (e.Delta > 0)
810
            {
811
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
812
                ZoomIn_Sync(currentContentMousePoint);
813
            }
814
            else
815
            {
816
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
817
                ZoomOut_Sync(currentContentMousePoint);
818
            }
819
        }
820

    
821
        #region ZoomIn & ZoomOut
822

    
823
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
824
        {
825
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
826
                zoomAndPanControl.ContentZoomFocusY));
827
        }
828

    
829
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
830
        {
831
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
832
                zoomAndPanControl.ContentZoomFocusY));
833
        }
834

    
835

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

    
849
            if (zoomAndPanControl2 != null && Sync.IsChecked)
850
            {
851
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
852
            }
853
        }
854

    
855
        private void ZoomIn(Point contentZoomCenter)
856
        {
857
            if (zoomAndPanControl.ContentScale > 0.19)
858
            {
859
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
860
            }
861
            else
862
            {
863
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
864
            }
865

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

    
871
        }
872

    
873
        private void ZoomOut_Sync(Point contentZoomCenter)
874
        {
875
            if (zoomAndPanControl2.ContentScale > 0.39)
876
            {
877
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
878
            }
879
            else
880
            {
881
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
882
            }
883

    
884
            if (Sync.IsChecked)
885
            {
886
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
887
            }
888
        }
889

    
890
        private void ZoomIn_Sync(Point contentZoomCenter)
891
        {
892
            if (zoomAndPanControl2.ContentScale > 0.19)
893
            {
894
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
895
            }
896
            else
897
            {
898
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
899
            }
900

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

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

    
916
        private void ZoomIn()
917
        {
918
            zoomAndPanControl.ContentScale += 0.1;
919
            //if (zoomAndPanControl2 != null)
920
            //{
921
            //    zoomAndPanControl2.ContentScale += 0.1;
922
            //}
923
        }
924

    
925
        #endregion
926

    
927
        private void init()
928
        {
929
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
930
            {
931

    
932
                ControlList.Clear();
933
                listBox.Items.Clear();
934
                selected_item.Clear();
935

    
936
                (item as IMarkupCommonData).IsSelected = false;
937
            }
938

    
939
        }
940

    
941
        private HitTestResultBehavior MyCallback(HitTestResult result)
942
        {
943
            //this.cursor = Cursors.UpArrow;
944
            var element = result.VisualHit;
945
            while (element != null && !(element is CommentUserInfo))
946
                element = VisualTreeHelper.GetParent(element);
947

    
948
            if (element == null)
949
            {
950
                return HitTestResultBehavior.Stop;
951
            }
952
            else
953
            {
954
                if (element is CommentUserInfo)
955
                {
956
                    if (!hitList.Contains(element))
957
                    {
958
                        hitList.Add((CommentUserInfo)element);
959
                    }
960
                    else
961
                    {
962
                        return HitTestResultBehavior.Stop;
963
                    }
964
                }
965
            }
966
            return HitTestResultBehavior.Continue;
967
        }
968

    
969
        public void ReleaseSelectPath()
970
        {
971
            if (SelectionPath == null)
972
            {
973
                SelectionPath = new Path();
974
                SelectionPath.Name = "";
975
            }
976
            if (SelectionPath.Name != "")
977
            {
978
                SelectionPath.Name = "None";
979
            }
980
            SelectionPath.Opacity = 0.01;
981
            SelectionPath.RenderTransform = null;
982
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
983
        }
984

    
985
        #region 컨트롤 초기화 
986
        public void Control_Init(object control)
987
        {
988
            if (L_Size != 0 && (control as IPath) != null)
989
            {
990
                (control as IPath).LineSize = L_Size;
991
                L_Size = 0;
992
            }
993

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

    
1080
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1081
        {
1082
            //Control_Init(e.Source);
1083
        }
1084
        //private Window _dragdropWindow = null;
1085

    
1086
        [DllImport("user32.dll")]
1087
        [return: MarshalAs(UnmanagedType.Bool)]
1088
        internal static extern bool GetCursorPos(ref Win32Point pt);
1089

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

    
1107

    
1108
               if (this._dragdropWindow != null)
1109
               {
1110
                   this._dragdropWindow.Close();
1111
                   this._dragdropWindow = null;
1112
               }
1113

    
1114
               symbol_id = id;
1115
               symbol_group_id = group_id;
1116
               symbol_SelectedIndex = SelectedIndex;
1117
               symbol_Data = Data_;
1118
               symbol_img = img;
1119

    
1120

    
1121
               CreateDragDropWindow2(img);
1122
              
1123
    }
1124

    
1125
    private void CreateDragDropWindow2(ImageSource image)
1126
        {
1127
            this._dragdropWindow = new Window();
1128
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1129
            _dragdropWindow.WindowStyle = WindowStyle.None;
1130
            _dragdropWindow.AllowsTransparency = true;           
1131
            _dragdropWindow.AllowDrop = false;
1132
            _dragdropWindow.Background = null;
1133
            _dragdropWindow.IsHitTestVisible = false;
1134
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1135
            _dragdropWindow.Topmost = true;
1136
            _dragdropWindow.ShowInTaskbar = false;
1137
            
1138
            Rectangle r = new Rectangle();
1139
            r.Width = image.Width;
1140
            r.Height = image.Height;
1141
            r.Opacity = 0.5;            
1142
            r.Fill = new ImageBrush(image);
1143
            this._dragdropWindow.Content = r;
1144

    
1145
            Win32Point w32Mouse = new Win32Point();
1146
            GetCursorPos(ref w32Mouse);
1147

    
1148
            //w32Mouse.X = getCurrentPoint.X;
1149
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1150
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1151
            this._dragdropWindow.Show();
1152
        }
1153
         */
1154
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1155
        {
1156
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1157
            {
1158
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1159

    
1160
                Point currentPos = e.GetPosition(rect);
1161

    
1162
                floatingTip.HorizontalOffset = currentPos.X + 20;
1163
                floatingTip.VerticalOffset = currentPos.Y;
1164
            }
1165

    
1166
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1167
            
1168
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1169
            {
1170
                SetCursor();
1171
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1172
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1173

    
1174
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1175
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1176
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1177

    
1178
                if (Sync.IsChecked)
1179
                {
1180
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1181
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1182
                }
1183
            }
1184

    
1185
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1186
            {
1187
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1188
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1189
                SetCursor();
1190

    
1191
                if (currentControl != null)
1192
                {
1193
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1194
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1195
                    //강인구 추가
1196
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1197

    
1198
                    if ((currentControl as IPath) != null)
1199
                    {
1200
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1201
                    }
1202
                    if ((currentControl as LineControl) != null)
1203
                    {
1204
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1205
                    }
1206

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

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

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

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

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

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

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

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

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

    
1403
                        case ControlType.Date:
1404
                            {
1405
                                var control = currentControl as DateControl;
1406
                                if (control != null)
1407
                                {
1408
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1409
                                }
1410
                            }
1411
                            break;
1412

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

    
1522
                                //inkBoard.Strokes.Add(stroke);
1523
                            }
1524
                            break;
1525
                    }
1526
                    return;
1527
                }
1528
            }
1529
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1530
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1531
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1532
            {
1533
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1534

    
1535
                if (isDraggingSelectionRect)
1536
                {
1537
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1538
                    e.Handled = true;
1539
                }
1540
                else if (isLeftMouseButtonDownOnWindow)
1541
                {
1542
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1543
                    double dragDistance = Math.Abs(dragDelta.Length);
1544

    
1545
                    if (dragDistance > DragThreshold)
1546
                    {
1547
                        isDraggingSelectionRect = true;
1548
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1549
                    }
1550

    
1551
                    e.Handled = true;
1552
                }
1553

    
1554
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1555
                {
1556
                }
1557
                else
1558
                {
1559
                    e.Handled = true;
1560
                }
1561
            }
1562
            /*
1563
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1564
            { //symbol      
1565
                if(_dragdropWindow != null)
1566
                {
1567
                    Win32Point w32Mouse = new Win32Point();
1568
                    GetCursorPos(ref w32Mouse);
1569

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

    
1595
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1596
        {
1597
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1598
            {
1599
                SetCursor();
1600
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1601
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1602

    
1603
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1604

    
1605
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1606
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1607

    
1608
                if (Sync.IsChecked)
1609
                {
1610
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1611
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1612
                }
1613
            }
1614
        }
1615

    
1616
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1617

    
1618
        private EllipseGeometry hitArea = new EllipseGeometry();
1619

    
1620
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1621
        {
1622
            IsDrawing = false;
1623

    
1624
            if (mouseHandlingMode != MouseHandlingMode.None)
1625
            {
1626
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1627
                {
1628
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1629

    
1630
                    SetCursor();
1631

    
1632
                    switch (controlType)
1633
                    {
1634
                        case ControlType.None:
1635
                            break;
1636
                        case ControlType.Rectangle:
1637
                            {
1638

    
1639
                            }
1640
                            break;
1641
                        case ControlType.PenControl:
1642
                            {
1643

    
1644
                            }
1645
                            break;
1646
                        default:
1647
                            break;
1648
                    }                    
1649
                }
1650
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1651
                {
1652
                    if (isLeftMouseButtonDownOnWindow)
1653
                    {
1654
                        bool wasDragSelectionApplied = false;
1655

    
1656
                        if (isDraggingSelectionRect)
1657
                        {
1658
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1659
                            {
1660
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1661
                                mouseHandlingMode = MouseHandlingMode.None;
1662
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1663
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1664
                                Set_Symbol_Capture(endPoint);
1665
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1666
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1667
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1668
                            }
1669
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1670
                            {
1671
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1672
                                mouseHandlingMode = MouseHandlingMode.None;
1673
                                Set_Capture();
1674

    
1675
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1676
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1677
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1678
                            }
1679
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1680
                            {
1681
                                ApplyDragSelectionRect();
1682
                            }
1683
                            else
1684
                            {
1685
                                double x = Canvas.GetLeft(dragZoomBorder);
1686
                                double y = Canvas.GetTop(dragZoomBorder);
1687
                                double width = dragZoomBorder.Width;
1688
                                double height = dragZoomBorder.Height;
1689
                                Rect dragRect = new Rect(x, y, width, height);
1690

    
1691
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1692

    
1693
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1694
                            }
1695

    
1696
                            isDraggingSelectionRect = false;
1697
                            e.Handled = true;
1698
                            wasDragSelectionApplied = true;
1699
                        }
1700

    
1701
                        if (isLeftMouseButtonDownOnWindow)
1702
                        {
1703
                            isLeftMouseButtonDownOnWindow = false;
1704
                            this.ReleaseMouseCapture();
1705
                            e.Handled = true;
1706
                        }
1707

    
1708
                        if (!wasDragSelectionApplied)
1709
                        {
1710
                            init();
1711
                        }
1712
                    }
1713
                }
1714
                else if (e.RightButton == MouseButtonState.Pressed)
1715
                {
1716
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1717
                    SetCursor();
1718
                }
1719

    
1720
                zoomAndPanControl.ReleaseMouseCapture();
1721

    
1722

    
1723
                e.Handled = true;
1724
            }
1725
            else
1726
            {
1727
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1728
                SetCursor();
1729
            }
1730

    
1731
            ///mouseButtonDown = MouseButton.Left;
1732
            //controlType = ControlType.SingleLine;
1733
        }
1734

    
1735
        public void Set_Symbol_Capture(Point endPoint)
1736
        {       
1737
            double x = canvasDrawingMouseDownPoint.X;
1738
            double y = canvasDrawingMouseDownPoint.Y;
1739
            if(x > endPoint.X)
1740
            {
1741
                x = endPoint.X;
1742
                y = endPoint.Y;
1743
            }
1744

    
1745
            double width = dragCaptureBorder.Width;
1746
            double height = dragCaptureBorder.Height;
1747

    
1748
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1749

    
1750
            if (x < 0)
1751
            {
1752
                width += x;
1753
                x = 0;
1754
            }
1755
            if (y < 0)
1756
            {
1757
                height += y;
1758
                y = 0;
1759

    
1760
                width = (int)canvasImage.PixelWidth - x;
1761
            }
1762
            if (x + width > canvasImage.PixelWidth)
1763
            {
1764
                width = (int)canvasImage.PixelWidth - x;
1765
            }
1766
            if (y + height > canvasImage.PixelHeight)
1767
            {
1768
                height = (int)canvasImage.PixelHeight - y;
1769
            }
1770
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1771

    
1772
            string uri = "";
1773
            if (userData.COMPANY != "EXT")
1774
            {
1775
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1776
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1777
            }
1778
            else
1779
            {
1780
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1781
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1782
            }
1783

    
1784
            var defaultBitmapImage = new BitmapImage();
1785
            defaultBitmapImage.BeginInit();
1786
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1787
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1788
            defaultBitmapImage.UriSource = new Uri(uri);
1789
            defaultBitmapImage.EndInit();
1790

    
1791
            //GC.Collect();
1792

    
1793
            if (defaultBitmapImage.IsDownloading)
1794
            {
1795
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1796
                {
1797
                    defaultBitmapImage.Freeze();
1798
                    //GC.Collect();
1799
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1800
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1801
                };
1802
            }
1803
        }
1804

    
1805
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1806
        {
1807
            ///mouseButtonDown = MouseButton.Left;
1808
        }
1809

    
1810
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1811
        {
1812
            ///mouseButtonDown = MouseButton.Left;
1813
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1814
        }
1815

    
1816
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1817
        {
1818

    
1819
        }
1820

    
1821
        /// <summary>
1822
        /// select items by dragging
1823
        /// </summary>
1824
        private void ApplyDragSelectionRect()
1825
        {
1826
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1827

    
1828
            double x = Canvas.GetLeft(dragSelectionBorder);
1829
            double y = Canvas.GetTop(dragSelectionBorder);
1830
            double width = dragSelectionBorder.Width;
1831
            double height = dragSelectionBorder.Height;
1832
            Boolean Flag = false;
1833
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1834
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1835

    
1836
            Rect dragRect = new Rect(x, y, width, height);
1837
            ///dragRect.Inflate(width / 10, height / 10);
1838

    
1839
            foreach (var item in Items)
1840
            {
1841
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1842

    
1843
                if (Flag)
1844
                {
1845
                    adornerSet.Add(item);
1846
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1847
                    Control_Style(item);
1848
                }
1849
            }
1850
            if (adornerSet.Count > 0)
1851
            {
1852
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1853
                SelectLayer.Children.Add(final);
1854
            }
1855
        }
1856

    
1857
        private void InitDragSelectionRect(Point pt1, Point pt2)
1858
        {
1859
            //캡쳐 중
1860
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1861
            {
1862
                dragCaptureBorder.Visibility = Visibility.Visible;
1863
            }
1864
            //선택 중
1865
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1866
            {
1867

    
1868
                dragSelectionBorder.Visibility = Visibility.Visible;
1869
            }
1870
            else
1871
            {
1872
                dragZoomBorder.Visibility = Visibility.Visible;
1873
            }
1874
            UpdateDragSelectionRect(pt1, pt2);
1875
        }
1876

    
1877
        /// <summary>
1878
        /// Update the position and size of the rectangle used for drag selection.
1879
        /// </summary>
1880
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1881
        {
1882
            double x, y, width, height;
1883

    
1884
            //
1885
            // Determine x,y,width and height of the rect inverting the points if necessary.
1886
            // 
1887

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

    
1899
            if (pt2.Y < pt1.Y)
1900
            {
1901
                y = pt2.Y;
1902
                height = pt1.Y - pt2.Y;
1903
            }
1904
            else
1905
            {
1906
                y = pt1.Y;
1907
                height = pt2.Y - pt1.Y;
1908
            }
1909

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

    
1938
        private void drawingPannelRotate(double angle)
1939
        {
1940
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1941
            rotate.Angle = angle;
1942
            var rotationNum = Math.Abs((rotate.Angle / 90));
1943

    
1944
            if (angle == 90 || angle == 270)
1945
            {
1946
                double emptySize = zoomAndPanCanvas.Width;
1947
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1948
                zoomAndPanCanvas.Height = emptySize;
1949
            }
1950
            if (angle == 0)
1951
            {
1952
                translate.X = 0;
1953
                translate.Y = 0;
1954
            }
1955
            else if (angle == 90)
1956
            {
1957
                translate.X = zoomAndPanCanvas.Width;
1958
                translate.Y = 0;
1959
            }
1960
            else if (angle == 180)
1961
            {
1962
                translate.X = zoomAndPanCanvas.Width;
1963
                translate.Y = zoomAndPanCanvas.Height;
1964
            }
1965
            else
1966
            {
1967
                translate.X = 0;
1968
                translate.Y = zoomAndPanCanvas.Height;
1969
            }
1970

    
1971
            zoomAndPanControl.RotationAngle = rotate.Angle;
1972

    
1973

    
1974
            if (!testPanel2.IsHidden)
1975
            {
1976
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1977
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1978
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1979
            }
1980

    
1981
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1982
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1983
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1984
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1985
            ViewerDataModel.Instance.Angle = rotate.Angle;
1986
        }
1987

    
1988
        private void syncPannelRotate(double angle)
1989
        {
1990
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1991
            rotate.Angle = angle;
1992
            var rotationNum = Math.Abs((rotate.Angle / 90));
1993

    
1994
            if (angle == 90 || angle == 270)
1995
            {
1996
                double emptySize = zoomAndPanCanvas2.Width;
1997
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
1998
                zoomAndPanCanvas2.Height = emptySize;
1999
            }
2000
            if (angle == 0)
2001
            {
2002
                translate2.X = 0;
2003
                translate2.Y = 0;
2004
            }
2005
            else if (angle == 90)
2006
            {
2007
                translate2.X = zoomAndPanCanvas2.Width;
2008
                translate2.Y = 0;
2009
            }
2010
            else if (angle == 180)
2011
            {
2012
                translate2.X = zoomAndPanCanvas2.Width;
2013
                translate2.Y = zoomAndPanCanvas2.Height;
2014
            }
2015
            else
2016
            {
2017
                translate2.X = 0;
2018
                translate2.Y = zoomAndPanCanvas2.Height;
2019
            }
2020

    
2021
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2022
        }
2023

    
2024
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2025
        {
2026
            string Data_ = "";
2027

    
2028
            try
2029
            {
2030
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2031
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2032
                if (Data_ != null || Data_ != "")
2033
                {
2034
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2035
                }
2036
                else
2037
                {
2038
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2039
                }
2040

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

    
2067
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2068
                    {
2069
                        PointSet = new List<Point>(),
2070
                        FilePath = Data_,
2071
                        ImageData = img.Source,
2072
                        StartPoint = canvasZoomPanningMouseDownPoint,
2073
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2074
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2075
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2076
                        canvasZoomPanningMouseDownPoint.Y),
2077
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2078
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2079
                    };
2080

    
2081
                    currentControl.PointSet = new List<Point>
2082
                                        {
2083
                                            currentControl.StartPoint,
2084
                                            currentControl.LeftBottomPoint,
2085
                                            currentControl.EndPoint,
2086
                                            currentControl.TopRightPoint,
2087
                                        };
2088
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2089
                    UndoData = new Undo_data()
2090
                    {
2091
                        IsUndo = false,
2092
                        Event = Event_Type.Create,
2093
                        EventTime = DateTime.Now,
2094
                        Markup_List = new List<Multi_Undo_data>()
2095
                    };
2096
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2097
                    {
2098
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2099
                    });
2100

    
2101
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2102
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2103
                    UndoData.Markup_List.Add(multi_Undo_Data);
2104
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2105

    
2106
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2107
                    currentControl.CommentID = Commons.shortGuid();
2108
                    currentControl.SymbolID = id;
2109
                    currentControl.GroupID = group_id;
2110
                    currentControl.ApplyTemplate();
2111
                    currentControl.SetImage();
2112

    
2113
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2114
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2115
                    SelectLayer.Children.Add(final);
2116
                }
2117
            }
2118
            catch (Exception ex)
2119
            {
2120
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2121
            }
2122
        }
2123

    
2124
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2125
        {            
2126
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2127
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2128
            {
2129
                set_option.Value = double.Parse(set_option.ContentText);
2130
                //set_option.Focusable = false;
2131
                zoomAndPanControl.Focus();
2132
            }
2133

    
2134
            ConvertInkControlToPolygon();
2135

    
2136
            ///TODO:
2137
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2138
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2139

    
2140
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2141
            {
2142
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2143
            }
2144
            /// up to here
2145

    
2146
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2147
            {
2148
                if (item as ArrowTextControl != null)
2149
                {
2150
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2151
                }
2152
                else if (item as TextControl != null)
2153
                {
2154
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2155
                }
2156
            }
2157

    
2158
            //if (currentControl != null)
2159
            {
2160
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2161
                if (text_item_ != null)
2162
                {
2163
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2164
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2165
                    (text_item_ as TextControl).IsEditingMode = false;                    
2166
                    currentControl = null;
2167
                }
2168

    
2169
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2170
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2171
                {
2172
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2173
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2174
                    currentControl = null;
2175
                }
2176
            }
2177

    
2178
            double Ang = 0;                                          
2179
            if (rotate.Angle != 0)
2180
            {
2181
                Ang = 360 - rotate.Angle;
2182
            }
2183

    
2184
            if (e.OriginalSource is System.Windows.Controls.Image)
2185
            {
2186
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2187
            }
2188
            /*
2189
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2190
            {                
2191
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2192
                if(symbol_id != null)
2193
                {
2194
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2195
                }                
2196
            }
2197

    
2198
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2199
            {
2200
                if (this._dragdropWindow != null)
2201
                {
2202
                    this._dragdropWindow.Close();
2203
                    this._dragdropWindow = null;
2204
                    symbol_id = null;
2205
                }
2206
            }
2207
            */
2208

    
2209
            if (e.LeftButton == MouseButtonState.Pressed)
2210
            {
2211
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2212
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2213

    
2214
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2215
                SetCursor();
2216

    
2217
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2218
            }
2219

    
2220
            if (e.MiddleButton == MouseButtonState.Pressed)
2221
            {
2222
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2223
                cursor = Cursors.SizeAll;
2224
                SetCursor();
2225
            }
2226
            if (e.RightButton == MouseButtonState.Pressed)
2227
            {
2228
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2229
                cursor = Cursors.SizeAll;
2230
                SetCursor();
2231
            }
2232
            else if (e.XButton1 == MouseButtonState.Pressed)
2233
            {
2234
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2235
                {
2236
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2237
                }
2238

    
2239
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2240

    
2241
            }
2242
            else if (e.XButton2 == MouseButtonState.Pressed)
2243
            {
2244
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2245
                {
2246
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2247
                }
2248
            }
2249

    
2250
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2251
            {
2252
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2253
                {
2254
                    if (SelectLayer.Children.Count == 0)
2255
                    {
2256
                        isLeftMouseButtonDownOnWindow = true;
2257
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2258
                    }
2259

    
2260
                    if (controlType == ControlType.None)
2261
                    {
2262
                        isLeftMouseButtonDownOnWindow = true;
2263
                    }
2264
                }
2265

    
2266
                /// 캡쳐 모드 설정
2267
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2268
                {
2269
                    dragCaptureBorder.Visibility = Visibility.Visible;
2270
                    isLeftMouseButtonDownOnWindow = true;
2271
                }
2272

    
2273
                /// 줌 모드 설정
2274
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2275
                {
2276
                    isLeftMouseButtonDownOnWindow = true;
2277
                }
2278

    
2279
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2280
                if (control != null)
2281
                {
2282
                    AdornerFinal final = null;
2283

    
2284
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2285
                    {
2286
                        /// 기존 selection 해제
2287
                        SelectionSet.Instance.UnSelect(this);
2288

    
2289
                        final = new AdornerFinal(control);
2290

    
2291
                        this.Control_Style(control);
2292

    
2293
                        if ((control as IPath) != null)
2294
                        {
2295
                            if ((control as IPath).LineSize != 0)
2296
                            {
2297
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2298
                            }
2299
                        }
2300
                        if ((control as IShapeControl) != null)
2301
                        {
2302
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2303
                            {
2304
                                ViewerDataModel.Instance.checkHatchShape = true;
2305
                            }
2306
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2307
                            {
2308
                                ViewerDataModel.Instance.checkFillShape = true;
2309
                            }
2310
                            else
2311
                            {
2312
                                ViewerDataModel.Instance.checkHatchShape = false;
2313
                                ViewerDataModel.Instance.checkFillShape = false;
2314
                            }
2315
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2316
                        }
2317

    
2318
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2319

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

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

    
2401
                        Control_Style(control);
2402

    
2403
                        final = new AdornerFinal(comment);
2404
                    }
2405

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

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

    
2462
                                    CreateCommand.Instance.Execute(currentControl);
2463

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

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

    
2491
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2492

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

    
2510
                                    CreateCommand.Instance.Execute(currentControl);
2511

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

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

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

    
2545
                                    CreateCommand.Instance.Execute(currentControl);
2546

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

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

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

    
2580
                                    CreateCommand.Instance.Execute(currentControl);
2581

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

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

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

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

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

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

    
2651
                                    CreateCommand.Instance.Execute(currentControl);
2652

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

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

    
2686
                                    CreateCommand.Instance.Execute(currentControl);
2687

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

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

    
2726
                                        CreateCommand.Instance.Execute(currentControl);
2727

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

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

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

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

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

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

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

    
2813
                                    control.ApplyOverViewData();
2814

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

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

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

    
2858
                                    CreateCommand.Instance.Execute(currentControl);
2859

    
2860
                                    currentControl = null;
2861
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2862
                                    return;
2863
                                }
2864

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

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

    
2915
                                    CreateCommand.Instance.Execute(currentControl);
2916

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

    
2958
                                    CreateCommand.Instance.Execute(currentControl);
2959

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

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

    
3018
                                            CreateCommand.Instance.Execute(currentControl);
3019

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

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

    
3063
                                    CreateCommand.Instance.Execute(currentControl);
3064

    
3065
                                    control.isTransOn = true;
3066
                                    var firstPoint = control.PointSet.First();
3067

    
3068
                                    control.PointSet.Add(firstPoint);
3069
                                    control.DrawingCloud();
3070
                                    control.ApplyOverViewData();
3071

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

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

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

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

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

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

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

    
3184
                                        CreateCommand.Instance.Execute(currentControl);
3185
                                        currentControl = null;
3186

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

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

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

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

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

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

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

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

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

    
3323
                                    CreateCommand.Instance.Execute(currentControl);
3324

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

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

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

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

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

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

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

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

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

    
3437
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3438

    
3439
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3440

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

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

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

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

    
3489
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3490

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3771
                                        CreateCommand.Instance.Execute(currentControl);
3772
                                        currentControl = null;
3773
                                   
3774

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4034
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4035
        {
4036
            UpdateMyMarkupList();
4037

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

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

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

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

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

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

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

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

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

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

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

    
4141
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4142
        {
4143

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

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

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

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

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

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

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

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

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

    
4222
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4223
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4224
                        }
4225

    
4226
                    }
4227
                    else
4228
                    {
4229
                        string uri = "";
4230

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

    
4240
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4241

    
4242
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4243
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4244
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4245

    
4246
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4247
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4248

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

    
4257
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4258
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4259
                            };
4260
                        }
4261
                    }
4262

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

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

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

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

    
4286
                }
4287
            }
4288
        }
4289

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

    
4296
                var uri = CurrentRev.TO_VENDOR;
4297

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

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

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

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

    
4341
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4342

    
4343
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4344
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4345
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4346

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

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

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

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

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

    
4403
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4404

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

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

    
4432
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4433
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4434
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4435

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

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

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

    
4471
        public void Sync_Event(VPRevision Currnet_Rev)
4472
        {
4473
            CurrentRev = Currnet_Rev;
4474

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

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

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

    
4507
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4508

    
4509
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4510

    
4511
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4512
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4513
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4514

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

    
4525

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

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

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

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

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

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

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

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

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

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

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

    
4654
                                    System.Drawing.Bitmap image;
4655

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

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

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

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

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

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

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

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

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

    
4802
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4803

    
4804
                List<SYMBOL_PUBLIC> symbol_Public;
4805

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

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

    
4845
                        byte[] Img_byte = fs.ToArray();
4846

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

    
4868
        public PngBitmapEncoder symImage(string data)
4869
        {
4870

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

    
4877
            BitmapEncoder encoder = new PngBitmapEncoder();
4878

    
4879

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

    
4882
            DrawingVisual dv = new DrawingVisual();
4883

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

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

    
4893
            try
4894
            {
4895
                renderBitmap.Render(dv);
4896

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

    
4907
            }
4908
            catch //(Exception ex)
4909
            {
4910
                return null;
4911
            }
4912

    
4913
        }
4914

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

    
4934
        #region 캡쳐 기능
4935

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

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

    
4959
            byte[] pixels = CopyPixels(x, y, width, height);
4960

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

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

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

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

    
4974
            return pixels;
4975
        }
4976

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

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

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

    
4992
            target.Render(drawingVisual);
4993
            return target;
4994
        }
4995

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

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

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

    
5024
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5025

    
5026
            RadWindow CheckPop = new RadWindow();
5027
            //Alert check = new Alert(Msg);
5028

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

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

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

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

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

    
5112
        }
5113

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

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

    
5130
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5131
        {
5132
            multi_Undo_Data = new Multi_Undo_data();
5133

    
5134
            multi_Undo_Data.Markup = control;
5135

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

    
5153
            return multi_Undo_Data;
5154
        }
5155

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

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

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

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

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

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

    
5227
            return false;
5228
        }
5229

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

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

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

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

    
5250
            ScaleImage(pageWidth, pageHeight);
5251
        }
5252

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

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

    
5269

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