프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 62fa27ec

이력 | 보기 | 이력해설 | 다운로드 (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
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
370
            SelectionSet.Instance.UnSelect(this);
371

    
372
            Button content = (sender as Button);
373
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
374

    
375
            DeleteItem(item);
376
        }
377

    
378
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
379

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

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

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

    
411
        
412

    
413
        private void timercallback(Object o)
414
        {
415
            Stopwatch sw = new Stopwatch();
416
            sw.Start();
417
            TempFile.TempFileAdd();
418
            sw.Stop();
419

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

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

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

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

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

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

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

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

    
509
            #region 페이지가 벗어난 경우
510

    
511
            if (BalancePoint < 1)
512
            {
513
                BalancePoint = 1;
514
                ViewerDataModel.Instance.PageBalanceNumber = 0;
515
            }
516

    
517
            if (pageNavigator.PageCount < BalancePoint)
518
            {
519
                BalancePoint = pageNavigator.PageCount;
520
                ViewerDataModel.Instance.PageBalanceNumber = 0;
521
            }
522

    
523
            #endregion
524

    
525
            ViewerDataModel.Instance.PageNumber = BalancePoint;
526

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

    
537
            var defaultBitmapImage = new BitmapImage();
538
            defaultBitmapImage.BeginInit();
539
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
540
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
541
            defaultBitmapImage.UriSource = new Uri(uri);
542
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
543
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
544
            defaultBitmapImage.EndInit();
545

    
546
            ViewerDataModel.Instance.ImageViewPath = null;
547
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
548
            if (defaultBitmapImage.IsDownloading)
549
            {
550
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
551
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
552
                {                   
553
                    defaultBitmapImage.Freeze();                                        
554
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
555
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
556
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
557
                    mainPanel.UpdateLayout();
558
                    this.pageNavigator.ChangePage(e.PageNumber); 
559
                    
560
                    //image dispose
561
                    defaultBitmapImage = null;
562
                    GC.Collect();
563
                };
564
            }
565

    
566
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
567
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
568

    
569

    
570
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
571
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
572
            inkBoard.Width = zoomAndPanCanvas.Width;
573
            inkBoard.Height = zoomAndPanCanvas.Height;
574

    
575

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

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

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

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

    
632
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
633

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

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

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

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

    
673
        }
674

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

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

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

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

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

    
726

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

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

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

    
744
            SetCommentPages(true);
745
        }
746

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

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

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

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

    
811
        #region ZoomIn & ZoomOut
812

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

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

    
825

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

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

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

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

    
861
        }
862

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

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

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

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

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

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

    
915
        #endregion
916

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

    
922
                ControlList.Clear();
923
                listBox.Items.Clear();
924
                selected_item.Clear();
925

    
926
                (item as IMarkupCommonData).IsSelected = false;
927
            }
928

    
929
        }
930

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

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

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

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

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

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

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

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

    
1097

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

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

    
1110

    
1111
               CreateDragDropWindow2(img);
1112
              
1113
    }
1114

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

    
1135
            Win32Point w32Mouse = new Win32Point();
1136
            GetCursorPos(ref w32Mouse);
1137

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

    
1150
                Point currentPos = e.GetPosition(rect);
1151

    
1152
                floatingTip.HorizontalOffset = currentPos.X + 20;
1153
                floatingTip.VerticalOffset = currentPos.Y;
1154
            }
1155

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

    
1164
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1165
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1166
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1167

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1541
                    e.Handled = true;
1542
                }
1543

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

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

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

    
1593
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1594

    
1595
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1596
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1597

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

    
1606
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1607

    
1608
        private EllipseGeometry hitArea = new EllipseGeometry();
1609

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

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

    
1620
                    SetCursor();
1621

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

    
1629
                            }
1630
                            break;
1631
                        case ControlType.PenControl:
1632
                            {
1633

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

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

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

    
1681
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1682

    
1683
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1684
                            }
1685

    
1686
                            isDraggingSelectionRect = false;
1687
                            e.Handled = true;
1688
                            wasDragSelectionApplied = true;
1689
                        }
1690

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

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

    
1710
                zoomAndPanControl.ReleaseMouseCapture();
1711

    
1712

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

    
1721
            ///mouseButtonDown = MouseButton.Left;
1722
            //controlType = ControlType.SingleLine;
1723
        }
1724

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

    
1735
            double width = dragCaptureBorder.Width;
1736
            double height = dragCaptureBorder.Height;
1737

    
1738
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1739

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

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

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

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

    
1781
            //GC.Collect();
1782

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

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

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

    
1806
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1807
        {
1808

    
1809
        }
1810

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1961
            zoomAndPanControl.RotationAngle = rotate.Angle;
1962

    
1963

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

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

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

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

    
2011
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2012
        }
2013

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

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

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

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

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

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

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

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

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

    
2122
            ConvertInkControlToPolygon();
2123

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

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

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

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

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

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

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

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

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

    
2198
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2199
                SetCursor();
2200

    
2201
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2202
            }
2203

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

    
2223
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2224

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

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

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

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

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

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

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

    
2273
                        final = new AdornerFinal(control);
2274

    
2275
                        this.Control_Style(control);
2276

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

    
2302
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2303

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

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

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

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

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

    
2404
                        Control_Style(control);
2405

    
2406
                        final = new AdornerFinal(comment);
2407
                    }
2408

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

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

    
2465
                                    CreateCommand.Instance.Execute(currentControl);
2466

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

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

    
2494
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2495

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

    
2513
                                    CreateCommand.Instance.Execute(currentControl);
2514

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

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

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

    
2548
                                    CreateCommand.Instance.Execute(currentControl);
2549

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

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

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

    
2583
                                    CreateCommand.Instance.Execute(currentControl);
2584

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

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

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

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

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

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

    
2654
                                    CreateCommand.Instance.Execute(currentControl);
2655

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

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

    
2689
                                    CreateCommand.Instance.Execute(currentControl);
2690

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

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

    
2729
                                        CreateCommand.Instance.Execute(currentControl);
2730

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

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

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

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

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

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

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

    
2816
                                    control.ApplyOverViewData();
2817

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

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

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

    
2861
                                    CreateCommand.Instance.Execute(currentControl);
2862

    
2863
                                    currentControl = null;
2864
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2865
                                    return;
2866
                                }
2867

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

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

    
2918
                                    CreateCommand.Instance.Execute(currentControl);
2919

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

    
2961
                                    CreateCommand.Instance.Execute(currentControl);
2962

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

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

    
3021
                                            CreateCommand.Instance.Execute(currentControl);
3022

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

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

    
3066
                                    CreateCommand.Instance.Execute(currentControl);
3067

    
3068
                                    control.isTransOn = true;
3069
                                    var firstPoint = control.PointSet.First();
3070

    
3071
                                    control.PointSet.Add(firstPoint);
3072
                                    control.DrawingCloud();
3073
                                    control.ApplyOverViewData();
3074

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

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

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

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

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

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

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

    
3187
                                        CreateCommand.Instance.Execute(currentControl);
3188
                                        currentControl = null;
3189

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

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

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

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

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

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

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

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

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

    
3326
                                    CreateCommand.Instance.Execute(currentControl);
3327

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

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

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

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

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

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

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

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

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

    
3440
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3441

    
3442
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3443

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

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

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

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

    
3492
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3493

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3774
                                        CreateCommand.Instance.Execute(currentControl);
3775
                                        currentControl = null;
3776
                                   
3777

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

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

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

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

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

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

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

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

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

    
3894
            stroke.DrawingAttributes.Color = Colors.Red;
3895
            stroke.DrawingAttributes.Width = 4;
3896
            stroke.DrawingAttributes.Height = 4;
3897

    
3898
            inkBoard.Strokes.Add(stroke);
3899
        }
3900

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

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

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

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

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

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

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

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

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

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

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

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

    
4030
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4031
        {
4032
            UpdateMyMarkupList();
4033

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

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

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

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

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

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

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

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

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

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

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

    
4137
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4138
        {
4139

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

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

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

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

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

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

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

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

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

    
4218
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4219
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4220
                        }
4221

    
4222
                    }
4223
                    else
4224
                    {
4225
                        string uri = "";
4226

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

    
4236
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4237

    
4238
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4239
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4240
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4241

    
4242
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4243
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4244

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

    
4253
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4254
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4255
                            };
4256
                        }
4257
                    }
4258

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

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

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

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

    
4282
                }
4283
            }
4284
        }
4285

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

    
4292
                var uri = CurrentRev.TO_VENDOR;
4293

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

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

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

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

    
4337
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4338

    
4339
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4340
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4341
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4342

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

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

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

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

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

    
4399
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4400

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

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

    
4428
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4429
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4430
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4431

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

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

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

    
4467
        public void Sync_Event(VPRevision Currnet_Rev)
4468
        {
4469
            CurrentRev = Currnet_Rev;
4470

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

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

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

    
4503
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4504

    
4505
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4506

    
4507
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4508
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4509
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4510

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

    
4521

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

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

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

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

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

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

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

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

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

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

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

    
4650
                                    System.Drawing.Bitmap image;
4651

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

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

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

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

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

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

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

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

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

    
4798
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4799

    
4800
                List<SYMBOL_PUBLIC> symbol_Public;
4801

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

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

    
4841
                        byte[] Img_byte = fs.ToArray();
4842

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

    
4864
        public PngBitmapEncoder symImage(string data)
4865
        {
4866

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

    
4873
            BitmapEncoder encoder = new PngBitmapEncoder();
4874

    
4875

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

    
4878
            DrawingVisual dv = new DrawingVisual();
4879

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

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

    
4889
            try
4890
            {
4891
                renderBitmap.Render(dv);
4892

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

    
4903
            }
4904
            catch //(Exception ex)
4905
            {
4906
                return null;
4907
            }
4908

    
4909
        }
4910

    
4911
        public void DialogMessage_Alert(string content, string header)
4912
        {
4913
            var box = new TextBlock();
4914
            box.MinWidth = 400;
4915
            box.FontSize = 11;
4916
            //box.FontSize = 12;
4917
            box.Text = content;
4918
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4919

    
4920
            DialogParameters parameters = new DialogParameters()
4921
            {
4922
                Owner = Application.Current.MainWindow,
4923
                Content = box,
4924
                Header = header,
4925
                Theme = new VisualStudio2013Theme(),
4926
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4927
            };            
4928
            RadWindow.Alert(parameters);
4929
        }
4930

    
4931
        #region 캡쳐 기능
4932

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

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

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

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

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

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

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

    
4971
            return pixels;
4972
        }
4973

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

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

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

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

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

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

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

    
5021
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5022

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

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

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

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

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

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

    
5109
        }
5110

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

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

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

    
5131
            multi_Undo_Data.Markup = control;
5132

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

    
5150
            return multi_Undo_Data;
5151
        }
5152

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

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

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

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

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

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

    
5224
            return false;
5225
        }
5226

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

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

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

    
5242
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5243
        {
5244
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5245
        }
5246

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