프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 3ffd4b2d

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

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

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

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

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

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

    
271
            return false;
272
        }
273

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

    
297
            return false;
298
        }
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
            });
319

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

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

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

    
361
        /// <summary>
362
        /// delete selected comments
363
        /// </summary>
364
        /// <param name="sender"></param>
365
        /// <param name="e"></param>
366
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
367
        {
368
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
369
            SelectionSet.Instance.UnSelect(this);
370

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

    
374
            DeleteItem(item);
375
        }
376

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

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

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

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

    
410
        
411

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

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

    
427
            ////GC.Collect();
428
        }
429
        
430
        /// <summary>
431
        /// update my markuplist
432
        ///  - update existing markup data if already exist
433
        ///  - add new markup data if control is new
434
        /// </summary>
435
        public void UpdateMyMarkupList()
436
        {
437
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
438
            bool isComingNewBie = false;
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
                        ComingNewBieEnd = false;
453
                    }
454
                }
455
                else if (root.CommentID != null)
456
                {
457
                    isComingNewBie = true;
458
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
459
                    {
460
                        ID = control.CommentID,
461
                        Data = root.ConvertData,
462
                        Data_Type = root.DATA_TYPE,
463
                        MarkupInfoID = App.Custom_ViewInfoId,
464
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
465
                        Symbol_ID = control.SymbolID,
466
                        //Group_ID = control.GroupID,
467
                    });
468
                    ComingNewBieEnd = false;
469
                }
470
            }
471

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

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

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

    
500
        bool ComingNewBieEnd = false;
501

    
502
        /// <summary>
503
        /// start page changing
504
        ///  - save controls if page is modified
505
        ///  - starting download page image
506
        /// </summary>
507
        /// <param name="sender"></param>
508
        /// <param name="e"></param>
509
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
510
        {
511
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
512

    
513
            CompareMode.IsChecked = false;
514
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
515

    
516
            #region 페이지가 벗어난 경우
517

    
518
            if (BalancePoint < 1)
519
            {
520
                BalancePoint = 1;
521
                ViewerDataModel.Instance.PageBalanceNumber = 0;
522
            }
523

    
524
            if (pageNavigator.PageCount < BalancePoint)
525
            {
526
                BalancePoint = pageNavigator.PageCount;
527
                ViewerDataModel.Instance.PageBalanceNumber = 0;
528
            }
529

    
530
            #endregion
531

    
532
            ViewerDataModel.Instance.PageNumber = BalancePoint;
533

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

    
544
            var defaultBitmapImage = new BitmapImage();
545
            defaultBitmapImage.BeginInit();
546
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
547
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
548
            defaultBitmapImage.UriSource = new Uri(uri);
549
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
550
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
551
            defaultBitmapImage.EndInit();
552

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

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

    
576

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

    
582

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

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

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

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

    
639
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
640

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

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

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

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

    
680
        }
681

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

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

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

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

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

    
733

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

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

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

    
751
            SetCommentPages(true);
752
        }
753

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

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

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

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

    
814
        #region ZoomIn & ZoomOut
815

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

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

    
828

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

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

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

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

    
864
        }
865

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

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

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

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

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

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

    
918
        #endregion
919

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

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

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

    
932
        }
933

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

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

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

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

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

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

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

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

    
1100

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

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

    
1113

    
1114
               CreateDragDropWindow2(img);
1115
              
1116
    }
1117

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1506
                                //inkBoard.Strokes.Add(stroke);
1507
                            }
1508
                            break;
1509
                    }
1510
                    return;
1511
                }
1512
            }
1513
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1514
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1515
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1516
            {
1517
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1518

    
1519
                if (isDraggingSelectionRect)
1520
                {
1521
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1522
                    e.Handled = true;
1523
                }
1524
                else if (isLeftMouseButtonDownOnWindow)
1525
                {
1526
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1527
                    double dragDistance = Math.Abs(dragDelta.Length);
1528

    
1529
                    if (dragDistance > DragThreshold)
1530
                    {
1531
                        isDraggingSelectionRect = true;
1532
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1533
                    }
1534

    
1535
                    e.Handled = true;
1536
                }
1537

    
1538
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1539
                {
1540
                }
1541
                else
1542
                {
1543
                    e.Handled = true;
1544
                }
1545
            }
1546
            /*
1547
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1548
            { //symbol      
1549
                if(_dragdropWindow != null)
1550
                {
1551
                    Win32Point w32Mouse = new Win32Point();
1552
                    GetCursorPos(ref w32Mouse);
1553

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

    
1579
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1580
        {
1581
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1582
            {
1583
                SetCursor();
1584
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1585
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1586

    
1587
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1588

    
1589
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1590
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1591

    
1592
                if (Sync.IsChecked)
1593
                {
1594
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1595
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1596
                }
1597
            }
1598
        }
1599

    
1600
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1601

    
1602
        private EllipseGeometry hitArea = new EllipseGeometry();
1603

    
1604
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1605
        {
1606
            IsDrawing = false;
1607

    
1608
            if (mouseHandlingMode != MouseHandlingMode.None)
1609
            {
1610
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1611
                {
1612
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1613

    
1614
                    SetCursor();
1615

    
1616
                    switch (controlType)
1617
                    {
1618
                        case ControlType.None:
1619
                            break;
1620
                        case ControlType.Rectangle:
1621
                            {
1622

    
1623
                            }
1624
                            break;
1625
                        case ControlType.PenControl:
1626
                            {
1627

    
1628
                            }
1629
                            break;
1630
                        default:
1631
                            break;
1632
                    }
1633
                }
1634
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1635
                {
1636
                    if (isLeftMouseButtonDownOnWindow)
1637
                    {
1638
                        bool wasDragSelectionApplied = false;
1639

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

    
1659
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1660
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1661
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1662
                            }
1663
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1664
                            {
1665
                                ApplyDragSelectionRect();
1666
                            }
1667
                            else
1668
                            {
1669
                                double x = Canvas.GetLeft(dragZoomBorder);
1670
                                double y = Canvas.GetTop(dragZoomBorder);
1671
                                double width = dragZoomBorder.Width;
1672
                                double height = dragZoomBorder.Height;
1673
                                Rect dragRect = new Rect(x, y, width, height);
1674

    
1675
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1676

    
1677
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1678
                            }
1679

    
1680
                            isDraggingSelectionRect = false;
1681
                            e.Handled = true;
1682
                            wasDragSelectionApplied = true;
1683
                        }
1684

    
1685
                        if (isLeftMouseButtonDownOnWindow)
1686
                        {
1687
                            isLeftMouseButtonDownOnWindow = false;
1688
                            this.ReleaseMouseCapture();
1689
                            e.Handled = true;
1690
                        }
1691

    
1692
                        if (!wasDragSelectionApplied)
1693
                        {
1694
                            init();
1695
                        }
1696
                    }
1697
                }
1698
                else if (e.RightButton == MouseButtonState.Pressed)
1699
                {
1700
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1701
                    SetCursor();
1702
                }
1703

    
1704
                zoomAndPanControl.ReleaseMouseCapture();
1705

    
1706

    
1707
                e.Handled = true;
1708
            }
1709
            else
1710
            {
1711
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1712
                SetCursor();
1713
            }
1714

    
1715
            ///mouseButtonDown = MouseButton.Left;
1716
            //controlType = ControlType.SingleLine;
1717
        }
1718

    
1719
        public void Set_Symbol_Capture(Point endPoint)
1720
        {       
1721
            double x = canvasDrawingMouseDownPoint.X;
1722
            double y = canvasDrawingMouseDownPoint.Y;
1723
            if(x > endPoint.X)
1724
            {
1725
                x = endPoint.X;
1726
                y = endPoint.Y;
1727
            }
1728

    
1729
            double width = dragCaptureBorder.Width;
1730
            double height = dragCaptureBorder.Height;
1731

    
1732
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1733

    
1734
            if (x < 0)
1735
            {
1736
                width += x;
1737
                x = 0;
1738
            }
1739
            if (y < 0)
1740
            {
1741
                height += y;
1742
                y = 0;
1743

    
1744
                width = (int)canvasImage.PixelWidth - x;
1745
            }
1746
            if (x + width > canvasImage.PixelWidth)
1747
            {
1748
                width = (int)canvasImage.PixelWidth - x;
1749
            }
1750
            if (y + height > canvasImage.PixelHeight)
1751
            {
1752
                height = (int)canvasImage.PixelHeight - y;
1753
            }
1754
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1755

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

    
1768
            var defaultBitmapImage = new BitmapImage();
1769
            defaultBitmapImage.BeginInit();
1770
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1771
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1772
            defaultBitmapImage.UriSource = new Uri(uri);
1773
            defaultBitmapImage.EndInit();
1774

    
1775
            //GC.Collect();
1776

    
1777
            if (defaultBitmapImage.IsDownloading)
1778
            {
1779
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1780
                {
1781
                    defaultBitmapImage.Freeze();
1782
                    //GC.Collect();
1783
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1784
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1785
                };
1786
            }
1787
        }
1788

    
1789
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1790
        {
1791
            ///mouseButtonDown = MouseButton.Left;
1792
        }
1793

    
1794
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1795
        {
1796
            ///mouseButtonDown = MouseButton.Left;
1797
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1798
        }
1799

    
1800
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1801
        {
1802

    
1803
        }
1804

    
1805
        /// <summary>
1806
        /// select items by dragging
1807
        /// </summary>
1808
        private void ApplyDragSelectionRect()
1809
        {
1810
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1811

    
1812
            double x = Canvas.GetLeft(dragSelectionBorder);
1813
            double y = Canvas.GetTop(dragSelectionBorder);
1814
            double width = dragSelectionBorder.Width;
1815
            double height = dragSelectionBorder.Height;
1816
            Boolean Flag = false;
1817
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1818
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1819

    
1820
            Rect dragRect = new Rect(x, y, width, height);
1821
            ///dragRect.Inflate(width / 10, height / 10);
1822

    
1823
            foreach (var item in Items)
1824
            {
1825
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1826

    
1827
                if (Flag)
1828
                {
1829
                    adornerSet.Add(item);
1830
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1831
                    Control_Style(item);
1832
                }
1833
            }
1834
            if (adornerSet.Count > 0)
1835
            {
1836
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1837
                SelectLayer.Children.Add(final);
1838
            }
1839
        }
1840

    
1841
        private void InitDragSelectionRect(Point pt1, Point pt2)
1842
        {
1843
            //캡쳐 중
1844
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1845
            {
1846
                dragCaptureBorder.Visibility = Visibility.Visible;
1847
            }
1848
            //선택 중
1849
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1850
            {
1851

    
1852
                dragSelectionBorder.Visibility = Visibility.Visible;
1853
            }
1854
            else
1855
            {
1856
                dragZoomBorder.Visibility = Visibility.Visible;
1857
            }
1858
            UpdateDragSelectionRect(pt1, pt2);
1859
        }
1860

    
1861
        /// <summary>
1862
        /// Update the position and size of the rectangle used for drag selection.
1863
        /// </summary>
1864
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1865
        {
1866
            double x, y, width, height;
1867

    
1868
            //
1869
            // Determine x,y,width and height of the rect inverting the points if necessary.
1870
            // 
1871

    
1872
            if (pt2.X < pt1.X)
1873
            {
1874
                x = pt2.X;
1875
                width = pt1.X - pt2.X;
1876
            }
1877
            else
1878
            {
1879
                x = pt1.X;
1880
                width = pt2.X - pt1.X;
1881
            }
1882

    
1883
            if (pt2.Y < pt1.Y)
1884
            {
1885
                y = pt2.Y;
1886
                height = pt1.Y - pt2.Y;
1887
            }
1888
            else
1889
            {
1890
                y = pt1.Y;
1891
                height = pt2.Y - pt1.Y;
1892
            }
1893

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

    
1922
        private void drawingPannelRotate(double angle)
1923
        {
1924
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1925
            rotate.Angle = angle;
1926
            var rotationNum = Math.Abs((rotate.Angle / 90));
1927

    
1928
            if (angle == 90 || angle == 270)
1929
            {
1930
                double emptySize = zoomAndPanCanvas.Width;
1931
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1932
                zoomAndPanCanvas.Height = emptySize;
1933
            }
1934
            if (angle == 0)
1935
            {
1936
                translate.X = 0;
1937
                translate.Y = 0;
1938
            }
1939
            else if (angle == 90)
1940
            {
1941
                translate.X = zoomAndPanCanvas.Width;
1942
                translate.Y = 0;
1943
            }
1944
            else if (angle == 180)
1945
            {
1946
                translate.X = zoomAndPanCanvas.Width;
1947
                translate.Y = zoomAndPanCanvas.Height;
1948
            }
1949
            else
1950
            {
1951
                translate.X = 0;
1952
                translate.Y = zoomAndPanCanvas.Height;
1953
            }
1954

    
1955
            zoomAndPanControl.RotationAngle = rotate.Angle;
1956

    
1957

    
1958
            if (!testPanel2.IsHidden)
1959
            {
1960
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1961
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1962
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1963
            }
1964

    
1965
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1966
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1967
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1968
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1969
            ViewerDataModel.Instance.Angle = rotate.Angle;
1970
        }
1971

    
1972
        private void syncPannelRotate(double angle)
1973
        {
1974
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1975
            rotate.Angle = angle;
1976
            var rotationNum = Math.Abs((rotate.Angle / 90));
1977

    
1978
            if (angle == 90 || angle == 270)
1979
            {
1980
                double emptySize = zoomAndPanCanvas2.Width;
1981
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
1982
                zoomAndPanCanvas2.Height = emptySize;
1983
            }
1984
            if (angle == 0)
1985
            {
1986
                translate2.X = 0;
1987
                translate2.Y = 0;
1988
            }
1989
            else if (angle == 90)
1990
            {
1991
                translate2.X = zoomAndPanCanvas2.Width;
1992
                translate2.Y = 0;
1993
            }
1994
            else if (angle == 180)
1995
            {
1996
                translate2.X = zoomAndPanCanvas2.Width;
1997
                translate2.Y = zoomAndPanCanvas2.Height;
1998
            }
1999
            else
2000
            {
2001
                translate2.X = 0;
2002
                translate2.Y = zoomAndPanCanvas2.Height;
2003
            }
2004

    
2005
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2006
        }
2007

    
2008
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2009
        {
2010
            string Data_ = "";
2011

    
2012
            try
2013
            {
2014
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2015
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2016
                if (Data_ != null || Data_ != "")
2017
                {
2018
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2019
                }
2020
                else
2021
                {
2022
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2023
                }
2024

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

    
2051
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2052
                    {
2053
                        PointSet = new List<Point>(),
2054
                        FilePath = Data_,
2055
                        ImageData = img.Source,
2056
                        StartPoint = canvasZoomPanningMouseDownPoint,
2057
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2058
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2059
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2060
                        canvasZoomPanningMouseDownPoint.Y),
2061
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2062
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2063
                    };
2064

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

    
2085
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2086
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2087
                    UndoData.Markup_List.Add(multi_Undo_Data);
2088
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2089

    
2090
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2091
                    currentControl.CommentID = Commons.shortGuid();
2092
                    currentControl.SymbolID = id;
2093
                    currentControl.GroupID = group_id;
2094
                    currentControl.ApplyTemplate();
2095
                    currentControl.SetImage();
2096

    
2097
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2098
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2099
                    SelectLayer.Children.Add(final);
2100
                }
2101
            }
2102
            catch (Exception ex)
2103
            {
2104
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2105
            }
2106
        }
2107

    
2108
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2109
        {            
2110
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2111
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2112
            {
2113
                set_option.Value = double.Parse(set_option.ContentText);
2114
            }
2115

    
2116
            ConvertInkControlToPolygon();
2117

    
2118
            ///TODO:
2119
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2120
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2121

    
2122
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2123
            {
2124
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2125
            }
2126
            /// up to here
2127

    
2128
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2129
            {
2130
                if (arrow_text as ArrowTextControl != null)
2131
                {
2132
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2133
                }
2134
            }
2135

    
2136
            //if (currentControl != null)
2137
            {
2138
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2139
                if (text_item_ != null)
2140
                {
2141
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2142
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2143
                    (text_item_ as TextControl).EnableEditing = false;
2144
                    currentControl = null;
2145
                }
2146

    
2147
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2148
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2149
                {
2150
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2151
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2152
                    currentControl = null;
2153
                }
2154
            }
2155

    
2156
            double Ang = 0;                                          
2157
            if (rotate.Angle != 0)
2158
            {
2159
                Ang = 360 - rotate.Angle;
2160
            }
2161

    
2162
            if (e.OriginalSource is System.Windows.Controls.Image)
2163
            {
2164
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2165
            }
2166
            /*
2167
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2168
            {                
2169
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2170
                if(symbol_id != null)
2171
                {
2172
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2173
                }                
2174
            }
2175

    
2176
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2177
            {
2178
                if (this._dragdropWindow != null)
2179
                {
2180
                    this._dragdropWindow.Close();
2181
                    this._dragdropWindow = null;
2182
                    symbol_id = null;
2183
                }
2184
            }
2185
            */
2186

    
2187
            if (e.LeftButton == MouseButtonState.Pressed)
2188
            {
2189
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2190
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2191

    
2192
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2193
                SetCursor();
2194

    
2195
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2196
            }
2197

    
2198
            if (e.MiddleButton == MouseButtonState.Pressed)
2199
            {
2200
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2201
                cursor = Cursors.SizeAll;
2202
                SetCursor();
2203
            }
2204
            if (e.RightButton == MouseButtonState.Pressed)
2205
            {
2206
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2207
                cursor = Cursors.SizeAll;
2208
                SetCursor();
2209
            }
2210
            else if (e.XButton1 == MouseButtonState.Pressed)
2211
            {
2212
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2213
                {
2214
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2215
                }
2216

    
2217
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2218

    
2219
            }
2220
            else if (e.XButton2 == MouseButtonState.Pressed)
2221
            {
2222
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2223
                {
2224
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2225
                }
2226
            }
2227

    
2228
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2229
            {
2230
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2231
                {
2232
                    if (SelectLayer.Children.Count == 0)
2233
                    {
2234
                        isLeftMouseButtonDownOnWindow = true;
2235
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2236
                    }
2237

    
2238
                    if (controlType == ControlType.None)
2239
                    {
2240
                        isLeftMouseButtonDownOnWindow = true;
2241
                    }
2242
                }
2243

    
2244
                /// 캡쳐 모드 설정
2245
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2246
                {
2247
                    dragCaptureBorder.Visibility = Visibility.Visible;
2248
                    isLeftMouseButtonDownOnWindow = true;
2249
                }
2250

    
2251
                /// 줌 모드 설정
2252
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2253
                {
2254
                    isLeftMouseButtonDownOnWindow = true;
2255
                }
2256

    
2257
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2258
                if (control != null)
2259
                {
2260
                    AdornerFinal final = null;
2261

    
2262
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2263
                    {
2264
                        /// 기존 selection 해제
2265
                        SelectionSet.Instance.UnSelect(this);
2266

    
2267
                        final = new AdornerFinal(control);
2268

    
2269
                        this.Control_Style(control);
2270

    
2271
                        if ((control as IPath) != null)
2272
                        {
2273
                            if ((control as IPath).LineSize != 0)
2274
                            {
2275
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2276
                            }
2277
                        }
2278
                        if ((control as IShapeControl) != null)
2279
                        {
2280
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2281
                            {
2282
                                ViewerDataModel.Instance.checkHatchShape = true;
2283
                            }
2284
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2285
                            {
2286
                                ViewerDataModel.Instance.checkFillShape = true;
2287
                            }
2288
                            else
2289
                            {
2290
                                ViewerDataModel.Instance.checkHatchShape = false;
2291
                                ViewerDataModel.Instance.checkFillShape = false;
2292
                            }
2293
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2294
                        }
2295

    
2296
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2297

    
2298
                        if ((control as TextControl) != null)
2299
                        {
2300
                            if(!((control as TextControl).EnableEditing)) {
2301
                                (control as TextControl).EnableEditing = true;
2302
                            }
2303

    
2304
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2305
                            {
2306
                                ViewerDataModel.Instance.checkTextStyle = true;
2307
                            }
2308
                            else
2309
                            {
2310
                                ViewerDataModel.Instance.checkTextStyle = false;
2311
                            }
2312

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

    
2340
                        }
2341
                        else if ((control as ArrowTextControl) != null)
2342
                        {
2343
                            if (!((control as ArrowTextControl).EnableEditing))
2344
                            {
2345
                                (control as ArrowTextControl).EnableEditing = true;
2346
                            }
2347
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2348
                            {
2349
                                ViewerDataModel.Instance.checkTextStyle = true;
2350
                            }
2351
                            else
2352
                            {
2353
                                ViewerDataModel.Instance.checkTextStyle = false;
2354
                            }
2355

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

    
2398
                        Control_Style(control);
2399

    
2400
                        final = new AdornerFinal(comment);
2401
                    }
2402

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

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

    
2459
                                    CreateCommand.Instance.Execute(currentControl);
2460

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

    
2484
                                        currentControl.CommentID = Commons.shortGuid();
2485
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2486
                                        currentControl.IsNew = true;
2487

    
2488
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2489

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

    
2507
                                    CreateCommand.Instance.Execute(currentControl);
2508

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

    
2521
                                    currentControl.CommentID = Commons.shortGuid();
2522
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2523
                                    currentControl.IsNew = true;
2524
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2525

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

    
2542
                                    CreateCommand.Instance.Execute(currentControl);
2543

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

    
2556
                                    currentControl.CommentID = Commons.shortGuid();
2557
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2558
                                    currentControl.IsNew = true;
2559
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2560

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

    
2577
                                    CreateCommand.Instance.Execute(currentControl);
2578

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

    
2591
                                    currentControl.CommentID = Commons.shortGuid();
2592
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2593
                                    currentControl.IsNew = true;
2594
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2595

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

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

    
2626
                                    currentControl.CommentID = Commons.shortGuid();
2627
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2628
                                    currentControl.IsNew = true;
2629
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2630

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

    
2648
                                    CreateCommand.Instance.Execute(currentControl);
2649

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

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

    
2683
                                    CreateCommand.Instance.Execute(currentControl);
2684

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

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

    
2723
                                        CreateCommand.Instance.Execute(currentControl);
2724

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

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

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

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

    
2788
                                if (e.RightButton == MouseButtonState.Pressed)
2789
                                {
2790
                                    control.IsCompleted = true;
2791
                                }
2792

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

    
2805
                                    var firstPoint = control.PointSet.First();
2806
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2807
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2808
                                    control.PointSet.Add(firstPoint);
2809

    
2810
                                    control.ApplyOverViewData();
2811

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

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

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

    
2855
                                    CreateCommand.Instance.Execute(currentControl);
2856

    
2857
                                    currentControl = null;
2858
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2859
                                    return;
2860
                                }
2861

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

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

    
2912
                                    CreateCommand.Instance.Execute(currentControl);
2913

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

    
2955
                                    CreateCommand.Instance.Execute(currentControl);
2956

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

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

    
3015
                                            CreateCommand.Instance.Execute(currentControl);
3016

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

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

    
3060
                                    CreateCommand.Instance.Execute(currentControl);
3061

    
3062
                                    control.isTransOn = true;
3063
                                    var firstPoint = control.PointSet.First();
3064

    
3065
                                    control.PointSet.Add(firstPoint);
3066
                                    control.DrawingCloud();
3067
                                    control.ApplyOverViewData();
3068

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

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

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

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

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

    
3153
                                        
3154
                                                currentControl.CommentID = Commons.shortGuid();                                            
3155
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3156
                                                currentControl.IsNew = true;
3157
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3158

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

    
3181
                                        CreateCommand.Instance.Execute(currentControl);
3182
                                        currentControl = null;
3183

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

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

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

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

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

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

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

    
3293
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3294
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3295
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3296

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

    
3320
                                    CreateCommand.Instance.Execute(currentControl);
3321

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

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

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

    
3346
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3347
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3348
                                        this.MainAngle.Visibility = Visibility.Visible;
3349

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

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

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

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

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

    
3434
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3435

    
3436
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3437

    
3438
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3439
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3440
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3441

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

    
3475
                                    currentControl = new ArrowTextControl()
3476
                                    {
3477
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3478
                                        ControlType = ControlType.ArrowTransTextBorderControl
3479

    
3480
                                    };
3481
                                        currentControl.CommentID = Commons.shortGuid();
3482
                                        currentControl.IsNew = true;
3483
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3484
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3485

    
3486
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3487

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

    
3498
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3499
                                        this.MainAngle.Visibility = Visibility.Visible;
3500
                                    
3501
                                    //20180911 LJY
3502
                                        (currentControl as ArrowTextControl).isTrans = true;
3503
                                    
3504

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

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

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

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

    
3590
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3591
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3592
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3593
                                        (currentControl as ArrowTextControl).isFixed = true;
3594
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3595

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

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

    
3619
                                    if (_sign == null)
3620
                                    {
3621
                                        txtBatch.Visibility = Visibility.Collapsed;
3622
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3623
                                        controlType = ControlType.None;
3624

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

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

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

    
3658
                                        currentControl.CommentID = Commons.shortGuid();
3659
                                        currentControl.IsNew = true;
3660
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3661
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3662

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

    
3684
                                        CreateCommand.Instance.Execute(currentControl);
3685
                                        (currentControl as RectangleControl).ApplyOverViewData();
3686
                                        currentControl = null;
3687
                                    
3688
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3689

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

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

    
3742
                                    currentControl.IsNew = true;
3743
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3744
                                    currentControl.CommentID = Commons.shortGuid();
3745
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3746

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

    
3768
                                        CreateCommand.Instance.Execute(currentControl);
3769
                                        currentControl = null;
3770
                                   
3771

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

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

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

    
3840
                    if (!mouseOff)
3841
                    {
3842
                        SelectionSet.Instance.UnSelect(this);
3843
                    }
3844
                }
3845
                zoomAndPanControl.CaptureMouse();
3846
                e.Handled = true;
3847
            }
3848
        }
3849

    
3850
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3851
        {
3852
            ///mouseButtonDown = e.ChangedButton;
3853
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3854
        }
3855

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

    
3865
        private void RemovePointStroke(Point P)
3866
        {
3867
            foreach (Stroke hits in inkBoard.Strokes)
3868
            {
3869
                foreach (StylusPoint sty in hits.StylusPoints)
3870
                {
3871

    
3872
                }
3873
                if (hits.HitTest(P))
3874
                {
3875
                    inkBoard.Strokes.Remove(hits);
3876
                    return;
3877
                }
3878
            }
3879
        }
3880

    
3881
        private void StartNewStroke(Point P)
3882
        {
3883
            strokePoints = new StylusPointCollection();
3884
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3885
            strokePoints.Add(segment1Start);
3886
            stroke = new Stroke(strokePoints);
3887

    
3888
            stroke.DrawingAttributes.Color = Colors.Red;
3889
            stroke.DrawingAttributes.Width = 4;
3890
            stroke.DrawingAttributes.Height = 4;
3891

    
3892
            inkBoard.Strokes.Add(stroke);
3893
        }
3894

    
3895
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3896
        {
3897
            ConsolidationMethod();
3898
        }
3899

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

    
3913
                ViewerDataModel.Instance.IsConsolidate = true;
3914
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3915

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

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

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

    
3964
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3965
        {
3966
            TeamConsolidationMethod();
3967
        }
3968

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

    
3981
                    if (!App.ViewInfo.NewCommentPermission)
3982
                    {
3983
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3984
                    }
3985
                }
3986
                else
3987
                {
3988
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3989
                }
3990
            }
3991
        }
3992

    
3993
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3994
        {
3995
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3996
            if (item != null)
3997
            {
3998
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3999

    
4000
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4001
            }
4002
            else
4003
            {
4004
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4005
            }
4006
        }
4007

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4221
                        if (userData.COMPANY != "EXT")
4222
                        {
4223
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4224
                        }
4225
                        else
4226
                        {
4227
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4228
                        }
4229

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

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

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

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

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

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

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

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

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

    
4276
                }
4277
            }
4278
        }
4279

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

    
4286
                var uri = CurrentRev.TO_VENDOR;
4287

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

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

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

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

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

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

    
4337
                if (defaultBitmapImage_Compare.IsDownloading)
4338
                {
4339
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4340
                    {
4341
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4342
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4343
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4344
                    };
4345
                }
4346
                zoomAndPanControl2.ApplyTemplate();
4347
                zoomAndPanControl2.UpdateLayout();
4348
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4349
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4350
            }
4351
        }
4352

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

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

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

    
4383
                        string uri = "";
4384
                        if (userData.COMPANY != "EXT")
4385
                        {
4386
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4387
                        }
4388
                        else
4389
                        {
4390
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4391
                        }
4392

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

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

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

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

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

    
4431
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4432
                };
4433
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4434
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4435
            }
4436
        }
4437
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4438
        {
4439
            try
4440
            {
4441
                if (sender is RadButton)
4442
                {
4443
                    if ((sender as RadButton).Tag != null)
4444
                    {
4445
                        var url = (sender as RadButton).Tag.ToString();
4446
                        System.Diagnostics.Process.Start(url);
4447
                    }
4448
                    else
4449
                    {
4450
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4451
                    }
4452
                }
4453
            }
4454
            catch (Exception ex)
4455
            {
4456
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4457
            }
4458
        }
4459

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

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

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

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

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

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

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

    
4504
                    if (defaultBitmapImage_Compare.IsDownloading)
4505
                    {
4506
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4507
                        {
4508
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4509
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4510
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4511
                        };
4512
                    }
4513

    
4514

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

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

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

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

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

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

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

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

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

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

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

    
4643
                                    System.Drawing.Bitmap image;
4644

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

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

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

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

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

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

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

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

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

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

    
4793
                List<SYMBOL_PUBLIC> symbol_Public;
4794

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

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

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

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

    
4857
        public PngBitmapEncoder symImage(string data)
4858
        {
4859

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

    
4866
            BitmapEncoder encoder = new PngBitmapEncoder();
4867

    
4868

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

    
4871
            DrawingVisual dv = new DrawingVisual();
4872

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

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

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

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

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

    
4902
        }
4903

    
4904
        public void DialogMessage_Alert(string content, string header)
4905
        {
4906
            var box = new TextBlock();
4907
            box.MinWidth = 400;
4908
            box.FontSize = 11;
4909
            //box.FontSize = 12;
4910
            box.Text = content;
4911
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4912

    
4913
            DialogParameters parameters = new DialogParameters()
4914
            {
4915
                Owner = Application.Current.MainWindow,
4916
                Content = box,
4917
                Header = header,
4918
                Theme = new VisualStudio2013Theme(),
4919
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4920
            };            
4921
            RadWindow.Alert(parameters);
4922
        }
4923

    
4924
        #region 캡쳐 기능
4925

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

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

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

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

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

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

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

    
4964
            return pixels;
4965
        }
4966

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

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

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

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

    
4986
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4987
        {
4988
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4989
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4990
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4991
            bmp.UnlockBits(data);
4992
            return bmp;
4993
        }
4994
        public string symbolname = null;
4995
        public bool symbolsvg = true;
4996
        public bool symbolpng = true;
4997

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

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

    
5014
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5015

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

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

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

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

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

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

    
5102
        }
5103

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

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

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

    
5124
            multi_Undo_Data.Markup = control;
5125

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

    
5143
            return multi_Undo_Data;
5144
        }
5145

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

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

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

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

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

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

    
5217
            return false;
5218
        }
5219

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

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

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

    
5235
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5236
        {
5237
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5238
        }
5239

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