프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

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

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

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

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

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

    
272
            return false;
273
        }
274

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

    
298
            return false;
299
        }
300

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

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

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

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

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

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

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

    
362
        /// <summary>
363
        /// delete selected comments
364
        /// </summary>
365
        /// <param name="sender"></param>
366
        /// <param name="e"></param>
367
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
368
        {
369
            if (MessageBox.Show("정말 삭제 하시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
370
            {
371
                //선택된 어도너가 있을시 삭제가 되지 않음
372
                SelectionSet.Instance.UnSelect(this);
373

    
374
                Button content = (sender as Button);
375
                MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
376

    
377
                DeleteItem(item);
378
            }
379
        }
380

    
381
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
382

    
383
        private static Timer timer;
384
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
385
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
386
        {
387
            InitializeComponent();            
388
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
389

    
390
            if (App.ParameterMode)
391
            {
392
                App.splashString(ISplashMessage.MAINMENU_1);
393
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
394
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
395
                imageViewer_Compare = new Image();
396
                ViewerDataModel.Instance.Capture_Opacity = 0;
397
                da.From = 0.8;
398
                da.To = 0;
399
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
400
                da.AutoReverse = true;
401
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
402

    
403
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
404
                {
405
                    this.SymbolPane.Visibility = Visibility.Collapsed;
406
                    this.FavoritePane.Visibility = Visibility.Collapsed;
407
                    this.drawingRotateCanvas.IsHitTestVisible = false;
408
                }
409
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
410
            }
411
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
412
        }
413

    
414
        
415

    
416
        private void timercallback(Object o)
417
        {
418
            Stopwatch sw = new Stopwatch();
419
            sw.Start();
420
            TempFile.TempFileAdd();
421
            sw.Stop();
422

    
423
            Dispatcher.InvokeAsync(new Action(delegate
424
            {
425
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
426
                {
427
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
428
                }
429
            }));
430

    
431
            ////GC.Collect();
432
        }
433
        
434
        /// <summary>
435
        /// update my markuplist
436
        ///  - update existing markup data if already exist
437
        ///  - add new markup data if control is new
438
        /// </summary>
439
        public void UpdateMyMarkupList()
440
        {
441
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
442

    
443
            /// add or update markup list
444
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
445
            {
446
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
447

    
448
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
449
                if (exist != null) //신규 추가 된 코멘트
450
                {
451
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
452
                    {
453
                        exist.Data = root.ConvertData;
454
                        exist.IsUpdate = true;
455
                    }
456
                }
457
                else if (root.CommentID != null)
458
                {
459
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
460
                    {
461
                        ID = control.CommentID,
462
                        Data = root.ConvertData,
463
                        Data_Type = root.DATA_TYPE,
464
                        MarkupInfoID = App.Custom_ViewInfoId,
465
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
466
                        Symbol_ID = control.SymbolID,
467
                        //Group_ID = control.GroupID,
468
                    });
469
                }
470
            }
471

    
472
            /// delete markup list
473
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
474
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
475
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
476
                          select markup).ToList();
477
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
478
            /// up to here
479

    
480
            //if (modified)
481
            //{
482
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
483
            //    {
484
            //        ComingNewBieEnd = true;
485
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
486
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
487
            //        gridViewMarkup.ItemsSource = null;
488
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
489
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
490

    
491
            //        GroupDescriptor descriptor = new GroupDescriptor();
492
            //        descriptor.Member = "Depatment";
493
            //        descriptor.DisplayContent = "DEPT";
494
            //        descriptor.SortDirection = ListSortDirection.Ascending;
495
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
496
            //    }
497
            //}
498
        }
499

    
500
        /// <summary>
501
        /// start page changing
502
        ///  - save controls if page is modified
503
        ///  - starting download page image
504
        /// </summary>
505
        /// <param name="sender"></param>
506
        /// <param name="e"></param>
507
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
508
        {
509
            CompareMode.IsChecked = false;
510
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
511

    
512
            #region 페이지가 벗어난 경우
513

    
514
            if (BalancePoint < 1)
515
            {
516
                BalancePoint = 1;
517
                ViewerDataModel.Instance.PageBalanceNumber = 0;
518
            }
519

    
520
            if (pageNavigator.PageCount < BalancePoint)
521
            {
522
                BalancePoint = pageNavigator.PageCount;
523
                ViewerDataModel.Instance.PageBalanceNumber = 0;
524
            }
525

    
526
            #endregion
527

    
528
            ViewerDataModel.Instance.PageNumber = BalancePoint;
529

    
530
            string uri = "";
531
            if (userData.COMPANY != "EXT")
532
            {
533
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
534
            }
535
            else
536
            {
537
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
538
            }
539

    
540
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
541
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
542

    
543
            var defaultBitmapImage = new BitmapImage();
544
            defaultBitmapImage.BeginInit();
545
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
546
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
547
            defaultBitmapImage.UriSource = new Uri(uri);
548
            defaultBitmapImage.DecodePixelWidth = Convert.ToInt32(pageWidth );
549
            defaultBitmapImage.DecodePixelHeight = Convert.ToInt32(pageHeight);// * zoomAndPanControl.ContentScale
550
            defaultBitmapImage.EndInit();
551

    
552
            ViewerDataModel.Instance.ImageViewPath = null;
553
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
554
            if (defaultBitmapImage.IsDownloading)
555
            {
556
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
557
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
558
                {                   
559
                    defaultBitmapImage.Freeze();                                        
560
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
561
                    ViewerDataModel.Instance.ImageViewWidth = pageWidth;
562
                    ViewerDataModel.Instance.ImageViewHeight = pageHeight;
563
                    mainPanel.UpdateLayout();
564
                    this.pageNavigator.ChangePage(e.PageNumber); 
565
                    
566
                    //image dispose
567
                    defaultBitmapImage = null;
568
                    GC.Collect();
569
                };
570
            }
571

    
572
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
573
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
574

    
575

    
576
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
577
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
578
            inkBoard.Width = zoomAndPanCanvas.Width;
579
            inkBoard.Height = zoomAndPanCanvas.Height;
580

    
581

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

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

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

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

    
638
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
639

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

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

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

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

    
679
        }
680

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

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

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

    
723
            if (!testPanel2.IsHidden)
724
            {
725
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
726
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
727
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
728

    
729
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
730
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
731

    
732

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

    
742
            var instanceMain = this.ParentOfType<MainWindow>();
743
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
744
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
745

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

    
750
            SetCommentPages(true);
751
        }
752

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

    
783
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
784
        {
785
            if (e.MiddleButton == MouseButtonState.Pressed)
786
            {
787

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

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

    
817
        #region ZoomIn & ZoomOut
818

    
819
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
820
        {
821
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
822
                zoomAndPanControl.ContentZoomFocusY));
823
        }
824

    
825
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
826
        {
827
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
828
                zoomAndPanControl.ContentZoomFocusY));
829
        }
830

    
831

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

    
845
            if (zoomAndPanControl2 != null && Sync.IsChecked)
846
            {
847
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
848
            }
849
        }
850

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

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

    
867
        }
868

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

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

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

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

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

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

    
921
        #endregion
922

    
923
        private void init()
924
        {
925
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
926
            {
927

    
928
                ControlList.Clear();
929
                listBox.Items.Clear();
930
                selected_item.Clear();
931

    
932
                (item as IMarkupCommonData).IsSelected = false;
933
            }
934

    
935
        }
936

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

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

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

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

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

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

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

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

    
1103

    
1104
               if (this._dragdropWindow != null)
1105
               {
1106
                   this._dragdropWindow.Close();
1107
                   this._dragdropWindow = null;
1108
               }
1109

    
1110
               symbol_id = id;
1111
               symbol_group_id = group_id;
1112
               symbol_SelectedIndex = SelectedIndex;
1113
               symbol_Data = Data_;
1114
               symbol_img = img;
1115

    
1116

    
1117
               CreateDragDropWindow2(img);
1118
              
1119
    }
1120

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

    
1141
            Win32Point w32Mouse = new Win32Point();
1142
            GetCursorPos(ref w32Mouse);
1143

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

    
1156
                Point currentPos = e.GetPosition(rect);
1157

    
1158
                floatingTip.HorizontalOffset = currentPos.X + 20;
1159
                floatingTip.VerticalOffset = currentPos.Y;
1160
            }
1161

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

    
1170
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1171
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1172
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1173

    
1174
                if (Sync.IsChecked)
1175
                {
1176
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1177
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1178
                }
1179
            }
1180

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1541
                    if (dragDistance > DragThreshold)
1542
                    {
1543
                        isDraggingSelectionRect = true;
1544
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1545
                    }
1546

    
1547
                    e.Handled = true;
1548
                }
1549

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

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

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

    
1599
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1600

    
1601
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1602
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1603

    
1604
                if (Sync.IsChecked)
1605
                {
1606
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1607
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1608
                }
1609
            }
1610
        }
1611

    
1612
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1613

    
1614
        private EllipseGeometry hitArea = new EllipseGeometry();
1615

    
1616
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1617
        {
1618
            IsDrawing = false;
1619

    
1620
            if (mouseHandlingMode != MouseHandlingMode.None)
1621
            {
1622
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1623
                {
1624
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1625

    
1626
                    SetCursor();
1627

    
1628
                    switch (controlType)
1629
                    {
1630
                        case ControlType.None:
1631
                            break;
1632
                        case ControlType.Rectangle:
1633
                            {
1634

    
1635
                            }
1636
                            break;
1637
                        case ControlType.PenControl:
1638
                            {
1639

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

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

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

    
1687
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1688

    
1689
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1690
                            }
1691

    
1692
                            isDraggingSelectionRect = false;
1693
                            e.Handled = true;
1694
                            wasDragSelectionApplied = true;
1695
                        }
1696

    
1697
                        if (isLeftMouseButtonDownOnWindow)
1698
                        {
1699
                            isLeftMouseButtonDownOnWindow = false;
1700
                            this.ReleaseMouseCapture();
1701
                            e.Handled = true;
1702
                        }
1703

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

    
1716
                zoomAndPanControl.ReleaseMouseCapture();
1717

    
1718

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

    
1727
            ///mouseButtonDown = MouseButton.Left;
1728
            //controlType = ControlType.SingleLine;
1729
        }
1730

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

    
1741
            double width = dragCaptureBorder.Width;
1742
            double height = dragCaptureBorder.Height;
1743

    
1744
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1745

    
1746
            if (x < 0)
1747
            {
1748
                width += x;
1749
                x = 0;
1750
            }
1751
            if (y < 0)
1752
            {
1753
                height += y;
1754
                y = 0;
1755

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

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

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

    
1787
            //GC.Collect();
1788

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

    
1801
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1802
        {
1803
            ///mouseButtonDown = MouseButton.Left;
1804
        }
1805

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

    
1812
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1813
        {
1814

    
1815
        }
1816

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

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

    
1832
            Rect dragRect = new Rect(x, y, width, height);
1833
            ///dragRect.Inflate(width / 10, height / 10);
1834

    
1835
            foreach (var item in Items)
1836
            {
1837
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1838

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

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

    
1864
                dragSelectionBorder.Visibility = Visibility.Visible;
1865
            }
1866
            else
1867
            {
1868
                dragZoomBorder.Visibility = Visibility.Visible;
1869
            }
1870
            UpdateDragSelectionRect(pt1, pt2);
1871
        }
1872

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

    
1880
            //
1881
            // Determine x,y,width and height of the rect inverting the points if necessary.
1882
            // 
1883

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

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

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

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

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

    
1967
            zoomAndPanControl.RotationAngle = rotate.Angle;
1968

    
1969

    
1970
            if (!testPanel2.IsHidden)
1971
            {
1972
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1973
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1974
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1975
            }
1976

    
1977
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1978
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1979
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1980
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1981
            ViewerDataModel.Instance.Angle = rotate.Angle;
1982
        }
1983

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

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

    
2017
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2018
        }
2019

    
2020
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2021
        {
2022
            string Data_ = "";
2023

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

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

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

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

    
2097
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2098
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2099
                    UndoData.Markup_List.Add(multi_Undo_Data);
2100
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2101

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

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

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

    
2128
            ConvertInkControlToPolygon();
2129

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2279
                        final = new AdornerFinal(control);
2280

    
2281
                        this.Control_Style(control);
2282

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

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

    
2310
                        if ((control as TextControl) != null)
2311
                        {
2312
                            if(!((control as TextControl).EnableEditing)) {
2313
                                (control as TextControl).EnableEditing = true;
2314
                            }
2315

    
2316
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2317
                            {
2318
                                ViewerDataModel.Instance.checkTextStyle = true;
2319
                            }
2320
                            else
2321
                            {
2322
                                ViewerDataModel.Instance.checkTextStyle = false;
2323
                            }
2324

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

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

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

    
2410
                        Control_Style(control);
2411

    
2412
                        final = new AdornerFinal(comment);
2413
                    }
2414

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

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

    
2471
                                    CreateCommand.Instance.Execute(currentControl);
2472

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

    
2496
                                        currentControl.CommentID = Commons.shortGuid();
2497
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2498
                                        currentControl.IsNew = true;
2499

    
2500
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2501

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

    
2519
                                    CreateCommand.Instance.Execute(currentControl);
2520

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

    
2533
                                    currentControl.CommentID = Commons.shortGuid();
2534
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2535
                                    currentControl.IsNew = true;
2536
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2537

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

    
2554
                                    CreateCommand.Instance.Execute(currentControl);
2555

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

    
2568
                                    currentControl.CommentID = Commons.shortGuid();
2569
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2570
                                    currentControl.IsNew = true;
2571
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2572

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

    
2589
                                    CreateCommand.Instance.Execute(currentControl);
2590

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

    
2603
                                    currentControl.CommentID = Commons.shortGuid();
2604
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2605
                                    currentControl.IsNew = true;
2606
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2607

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

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

    
2638
                                    currentControl.CommentID = Commons.shortGuid();
2639
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2640
                                    currentControl.IsNew = true;
2641
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2642

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

    
2660
                                    CreateCommand.Instance.Execute(currentControl);
2661

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

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

    
2695
                                    CreateCommand.Instance.Execute(currentControl);
2696

    
2697
                                    currentControl = null;
2698
                                }
2699
                                else
2700
                                {
2701
                                    currentControl = new CircleControl
2702
                                    {
2703
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2704
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2705
                                        Background = new SolidColorBrush(Colors.Black)
2706
                                    };
2707

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

    
2735
                                        CreateCommand.Instance.Execute(currentControl);
2736

    
2737
                                        currentControl = null;
2738
                                    }
2739
                                }
2740
                                else
2741
                                {
2742
                                    currentControl = new TriControl
2743
                                    {
2744
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2745
                                        Background = new SolidColorBrush(Colors.Black),
2746
                                    };
2747

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

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

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

    
2800
                                if (e.RightButton == MouseButtonState.Pressed)
2801
                                {
2802
                                    control.IsCompleted = true;
2803
                                }
2804

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

    
2817
                                    var firstPoint = control.PointSet.First();
2818
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2819
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2820
                                    control.PointSet.Add(firstPoint);
2821

    
2822
                                    control.ApplyOverViewData();
2823

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

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

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

    
2867
                                    CreateCommand.Instance.Execute(currentControl);
2868

    
2869
                                    currentControl = null;
2870
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2871
                                    return;
2872
                                }
2873

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

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

    
2924
                                    CreateCommand.Instance.Execute(currentControl);
2925

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

    
2967
                                    CreateCommand.Instance.Execute(currentControl);
2968

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

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

    
3027
                                            CreateCommand.Instance.Execute(currentControl);
3028

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

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

    
3072
                                    CreateCommand.Instance.Execute(currentControl);
3073

    
3074
                                    control.isTransOn = true;
3075
                                    var firstPoint = control.PointSet.First();
3076

    
3077
                                    control.PointSet.Add(firstPoint);
3078
                                    control.DrawingCloud();
3079
                                    control.ApplyOverViewData();
3080

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

    
3094
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3095
                                    //{
3096
                                        var polygonControl = (currentControl as CloudControl);
3097
                                        currentControl.CommentID = Commons.shortGuid();
3098
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3099
                                        currentControl.IsNew = true;
3100
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3101

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

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

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

    
3165
                                        
3166
                                                currentControl.CommentID = Commons.shortGuid();                                            
3167
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3168
                                                currentControl.IsNew = true;
3169
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3170

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

    
3193
                                        CreateCommand.Instance.Execute(currentControl);
3194
                                        currentControl = null;
3195

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

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

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

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

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

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

    
3299
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3300
                                    currentControl.CommentID = Commons.shortGuid();
3301
                                    currentControl.IsNew = true;
3302
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3303
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3304

    
3305
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3306
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3307
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3308

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

    
3332
                                    CreateCommand.Instance.Execute(currentControl);
3333

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

    
3349
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3350
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3351
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3352
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3353
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3354

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

    
3358
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3359
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3360
                                        this.MainAngle.Visibility = Visibility.Visible;
3361

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

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

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

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

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

    
3446
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3447

    
3448
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3449

    
3450
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3451
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3452
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3453

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

    
3487
                                    currentControl = new ArrowTextControl()
3488
                                    {
3489
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3490
                                        ControlType = ControlType.ArrowTransTextBorderControl
3491

    
3492
                                    };
3493
                                        currentControl.CommentID = Commons.shortGuid();
3494
                                        currentControl.IsNew = true;
3495
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3496
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3497

    
3498
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3499

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

    
3510
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3511
                                        this.MainAngle.Visibility = Visibility.Visible;
3512
                                    
3513
                                    //20180911 LJY
3514
                                        (currentControl as ArrowTextControl).isTrans = true;
3515
                                    
3516

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

    
3552
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3553
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3554
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3555
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3556
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3557

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

    
3595
                                        };
3596
                                        currentControl.CommentID = Commons.shortGuid();
3597
                                        currentControl.IsNew = true; 
3598
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3599
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3600
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3601

    
3602
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3603
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3604
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3605
                                        (currentControl as ArrowTextControl).isFixed = true;
3606
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3607

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

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

    
3631
                                    if (_sign == null)
3632
                                    {
3633
                                        txtBatch.Visibility = Visibility.Collapsed;
3634
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3635
                                        controlType = ControlType.None;
3636

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

    
3642
                                    if (currentControl is SignControl)
3643
                                    {
3644
                                        //20180906 LJY TEST IsRotationDrawingEnable
3645
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3646
                                        {
3647
                                            return;
3648
                                        }
3649

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

    
3670
                                        currentControl.CommentID = Commons.shortGuid();
3671
                                        currentControl.IsNew = true;
3672
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3673
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3674

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

    
3696
                                        CreateCommand.Instance.Execute(currentControl);
3697
                                        (currentControl as RectangleControl).ApplyOverViewData();
3698
                                        currentControl = null;
3699
                                    
3700
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3701

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

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

    
3754
                                    currentControl.IsNew = true;
3755
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3756
                                    currentControl.CommentID = Commons.shortGuid();
3757
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3758

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

    
3780
                                        CreateCommand.Instance.Execute(currentControl);
3781
                                        currentControl = null;
3782
                                   
3783

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

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

    
3844
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3845
                            if (over != null)
3846
                            {
3847
                                mouseOff = true;
3848
                            }
3849
                        }
3850
                    }
3851

    
3852
                    if (!mouseOff)
3853
                    {
3854
                        SelectionSet.Instance.UnSelect(this);
3855
                    }
3856
                }
3857
                zoomAndPanControl.CaptureMouse();
3858
                e.Handled = true;
3859
            }
3860
        }
3861

    
3862
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3863
        {
3864
            ///mouseButtonDown = e.ChangedButton;
3865
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3866
        }
3867

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

    
3877
        private void RemovePointStroke(Point P)
3878
        {
3879
            foreach (Stroke hits in inkBoard.Strokes)
3880
            {
3881
                foreach (StylusPoint sty in hits.StylusPoints)
3882
                {
3883

    
3884
                }
3885
                if (hits.HitTest(P))
3886
                {
3887
                    inkBoard.Strokes.Remove(hits);
3888
                    return;
3889
                }
3890
            }
3891
        }
3892

    
3893
        private void StartNewStroke(Point P)
3894
        {
3895
            strokePoints = new StylusPointCollection();
3896
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3897
            strokePoints.Add(segment1Start);
3898
            stroke = new Stroke(strokePoints);
3899

    
3900
            stroke.DrawingAttributes.Color = Colors.Red;
3901
            stroke.DrawingAttributes.Width = 4;
3902
            stroke.DrawingAttributes.Height = 4;
3903

    
3904
            inkBoard.Strokes.Add(stroke);
3905
        }
3906

    
3907
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3908
        {
3909
            ConsolidationMethod();
3910
        }
3911

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

    
3925
                ViewerDataModel.Instance.IsConsolidate = true;
3926
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3927

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

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

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

    
3976
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3977
        {
3978
            TeamConsolidationMethod();
3979
        }
3980

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

    
3993
                    if (!App.ViewInfo.NewCommentPermission)
3994
                    {
3995
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3996
                    }
3997
                }
3998
                else
3999
                {
4000
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4001
                }
4002
            }
4003
        }
4004

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

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

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

    
4036
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4037
        {
4038
            UpdateMyMarkupList();
4039

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

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

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

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

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

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

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

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

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

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

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

    
4143
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4144
        {
4145

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

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

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

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

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

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

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

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

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

    
4224
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4225
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4226
                        }
4227

    
4228
                    }
4229
                    else
4230
                    {
4231
                        string uri = "";
4232

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

    
4242
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4243

    
4244
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4245
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4246
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4247

    
4248
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4249
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4250

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

    
4259
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4260
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4261
                            };
4262
                        }
4263
                    }
4264

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

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

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

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

    
4288
                }
4289
            }
4290
        }
4291

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

    
4298
                var uri = CurrentRev.TO_VENDOR;
4299

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

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

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

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

    
4343
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4344

    
4345
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4346
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4347
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4348

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

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

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

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

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

    
4405
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4406

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

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

    
4434
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4435
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4436
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4437

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

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

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

    
4473
        public void Sync_Event(VPRevision Currnet_Rev)
4474
        {
4475
            CurrentRev = Currnet_Rev;
4476

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

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

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

    
4509
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4510

    
4511
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4512

    
4513
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4514
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4515
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4516

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

    
4527

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

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

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

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

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

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

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

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

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

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

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

    
4656
                                    System.Drawing.Bitmap image;
4657

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

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

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

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

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

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

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

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

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

    
4804
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4805

    
4806
                List<SYMBOL_PUBLIC> symbol_Public;
4807

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

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

    
4847
                        byte[] Img_byte = fs.ToArray();
4848

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

    
4870
        public PngBitmapEncoder symImage(string data)
4871
        {
4872

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

    
4879
            BitmapEncoder encoder = new PngBitmapEncoder();
4880

    
4881

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

    
4884
            DrawingVisual dv = new DrawingVisual();
4885

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

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

    
4895
            try
4896
            {
4897
                renderBitmap.Render(dv);
4898

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

    
4909
            }
4910
            catch //(Exception ex)
4911
            {
4912
                return null;
4913
            }
4914

    
4915
        }
4916

    
4917
        public void DialogMessage_Alert(string content, string header)
4918
        {
4919
            var box = new TextBlock();
4920
            box.MinWidth = 400;
4921
            box.FontSize = 11;
4922
            //box.FontSize = 12;
4923
            box.Text = content;
4924
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4925

    
4926
            DialogParameters parameters = new DialogParameters()
4927
            {
4928
                Owner = Application.Current.MainWindow,
4929
                Content = box,
4930
                Header = header,
4931
                Theme = new VisualStudio2013Theme(),
4932
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4933
            };            
4934
            RadWindow.Alert(parameters);
4935
        }
4936

    
4937
        #region 캡쳐 기능
4938

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

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

    
4962
            byte[] pixels = CopyPixels(x, y, width, height);
4963

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

    
4966
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4967
        }
4968

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

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

    
4977
            return pixels;
4978
        }
4979

    
4980
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4981
        {
4982
            DrawingVisual drawingVisual = new DrawingVisual();
4983
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4984

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

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

    
4995
            target.Render(drawingVisual);
4996
            return target;
4997
        }
4998

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

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

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

    
5027
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5028

    
5029
            RadWindow CheckPop = new RadWindow();
5030
            //Alert check = new Alert(Msg);
5031

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

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

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

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

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

    
5115
        }
5116

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

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

    
5133
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5134
        {
5135
            multi_Undo_Data = new Multi_Undo_data();
5136

    
5137
            multi_Undo_Data.Markup = control;
5138

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

    
5156
            return multi_Undo_Data;
5157
        }
5158

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

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

    
5189
                    List<Point> inkPointSet = new List<Point>();
5190
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5191

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

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

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

    
5230
            return false;
5231
        }
5232

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

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

    
5243
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5244
        {
5245
            e.Effects = DragDropEffects.None;
5246
        }
5247

    
5248
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5249
        {
5250
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5251
        }
5252

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