프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (253 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
                
564
            }
565
            catch (Exception ex)
566
            {
567
                ViewerDataModel.Instance.ImageViewPath = null;
568
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
569
                DialogMessage_Alert(imgfailedmsg, "Warning");
570
                App.FileLogger.Fatal(ex);
571
            }
572
            ScaleImage(pageWidth, pageHeight);
573

    
574
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
575
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
576

    
577
            zoomAndPanCanvas.Width = pageWidth;
578
            zoomAndPanCanvas.Height = pageHeight;
579

    
580
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
581
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
582

    
583
            inkBoard.Width = pageWidth;
584
            inkBoard.Height = pageHeight;
585

    
586
            #endregion
587

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

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

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

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

    
644
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
645

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

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

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

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

    
685
            this.pageNavigator.ChangePage(e.PageNumber);
686
        }
687

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

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

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

    
730
            if (!testPanel2.IsHidden)
731
            {
732
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
733
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
734
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
735

    
736
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
737
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
738

    
739

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

    
749
            var instanceMain = this.ParentOfType<MainWindow>();
750
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
751
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
752

    
753
            instanceMain.dzTopMenu.rotateOffSet = 0;
754
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
755
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
756
            
757
            SetCommentPages(true);
758
        }
759

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

    
791
        public void MarkupitemViewUpdate(string markupinfo_id)
792
        {
793
            //db에 업데이트 한 list 를 view 에 업데이트
794
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
795
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
796
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
797
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
798
            if (dbinfo.MarkupList.Count > 0)
799
            {
800
                if (viewinfo.MarkupList != null)
801
                {
802
                    viewinfo.MarkupList.Clear();
803
                    viewinfo.MarkupList = null;
804
                }
805
                viewinfo.MarkupList = new List<MarkupItem>();
806
                foreach (var item in dbinfo.MarkupList)
807
                {
808
                    viewinfo.MarkupList.Add(item);
809
                }
810
            }
811
        }
812

    
813
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
814
        {
815
            if (e.MiddleButton == MouseButtonState.Pressed)
816
            {
817

    
818
            }
819
            e.Handled = true;
820
            if (e.Delta > 0)
821
            {
822
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
823
                ZoomIn(currentContentMousePoint);
824
            }
825
            else
826
            {
827
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
828
                ZoomOut(currentContentMousePoint);
829
            }
830
        }
831

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

    
847
        #region ZoomIn & ZoomOut
848

    
849
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
850
        {
851
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
852
                zoomAndPanControl.ContentZoomFocusY));
853
        }
854

    
855
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
856
        {
857
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
858
                zoomAndPanControl.ContentZoomFocusY));
859
        }
860

    
861

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

    
875
            if (zoomAndPanControl2 != null && Sync.IsChecked)
876
            {
877
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
878
            }
879
        }
880

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

    
892
            if (zoomAndPanControl2 != null && Sync.IsChecked)
893
            {
894
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
895
            }
896

    
897
        }
898

    
899
        private void ZoomOut_Sync(Point contentZoomCenter)
900
        {
901
            if (zoomAndPanControl2.ContentScale > 0.39)
902
            {
903
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
904
            }
905
            else
906
            {
907
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
908
            }
909

    
910
            if (Sync.IsChecked)
911
            {
912
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
913
            }
914
        }
915

    
916
        private void ZoomIn_Sync(Point contentZoomCenter)
917
        {
918
            if (zoomAndPanControl2.ContentScale > 0.19)
919
            {
920
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
921
            }
922
            else
923
            {
924
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
925
            }
926

    
927
            if (Sync.IsChecked)
928
            {
929
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
930
            }
931
        }
932

    
933
        private void ZoomOut()
934
        {
935
            zoomAndPanControl.ContentScale -= 0.1;
936
            //if (zoomAndPanControl2 != null)
937
            //{
938
            //    zoomAndPanControl2.ContentScale -= 0.1;
939
            //}
940
        }
941

    
942
        private void ZoomIn()
943
        {
944
            zoomAndPanControl.ContentScale += 0.1;
945
            //if (zoomAndPanControl2 != null)
946
            //{
947
            //    zoomAndPanControl2.ContentScale += 0.1;
948
            //}
949
        }
950

    
951
        #endregion
952

    
953
        private void init()
954
        {
955
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
956
            {
957

    
958
                ControlList.Clear();
959
                listBox.Items.Clear();
960
                selected_item.Clear();
961

    
962
                (item as IMarkupCommonData).IsSelected = false;
963
            }
964

    
965
        }
966

    
967
        private HitTestResultBehavior MyCallback(HitTestResult result)
968
        {
969
            //this.cursor = Cursors.UpArrow;
970
            var element = result.VisualHit;
971
            while (element != null && !(element is CommentUserInfo))
972
                element = VisualTreeHelper.GetParent(element);
973

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

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

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

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

    
1106
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1107
        {
1108
            //Control_Init(e.Source);
1109
        }
1110
        //private Window _dragdropWindow = null;
1111

    
1112
        [DllImport("user32.dll")]
1113
        [return: MarshalAs(UnmanagedType.Bool)]
1114
        internal static extern bool GetCursorPos(ref Win32Point pt);
1115

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

    
1133

    
1134
               if (this._dragdropWindow != null)
1135
               {
1136
                   this._dragdropWindow.Close();
1137
                   this._dragdropWindow = null;
1138
               }
1139

    
1140
               symbol_id = id;
1141
               symbol_group_id = group_id;
1142
               symbol_SelectedIndex = SelectedIndex;
1143
               symbol_Data = Data_;
1144
               symbol_img = img;
1145

    
1146

    
1147
               CreateDragDropWindow2(img);
1148
              
1149
    }
1150

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

    
1171
            Win32Point w32Mouse = new Win32Point();
1172
            GetCursorPos(ref w32Mouse);
1173

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

    
1186
                Point currentPos = e.GetPosition(rect);
1187

    
1188
                floatingTip.HorizontalOffset = currentPos.X + 20;
1189
                floatingTip.VerticalOffset = currentPos.Y;
1190
            }
1191

    
1192
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1193
            
1194
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1195
            {
1196
                SetCursor();
1197
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1198
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1199

    
1200
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1201
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1202
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1203

    
1204
                if (Sync.IsChecked)
1205
                {
1206
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1207
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1208
                }
1209
            }
1210

    
1211
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1212
            {
1213
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1214
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1215
                SetCursor();
1216

    
1217
                if (currentControl != null)
1218
                {
1219
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1220
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1221
                    //강인구 추가
1222
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1223

    
1224
                    if ((currentControl as IPath) != null)
1225
                    {
1226
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1227
                    }
1228
                    if ((currentControl as LineControl) != null)
1229
                    {
1230
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1231
                    }
1232

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1571
                    if (dragDistance > DragThreshold)
1572
                    {
1573
                        isDraggingSelectionRect = true;
1574
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1575
                    }
1576

    
1577
                    e.Handled = true;
1578
                }
1579

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

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

    
1621
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1622
        {
1623
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1624
            {
1625
                SetCursor();
1626
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1627
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1628

    
1629
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1630

    
1631
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1632
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1633

    
1634
                if (Sync.IsChecked)
1635
                {
1636
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1637
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1638
                }
1639
            }
1640
        }
1641

    
1642
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1643

    
1644
        private EllipseGeometry hitArea = new EllipseGeometry();
1645

    
1646
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1647
        {
1648
            IsDrawing = false;
1649

    
1650
            if (mouseHandlingMode != MouseHandlingMode.None)
1651
            {
1652
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1653
                {
1654
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1655

    
1656
                    SetCursor();
1657

    
1658
                    switch (controlType)
1659
                    {
1660
                        case ControlType.None:
1661
                            break;
1662
                        case ControlType.Rectangle:
1663
                            {
1664

    
1665
                            }
1666
                            break;
1667
                        case ControlType.PenControl:
1668
                            {
1669

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

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

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

    
1717
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1718

    
1719
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1720
                            }
1721

    
1722
                            isDraggingSelectionRect = false;
1723
                            e.Handled = true;
1724
                            wasDragSelectionApplied = true;
1725
                        }
1726

    
1727
                        if (isLeftMouseButtonDownOnWindow)
1728
                        {
1729
                            isLeftMouseButtonDownOnWindow = false;
1730
                            this.ReleaseMouseCapture();
1731
                            e.Handled = true;
1732
                        }
1733

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

    
1746
                zoomAndPanControl.ReleaseMouseCapture();
1747

    
1748

    
1749
                e.Handled = true;
1750
            }
1751
            else
1752
            {
1753
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1754
                SetCursor();
1755
            }
1756

    
1757
            ///mouseButtonDown = MouseButton.Left;
1758
            //controlType = ControlType.SingleLine;
1759
        }
1760

    
1761
        public void Set_Symbol_Capture(Point endPoint)
1762
        {       
1763
            double x = canvasDrawingMouseDownPoint.X;
1764
            double y = canvasDrawingMouseDownPoint.Y;
1765
            if(x > endPoint.X)
1766
            {
1767
                x = endPoint.X;
1768
                y = endPoint.Y;
1769
            }
1770

    
1771
            double width = dragCaptureBorder.Width;
1772
            double height = dragCaptureBorder.Height;
1773

    
1774
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1775

    
1776
            if (x < 0)
1777
            {
1778
                width += x;
1779
                x = 0;
1780
            }
1781
            if (y < 0)
1782
            {
1783
                height += y;
1784
                y = 0;
1785

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

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

    
1810
            var defaultBitmapImage = new BitmapImage();
1811
            defaultBitmapImage.BeginInit();
1812
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1813
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1814
            defaultBitmapImage.UriSource = new Uri(uri);
1815
            defaultBitmapImage.EndInit();
1816

    
1817
            //GC.Collect();
1818

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

    
1831
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1832
        {
1833
            ///mouseButtonDown = MouseButton.Left;
1834
        }
1835

    
1836
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1837
        {
1838
            ///mouseButtonDown = MouseButton.Left;
1839
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1840
        }
1841

    
1842
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1843
        {
1844

    
1845
        }
1846

    
1847
        /// <summary>
1848
        /// select items by dragging
1849
        /// </summary>
1850
        private void ApplyDragSelectionRect()
1851
        {
1852
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1853

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

    
1862
            Rect dragRect = new Rect(x, y, width, height);
1863
            ///dragRect.Inflate(width / 10, height / 10);
1864

    
1865
            foreach (var item in Items)
1866
            {
1867
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1868

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

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

    
1894
                dragSelectionBorder.Visibility = Visibility.Visible;
1895
            }
1896
            else
1897
            {
1898
                dragZoomBorder.Visibility = Visibility.Visible;
1899
            }
1900
            UpdateDragSelectionRect(pt1, pt2);
1901
        }
1902

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

    
1910
            //
1911
            // Determine x,y,width and height of the rect inverting the points if necessary.
1912
            // 
1913

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

    
1925
            if (pt2.Y < pt1.Y)
1926
            {
1927
                y = pt2.Y;
1928
                height = pt1.Y - pt2.Y;
1929
            }
1930
            else
1931
            {
1932
                y = pt1.Y;
1933
                height = pt2.Y - pt1.Y;
1934
            }
1935

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

    
1964
        private void drawingPannelRotate(double angle)
1965
        {
1966
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1967
            rotate.Angle = angle;
1968
            var rotationNum = Math.Abs((rotate.Angle / 90));
1969

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

    
1997
            zoomAndPanControl.RotationAngle = rotate.Angle;
1998

    
1999

    
2000
            if (!testPanel2.IsHidden)
2001
            {
2002
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2003
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2004
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2005
            }
2006

    
2007
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2008
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2009
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2010
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2011
            ViewerDataModel.Instance.Angle = rotate.Angle;
2012
        }
2013

    
2014
        private void syncPannelRotate(double angle)
2015
        {
2016
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2017
            rotate.Angle = angle;
2018
            var rotationNum = Math.Abs((rotate.Angle / 90));
2019

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

    
2047
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2048
        }
2049

    
2050
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2051
        {
2052
            string Data_ = "";
2053

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

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

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

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

    
2127
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2128
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2129
                    UndoData.Markup_List.Add(multi_Undo_Data);
2130
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2131

    
2132
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2133
                    currentControl.CommentID = Commons.shortGuid();
2134
                    currentControl.SymbolID = id;
2135
                    currentControl.GroupID = group_id;
2136
                    currentControl.ApplyTemplate();
2137
                    currentControl.SetImage();
2138

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

    
2150
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2151
        {            
2152
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2153
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2154
            {
2155
                set_option.Value = double.Parse(set_option.ContentText);
2156
                //set_option.Focusable = false;
2157
                zoomAndPanControl.Focus();
2158
            }
2159

    
2160
            ConvertInkControlToPolygon();
2161

    
2162
            ///TODO:
2163
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2164
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2165

    
2166
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2167
            {
2168
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2169
            }
2170
            /// up to here
2171

    
2172
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2173
            {
2174
                if (item as ArrowTextControl != null)
2175
                {
2176
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2177
                }
2178
                else if (item as TextControl != null)
2179
                {
2180
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2181
                }
2182
            }
2183

    
2184
            //if (currentControl != null)
2185
            {
2186
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2187
                if (text_item_ != null)
2188
                {
2189
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2190
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2191
                    (text_item_ as TextControl).IsEditingMode = false;                    
2192
                    currentControl = null;
2193
                }
2194

    
2195
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2196
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2197
                {
2198
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2199
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2200
                    currentControl = null;
2201
                }
2202
            }
2203

    
2204
            double Ang = 0;                                          
2205
            if (rotate.Angle != 0)
2206
            {
2207
                Ang = 360 - rotate.Angle;
2208
            }
2209

    
2210
            if (e.OriginalSource is System.Windows.Controls.Image)
2211
            {
2212
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2213
            }
2214
            /*
2215
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2216
            {                
2217
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2218
                if(symbol_id != null)
2219
                {
2220
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2221
                }                
2222
            }
2223

    
2224
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2225
            {
2226
                if (this._dragdropWindow != null)
2227
                {
2228
                    this._dragdropWindow.Close();
2229
                    this._dragdropWindow = null;
2230
                    symbol_id = null;
2231
                }
2232
            }
2233
            */
2234

    
2235
            if (e.LeftButton == MouseButtonState.Pressed)
2236
            {
2237
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2238
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2239

    
2240
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2241
                SetCursor();
2242

    
2243
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2244
            }
2245

    
2246
            if (e.MiddleButton == MouseButtonState.Pressed)
2247
            {
2248
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2249
                cursor = Cursors.SizeAll;
2250
                SetCursor();
2251
            }
2252
            if (e.RightButton == MouseButtonState.Pressed)
2253
            {
2254
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2255
                cursor = Cursors.SizeAll;
2256
                SetCursor();
2257
            }
2258
            else if (e.XButton1 == MouseButtonState.Pressed)
2259
            {
2260
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2261
                {
2262
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2263
                }
2264

    
2265
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2266

    
2267
            }
2268
            else if (e.XButton2 == MouseButtonState.Pressed)
2269
            {
2270
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2271
                {
2272
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2273
                }
2274
            }
2275

    
2276
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2277
            {
2278
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2279
                {
2280
                    if (SelectLayer.Children.Count == 0)
2281
                    {
2282
                        isLeftMouseButtonDownOnWindow = true;
2283
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2284
                    }
2285

    
2286
                    if (controlType == ControlType.None)
2287
                    {
2288
                        isLeftMouseButtonDownOnWindow = true;
2289
                    }
2290
                }
2291

    
2292
                /// 캡쳐 모드 설정
2293
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2294
                {
2295
                    dragCaptureBorder.Visibility = Visibility.Visible;
2296
                    isLeftMouseButtonDownOnWindow = true;
2297
                }
2298

    
2299
                /// 줌 모드 설정
2300
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2301
                {
2302
                    isLeftMouseButtonDownOnWindow = true;
2303
                }
2304

    
2305
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2306
                if (control != null)
2307
                {
2308
                    AdornerFinal final = null;
2309

    
2310
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2311
                    {
2312
                        /// 기존 selection 해제
2313
                        SelectionSet.Instance.UnSelect(this);
2314

    
2315
                        final = new AdornerFinal(control);
2316

    
2317
                        this.Control_Style(control);
2318

    
2319
                        if ((control as IPath) != null)
2320
                        {
2321
                            if ((control as IPath).LineSize != 0)
2322
                            {
2323
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2324
                            }
2325
                        }
2326
                        if ((control as IShapeControl) != null)
2327
                        {
2328
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2329
                            {
2330
                                ViewerDataModel.Instance.checkHatchShape = true;
2331
                            }
2332
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2333
                            {
2334
                                ViewerDataModel.Instance.checkFillShape = true;
2335
                            }
2336
                            else
2337
                            {
2338
                                ViewerDataModel.Instance.checkHatchShape = false;
2339
                                ViewerDataModel.Instance.checkFillShape = false;
2340
                            }
2341
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2342
                        }
2343

    
2344
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2345

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

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

    
2427
                        Control_Style(control);
2428

    
2429
                        final = new AdornerFinal(comment);
2430
                    }
2431

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

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

    
2488
                                    CreateCommand.Instance.Execute(currentControl);
2489

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

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

    
2517
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2518

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

    
2536
                                    CreateCommand.Instance.Execute(currentControl);
2537

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

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

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

    
2571
                                    CreateCommand.Instance.Execute(currentControl);
2572

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

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

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

    
2606
                                    CreateCommand.Instance.Execute(currentControl);
2607

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

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

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

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

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

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

    
2677
                                    CreateCommand.Instance.Execute(currentControl);
2678

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

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

    
2712
                                    CreateCommand.Instance.Execute(currentControl);
2713

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

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

    
2752
                                        CreateCommand.Instance.Execute(currentControl);
2753

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

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

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

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

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

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

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

    
2839
                                    control.ApplyOverViewData();
2840

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

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

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

    
2884
                                    CreateCommand.Instance.Execute(currentControl);
2885

    
2886
                                    currentControl = null;
2887
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2888
                                    return;
2889
                                }
2890

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

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

    
2941
                                    CreateCommand.Instance.Execute(currentControl);
2942

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

    
2984
                                    CreateCommand.Instance.Execute(currentControl);
2985

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

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

    
3044
                                            CreateCommand.Instance.Execute(currentControl);
3045

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

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

    
3089
                                    CreateCommand.Instance.Execute(currentControl);
3090

    
3091
                                    control.isTransOn = true;
3092
                                    var firstPoint = control.PointSet.First();
3093

    
3094
                                    control.PointSet.Add(firstPoint);
3095
                                    control.DrawingCloud();
3096
                                    control.ApplyOverViewData();
3097

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

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

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

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

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

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

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

    
3210
                                        CreateCommand.Instance.Execute(currentControl);
3211
                                        currentControl = null;
3212

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

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

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

    
3261
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3262
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3263
                                    
3264
                                    (currentControl as TextControl).ControlType_No = 0;
3265
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3266
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3267
                                    (currentControl as TextControl).ApplyTemplate();
3268
                                    (currentControl as TextControl).Base_TextBox.Focus();
3269
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3270
                                    CreateCommand.Instance.Execute(currentControl);
3271
                                }
3272
                            }
3273
                        }
3274
                        break;
3275
                    case ControlType.TextBorder:
3276
                        {
3277
                            if (e.LeftButton == MouseButtonState.Pressed)
3278
                            {
3279
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3280
                                {
3281
                                    currentControl = new TextControl
3282
                                    {
3283
                                        ControlType = controlType
3284
                                    };
3285

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

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

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

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

    
3351
                                    CreateCommand.Instance.Execute(currentControl);
3352

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

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

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

    
3377
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3378
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3379
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3380
                                        this.MainAngle.Visibility = Visibility.Visible;
3381

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

    
3400
                                    CreateCommand.Instance.Execute(currentControl);
3401

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

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

    
3430
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3431
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3432
                                    (currentControl as ArrowTextControl).isTrans = true;
3433
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3434
                                }
3435
                            }
3436
                        }
3437
                        break;
3438
                    case ControlType.ArrowTextBorderControl:
3439
                         {
3440
                            if (e.LeftButton == MouseButtonState.Pressed)
3441
                            {
3442
                                if (currentControl is ArrowTextControl)
3443
                                {
3444
                                    //20180906 LJY TEST IsRotationDrawingEnable
3445
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3446
                                    {
3447
                                        return;
3448
                                    }
3449

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

    
3469
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3470

    
3471
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3472

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

    
3503
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3504
                                }
3505
                                else
3506
                                {
3507
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3508
                                    //{
3509
                                    
3510

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

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

    
3522
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3523

    
3524
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3525
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3526
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3527
                                        (currentControl as ArrowTextControl).isFixed = true;
3528
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3529
                                     
3530
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3531
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3532
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3533
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3534
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3535
                                        this.MainAngle.Visibility = Visibility.Visible;
3536
                                    
3537
                                    //20180911 LJY
3538
                                        (currentControl as ArrowTextControl).isTrans = true;
3539
                                    
3540

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

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

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

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

    
3632
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3633
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3634
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3635
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3636
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3637
                                        this.MainAngle.Visibility = Visibility.Visible;  
3638
                                    
3639
                                    //20180911 LJY
3640
                                        (currentControl as ArrowTextControl).isTrans = true;
3641
                                    //}
3642
                                }
3643
                            }
3644
                        }
3645
                        break;
3646
                    //강인구 추가
3647
                    case ControlType.Sign:
3648
                        {
3649
                            if (e.LeftButton == MouseButtonState.Pressed)
3650
                            {
3651
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3652
                                //{
3653
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3654

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

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

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

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

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

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

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

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

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

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

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

    
3804
                                        CreateCommand.Instance.Execute(currentControl);
3805
                                        currentControl = null;
3806
                                   
3807

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4030
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4031
        {
4032
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4033
            if(item != null)
4034
            {
4035
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4036
                {
4037
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4038
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4039
                }
4040
                else
4041
                {
4042
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4043
                }
4044
            }else{
4045
                //Consolidate 가 없는 경우
4046
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4047
            }
4048
            
4049
        }
4050

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

    
4067
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4068
        {
4069
            UpdateMyMarkupList();
4070

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

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

    
4094
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4095
                if (item2 != null)
4096
                {
4097
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4098

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

    
4109
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4110
        {
4111
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4112

    
4113
            if (App.ViewInfo != null)
4114
            {
4115
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4116
                {
4117
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4118
                }
4119
            }
4120
        }
4121

    
4122
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4123
        {
4124
            if (CompareMode.IsChecked)
4125
            {
4126
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4127
                {
4128
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4129
                }
4130
                if (ViewerDataModel.Instance.PageNumber == 0)
4131
                {
4132
                    ViewerDataModel.Instance.PageNumber = 1;
4133
                }
4134

    
4135
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4136
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4137
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4138

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

    
4152
        private void Sync_Click(object sender, RoutedEventArgs e)
4153
        {
4154
            if (Sync.IsChecked)
4155
            {
4156
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4157
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4158
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4159
            }
4160
        }
4161

    
4162
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4163
        {
4164
            if (UserList.IsChecked)
4165
            {
4166
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4167
            }
4168
            else
4169
            {
4170
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4171
            }
4172
        }
4173

    
4174
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4175
        {
4176

    
4177
            if (BalanceMode.IsChecked)
4178
            {
4179
                ViewerDataModel.Instance.PageBalanceMode = true;
4180
            }
4181
            else
4182
            {
4183
                ViewerDataModel.Instance.PageBalanceMode = false;
4184
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4185
            }
4186
        }
4187

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

    
4201
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4202
        {
4203
            if ((sender as System.Windows.Controls.Control).Tag != null)
4204
            {
4205
                //Compare 초기화
4206
                CompareMode.IsChecked = false;
4207
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4208

    
4209
                if (ViewerDataModel.Instance.PageNumber == 0)
4210
                {
4211
                    ViewerDataModel.Instance.PageNumber = 1;
4212
                }
4213

    
4214
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4215
                {
4216
                }
4217
                else
4218
                {
4219
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4220
                }
4221

    
4222
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4223
                {
4224

    
4225
                }
4226
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4227
                {
4228
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4229
                }
4230

    
4231
                if (!testPanel2.IsHidden)
4232
                {
4233
                    if (IsSyncPDFMode)
4234
                    {
4235
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4236
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4237

    
4238
                        if (pdfpath.IsDownloading)
4239
                        {
4240
                            pdfpath.DownloadCompleted += (ex, arg) =>
4241
                            {
4242
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4243
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4244
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4245
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4246
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4247
                            };
4248
                        }
4249
                        else
4250
                        {
4251
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4252
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4253
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4254

    
4255
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4256
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4257
                        }
4258

    
4259
                    }
4260
                    else
4261
                    {
4262
                        string uri = "";
4263

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

    
4273
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4274

    
4275
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4276
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4277
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4278

    
4279
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4280
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4281

    
4282
                        if (defaultBitmapImage_Compare.IsDownloading)
4283
                        {
4284
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4285
                            {
4286
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4287
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4288
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4289

    
4290
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4291
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4292
                            };
4293
                        }
4294
                    }
4295

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

    
4300
                    foreach (var item in gridSelectionRevItem)
4301
                    {
4302
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4303
                        {
4304
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4305
                        });
4306
                    }
4307

    
4308
                    //강인구 추가
4309
                    zoomAndPanControl2.ZoomTo(new Rect
4310
                    {
4311
                        X = 0,
4312
                        Y = 0,
4313
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4314
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4315
                    });
4316

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

    
4319
                }
4320
            }
4321
        }
4322

    
4323
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4324
        {
4325
            if (MarkupMode.IsChecked)
4326
            {
4327
                IsSyncPDFMode = true;
4328

    
4329
                var uri = CurrentRev.TO_VENDOR;
4330

    
4331
                if (ViewerDataModel.Instance.PageNumber == 0)
4332
                {
4333
                    ViewerDataModel.Instance.PageNumber = 1;
4334
                }
4335

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

    
4340
                if (pdfpath.IsDownloading)
4341
                {
4342
                    pdfpath.DownloadCompleted += (ex, arg) =>
4343
                    {
4344
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4345
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4346
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4347
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4348
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4349
                    };
4350
                }
4351
                else
4352
                {
4353
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4354
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4355
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4356

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

    
4374
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4375

    
4376
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4377
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4378
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4379

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

    
4396
        private void RadButton_Click(object sender, RoutedEventArgs e)
4397
        {
4398
            gridViewHistory_Busy.IsBusy = true;
4399

    
4400
            RadButton instance = sender as RadButton;
4401
            if (instance.CommandParameter != null)
4402
            {
4403
                CurrentRev = instance.CommandParameter as VPRevision;
4404
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4405
                {
4406
                    if (ea.Error == null && ea.Result != null)
4407
                    {
4408
                        testPanel2.IsHidden = false;
4409

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

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

    
4436
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4437

    
4438
                        var defaultBitmapImage_Compare = new BitmapImage();
4439
                        defaultBitmapImage_Compare.BeginInit();
4440
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4441
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4442
                        defaultBitmapImage_Compare.EndInit();
4443

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

    
4465
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4466
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4467
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4468

    
4469
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4470
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4471
                        gridViewHistory_Busy.IsBusy = false;
4472
                    }
4473

    
4474
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4475
                };
4476
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4477
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4478
            }
4479
        }
4480

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

    
4504
        public void Sync_Event(VPRevision Currnet_Rev)
4505
        {
4506
            CurrentRev = Currnet_Rev;
4507

    
4508
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4509
            {
4510
                if (ea.Error == null && ea.Result != null)
4511
                {
4512
                    testPanel2.IsHidden = false;
4513

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

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

    
4540
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4541

    
4542
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4543

    
4544
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4545
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4546
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4547

    
4548
                    if (defaultBitmapImage_Compare.IsDownloading)
4549
                    {
4550
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4551
                        {
4552
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4553
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4554
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4555
                        };
4556
                    }
4557

    
4558

    
4559
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4560
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4561
                    zoomAndPanControl2.ApplyTemplate();
4562
                    zoomAndPanControl2.UpdateLayout();
4563

    
4564
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4565
                    {
4566
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4567
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4568
                    }
4569
                    //}
4570

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

    
4577
            };
4578
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4579
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4580
        }
4581

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

    
4598
        private void Create_Symbol(object sender, RoutedEventArgs e)
4599
        {
4600
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4601

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

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

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

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

    
4675
                            if (symbolsvg == true)
4676
                            {
4677
                                try
4678
                                {
4679
                                    var defaultBitmapImage = new BitmapImage();
4680
                                    defaultBitmapImage.BeginInit();
4681
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4682
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4683
                                    Check_Uri.UriCheck(filename);
4684
                                    defaultBitmapImage.UriSource = new Uri(filename);
4685
                                    defaultBitmapImage.EndInit();
4686

    
4687
                                    System.Drawing.Bitmap image;
4688

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

    
4711
                                            StringBuilder svgBuilder = new StringBuilder();
4712
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4713
                                            {
4714
                                                svgBuilder.AppendLine(e2.Data);
4715
                                            };
4716

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

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

    
4758
        public void SymbolSave(string Name, string Url, string Data)
4759
        {
4760
            try
4761
            {
4762
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4763
                {
4764
                    ID = Commons.shortGuid(),
4765
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4766
                    NAME = Name,
4767
                    IMAGE_URL = Url,
4768
                    DATA = Data
4769
                };
4770

    
4771
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4772
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4773
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4774
            }
4775
            catch (Exception)
4776
            {
4777
                throw;
4778
            }
4779
        }
4780

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

    
4803
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4804
        {           
4805
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4806
            DataBind();
4807
        }
4808

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

    
4835
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4836

    
4837
                List<SYMBOL_PUBLIC> symbol_Public;
4838

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

    
4874
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4875
                        _Encoder.Save(fs);
4876
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4877

    
4878
                        byte[] Img_byte = fs.ToArray();
4879

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

    
4901
        public PngBitmapEncoder symImage(string data)
4902
        {
4903

    
4904
            Canvas _canvas = new Canvas();
4905
            _canvas.Background = Brushes.White;
4906
            _canvas.Width = adorner_.BorderSize.Width;
4907
            _canvas.Height = adorner_.BorderSize.Height;
4908
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4909

    
4910
            BitmapEncoder encoder = new PngBitmapEncoder();
4911

    
4912

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

    
4915
            DrawingVisual dv = new DrawingVisual();
4916

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

    
4920
            using (DrawingContext ctx = dv.RenderOpen())
4921
            {
4922
                VisualBrush vb = new VisualBrush(_canvas);
4923
                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)));
4924
            }
4925

    
4926
            try
4927
            {
4928
                renderBitmap.Render(dv);
4929

    
4930
                //GC.Collect();
4931
                GC.WaitForPendingFinalizers();
4932
                //GC.Collect();
4933
                // encode png data
4934
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4935
                // puch rendered bitmap into it
4936
                pngEncoder.Interlace = PngInterlaceOption.Off;
4937
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4938
                return pngEncoder;
4939

    
4940
            }
4941
            catch //(Exception ex)
4942
            {
4943
                return null;
4944
            }
4945

    
4946
        }
4947

    
4948
        public void DialogMessage_Alert(string content, string header)
4949
        {
4950
            DialogParameters parameters = new DialogParameters()
4951
            {
4952
                Owner = Application.Current.MainWindow,
4953
                Content = new TextBlock()
4954
                { 
4955
                    MinWidth = 400,
4956
                    FontSize = 11,
4957
                    Text = content,
4958
                    TextWrapping = System.Windows.TextWrapping.Wrap
4959
                },
4960
                Header = header,
4961
                Theme = new VisualStudio2013Theme(),
4962
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4963
            };            
4964
            RadWindow.Alert(parameters);
4965
        }
4966

    
4967
        #region 캡쳐 기능
4968

    
4969
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4970
        {
4971
            if (x < 0)
4972
            {
4973
                width += x;
4974
                x = 0;
4975
            }
4976
            if (y < 0)
4977
            {
4978
                height += y;
4979
                y = 0;
4980

    
4981
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4982
            }
4983
            if (x + width > zoomAndPanCanvas.ActualWidth)
4984
            {
4985
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4986
            }
4987
            if (y + height > zoomAndPanCanvas.ActualHeight)
4988
            {
4989
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4990
            }
4991

    
4992
            byte[] pixels = CopyPixels(x, y, width, height);
4993

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

    
4996
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4997
        }
4998

    
4999
        public byte[] CopyPixels(int x, int y, int width, int height)
5000
        {
5001
            byte[] pixels = new byte[width * height * 4];
5002
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5003

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

    
5007
            return pixels;
5008
        }
5009

    
5010
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5011
        {
5012
            DrawingVisual drawingVisual = new DrawingVisual();
5013
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5014

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

    
5020
            // 비트맵으로 변환합니다.
5021
            RenderTargetBitmap target =
5022
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5023
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5024

    
5025
            target.Render(drawingVisual);
5026
            return target;
5027
        }
5028

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

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

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

    
5057
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5058

    
5059
            RadWindow CheckPop = new RadWindow();
5060
            //Alert check = new Alert(Msg);
5061

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

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

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

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

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

    
5145
        }
5146

    
5147
        public void Set_Capture()
5148
        {
5149
            double x = canvasDrawingMouseDownPoint.X;
5150
            double y = canvasDrawingMouseDownPoint.Y;
5151
            double width = dragCaptureBorder.Width;
5152
            double height = dragCaptureBorder.Height;
5153

    
5154
            if (width > 5 || height > 5)
5155
            {
5156
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5157
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5158
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5159
            }
5160
        }
5161
        #endregion
5162

    
5163
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5164
        {
5165
            multi_Undo_Data = new Multi_Undo_data();
5166

    
5167
            multi_Undo_Data.Markup = control;
5168

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

    
5186
            return multi_Undo_Data;
5187
        }
5188

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

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

    
5219
                    List<Point> inkPointSet = new List<Point>();
5220
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5221

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

    
5234
                    if (pc.PointSet.Count > 0)
5235
                    {
5236
                        CreateCommand.Instance.Execute(pc);
5237
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5238
                    }
5239
                });
5240
                inkBoard.Strokes.Clear();
5241
            }
5242
        }
5243

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

    
5260
            return false;
5261
        }
5262

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

    
5268
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5269
        {
5270
            e.Effects = DragDropEffects.Copy;
5271
        }
5272

    
5273
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5274
        {
5275
            e.Effects = DragDropEffects.None;
5276
        }
5277

    
5278
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5279
        {
5280
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5281
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5282

    
5283
            ScaleImage(pageWidth, pageHeight);
5284
        }
5285

    
5286
        /// <summary>
5287
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5288
        /// </summary>
5289
        /// <param name="pageWidth">원본 사이즈</param>
5290
        /// <param name="pageHeight">원본 사이즈</param>
5291
        /// <returns></returns>
5292
        private void ScaleImage(double pageWidth,double pageHeight)
5293
        {
5294
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5295
        }
5296

    
5297
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5298
        {
5299
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5300
        }
5301

    
5302

    
5303
        /*
5304
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5305
        {
5306
            try
5307
            {
5308
                if (e.Data.GetDataPresent(typeof(string)))
5309
                {
5310
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5311
                    string dragData = e.Data.GetData(typeof(string)) as string;
5312
                    Move_Symbol(sender, dragData);
5313
                }
5314
            }
5315
            catch (Exception ex)
5316
            {
5317
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5318
            }            
5319
        }
5320
        */
5321
    }
5322
}
클립보드 이미지 추가 (최대 크기: 500 MB)