프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (245 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
            //InitializeComponent();    
240
            this.Loaded += MainMenu_Loaded;
241
        }
242

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

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

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

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

    
270
            return false;
271
        }
272

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

    
296
            return false;
297
        }
298

    
299

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

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

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

    
314
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
315
            {
316
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
317
            });
318

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

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

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

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

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

    
373
            DeleteItem(item);
374
        }
375

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

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

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

    
397
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
398
                {
399
                    this.SymbolPane.Visibility = Visibility.Collapsed;
400
                    this.FavoritePane.Visibility = Visibility.Collapsed;
401
                    this.drawingRotateCanvas.IsHitTestVisible = false;
402
                }
403
            }
404
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
405
        }
406

    
407
        private void timercallback(Object o)
408
        {
409
            Stopwatch sw = new Stopwatch();
410
            sw.Start();
411
            TempFile.TempFileAdd();
412
            sw.Stop();
413

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

    
422
            ////GC.Collect();
423
        }
424
        
425
        /// <summary>
426
        /// update my markuplist
427
        ///  - update existing markup data if already exist
428
        ///  - add new markup data if control is new
429
        /// </summary>
430
        public void UpdateMyMarkupList()
431
        {
432
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
433
            bool isComingNewBie = false;
434

    
435
            /// add or update markup list
436
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
437
            {
438
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
439

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

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

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

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

    
495
        bool ComingNewBieEnd = false;
496

    
497
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
498
        {
499
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
500
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
501
            {
502
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
503
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
504
            }
505
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
506
            ViewerDataModel.Instance.UndoDataList.Clear();
507

    
508
            ConvertInkControlToPolygon();
509

    
510
            SelectionSet.Instance.UnSelect(this);
511
            UpdateMyMarkupList();
512

    
513
            Logger.sendCheckLog("pageNavigator_PageChanging_변수생성 및 값 설정", 1);
514
            CompareMode.IsChecked = false;
515
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
516

    
517

    
518
            #region 페이지가 벗어난 경우
519

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

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

    
532
            #endregion
533

    
534
            ViewerDataModel.Instance.PageNumber = BalancePoint;
535

    
536
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
537
            string uri = "";
538
            if (userData.COMPANY != "EXT")
539
            {
540
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
541
            }
542
            else
543
            {
544
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
545
            }
546

    
547
            var defaultBitmapImage = new BitmapImage();
548
            defaultBitmapImage.BeginInit();
549
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
550
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
551
            defaultBitmapImage.UriSource = new Uri(uri);
552
            defaultBitmapImage.EndInit();
553

    
554
            ViewerDataModel.Instance.ImageViewPath = null;
555
            GC.Collect();
556

    
557
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
558
            if (defaultBitmapImage.IsDownloading)
559
            {
560
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
561
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
562
                {
563
                    defaultBitmapImage.Freeze();
564
                    mainPanel.UpdateLayout();
565
                    GC.Collect();
566
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
567
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
568
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
569
                };
570
            }
571

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

    
575

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

    
581

    
582

    
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(new Uri(uri2));
631

    
632
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
633
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
634
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
635
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
636
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
637
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
638

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

    
648
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
649
                    if (defaultBitmapImage_Compare.IsDownloading)
650
                    {
651
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
652
                        {
653
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
654
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
655
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
656
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
657

    
658
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
659
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
660

    
661
                            zoomAndPanControl.ZoomTo(new Rect
662
                            {
663
                                X = 0,
664
                                Y = 0,
665
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
666
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
667
                            });
668
                        };
669
                    }
670
                }
671
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
672
            }
673

    
674
            this.pageNavigator.SetNextPage();
675

    
676
            if (zoomAndPanCanvas2.Width.IsNaN())
677
            {
678
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
679
            }
680

    
681
            Logger.sendCheckLog("-- pageNavigator_PageChanging_ControlData Setting --", 1);
682
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
683
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
684

    
685
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
686
            foreach (var info in gridSelectionItem)
687
            {
688
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
689
            }
690
            /// fire selection event
691
            this.gridViewMarkup.UnselectAll();
692
            this.gridViewMarkup.Select(gridSelectionItem);
693

    
694
            if (!testPanel2.IsHidden)
695
            {
696
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
697
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
698
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
699

    
700
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
701
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
702

    
703

    
704
                foreach (var item in gridSelectionRevItem)
705
                {
706
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
707
                    {
708
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
709
                    });
710
                }
711
            }
712

    
713
            var instanceMain = this.ParentOfType<MainWindow>();
714
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
715
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
716

    
717
            instanceMain.dzTopMenu.rotateOffSet = 0;
718
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
719
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
720

    
721
            //}
722
            SetCommentPages(true);
723
        }
724

    
725

    
726
        
727

    
728
        private void SetCommentPages(bool onlyMe = false)
729
        {
730
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
731
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
732
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
733
            {
734
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
735
                instance.UserName = item.UserName;
736
                instance.Depart = item.Depatment;
737
                instance.MarkupInfoID = item.MarkupInfoID;
738
                instance.IsSelected = true;
739
                instance.isConSolidation = item.Consolidate;
740
                instance.SetColor = item.DisplayColor;
741
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
742
                {
743
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
744
                }
745
                else
746
                {
747
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
748
                }
749
                _pages.Add(instance);
750
            }
751
            this.pageNavigator.SetCommentList(_pages.ToList());
752
        }
753

    
754
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
755
        {
756
            if (e.MiddleButton == MouseButtonState.Pressed)
757
            {
758

    
759
            }
760
            e.Handled = true;
761
            if (e.Delta > 0)
762
            {
763
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
764
                ZoomIn(currentContentMousePoint);
765
            }
766
            else
767
            {
768
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
769
                ZoomOut(currentContentMousePoint);
770
            }
771
        }
772

    
773
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
774
        {
775
            e.Handled = true;
776
            if (e.Delta > 0)
777
            {
778
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
779
                ZoomIn_Sync(currentContentMousePoint);
780
            }
781
            else
782
            {
783
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
784
                ZoomOut_Sync(currentContentMousePoint);
785
            }
786
        }
787

    
788
        #region ZoomIn & ZoomOut
789

    
790
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
791
        {
792
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
793
                zoomAndPanControl.ContentZoomFocusY));
794
        }
795

    
796
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
797
        {
798
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
799
                zoomAndPanControl.ContentZoomFocusY));
800
        }
801

    
802

    
803
        //강인구 추가 (줌 인아웃 수치 변경)
804
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
805
        private void ZoomOut(Point contentZoomCenter)
806
        {
807
            if (zoomAndPanControl.ContentScale > 0.39)
808
            {
809
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
810
            }
811
            else
812
            {
813
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
814
            }
815

    
816
            if (zoomAndPanControl2 != null && Sync.IsChecked)
817
            {
818
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
819
            }
820
        }
821

    
822
        private void ZoomIn(Point contentZoomCenter)
823
        {
824
            if (zoomAndPanControl.ContentScale > 0.19)
825
            {
826
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
827
            }
828
            else
829
            {
830
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
831
            }
832

    
833
            if (zoomAndPanControl2 != null && Sync.IsChecked)
834
            {
835
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
836
            }
837

    
838
        }
839

    
840
        private void ZoomOut_Sync(Point contentZoomCenter)
841
        {
842
            if (zoomAndPanControl2.ContentScale > 0.39)
843
            {
844
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
845
            }
846
            else
847
            {
848
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
849
            }
850

    
851
            if (Sync.IsChecked)
852
            {
853
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
854
            }
855
        }
856

    
857
        private void ZoomIn_Sync(Point contentZoomCenter)
858
        {
859
            if (zoomAndPanControl2.ContentScale > 0.19)
860
            {
861
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
862
            }
863
            else
864
            {
865
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
866
            }
867

    
868
            if (Sync.IsChecked)
869
            {
870
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
871
            }
872
        }
873

    
874
        private void ZoomOut()
875
        {
876
            zoomAndPanControl.ContentScale -= 0.1;
877
            //if (zoomAndPanControl2 != null)
878
            //{
879
            //    zoomAndPanControl2.ContentScale -= 0.1;
880
            //}
881
        }
882

    
883
        private void ZoomIn()
884
        {
885
            zoomAndPanControl.ContentScale += 0.1;
886
            //if (zoomAndPanControl2 != null)
887
            //{
888
            //    zoomAndPanControl2.ContentScale += 0.1;
889
            //}
890
        }
891

    
892
        #endregion
893

    
894
        private void init()
895
        {
896
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
897
            {
898

    
899
                ControlList.Clear();
900
                listBox.Items.Clear();
901
                selected_item.Clear();
902

    
903
                (item as IMarkupCommonData).IsSelected = false;
904
            }
905

    
906
        }
907

    
908
        private HitTestResultBehavior MyCallback(HitTestResult result)
909
        {
910
            //this.cursor = Cursors.UpArrow;
911
            var element = result.VisualHit;
912
            while (element != null && !(element is CommentUserInfo))
913
                element = VisualTreeHelper.GetParent(element);
914

    
915
            if (element == null)
916
            {
917
                return HitTestResultBehavior.Stop;
918
            }
919
            else
920
            {
921
                if (element is CommentUserInfo)
922
                {
923
                    if (!hitList.Contains(element))
924
                    {
925
                        hitList.Add((CommentUserInfo)element);
926
                    }
927
                    else
928
                    {
929
                        return HitTestResultBehavior.Stop;
930
                    }
931
                }
932
            }
933
            return HitTestResultBehavior.Continue;
934
        }
935

    
936
        public void ReleaseSelectPath()
937
        {
938
            if (SelectionPath == null)
939
            {
940
                SelectionPath = new Path();
941
                SelectionPath.Name = "";
942
            }
943
            if (SelectionPath.Name != "")
944
            {
945
                SelectionPath.Name = "None";
946
            }
947
            SelectionPath.Opacity = 0.01;
948
            SelectionPath.RenderTransform = null;
949
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
950
        }
951

    
952
        #region 컨트롤 초기화 
953
        public void Control_Init(object control)
954
        {
955
            if (L_Size != 0 && (control as IPath) != null)
956
            {
957
                (control as IPath).LineSize = L_Size;
958
                L_Size = 0;
959
            }
960

    
961
            switch (control.GetType().Name)
962
            {
963
                case "RectangleControl":
964
                    {
965
                        (control as RectangleControl).StrokeColor = Brushes.Red;
966
                    }
967
                    break;
968
                case "CircleControl":
969
                    {
970
                        (control as CircleControl).StrokeColor = Brushes.Red;
971
                    }
972
                    break;
973
                case "TriControl":
974
                    {
975
                        (control as TriControl).StrokeColor = Brushes.Red;
976
                    }
977
                    break;
978
                case "RectCloudControl":
979
                    {
980
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
981
                    }
982
                    break;
983
                case "CloudControl":
984
                    {
985
                        (control as CloudControl).StrokeColor = Brushes.Red;
986
                    }
987
                    break;
988
                case "PolygonControl":
989
                    {
990
                        (control as PolygonControl).StrokeColor = Brushes.Red;
991
                    }
992
                    break;
993
                case "ArcControl":
994
                    {
995
                        (control as ArcControl).StrokeColor = Brushes.Red;
996
                    }
997
                    break;
998
                case "ArrowArcControl":
999
                    {
1000
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1001
                    }
1002
                    break;
1003
                case "LineControl":
1004
                    {
1005
                        (control as LineControl).StrokeColor = Brushes.Red;
1006
                    }
1007
                    break;
1008
                case "ArrowControl_Multi":
1009
                    {
1010
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1011
                    }
1012
                    break;
1013
                case "TextControl":
1014
                    {
1015
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1016
                    }
1017
                    break;
1018
                case "ArrowTextControl":
1019
                    {
1020
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1021
                    }
1022
                    break;
1023
                case "InsideWhiteControl":
1024
                    {
1025
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1026
                    }
1027
                    break;
1028
                case "OverlapWhiteControl":
1029
                    {
1030
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1031
                    }
1032
                    break;
1033
                case "ClipWhiteControl":
1034
                    {
1035
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1036
                    }
1037
                    break;
1038
                case "CoordinateControl":
1039
                    {
1040
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1041
                    }
1042
                    break;
1043
            }
1044
        }
1045
        #endregion
1046

    
1047
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1048
        {
1049
            //Control_Init(e.Source);
1050
        }
1051
        private Window _dragdropWindow = null;
1052

    
1053
        [DllImport("user32.dll")]
1054
        [return: MarshalAs(UnmanagedType.Bool)]
1055
        internal static extern bool GetCursorPos(ref Win32Point pt);
1056

    
1057
        [StructLayout(LayoutKind.Sequential)]
1058
        internal struct Win32Point
1059
        {
1060
            public Int32 X;
1061
            public Int32 Y;
1062
        };
1063
        public string symbol_id = null;
1064
        public long symbol_group_id;
1065
        public int symbol_SelectedIndex;
1066
        public ImageSource symbol_img;
1067
        public string symbol_Data = null;
1068
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1069
        {
1070
            if (this._dragdropWindow != null)
1071
            {
1072
                this._dragdropWindow.Close();
1073
                this._dragdropWindow = null;
1074
            }
1075

    
1076
            symbol_id = id;
1077
            symbol_group_id = group_id;
1078
            symbol_SelectedIndex = SelectedIndex;
1079
            symbol_Data = Data_;
1080
            symbol_img = img;
1081

    
1082
      
1083
            CreateDragDropWindow2(img);
1084
        }
1085

    
1086
        private void CreateDragDropWindow2(ImageSource image)
1087
        {
1088
            this._dragdropWindow = new Window();
1089
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1090
            _dragdropWindow.WindowStyle = WindowStyle.None;
1091
            _dragdropWindow.AllowsTransparency = true;           
1092
            _dragdropWindow.AllowDrop = false;
1093
            _dragdropWindow.Background = null;
1094
            _dragdropWindow.IsHitTestVisible = false;
1095
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1096
            _dragdropWindow.Topmost = true;
1097
            _dragdropWindow.ShowInTaskbar = false;
1098
            
1099
            Rectangle r = new Rectangle();
1100
            r.Width = image.Width;
1101
            r.Height = image.Height;
1102
            r.Opacity = 0.5;            
1103
            r.Fill = new ImageBrush(image);
1104
            this._dragdropWindow.Content = r;
1105

    
1106
            Win32Point w32Mouse = new Win32Point();
1107
            GetCursorPos(ref w32Mouse);
1108

    
1109
            //w32Mouse.X = getCurrentPoint.X;
1110
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1111
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1112
            this._dragdropWindow.Show();
1113
        }
1114

    
1115
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1116
        {
1117
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1118
            {
1119
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1120

    
1121
                Point currentPos = e.GetPosition(rect);
1122

    
1123
                floatingTip.HorizontalOffset = currentPos.X + 20;
1124
                floatingTip.VerticalOffset = currentPos.Y;
1125
            }
1126

    
1127
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1128
            
1129
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1130
            {
1131
                SetCursor();
1132
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1133
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1134

    
1135
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1136
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1137
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1138

    
1139
                if (Sync.IsChecked)
1140
                {
1141
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1142
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1143
                }
1144
            }
1145

    
1146
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1147
            {
1148
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1149
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1150
                SetCursor();
1151

    
1152
                if (currentControl != null)
1153
                {
1154
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1155
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1156
                    //강인구 추가
1157
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1158

    
1159
                    if ((currentControl as IPath) != null)
1160
                    {
1161
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1162
                    }
1163
                    if ((currentControl as LineControl) != null)
1164
                    {
1165
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1166
                    }
1167

    
1168
                    if ((currentControl as IShapeControl) != null)
1169
                    {
1170
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1171
                    }
1172
                    if ((currentControl as TextControl) != null)
1173
                    {
1174
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1175
                        {
1176
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1177
                        }
1178
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1179
                        {
1180
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1181
                        }
1182
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1183
                        {
1184
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1185
                        }
1186
                    }
1187
                    else if ((currentControl as ArrowTextControl) != null)
1188
                    {
1189
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1190
                        {
1191
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1192
                        }
1193
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1194
                        {
1195
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1196
                        }
1197
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1198
                        {
1199
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1200
                        }
1201
                    }
1202
                    else if ((currentControl as RectCloudControl) != null)
1203
                    {
1204
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1205
                    }
1206
                    else if ((currentControl as CloudControl) != null)
1207
                    {
1208
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1209
                    }
1210

    
1211
                    switch (controlType)
1212
                    {
1213
                        case (ControlType.Coordinate):
1214
                            {
1215
                                var control = currentControl as CoordinateControl;
1216
                                if (control != null)
1217
                                {
1218
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1219
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1220
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1221
                                }
1222
                            }
1223
                            break;
1224
                        case (ControlType.InsideWhite):
1225
                            {
1226
                                var control = currentControl as InsideWhiteControl;
1227
                                if (control != null)
1228
                                {
1229
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1230
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1231
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1232
                                    control.Paint = PaintSet.Fill;
1233
                                }
1234
                            }
1235
                            break;
1236
                        case ControlType.OverlapWhite:
1237
                            {
1238
                                var control = currentControl as OverlapWhiteControl;
1239
                                if (control != null)
1240
                                {
1241
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1242
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1243
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1244
                                    control.Paint = PaintSet.Fill;
1245
                                }
1246
                            }
1247
                            break;
1248
                        case ControlType.ClipWhite:
1249
                            {
1250
                                var control = currentControl as ClipWhiteControl;
1251
                                if (control != null)
1252
                                {
1253
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1254
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1255
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1256
                                    control.Paint = PaintSet.Fill;
1257
                                }
1258
                            }
1259
                            break;
1260
                        case ControlType.RectCloud:
1261
                            {
1262
                                var control = currentControl as RectCloudControl;
1263
                                if (control != null)
1264
                                {
1265
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1266
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1267
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1268
                                }
1269
                            }
1270
                            break;
1271
                        case ControlType.SingleLine:
1272
                        case ControlType.CancelLine:
1273
                        case ControlType.ArrowLine:
1274
                        case ControlType.TwinLine:
1275
                        case ControlType.DimLine:
1276
                            {
1277
                                var control = currentControl as LineControl;
1278
                                if (control != null)
1279
                                {
1280
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1281
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1282
                                }
1283
                            }
1284
                            break;
1285

    
1286
                        case ControlType.ArcLine:
1287
                            {
1288
                                var control = currentControl as ArcControl;
1289
                                if (control != null)
1290
                                {
1291
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1292
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1293
                                }
1294
                            }
1295
                            break;
1296

    
1297
                        case ControlType.ArcArrow:
1298
                            {
1299
                                var control = currentControl as ArrowArcControl;
1300
                                if (control != null)
1301
                                {
1302
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1303
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1304
                                }
1305
                            }
1306
                            break;
1307

    
1308
                        case ControlType.ArrowMultiLine:
1309
                            {
1310
                                var control = currentControl as ArrowControl_Multi;
1311
                                if (control != null)
1312
                                {
1313
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1314
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1315
                                }
1316
                            }
1317
                            break;
1318

    
1319
                        case ControlType.Circle:
1320
                            {
1321
                                if (currentControl != null)
1322
                                {
1323
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1324
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1325
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1326
                                }
1327
                            }
1328
                            break;
1329

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

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

    
1354
                        case ControlType.ImgControl:
1355
                            {
1356
                                var control = currentControl as ImgControl;
1357
                                if (control != null)
1358
                                {
1359
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1360
                                }
1361
                            }
1362
                            break;
1363

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

    
1374
                        case ControlType.ArrowTextControl:
1375
                        case ControlType.ArrowTransTextControl:
1376
                        case ControlType.ArrowTextBorderControl:
1377
                        case ControlType.ArrowTransTextBorderControl:
1378
                        case ControlType.ArrowTextCloudControl:
1379
                        case ControlType.ArrowTransTextCloudControl:
1380
                            {
1381
                                var control = currentControl as ArrowTextControl;
1382
                                if (control != null)
1383
                                {
1384
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1385
                                }
1386
                            }
1387
                            break;
1388
                        case ControlType.PolygonControl:
1389
                        case ControlType.ChainLine:
1390
                            {
1391
                                var control = currentControl as PolygonControl;
1392
                                if (control != null)
1393
                                {
1394
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1395
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1396
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1397
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1398
                                }
1399
                            }
1400
                            break;
1401
                        case ControlType.Sign:
1402
                            {
1403
                                var control = currentControl as SignControl;
1404
                                if (control != null)
1405
                                {
1406
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1407
                                }
1408
                            }
1409
                            break;
1410
                        case ControlType.Symbol:
1411
                            {
1412
                                var control = currentControl as SymControl;
1413
                                if (control != null)
1414
                                {
1415
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1416
                                }
1417
                            }
1418
                            break;
1419
                        case ControlType.Stamp:
1420
                            {
1421
                                var control = currentControl as SymControlN;
1422
                                if (control != null)
1423
                                {
1424
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1425
                                }
1426
                            }
1427
                            break;
1428
                        case ControlType.Rectangle:
1429
                        case ControlType.Mark:
1430
                            {
1431
                                var control = currentControl as RectangleControl;
1432
                                if (control != null)
1433
                                {
1434
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1435
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1436
                                }
1437
                            }
1438
                            break;
1439
                        case ControlType.PenControl:
1440
                            {
1441
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1442
                                //inkBoard.Strokes.Add(stroke);
1443
                            }
1444
                            break;
1445
                        default:
1446
                            break;
1447
                    }
1448
                }
1449
            }
1450
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1451
            {
1452
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1453
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1454
                SetCursor();
1455
                if (currentControl == null)
1456
                {
1457
                    switch (controlType)
1458
                    {
1459
                        case ControlType.PenControl:
1460
                            {
1461
                                if (inkBoard.Tag.ToString() == "Ink")
1462
                                {
1463
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1464
                                }
1465
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1466
                                {
1467
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1468
                                }
1469
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1470
                                {
1471
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1472
                                }
1473

    
1474
                                //inkBoard.Strokes.Add(stroke);
1475
                            }
1476
                            break;
1477
                    }
1478
                    return;
1479
                }
1480
            }
1481
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1482
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1483
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1484
            {
1485
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1486

    
1487
                if (isDraggingSelectionRect)
1488
                {
1489
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1490
                    e.Handled = true;
1491
                }
1492
                else if (isLeftMouseButtonDownOnWindow)
1493
                {
1494
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1495
                    double dragDistance = Math.Abs(dragDelta.Length);
1496

    
1497
                    if (dragDistance > DragThreshold)
1498
                    {
1499
                        isDraggingSelectionRect = true;
1500
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1501
                    }
1502

    
1503
                    e.Handled = true;
1504
                }
1505

    
1506
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1507
                {
1508
                }
1509
                else
1510
                {
1511
                    e.Handled = true;
1512
                }
1513
            }
1514
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1515
            { //symbol      
1516
                if(_dragdropWindow != null)
1517
                {
1518
                    Win32Point w32Mouse = new Win32Point();
1519
                    GetCursorPos(ref w32Mouse);
1520

    
1521
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1522
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1523
                }                
1524
            }
1525
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1526
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1527
            {
1528
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1529
                if(control != null)
1530
                {
1531
                    this.cursor = Cursors.Hand;
1532
                    SetCursor();
1533
                }
1534
                else
1535
                {
1536
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1537
                    SetCursor();
1538
                }
1539
            }
1540
            else
1541
            {
1542
            }
1543
        }
1544

    
1545
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1546
        {
1547
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1548
            {
1549
                SetCursor();
1550
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1551
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1552

    
1553
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1554

    
1555
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1556
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1557

    
1558
                if (Sync.IsChecked)
1559
                {
1560
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1561
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1562
                }
1563
            }
1564
        }
1565

    
1566
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1567

    
1568
        private EllipseGeometry hitArea = new EllipseGeometry();
1569

    
1570
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1571
        {
1572
            IsDrawing = false;
1573

    
1574
            if (mouseHandlingMode != MouseHandlingMode.None)
1575
            {
1576
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1577
                {
1578
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1579

    
1580
                    SetCursor();
1581

    
1582
                    switch (controlType)
1583
                    {
1584
                        case ControlType.None:
1585
                            break;
1586
                        case ControlType.Rectangle:
1587
                            {
1588

    
1589
                            }
1590
                            break;
1591
                        case ControlType.PenControl:
1592
                            {
1593

    
1594
                            }
1595
                            break;
1596
                        default:
1597
                            break;
1598
                    }
1599
                }
1600
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1601
                {
1602
                    if (isLeftMouseButtonDownOnWindow)
1603
                    {
1604
                        bool wasDragSelectionApplied = false;
1605

    
1606
                        if (isDraggingSelectionRect)
1607
                        {
1608
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1609
                            {
1610
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1611
                                mouseHandlingMode = MouseHandlingMode.None;
1612
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1613
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1614
                                Set_Symbol_Capture(endPoint);
1615
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1616
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1617
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1618
                            }
1619
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1620
                            {
1621
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1622
                                mouseHandlingMode = MouseHandlingMode.None;
1623
                                Set_Capture();
1624

    
1625
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1626
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1627
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1628
                            }
1629
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1630
                            {
1631
                                ApplyDragSelectionRect();
1632
                            }
1633
                            else
1634
                            {
1635
                                double x = Canvas.GetLeft(dragZoomBorder);
1636
                                double y = Canvas.GetTop(dragZoomBorder);
1637
                                double width = dragZoomBorder.Width;
1638
                                double height = dragZoomBorder.Height;
1639
                                Rect dragRect = new Rect(x, y, width, height);
1640

    
1641
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1642

    
1643
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1644
                            }
1645

    
1646
                            isDraggingSelectionRect = false;
1647
                            e.Handled = true;
1648
                            wasDragSelectionApplied = true;
1649
                        }
1650

    
1651
                        if (isLeftMouseButtonDownOnWindow)
1652
                        {
1653
                            isLeftMouseButtonDownOnWindow = false;
1654
                            this.ReleaseMouseCapture();
1655
                            e.Handled = true;
1656
                        }
1657

    
1658
                        if (!wasDragSelectionApplied)
1659
                        {
1660
                            init();
1661
                        }
1662
                    }
1663
                }
1664
                else if (e.RightButton == MouseButtonState.Pressed)
1665
                {
1666
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1667
                    SetCursor();
1668
                }
1669

    
1670
                zoomAndPanControl.ReleaseMouseCapture();
1671

    
1672

    
1673
                e.Handled = true;
1674
            }
1675
            else
1676
            {
1677
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1678
                SetCursor();
1679
            }
1680

    
1681
            ///mouseButtonDown = MouseButton.Left;
1682
            //controlType = ControlType.SingleLine;
1683
        }
1684

    
1685
        public void Set_Symbol_Capture(Point endPoint)
1686
        {       
1687
            double x = canvasDrawingMouseDownPoint.X;
1688
            double y = canvasDrawingMouseDownPoint.Y;
1689
            if(x > endPoint.X)
1690
            {
1691
                x = endPoint.X;
1692
                y = endPoint.Y;
1693
            }
1694

    
1695
            double width = dragCaptureBorder.Width;
1696
            double height = dragCaptureBorder.Height;
1697

    
1698
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1699

    
1700
            if (x < 0)
1701
            {
1702
                width += x;
1703
                x = 0;
1704
            }
1705
            if (y < 0)
1706
            {
1707
                height += y;
1708
                y = 0;
1709

    
1710
                width = (int)canvasImage.PixelWidth - x;
1711
            }
1712
            if (x + width > canvasImage.PixelWidth)
1713
            {
1714
                width = (int)canvasImage.PixelWidth - x;
1715
            }
1716
            if (y + height > canvasImage.PixelHeight)
1717
            {
1718
                height = (int)canvasImage.PixelHeight - y;
1719
            }
1720
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1721

    
1722
            string uri = "";
1723
            if (userData.COMPANY != "EXT")
1724
            {
1725
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1726
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1727
            }
1728
            else
1729
            {
1730
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1731
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1732
            }
1733

    
1734
            var defaultBitmapImage = new BitmapImage();
1735
            defaultBitmapImage.BeginInit();
1736
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1737
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1738
            defaultBitmapImage.UriSource = new Uri(uri);
1739
            defaultBitmapImage.EndInit();
1740

    
1741
            //GC.Collect();
1742

    
1743
            if (defaultBitmapImage.IsDownloading)
1744
            {
1745
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1746
                {
1747
                    defaultBitmapImage.Freeze();
1748
                    //GC.Collect();
1749
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1750
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1751
                };
1752
            }
1753
        }
1754

    
1755
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1756
        {
1757
            ///mouseButtonDown = MouseButton.Left;
1758
        }
1759

    
1760
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1761
        {
1762
            ///mouseButtonDown = MouseButton.Left;
1763
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1764
        }
1765

    
1766
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1767
        {
1768

    
1769
        }
1770

    
1771
        /// <summary>
1772
        /// select items by dragging
1773
        /// </summary>
1774
        private void ApplyDragSelectionRect()
1775
        {
1776
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1777

    
1778
            double x = Canvas.GetLeft(dragSelectionBorder);
1779
            double y = Canvas.GetTop(dragSelectionBorder);
1780
            double width = dragSelectionBorder.Width;
1781
            double height = dragSelectionBorder.Height;
1782
            Boolean Flag = false;
1783
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1784
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1785

    
1786
            Rect dragRect = new Rect(x, y, width, height);
1787
            ///dragRect.Inflate(width / 10, height / 10);
1788

    
1789
            foreach (var item in Items)
1790
            {
1791
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1792

    
1793
                if (Flag)
1794
                {
1795
                    adornerSet.Add(item);
1796
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1797
                    Control_Style(item);
1798
                }
1799
            }
1800
            if (adornerSet.Count > 0)
1801
            {
1802
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1803
                SelectLayer.Children.Add(final);
1804
            }
1805
        }
1806

    
1807
        private void InitDragSelectionRect(Point pt1, Point pt2)
1808
        {
1809
            //캡쳐 중
1810
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1811
            {
1812
                dragCaptureBorder.Visibility = Visibility.Visible;
1813
            }
1814
            //선택 중
1815
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1816
            {
1817

    
1818
                dragSelectionBorder.Visibility = Visibility.Visible;
1819
            }
1820
            else
1821
            {
1822
                dragZoomBorder.Visibility = Visibility.Visible;
1823
            }
1824
            UpdateDragSelectionRect(pt1, pt2);
1825
        }
1826

    
1827
        /// <summary>
1828
        /// Update the position and size of the rectangle used for drag selection.
1829
        /// </summary>
1830
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1831
        {
1832
            double x, y, width, height;
1833

    
1834
            //
1835
            // Determine x,y,width and height of the rect inverting the points if necessary.
1836
            // 
1837

    
1838
            if (pt2.X < pt1.X)
1839
            {
1840
                x = pt2.X;
1841
                width = pt1.X - pt2.X;
1842
            }
1843
            else
1844
            {
1845
                x = pt1.X;
1846
                width = pt2.X - pt1.X;
1847
            }
1848

    
1849
            if (pt2.Y < pt1.Y)
1850
            {
1851
                y = pt2.Y;
1852
                height = pt1.Y - pt2.Y;
1853
            }
1854
            else
1855
            {
1856
                y = pt1.Y;
1857
                height = pt2.Y - pt1.Y;
1858
            }
1859

    
1860
            //
1861
            // Update the coordinates of the rectangle used for drag selection.
1862
            //
1863
            //캡쳐 중
1864
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1865
            {
1866
                Canvas.SetLeft(dragCaptureBorder, x);
1867
                Canvas.SetTop(dragCaptureBorder, y);
1868
                dragCaptureBorder.Width = width;
1869
                dragCaptureBorder.Height = height;
1870
            }
1871
            //선택 중
1872
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1873
            {
1874
                Canvas.SetLeft(dragSelectionBorder, x);
1875
                Canvas.SetTop(dragSelectionBorder, y);
1876
                dragSelectionBorder.Width = width;
1877
                dragSelectionBorder.Height = height;
1878
            }
1879
            else
1880
            {
1881
                Canvas.SetLeft(dragZoomBorder, x);
1882
                Canvas.SetTop(dragZoomBorder, y);
1883
                dragZoomBorder.Width = width;
1884
                dragZoomBorder.Height = height;
1885
            }
1886
        }
1887

    
1888
        private void drawingPannelRotate(double angle)
1889
        {
1890
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1891
            rotate.Angle = angle;
1892
            var rotationNum = Math.Abs((rotate.Angle / 90));
1893

    
1894
            if (angle == 90 || angle == 270)
1895
            {
1896
                double emptySize = zoomAndPanCanvas.Width;
1897
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1898
                zoomAndPanCanvas.Height = emptySize;
1899
            }
1900
            if (angle == 0)
1901
            {
1902
                translate.X = 0;
1903
                translate.Y = 0;
1904
            }
1905
            else if (angle == 90)
1906
            {
1907
                translate.X = zoomAndPanCanvas.Width;
1908
                translate.Y = 0;
1909
            }
1910
            else if (angle == 180)
1911
            {
1912
                translate.X = zoomAndPanCanvas.Width;
1913
                translate.Y = zoomAndPanCanvas.Height;
1914
            }
1915
            else
1916
            {
1917
                translate.X = 0;
1918
                translate.Y = zoomAndPanCanvas.Height;
1919
            }
1920

    
1921
            zoomAndPanControl.RotationAngle = rotate.Angle;
1922

    
1923

    
1924
            if (!testPanel2.IsHidden)
1925
            {
1926
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1927
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1928
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1929
            }
1930

    
1931
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1932
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1933
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1934
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1935
            ViewerDataModel.Instance.Angle = rotate.Angle;
1936
        }
1937

    
1938
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1939
        {
1940
            string Data_ = "";
1941

    
1942
            try
1943
            {
1944
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1945
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1946
                if (Data_ != null || Data_ != "")
1947
                {
1948
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1949
                }
1950
                else
1951
                {
1952
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1953
                }
1954

    
1955
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1956
                //{
1957
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1958
                //    STATE = 0,
1959
                //};
1960
                if (Data_ != null)
1961
                {
1962
                    Image img = new Image();
1963
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1964
                    if (Data_.Contains(".svg"))
1965
                    {
1966
                        byte[] imageData = null;
1967
                        DrawingImage image = null;
1968
                        using (System.Net.WebClient web = new System.Net.WebClient())
1969
                        {
1970
                            imageData = web.DownloadData(new Uri(Data_));
1971
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1972
                            image = SvgReader.Load(stream);
1973
                        }
1974
                        img.Source = image;
1975
                    }
1976
                    else
1977
                    {
1978
                        img.Source = new BitmapImage(new Uri(Data_));
1979
                    }
1980

    
1981
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1982
                    {
1983
                        PointSet = new List<Point>(),
1984
                        FilePath = Data_,
1985
                        ImageData = img.Source,
1986
                        StartPoint = canvasZoomPanningMouseDownPoint,
1987
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
1988
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
1989
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
1990
                        canvasZoomPanningMouseDownPoint.Y),
1991
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
1992
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
1993
                    };
1994

    
1995
                    currentControl.PointSet = new List<Point>
1996
                                        {
1997
                                            currentControl.StartPoint,
1998
                                            currentControl.LeftBottomPoint,
1999
                                            currentControl.EndPoint,
2000
                                            currentControl.TopRightPoint,
2001
                                        };
2002
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2003
                    UndoData = new Undo_data()
2004
                    {
2005
                        IsUndo = false,
2006
                        Event = Event_Type.Create,
2007
                        EventTime = DateTime.Now,
2008
                        Markup_List = new List<Multi_Undo_data>()
2009
                    };
2010
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2011
                    {
2012
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2013
                    });
2014

    
2015
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2016
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2017
                    UndoData.Markup_List.Add(multi_Undo_Data);
2018
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2019

    
2020
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2021
                    currentControl.CommentID = Commons.shortGuid();
2022
                    currentControl.SymbolID = id;
2023
                    currentControl.GroupID = group_id;
2024
                    currentControl.ApplyTemplate();
2025
                    currentControl.SetImage();
2026

    
2027
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2028
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2029
                    SelectLayer.Children.Add(final);
2030
                }
2031
            }
2032
            catch (Exception ex)
2033
            {
2034
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2035
            }
2036
        }
2037

    
2038
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2039
        {            
2040
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2041
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2042
            {
2043
                set_option.Value = double.Parse(set_option.ContentText);
2044
            }
2045

    
2046
            ConvertInkControlToPolygon();
2047

    
2048
            ///TODO:
2049
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2050
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2051

    
2052
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2053
            {
2054
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2055
            }
2056
            /// up to here
2057

    
2058
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2059
            {
2060
                if (arrow_text as ArrowTextControl != null)
2061
                {
2062
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2063
                }
2064
            }
2065

    
2066
            //if (currentControl != null)
2067
            {
2068
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2069
                if (text_item_ != null)
2070
                {
2071
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2072
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2073
                    (text_item_ as TextControl).EnableEditing = false;
2074
                    currentControl = null;
2075
                }
2076

    
2077
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2078
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2079
                {
2080
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2081
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2082
                    currentControl = null;
2083
                }
2084
            }
2085

    
2086
            double Ang = 0;                                          
2087
            if (rotate.Angle != 0)
2088
            {
2089
                Ang = 360 - rotate.Angle;
2090
            }
2091

    
2092
            if (e.OriginalSource is System.Windows.Controls.Image)
2093
            {
2094
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2095
            }
2096

    
2097
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2098
            {                
2099
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2100
                if(symbol_id != null)
2101
                {
2102
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2103
                }                
2104
            }
2105

    
2106
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2107
            {
2108
                if (this._dragdropWindow != null)
2109
                {
2110
                    this._dragdropWindow.Close();
2111
                    this._dragdropWindow = null;
2112
                    symbol_id = null;
2113
                }
2114
            }
2115

    
2116
            if (e.LeftButton == MouseButtonState.Pressed)
2117
            {
2118
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2119
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2120

    
2121
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2122
                SetCursor();
2123

    
2124
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2125
            }
2126

    
2127
            if (e.MiddleButton == MouseButtonState.Pressed)
2128
            {
2129
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2130
                cursor = Cursors.SizeAll;
2131
                SetCursor();
2132
            }
2133
            if (e.RightButton == MouseButtonState.Pressed)
2134
            {
2135
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2136
                cursor = Cursors.SizeAll;
2137
                SetCursor();
2138
            }
2139
            else if (e.XButton1 == MouseButtonState.Pressed)
2140
            {
2141
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2142
                {
2143
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2144
                }
2145

    
2146
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2147

    
2148
            }
2149
            else if (e.XButton2 == MouseButtonState.Pressed)
2150
            {
2151
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2152
                {
2153
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2154
                }
2155
            }
2156

    
2157
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2158
            {
2159
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2160
                {
2161
                    if (SelectLayer.Children.Count == 0)
2162
                    {
2163
                        isLeftMouseButtonDownOnWindow = true;
2164
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2165
                    }
2166

    
2167
                    if (controlType == ControlType.None)
2168
                    {
2169
                        isLeftMouseButtonDownOnWindow = true;
2170
                    }
2171
                }
2172

    
2173
                /// 캡쳐 모드 설정
2174
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2175
                {
2176
                    dragCaptureBorder.Visibility = Visibility.Visible;
2177
                    isLeftMouseButtonDownOnWindow = true;
2178
                }
2179

    
2180
                /// 줌 모드 설정
2181
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2182
                {
2183
                    isLeftMouseButtonDownOnWindow = true;
2184
                }
2185

    
2186
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2187
                if (control != null)
2188
                {
2189
                    AdornerFinal final = null;
2190

    
2191
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2192
                    {
2193
                        /// 기존 selection 해제
2194
                        SelectionSet.Instance.UnSelect(this);
2195

    
2196
                        final = new AdornerFinal(control);
2197

    
2198
                        this.Control_Style(control);
2199

    
2200
                        if ((control as IPath) != null)
2201
                        {
2202
                            if ((control as IPath).LineSize != 0)
2203
                            {
2204
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2205
                            }
2206
                        }
2207
                        if ((control as IShapeControl) != null)
2208
                        {
2209
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2210
                            {
2211
                                ViewerDataModel.Instance.checkHatchShape = true;
2212
                            }
2213
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2214
                            {
2215
                                ViewerDataModel.Instance.checkFillShape = true;
2216
                            }
2217
                            else
2218
                            {
2219
                                ViewerDataModel.Instance.checkHatchShape = false;
2220
                                ViewerDataModel.Instance.checkFillShape = false;
2221
                            }
2222
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2223
                        }
2224

    
2225
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2226

    
2227
                        if ((control as TextControl) != null)
2228
                        {
2229
                            if(!((control as TextControl).EnableEditing)) {
2230
                                (control as TextControl).EnableEditing = true;
2231
                            }
2232

    
2233
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2234
                            {
2235
                                ViewerDataModel.Instance.checkTextStyle = true;
2236
                            }
2237
                            else
2238
                            {
2239
                                ViewerDataModel.Instance.checkTextStyle = false;
2240
                            }
2241

    
2242
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2243
                            {
2244
                                ViewerDataModel.Instance.checkTextStyle = true;
2245
                            }
2246
                            else
2247
                            {
2248
                                ViewerDataModel.Instance.checkTextStyle = false;
2249
                            }
2250
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2251
                            {
2252
                                ViewerDataModel.Instance.checkTextWeight = true;
2253
                            }
2254
                            else
2255
                            {
2256
                                ViewerDataModel.Instance.checkTextWeight = false;
2257
                            }
2258
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2259
                            {
2260
                                ViewerDataModel.Instance.checkUnderLine = true;
2261
                            }
2262
                            else
2263
                            {
2264
                                ViewerDataModel.Instance.checkUnderLine = false;
2265
                            }
2266
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2267
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2268

    
2269
                        }
2270
                        else if ((control as ArrowTextControl) != null)
2271
                        {
2272
                            if (!((control as ArrowTextControl).EnableEditing))
2273
                            {
2274
                                (control as ArrowTextControl).EnableEditing = true;
2275
                            }
2276
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2277
                            {
2278
                                ViewerDataModel.Instance.checkTextStyle = true;
2279
                            }
2280
                            else
2281
                            {
2282
                                ViewerDataModel.Instance.checkTextStyle = false;
2283
                            }
2284

    
2285
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2286
                            {
2287
                                ViewerDataModel.Instance.checkTextStyle = true;
2288
                            }
2289
                            else
2290
                            {
2291
                                ViewerDataModel.Instance.checkTextStyle = false;
2292
                            }
2293
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2294
                            {
2295
                                ViewerDataModel.Instance.checkTextWeight = true;
2296
                            }
2297
                            else
2298
                            {
2299
                                ViewerDataModel.Instance.checkTextWeight = false;
2300
                            }
2301
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2302
                            {
2303
                                ViewerDataModel.Instance.checkUnderLine = true;
2304
                            }
2305
                            else
2306
                            {
2307
                                ViewerDataModel.Instance.checkUnderLine = false;
2308
                            }
2309
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2310
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2311
                        }
2312
                        else if ((control as RectCloudControl) != null)
2313
                        {
2314
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2315
                        }
2316
                        else if ((control as CloudControl) != null)
2317
                        {
2318
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2319
                        }
2320
                    }
2321
                    else
2322
                    {
2323
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2324
                        SelectionSet.Instance.UnSelect(this);
2325
                        comment.Add(control);
2326

    
2327
                        Control_Style(control);
2328

    
2329
                        final = new AdornerFinal(comment);
2330
                    }
2331

    
2332
                    if (final != null)
2333
                    {
2334
                        this.SelectLayer.Children.Add(final);
2335
                    }
2336
                }              
2337
            }
2338
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2339
            {               
2340
                init();
2341
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2342
                if (cursor != Cursors.SizeAll)
2343
                {
2344
                    cursor = Cursors.Cross;
2345
                    SetCursor();
2346
                }
2347
                bool init_user = false;
2348
                foreach (var user in gridViewMarkup.Items)
2349
                {
2350
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2351
                    {
2352
                        init_user = true;
2353
                    }
2354
                }
2355
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2356
                {
2357
                    RadWindow.Alert(new DialogParameters
2358
                    {
2359
                        Owner = Application.Current.MainWindow,
2360
                        Theme = new VisualStudio2013Theme(),
2361
                        Header = "안내",
2362
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2363
                    });
2364
                    return;
2365
                }
2366
                else
2367
                {
2368
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2369
                    if (item != null)
2370
                    {
2371
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2372
                    }
2373
                }
2374

    
2375
                switch (controlType)
2376
                {
2377
                    case ControlType.Coordinate:
2378
                        {
2379
                            if (e.LeftButton == MouseButtonState.Pressed)
2380
                            {
2381
                                if (currentControl is CoordinateControl)
2382
                                {
2383
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2384
                                    {
2385
                                        return;
2386
                                    }
2387

    
2388
                                    CreateCommand.Instance.Execute(currentControl);
2389

    
2390
                                    currentControl = null;
2391
                                    this.cursor = Cursors.Arrow;
2392
                                }
2393
                                else
2394
                                {
2395
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2396
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2397
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2398
                                    {
2399
                                        currentControl = null;
2400
                                        this.cursor = Cursors.Arrow;
2401
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2402
                                        return;
2403
                                    }
2404
                                    else
2405
                                    {
2406
                                        currentControl = new CoordinateControl
2407
                                        {
2408
                                            Background = new SolidColorBrush(Colors.Black),
2409
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2410
                                            ControlType = ControlType.Coordinate
2411
                                        };
2412

    
2413
                                        currentControl.CommentID = Commons.shortGuid();
2414
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2415
                                        currentControl.IsNew = true;
2416

    
2417
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2418

    
2419
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2420
                                    }
2421
                                }
2422
                            }
2423
                        }
2424
                        break;
2425
                    case ControlType.InsideWhite:
2426
                        {
2427
                            if (e.LeftButton == MouseButtonState.Pressed)
2428
                            {
2429
                                if (currentControl is InsideWhiteControl)
2430
                                {
2431
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2432
                                    {
2433
                                        return;
2434
                                    }
2435

    
2436
                                    CreateCommand.Instance.Execute(currentControl);
2437

    
2438
                                    currentControl = null;
2439
                                    this.cursor = Cursors.Arrow;
2440
                                }
2441
                                else
2442
                                {
2443
                                    currentControl = new InsideWhiteControl
2444
                                    {
2445
                                        Background = new SolidColorBrush(Colors.Black),
2446
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2447
                                        ControlType = ControlType.InsideWhite
2448
                                    };
2449

    
2450
                                    currentControl.CommentID = Commons.shortGuid();
2451
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2452
                                    currentControl.IsNew = true;
2453
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2454

    
2455
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2456
                                }
2457
                            }
2458
                        }
2459
                        break;
2460
                    case ControlType.OverlapWhite:
2461
                        {
2462
                            if (e.LeftButton == MouseButtonState.Pressed)
2463
                            {
2464
                                if (currentControl is OverlapWhiteControl)
2465
                                {
2466
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2467
                                    {
2468
                                        return;
2469
                                    }
2470

    
2471
                                    CreateCommand.Instance.Execute(currentControl);
2472

    
2473
                                    currentControl = null;
2474
                                    this.cursor = Cursors.Arrow;
2475
                                }
2476
                                else
2477
                                {
2478
                                    currentControl = new OverlapWhiteControl
2479
                                    {
2480
                                        Background = new SolidColorBrush(Colors.Black),
2481
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2482
                                        ControlType = ControlType.OverlapWhite
2483
                                    };
2484

    
2485
                                    currentControl.CommentID = Commons.shortGuid();
2486
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2487
                                    currentControl.IsNew = true;
2488
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2489

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

    
2506
                                    CreateCommand.Instance.Execute(currentControl);
2507

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

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

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

    
2542
                                    CreateCommand.Instance.Execute(currentControl);
2543
                                    currentControl = null;
2544
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2545
                                }
2546
                                else
2547
                                {
2548
                                    currentControl = new RectangleControl
2549
                                    {
2550
                                        Background = new SolidColorBrush(Colors.Black),
2551
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2552
                                        ControlType = ControlType.Rectangle
2553
                                    };
2554

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

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

    
2577
                                    CreateCommand.Instance.Execute(currentControl);
2578

    
2579
                                    currentControl = null;
2580
                                
2581
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2582
                                }
2583
                                else
2584
                                {
2585
                                    currentControl = new RectCloudControl
2586
                                    {
2587
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2588
                                        ControlType = ControlType.RectCloud,
2589
                                        Background = new SolidColorBrush(Colors.Black)
2590
                                    };
2591

    
2592
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2593
                                    currentControl.CommentID = Commons.shortGuid();
2594
                                    currentControl.IsNew = true;
2595
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2596
                                }
2597
                            }
2598
                        }
2599
                        break;
2600
                    case ControlType.Circle:
2601
                        {
2602
                            if (e.LeftButton == MouseButtonState.Pressed)
2603
                            {
2604
                                if (currentControl is CircleControl)
2605
                                {
2606
                                    //20180906 LJY TEST IsRotationDrawingEnable
2607
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2608
                                    {
2609
                                        return;
2610
                                    }
2611

    
2612
                                    CreateCommand.Instance.Execute(currentControl);
2613

    
2614
                                    currentControl = null;
2615
                                }
2616
                                else
2617
                                {
2618
                                    currentControl = new CircleControl
2619
                                    {
2620
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2621
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2622
                                        Background = new SolidColorBrush(Colors.Black)
2623
                                    };
2624

    
2625
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2626
                                    currentControl.CommentID = Commons.shortGuid();
2627
                                    currentControl.IsNew = true;
2628
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2629
                                }
2630
                            }
2631
                        }
2632
                        break;
2633
                    case ControlType.Triangle:
2634
                        {
2635
                            if (e.LeftButton == MouseButtonState.Pressed)
2636
                            {
2637
                                if (currentControl is TriControl)
2638
                                {
2639
                                    var content = currentControl as TriControl;
2640
                                    if (content.MidPoint == new Point(0, 0))
2641
                                    {
2642
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2643
                                    }
2644
                                    else
2645
                                    {
2646
                                        //20180906 LJY TEST IsRotationDrawingEnable
2647
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2648
                                        {
2649
                                            return;
2650
                                        }
2651

    
2652
                                        CreateCommand.Instance.Execute(currentControl);
2653

    
2654
                                        currentControl = null;
2655
                                    }
2656
                                }
2657
                                else
2658
                                {
2659
                                    currentControl = new TriControl
2660
                                    {
2661
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2662
                                        Background = new SolidColorBrush(Colors.Black),
2663
                                    };
2664

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

    
2689
                                    CreateCommand.Instance.Execute(currentControl);
2690
                                    currentControl = null;
2691
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2692
                                }
2693
                                else
2694
                                {
2695
                                    currentControl = new LineControl
2696
                                    {
2697
                                        ControlType = this.controlType,
2698
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2699
                                        Background = new SolidColorBrush(Colors.Black)
2700
                                    };
2701

    
2702
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2703
                                    currentControl.CommentID = Commons.shortGuid();
2704
                                    currentControl.IsNew = true;
2705
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2706
                                    this.MainAngle.Visibility = Visibility.Visible;
2707
                                }
2708
                            }
2709
                        }
2710
                        break;
2711
                    case ControlType.PolygonControl:
2712
                        {
2713
                            if (currentControl is PolygonControl)
2714
                            {
2715
                                var control = currentControl as PolygonControl;
2716

    
2717
                                if (e.RightButton == MouseButtonState.Pressed)
2718
                                {
2719
                                    control.IsCompleted = true;
2720
                                }
2721

    
2722
                                if (!control.IsCompleted)
2723
                                {
2724
                                    control.PointSet.Add(control.EndPoint);
2725
                                }
2726
                                else
2727
                                {
2728
                                    //20180906 LJY TEST IsRotationDrawingEnable
2729
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2730
                                    {
2731
                                        return;
2732
                                    }
2733

    
2734
                                    var firstPoint = control.PointSet.First();
2735
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2736
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2737
                                    control.PointSet.Add(firstPoint);
2738

    
2739
                                    control.ApplyOverViewData();
2740

    
2741
                                    CreateCommand.Instance.Execute(currentControl);
2742
                                    control.updateControl();
2743
                                    currentControl = null;
2744
                                }
2745
                            }
2746
                            else
2747
                            {
2748
                                if (e.LeftButton == MouseButtonState.Pressed)
2749
                                {
2750
                                    currentControl = new PolygonControl
2751
                                    {
2752
                                        PointSet = new List<Point>(),
2753
                                    };
2754

    
2755
                                    var polygonControl = (currentControl as PolygonControl);
2756
                                    currentControl.CommentID = Commons.shortGuid();
2757
                                    currentControl.IsNew = true;
2758
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2759
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2760
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2761
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2762
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2763
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2764
                                    polygonControl.ApplyTemplate();
2765
                                    polygonControl.Visibility = Visibility.Visible;
2766
                                }
2767
                            }
2768
                        }
2769
                        break;
2770
                    case ControlType.ChainLine:
2771
                        {
2772
                            if (currentControl is PolygonControl)
2773
                            {
2774
                                var control = currentControl as PolygonControl;
2775

    
2776
                                if (e.RightButton == MouseButtonState.Pressed)
2777
                                {
2778
                                    //20180906 LJY TEST IsRotationDrawingEnable
2779
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2780
                                    {
2781
                                        return;
2782
                                    }
2783

    
2784
                                    CreateCommand.Instance.Execute(currentControl);
2785

    
2786
                                    currentControl = null;
2787
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2788
                                    return;
2789
                                }
2790

    
2791
                                if (!control.IsCompleted)
2792
                                {
2793
                                    control.PointSet.Add(control.EndPoint);
2794
                                    this.MainAngle.Visibility = Visibility.Visible;
2795
                                }
2796
                            }
2797
                            else
2798
                            {
2799
                                if (e.LeftButton == MouseButtonState.Pressed)
2800
                                {
2801
                                    MainAngle.Visibility = Visibility.Visible;
2802
                                    currentControl = new PolygonControl
2803
                                    {
2804
                                        PointSet = new List<Point>(),
2805
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2806
                                        ControlType = ControlType.ChainLine,
2807
                                        DashSize = ViewerDataModel.Instance.DashSize,
2808
                                        LineSize = ViewerDataModel.Instance.LineSize,
2809
                                        //PointC = new StylusPointSet()
2810
                                    };
2811

    
2812
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2813
                                    //{
2814
                                        var polygonControl = (currentControl as PolygonControl);
2815
                                        currentControl.CommentID = Commons.shortGuid();
2816
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2817
                                        currentControl.IsNew = true;
2818
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2819
                                        //currentControl.OnApplyTemplate();
2820
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2821
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2822
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2823
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2824
                                    //}
2825
                                }
2826
                            }
2827
                        }
2828
                        break;
2829
                    case ControlType.ArcLine:
2830
                        {
2831
                            if (e.LeftButton == MouseButtonState.Pressed)
2832
                            {
2833
                                if (currentControl is ArcControl)
2834
                                {
2835
                                    //20180906 LJY TEST IsRotationDrawingEnable
2836
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2837
                                    {
2838
                                        return;
2839
                                    }
2840

    
2841
                                    CreateCommand.Instance.Execute(currentControl);
2842

    
2843
                                    currentControl = null;
2844
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2845
                                }
2846
                                else
2847
                                {
2848
                                    currentControl = new ArcControl
2849
                                    {
2850
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2851
                                        Background = new SolidColorBrush(Colors.Black)
2852
                                    };
2853
                                    currentControl.CommentID = Commons.shortGuid();
2854
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2855
                                    currentControl.IsNew = true;
2856
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2857
                                    this.MainAngle.Visibility = Visibility.Visible;
2858
                                }
2859
                            }
2860
                            else if (e.RightButton == MouseButtonState.Pressed)
2861
                            {
2862
                                if (currentControl != null)
2863
                                {
2864
                                    (currentControl as ArcControl).setClock();
2865
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2866
                                }
2867
                            }
2868
                        }
2869
                        break;
2870
                    case ControlType.ArcArrow:
2871
                        {
2872
                            if (e.LeftButton == MouseButtonState.Pressed)
2873
                            {
2874
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2875
                                //{
2876
                                if (currentControl is ArrowArcControl)
2877
                                {
2878
                                    //20180906 LJY TEST IsRotationDrawingEnable
2879
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2880
                                    {
2881
                                        return;
2882
                                    }
2883

    
2884
                                    CreateCommand.Instance.Execute(currentControl);
2885

    
2886
                                    currentControl = null;
2887
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2888
                                }
2889
                                else
2890
                                {
2891
                                    currentControl = new ArrowArcControl
2892
                                    {
2893
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2894
                                        Background = new SolidColorBrush(Colors.Black)
2895
                                    };
2896
                                    currentControl.CommentID = Commons.shortGuid();
2897
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2898
                                    currentControl.IsNew = true;
2899
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2900
                                    this.MainAngle.Visibility = Visibility.Visible;
2901
                                }
2902
                                //}
2903
                            }
2904
                            else if (e.RightButton == MouseButtonState.Pressed)
2905
                            {
2906
                                if (currentControl != null)
2907
                                {
2908
                                    (currentControl as ArrowArcControl).setClock();
2909
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2910
                                    //(currentControl as ArcControl).ApplyTemplate();
2911
                                }
2912
                            }
2913
                        }
2914
                        break;
2915
                    case ControlType.ArrowMultiLine:
2916
                        {
2917
                            if (e.LeftButton == MouseButtonState.Pressed)
2918
                            {
2919
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2920
                                //{
2921

    
2922
                                    if (currentControl is ArrowControl_Multi)
2923
                                    {
2924
                                        var content = currentControl as ArrowControl_Multi;
2925
                                        if (content.MiddlePoint == new Point(0, 0))
2926
                                        {
2927
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2928
                                            {
2929
                                                content.MiddlePoint = content.EndPoint;
2930
                                            }
2931
                                            else
2932
                                            {
2933
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2934
                                            }
2935
                                        }
2936
                                        else
2937
                                        {
2938
                                            //20180906 LJY TEST IsRotationDrawingEnable
2939
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2940
                                            {
2941
                                                return;
2942
                                            }
2943

    
2944
                                            CreateCommand.Instance.Execute(currentControl);
2945

    
2946
                                            currentControl = null;
2947
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2948
                                        }
2949
                                    }
2950
                                    else
2951
                                    {
2952
                                        currentControl = new ArrowControl_Multi
2953
                                        {
2954
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2955
                                            Background = new SolidColorBrush(Colors.Black)
2956
                                        };
2957
                                        currentControl.CommentID = Commons.shortGuid();
2958
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2959
                                        currentControl.IsNew = true;
2960
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2961
                                        this.MainAngle.Visibility = Visibility.Visible;
2962
                                    }
2963
                                //}
2964
                            }
2965
                        }
2966
                        break;
2967
                    case ControlType.PolygonCloud:
2968
                        {
2969
                            if (currentControl is CloudControl)
2970
                            {
2971
                                var control = currentControl as CloudControl;
2972
                                if (e.RightButton == MouseButtonState.Pressed)
2973
                                {
2974
                                    control.IsCompleted = true;
2975
                                }
2976

    
2977
                                if (!control.IsCompleted)
2978
                                {
2979
                                    control.PointSet.Add(control.EndPoint);
2980
                                }
2981
                                else
2982
                                {
2983
                                    //20180906 LJY TEST IsRotationDrawingEnable
2984
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2985
                                    {
2986
                                        return;
2987
                                    }
2988

    
2989
                                    CreateCommand.Instance.Execute(currentControl);
2990

    
2991
                                    control.isTransOn = true;
2992
                                    var firstPoint = control.PointSet.First();
2993

    
2994
                                    control.PointSet.Add(firstPoint);
2995
                                    control.DrawingCloud();
2996
                                    control.ApplyOverViewData();
2997

    
2998
                                    currentControl = null;
2999
                                }
3000
                            }
3001
                            else
3002
                            {
3003
                                if (e.LeftButton == MouseButtonState.Pressed)
3004
                                {
3005
                                    currentControl = new CloudControl
3006
                                    {
3007
                                        PointSet = new List<Point>(),
3008
                                        PointC = new StylusPointSet()
3009
                                    };
3010

    
3011
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3012
                                    //{
3013
                                        var polygonControl = (currentControl as CloudControl);
3014
                                        currentControl.CommentID = Commons.shortGuid();
3015
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3016
                                        currentControl.IsNew = true;
3017
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3018

    
3019
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3020
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3021
                                    
3022
                                    //}
3023
                                }
3024
                            }
3025
                        }
3026
                        break;
3027
                    case ControlType.ImgControl:
3028
                        {
3029
                            if (e.LeftButton == MouseButtonState.Pressed)
3030
                            {
3031
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3032
                                //{
3033
                                    if (currentControl is ImgControl)
3034
                                    {
3035
                                        //20180906 LJY TEST IsRotationDrawingEnable
3036
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3037
                                        {
3038
                                            return;
3039
                                        }
3040

    
3041
                                        CreateCommand.Instance.Execute(currentControl);
3042
                                        controlType = ControlType.ImgControl;
3043
                                        currentControl = null;
3044
                                    }
3045
                                    else
3046
                                    {
3047
                                        
3048
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3049
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3050
                                        {
3051
                                            Image img = new Image();
3052
                                            if (filename.Contains(".svg"))
3053
                                            {
3054
                                                byte[] imageData = null;
3055
                                                DrawingImage image = null;
3056
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3057
                                                {
3058
                                                    imageData = web.DownloadData(new Uri(filename));
3059
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3060
                                                    image = SvgReader.Load(stream);
3061
                                                }
3062
                                                img.Source = image;
3063
                                            }
3064
                                            else
3065
                                            {
3066
                                                img.Source = new BitmapImage(new Uri(filename));
3067
                                            }
3068

    
3069
                                            currentControl = new ImgControl
3070
                                            {
3071
                                                    Background = new SolidColorBrush(Colors.Black),
3072
                                                    PointSet = new List<Point>(),
3073
                                                    FilePath = filename,
3074
                                                    ImageData = img.Source,
3075
                                                    StartPoint = canvasDrawingMouseDownPoint,
3076
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3077
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3078
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3079
                                                    ControlType = ControlType.ImgControl
3080
                                                };
3081

    
3082
                                        
3083
                                                currentControl.CommentID = Commons.shortGuid();                                            
3084
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3085
                                                currentControl.IsNew = true;
3086
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3087

    
3088
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3089
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3090
                                        }
3091
                                    }
3092
                                //}
3093
                            }
3094
                        }
3095
                        break;
3096
                    case ControlType.Date:
3097
                        {
3098
                            if (e.LeftButton == MouseButtonState.Pressed)
3099
                            {
3100
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3101
                                //{
3102
                                    if (currentControl is DateControl)
3103
                                    {
3104
                                        //20180906 LJY TEST IsRotationDrawingEnable
3105
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3106
                                        {
3107
                                            return;
3108
                                        }
3109

    
3110
                                        CreateCommand.Instance.Execute(currentControl);
3111
                                        currentControl = null;
3112

    
3113
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3114
                                        {
3115
                                            controlType = ControlType.None;
3116
                                            IsSwingMode = false;
3117
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3118
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3119
                                            mouseHandlingMode = MouseHandlingMode.None;
3120
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3121
                                            txtBatch.Visibility = Visibility.Collapsed;
3122

    
3123
                                        }
3124
                                    }
3125
                                    else
3126
                                    {
3127
                                        currentControl = new DateControl
3128
                                        {
3129
                                            StartPoint = canvasDrawingMouseDownPoint,
3130
                                            Background = new SolidColorBrush(Colors.Black)
3131
                                        };
3132
                                        currentControl.CommentID = Commons.shortGuid();
3133
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3134
                                        currentControl.IsNew = true;
3135
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3136

    
3137
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3138
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3139
                                }
3140
                                //}
3141
                            }
3142
                        }
3143
                        break;
3144
                    case ControlType.TextControl:
3145
                        {
3146
                            if (e.LeftButton == MouseButtonState.Pressed)
3147
                            {
3148
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3149
                                {
3150
                                    currentControl = new TextControl
3151
                                    {
3152
                                        ControlType = controlType
3153
                                    };
3154
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3155
                                    currentControl.CommentID = Commons.shortGuid();
3156
                                    currentControl.IsNew = true;
3157
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3158
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3159
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3160

    
3161
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3162
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3163
                                    
3164
                                    (currentControl as TextControl).ControlType_No = 0;
3165
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3166
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3167
                                    (currentControl as TextControl).ApplyTemplate();
3168
                                    (currentControl as TextControl).Base_TextBox.Focus();
3169

    
3170
                                    CreateCommand.Instance.Execute(currentControl);
3171
                                }
3172
                            }
3173
                        }
3174
                        break;
3175
                    case ControlType.TextBorder:
3176
                        {
3177
                            if (e.LeftButton == MouseButtonState.Pressed)
3178
                            {
3179
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3180
                                {
3181
                                    currentControl = new TextControl
3182
                                    {
3183
                                        ControlType = controlType
3184
                                    };
3185

    
3186
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3187
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3188
                                    currentControl.CommentID = Commons.shortGuid();
3189
                                    currentControl.IsNew = true;
3190
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3191
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3192
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3193
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3194
                                    
3195
                                    (currentControl as TextControl).ControlType_No = 1;
3196
                                    (currentControl as TextControl).Angle = Ang;
3197
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3198
                                    (currentControl as TextControl).ApplyTemplate();
3199
                                    (currentControl as TextControl).Base_TextBox.Focus();
3200
                                    CreateCommand.Instance.Execute(currentControl);
3201
                                }
3202
                            }
3203
                        }
3204
                        break;
3205
                    case ControlType.TextCloud:
3206
                        {
3207
                            if (e.LeftButton == MouseButtonState.Pressed)
3208
                            {
3209
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3210
                                {
3211
                                    currentControl = new TextControl
3212
                                    {
3213
                                        ControlType = controlType
3214
                                    };
3215

    
3216
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3217
                                    currentControl.CommentID = Commons.shortGuid();
3218
                                    currentControl.IsNew = true;
3219
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3220
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3221

    
3222
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3223
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3224
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3225

    
3226
                                    (currentControl as TextControl).Angle = Ang;
3227
                                    (currentControl as TextControl).ControlType_No = 2;
3228
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3229
                                    (currentControl as TextControl).ApplyTemplate();
3230
                                    (currentControl as TextControl).Base_TextBox.Focus();
3231
                                    CreateCommand.Instance.Execute(currentControl);
3232
                                    //currentControl = null;
3233
                                }
3234
                            }
3235
                        }
3236
                        break;
3237
                    case ControlType.ArrowTextControl:
3238
                         {
3239
                            if (e.LeftButton == MouseButtonState.Pressed)
3240
                            {
3241
                                if (currentControl is ArrowTextControl)
3242
                                {
3243
                                    //20180906 LJY TEST IsRotationDrawingEnable
3244
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3245
                                    {
3246
                                        return;
3247
                                    }
3248

    
3249
                                    CreateCommand.Instance.Execute(currentControl);
3250

    
3251
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3252
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3253
                                    (currentControl as ArrowTextControl).IsNew = false;
3254
                                    currentControl = null;
3255
                                }
3256
                                else
3257
                                {
3258
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3259
                                    //{
3260
                                        currentControl = new ArrowTextControl();
3261
                                        currentControl.CommentID = Commons.shortGuid();
3262
                                        currentControl.IsNew = true;
3263
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3264
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3265

    
3266
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3267
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3268
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3269
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3270
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3271

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

    
3275
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3276
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3277
                                        this.MainAngle.Visibility = Visibility.Visible;
3278

    
3279
                                    
3280
                                    //}
3281
                                }
3282
                            }
3283
                        }
3284
                        break;
3285
                    case ControlType.ArrowTransTextControl:
3286
                        {
3287
                            if (e.LeftButton == MouseButtonState.Pressed)
3288
                            {
3289
                                if (currentControl is ArrowTextControl)
3290
                                {
3291
                                    //20180906 LJY TEST IsRotationDrawingEnable
3292
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3293
                                    {
3294
                                        return;
3295
                                    }
3296

    
3297
                                    CreateCommand.Instance.Execute(currentControl);
3298
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3299
                                    currentControl.IsNew = false;
3300
                                    currentControl = null;
3301
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3302
                                }
3303
                                else
3304
                                {
3305
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3306
                                    //{
3307
                                    currentControl = new ArrowTextControl()
3308
                                    {
3309
                                        ControlType = ControlType.ArrowTransTextControl
3310
                                    };
3311
                                    currentControl.CommentID = Commons.shortGuid();
3312
                                    currentControl.IsNew = true;
3313
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3314
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3315
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3316
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3317
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3318
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3319
                                    (currentControl as ArrowTextControl).isFixed = true;
3320
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3321

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

    
3325
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3326
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3327
                                    (currentControl as ArrowTextControl).isTrans = true;
3328
                                }
3329
                            }
3330
                        }
3331
                        break;
3332
                    case ControlType.ArrowTextBorderControl:
3333
                         {
3334
                            if (e.LeftButton == MouseButtonState.Pressed)
3335
                            {
3336
                                if (currentControl is ArrowTextControl)
3337
                                {
3338
                                    //20180906 LJY TEST IsRotationDrawingEnable
3339
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3340
                                    {
3341
                                        return;
3342
                                    }
3343

    
3344
                                    CreateCommand.Instance.Execute(currentControl);
3345
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3346
                                    currentControl.IsNew = false;
3347
                                    currentControl = null;
3348
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3349
                                }
3350
                                else
3351
                                {
3352
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3353
                                    //{
3354
                                        currentControl = new ArrowTextControl()
3355
                                        {
3356
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3357
                                        };
3358
                                        currentControl.CommentID = Commons.shortGuid();
3359
                                        currentControl.IsNew = true;
3360
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3361
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3362

    
3363
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3364

    
3365
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3366

    
3367
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3368
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3369
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3370

    
3371
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3372
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3373
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3374
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3375
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3376
                                    //}
3377
                                }
3378
                            }
3379
                        }
3380
                        break;
3381
                    case ControlType.ArrowTransTextBorderControl:
3382
                        {
3383
                            if (e.LeftButton == MouseButtonState.Pressed)
3384
                            {
3385
                                if (currentControl is ArrowTextControl)
3386
                                {
3387
                                    //20180906 LJY TEST IsRotationDrawingEnable
3388
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3389
                                    {
3390
                                        return;
3391
                                    }
3392
                                    CreateCommand.Instance.Execute(currentControl);
3393
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3394
                                    currentControl.IsNew = false;
3395
                                    currentControl = null;
3396
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3397
                                }
3398
                                else
3399
                                {
3400
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3401
                                    //{
3402
                                    
3403

    
3404
                                    currentControl = new ArrowTextControl()
3405
                                    {
3406
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3407
                                        ControlType = ControlType.ArrowTransTextBorderControl
3408

    
3409
                                    };
3410
                                        currentControl.CommentID = Commons.shortGuid();
3411
                                        currentControl.IsNew = true;
3412
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3413
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3414

    
3415
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3416

    
3417
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3418
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3419
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3420
                                        (currentControl as ArrowTextControl).isFixed = true;
3421
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3422
                                     
3423
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3424
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3425
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3426

    
3427
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3428
                                        this.MainAngle.Visibility = Visibility.Visible;
3429
                                    
3430
                                    //20180911 LJY
3431
                                        (currentControl as ArrowTextControl).isTrans = true;
3432
                                    
3433

    
3434
                                    //}
3435
                                }
3436
                            }
3437
                        }
3438
                        break;
3439
                    case ControlType.ArrowTextCloudControl:
3440
                        {
3441
                            if (e.LeftButton == MouseButtonState.Pressed)
3442
                            {
3443
                                if (currentControl is ArrowTextControl)
3444
                                {
3445
                                    //20180906 LJY TEST IsRotationDrawingEnable
3446
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3447
                                    {
3448
                                        return;
3449
                                    }
3450
                                    CreateCommand.Instance.Execute(currentControl);
3451
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3452
                                    currentControl.IsNew = false;
3453
                                    currentControl = null;
3454
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3455
                                }
3456
                                else
3457
                                {
3458
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3459
                                    //{
3460
                                        currentControl = new ArrowTextControl()
3461
                                        {
3462
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3463
                                        };
3464
                                        currentControl.CommentID = Commons.shortGuid();
3465
                                        currentControl.IsNew = true;
3466
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3467
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3468

    
3469
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3470
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3471
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3472
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3473
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3474

    
3475
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3476
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3477
                                    
3478
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3479
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3480
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3481
                                    //}
3482
                                }
3483
                            }
3484
                        }
3485
                        break;
3486
                    case ControlType.ArrowTransTextCloudControl:
3487
                        {
3488
                            if (e.LeftButton == MouseButtonState.Pressed)
3489
                            {
3490
                                if (currentControl is ArrowTextControl)
3491
                                {
3492
                                    //20180906 LJY TEST IsRotationDrawingEnable
3493
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3494
                                    {
3495
                                        return;
3496
                                    }
3497
                                    CreateCommand.Instance.Execute(currentControl);
3498
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3499
                                    currentControl.IsNew = false;
3500
                                    currentControl = null;
3501
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3502
                                }
3503
                                else
3504
                                {
3505
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3506
                                    //{
3507
                                        currentControl = new ArrowTextControl()
3508
                                        {
3509
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3510
                                            ControlType = ControlType.ArrowTransTextCloudControl
3511

    
3512
                                        };
3513
                                        currentControl.CommentID = Commons.shortGuid();
3514
                                        currentControl.IsNew = true; 
3515
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3516
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3517
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3518

    
3519
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3520
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3521
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3522
                                        (currentControl as ArrowTextControl).isFixed = true;
3523
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3524

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

    
3528
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3529
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3530
                                        this.MainAngle.Visibility = Visibility.Visible;  
3531
                                    
3532
                                    //20180911 LJY
3533
                                        (currentControl as ArrowTextControl).isTrans = true;
3534
                                    //}
3535
                                }
3536
                            }
3537
                        }
3538
                        break;
3539
                    //강인구 추가
3540
                    case ControlType.Sign:
3541
                        {
3542
                            if (e.LeftButton == MouseButtonState.Pressed)
3543
                            {
3544
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3545
                                //{
3546
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3547

    
3548
                                    if (_sign == null)
3549
                                    {
3550
                                        txtBatch.Visibility = Visibility.Collapsed;
3551
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3552
                                        controlType = ControlType.None;
3553

    
3554
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3555
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3556
                                        return;
3557
                                    }
3558

    
3559
                                    if (currentControl is SignControl)
3560
                                    {
3561
                                        //20180906 LJY TEST IsRotationDrawingEnable
3562
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3563
                                        {
3564
                                            return;
3565
                                        }
3566

    
3567
                                        CreateCommand.Instance.Execute(currentControl);
3568
                                        currentControl = null;
3569
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3570
                                        {
3571
                                            txtBatch.Text = "Place Date";
3572
                                            controlType = ControlType.Date;
3573
                                        }
3574
                                    }
3575
                                    else
3576
                                    {
3577
                                        currentControl = new SignControl
3578
                                        {
3579
                                            Background = new SolidColorBrush(Colors.Black),
3580
                                            UserNumber = App.ViewInfo.UserID,
3581
                                            ProjectNO = App.ViewInfo.ProjectNO,
3582
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3583
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3584
                                            ControlType = ControlType.Sign
3585
                                        };
3586

    
3587
                                        currentControl.CommentID = Commons.shortGuid();
3588
                                        currentControl.IsNew = true;
3589
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3590
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3591

    
3592
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3593
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3594
                                }
3595
                                //}
3596
                            }
3597
                        }
3598
                        break;
3599
                    case ControlType.Mark:
3600
                        {
3601
                            if (e.LeftButton == MouseButtonState.Pressed)
3602
                            {
3603
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3604
                                //{
3605
                                    if (currentControl is RectangleControl)
3606
                                    {
3607
                                        //20180906 LJY TEST IsRotationDrawingEnable
3608
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3609
                                        {
3610
                                            return;
3611
                                        }
3612

    
3613
                                        CreateCommand.Instance.Execute(currentControl);
3614
                                        (currentControl as RectangleControl).ApplyOverViewData();
3615
                                        currentControl = null;
3616
                                    
3617
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3618

    
3619
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3620
                                        {
3621
                                            txtBatch.Text = "Place Signature";
3622
                                            controlType = ControlType.Sign;
3623
                                        }
3624
                                    }
3625
                                    else
3626
                                    {
3627
                                        currentControl = new RectangleControl
3628
                                        {
3629
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3630
                                            Background = new SolidColorBrush(Colors.Black),
3631
                                            ControlType = ControlType.Mark ,
3632
                                            Paint = PaintSet.Fill
3633
                                        };
3634

    
3635
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3636
                                        currentControl.CommentID = Commons.shortGuid();
3637
                                        currentControl.IsNew = true;
3638
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3639
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3640
                                    }
3641
                                //}
3642
                            }
3643
                        }
3644
                        break;
3645
                    case ControlType.Symbol:
3646
                        {
3647
                            if (e.LeftButton == MouseButtonState.Pressed)
3648
                            {
3649
                                if (currentControl is SymControl)
3650
                                {
3651
                                    //20180906 LJY TEST IsRotationDrawingEnable
3652
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3653
                                    {
3654
                                        return;
3655
                                    }
3656
                                    CreateCommand.Instance.Execute(currentControl);
3657
                                    currentControl = null;
3658
                                
3659
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3660
                                }
3661
                                else
3662
                                {
3663
                                    currentControl = new SymControl
3664
                                    {
3665
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3666
                                        Background = new SolidColorBrush(Colors.Black),
3667
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3668
                                        ControlType = ControlType.Symbol
3669
                                    };
3670

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

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

    
3697
                                        CreateCommand.Instance.Execute(currentControl);
3698
                                        currentControl = null;
3699
                                   
3700

    
3701
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3702
                                    }
3703
                                    else
3704
                                    {
3705
                                        currentControl = new SymControlN
3706
                                        {
3707
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3708
                                            Background = new SolidColorBrush(Colors.Black),
3709
                                            STAMP = App.SystemInfo.STAMP,
3710
                                            ControlType = ControlType.Stamp
3711
                                        };
3712

    
3713
                                        currentControl.IsNew = true;
3714
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3715
                                        currentControl.CommentID = Commons.shortGuid();
3716
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3717
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3718
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3719
                                }                                    
3720
                                //}
3721
                            }
3722
                        }
3723
                        break;
3724
                    case ControlType.PenControl:
3725
                        {
3726
                            if (inkBoard.Tag.ToString() == "Ink")
3727
                            {
3728
                                inkBoard.IsEnabled = true;
3729
                                StartNewStroke(canvasDrawingMouseDownPoint);
3730
                            }
3731
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3732
                            {
3733
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3734
                            }
3735
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3736
                            {
3737
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3738
                            }
3739
                            IsDrawing = true;
3740
                            return;
3741
                        }
3742
                    default:
3743
                        if (currentControl != null)
3744
                        {
3745
                            currentControl.CommentID = null;
3746
                            currentControl.IsNew = false;
3747
                        }
3748
                        break;
3749
                }
3750
            }
3751
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3752
            {
3753
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3754
                {
3755
                    bool mouseOff = false;
3756
                    foreach (var item in SelectLayer.Children)
3757
                    {
3758
                        if (item is AdornerFinal)
3759
                        {
3760

    
3761
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3762
                            if (over != null)
3763
                            {
3764
                                mouseOff = true;
3765
                            }
3766
                        }
3767
                    }
3768

    
3769
                    if (!mouseOff)
3770
                    {
3771
                        SelectionSet.Instance.UnSelect(this);
3772
                    }
3773
                }
3774
                zoomAndPanControl.CaptureMouse();
3775
                e.Handled = true;
3776
            }
3777
        }
3778

    
3779
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3780
        {
3781
            ///mouseButtonDown = e.ChangedButton;
3782
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3783
        }
3784

    
3785
        private void RemoveLineStroke(Point P)
3786
        {
3787
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3788
            if (control != null)
3789
            {
3790
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3791
            }
3792
        }
3793

    
3794
        private void RemovePointStroke(Point P)
3795
        {
3796
            foreach (Stroke hits in inkBoard.Strokes)
3797
            {
3798
                foreach (StylusPoint sty in hits.StylusPoints)
3799
                {
3800

    
3801
                }
3802
                if (hits.HitTest(P))
3803
                {
3804
                    inkBoard.Strokes.Remove(hits);
3805
                    return;
3806
                }
3807
            }
3808
        }
3809

    
3810
        private void StartNewStroke(Point P)
3811
        {
3812
            strokePoints = new StylusPointCollection();
3813
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3814
            strokePoints.Add(segment1Start);
3815
            stroke = new Stroke(strokePoints);
3816

    
3817
            stroke.DrawingAttributes.Color = Colors.Red;
3818
            stroke.DrawingAttributes.Width = 4;
3819
            stroke.DrawingAttributes.Height = 4;
3820

    
3821
            inkBoard.Strokes.Add(stroke);
3822

    
3823
        }
3824

    
3825
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3826
        {
3827
            ConsolidationMethod();
3828
        }
3829

    
3830
        /// <summary>
3831
        /// execute TeamConsolidationCommand
3832
        /// </summary>
3833
        public void TeamConsolidationMethod()
3834
        {
3835
            this.UpdateMyMarkupList();
3836
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3837
            {
3838
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3839
            }
3840
            else
3841
            {
3842

    
3843
                ViewerDataModel.Instance.IsConsolidate = true;
3844
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3845

    
3846
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3847
                {
3848
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3849
                    {
3850
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3851
                        return;
3852
                    }                    
3853
                }
3854
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3855
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3856
                {
3857
                    MarkupInfoList.Add(item);
3858
                }
3859
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3860
            }
3861
        }
3862

    
3863
        public void ConsolidationMethod()
3864
        {
3865
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3866
            {
3867
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3868
            }
3869
            else
3870
            {
3871
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3872
                foreach (var item in this.gridViewMarkup.SelectedItems)
3873
                {
3874
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3875
                }
3876
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3877
                
3878
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3879
            }
3880
        }
3881

    
3882
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3883
        {
3884
            if (App.ViewInfo != null)
3885
            {
3886
                btnConsolidate = (sender as RadRibbonButton);
3887
                if (!App.ViewInfo.NewCommentPermission)
3888
                {
3889
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3890
                }
3891
            }
3892
        }
3893

    
3894
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3895
        {
3896
            TeamConsolidationMethod();
3897
        }
3898

    
3899
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3900
        {
3901
            btnTeamConsolidate = sender as RadRibbonButton;
3902
            if (App.ViewInfo != null)
3903
            {
3904
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3905
                {
3906
                    if (btnConsolidate != null)
3907
                    {
3908
                        btnConsolidate.Visibility = Visibility.Collapsed;
3909
                    }
3910

    
3911
                    if (!App.ViewInfo.NewCommentPermission)
3912
                    {
3913
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3914
                    }
3915
                }
3916
                else
3917
                {
3918
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3919
                }
3920
            }
3921
        }
3922

    
3923
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3924
        {
3925
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3926
            if (item != null)
3927
            {
3928
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3929

    
3930
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3931
            }
3932
            else
3933
            {
3934
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3935
            }
3936
        }
3937

    
3938
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3939
        {
3940
            btnFinalPDF = sender as RadRibbonButton;
3941
            if (App.ViewInfo != null)
3942
            {
3943
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3944
                {
3945
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3946
                    if (btnConsolidate != null)
3947
                    {
3948
                        btnConsolidate.Visibility = Visibility.Collapsed;
3949
                    }
3950
                }
3951
            }
3952
        }
3953

    
3954
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3955
        {
3956
            UpdateMyMarkupList();
3957

    
3958
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3959
            {
3960
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3961
            }
3962
            else
3963
            {
3964
                ViewerDataModel.Instance.IsConsolidate = true;
3965
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3966
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3967

    
3968
                string project_no = App.ViewInfo.ProjectNO;
3969
                string doc_id = _DocInfo.ID;
3970
                string user_id = App.ViewInfo.UserID;
3971
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3972
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3973
                {
3974
                    markupInfoItems.Add(item);
3975
                }
3976
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3977
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3978
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3979
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3980

    
3981
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3982
                if (item2 != null)
3983
                {
3984
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3985

    
3986
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
3987
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
3988
                }
3989
                else
3990
                {
3991
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3992
                }
3993
            }
3994
        }
3995

    
3996
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
3997
        {
3998
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
3999

    
4000
            if (App.ViewInfo != null)
4001
            {
4002
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4003
                {
4004
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4005
                }
4006
            }
4007
        }
4008

    
4009
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4010
        {
4011
            if (CompareMode.IsChecked)
4012
            {
4013
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4014
                {
4015
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4016
                }
4017
                if (ViewerDataModel.Instance.PageNumber == 0)
4018
                {
4019
                    ViewerDataModel.Instance.PageNumber = 1;
4020
                }
4021

    
4022
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4023
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4024
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4025

    
4026
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4027
            }
4028
            else
4029
            {
4030
                da.From = 1;
4031
                da.To = 1;
4032
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4033
                da.AutoReverse = false;
4034
                canvas_compareBorder.Children.Clear();
4035
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4036
            }
4037
        }
4038

    
4039
        private void Sync_Click(object sender, RoutedEventArgs e)
4040
        {
4041
            if (Sync.IsChecked)
4042
            {
4043
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4044
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4045
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4046
            }
4047
        }
4048

    
4049
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4050
        {
4051
            if (UserList.IsChecked)
4052
            {
4053
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4054
            }
4055
            else
4056
            {
4057
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4058
            }
4059
        }
4060

    
4061
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4062
        {
4063

    
4064
            if (BalanceMode.IsChecked)
4065
            {
4066
                ViewerDataModel.Instance.PageBalanceMode = true;
4067
            }
4068
            else
4069
            {
4070
                ViewerDataModel.Instance.PageBalanceMode = false;
4071
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4072
            }
4073
        }
4074

    
4075
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4076
        {
4077
            //초기화
4078
            testPanel2.IsHidden = true;
4079
            ViewerDataModel.Instance.PageBalanceMode = false;
4080
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4081
            ViewerDataModel.Instance.PageNumber = 0;
4082
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4083
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4084
            UserList.IsChecked = false;
4085
            BalanceMode.IsChecked = false;
4086
        }
4087

    
4088
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4089
        {
4090
            if ((sender as System.Windows.Controls.Control).Tag != null)
4091
            {
4092
                //Compare 초기화
4093
                CompareMode.IsChecked = false;
4094
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4095

    
4096
                if (ViewerDataModel.Instance.PageNumber == 0)
4097
                {
4098
                    ViewerDataModel.Instance.PageNumber = 1;
4099
                }
4100

    
4101
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4102
                {
4103
                }
4104
                else
4105
                {
4106
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4107
                }
4108

    
4109
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4110
                {
4111

    
4112
                }
4113
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4114
                {
4115
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4116
                }
4117

    
4118
                if (!testPanel2.IsHidden)
4119
                {
4120
                    if (IsSyncPDFMode)
4121
                    {
4122
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4123
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4124

    
4125
                        if (pdfpath.IsDownloading)
4126
                        {
4127
                            pdfpath.DownloadCompleted += (ex, arg) =>
4128
                            {
4129
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4130
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4131
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4132
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4133
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4134
                            };
4135
                        }
4136
                        else
4137
                        {
4138
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4139
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4140
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4141

    
4142
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4143
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4144
                        }
4145

    
4146
                    }
4147
                    else
4148
                    {
4149
                        string uri = "";
4150

    
4151
                        if (userData.COMPANY != "EXT")
4152
                        {
4153
                            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);
4154
                        }
4155
                        else
4156
                        {
4157
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4158
                        }
4159

    
4160
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4161

    
4162
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4163
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4164
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4165

    
4166
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4167
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4168

    
4169
                        if (defaultBitmapImage_Compare.IsDownloading)
4170
                        {
4171
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4172
                            {
4173
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4174
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4175
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4176

    
4177
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4178
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4179
                            };
4180
                        }
4181
                    }
4182

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

    
4187
                    foreach (var item in gridSelectionRevItem)
4188
                    {
4189
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4190
                        {
4191
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4192
                        });
4193
                    }
4194

    
4195
                    //강인구 추가
4196
                    zoomAndPanControl2.ZoomTo(new Rect
4197
                    {
4198
                        X = 0,
4199
                        Y = 0,
4200
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4201
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4202
                    });
4203

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

    
4206
                }
4207
            }
4208
        }
4209

    
4210
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4211
        {
4212
            if (MarkupMode.IsChecked)
4213
            {
4214
                IsSyncPDFMode = true;
4215

    
4216
                var uri = CurrentRev.TO_VENDOR;
4217

    
4218
                if (ViewerDataModel.Instance.PageNumber == 0)
4219
                {
4220
                    ViewerDataModel.Instance.PageNumber = 1;
4221
                }
4222

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

    
4227
                if (pdfpath.IsDownloading)
4228
                {
4229
                    pdfpath.DownloadCompleted += (ex, arg) =>
4230
                    {
4231
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4232
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4233
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4234
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4235
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4236
                    };
4237
                }
4238
                else
4239
                {
4240
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4241
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4242
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4243

    
4244
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4245
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4246
                }
4247
            }
4248
            else
4249
            {
4250
                IsSyncPDFMode = false;
4251
                string uri = "";
4252
                if (userData.COMPANY != "EXT")
4253
                {
4254
                    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);
4255
                }
4256
                else
4257
                {
4258
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4259
                }
4260

    
4261
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4262

    
4263
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4264
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4265
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4266

    
4267
                if (defaultBitmapImage_Compare.IsDownloading)
4268
                {
4269
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4270
                    {
4271
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4272
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4273
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4274
                    };
4275
                }
4276
                zoomAndPanControl2.ApplyTemplate();
4277
                zoomAndPanControl2.UpdateLayout();
4278
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4279
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4280
            }
4281
        }
4282

    
4283
        private void RadButton_Click(object sender, RoutedEventArgs e)
4284
        {
4285
            gridViewHistory_Busy.IsBusy = true;
4286

    
4287
            RadButton instance = sender as RadButton;
4288
            if (instance.CommandParameter != null)
4289
            {
4290
                CurrentRev = instance.CommandParameter as VPRevision;
4291
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4292
                {
4293
                    if (ea.Error == null && ea.Result != null)
4294
                    {
4295
                        testPanel2.IsHidden = false;
4296

    
4297
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4298
                        foreach(var info in ea.Result)
4299
                        {
4300
                            if(info.UserID == App.ViewInfo.UserID)
4301
                            {
4302
                                info.userDelete = true;
4303
                                info.DisplayColor = "FFFF0000";
4304
                            }
4305
                            else
4306
                            {
4307
                                info.userDelete = false;
4308
                            }
4309
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4310
                        }
4311
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4312

    
4313
                        string uri = "";
4314
                        if (userData.COMPANY != "EXT")
4315
                        {
4316
                            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);
4317
                        }
4318
                        else
4319
                        {
4320
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4321
                        }
4322

    
4323
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4324

    
4325
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4326

    
4327
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4328
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4329
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4330

    
4331
                        if (defaultBitmapImage_Compare.IsDownloading)
4332
                        {
4333
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4334
                            {
4335
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4336
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4337
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4338
                            };
4339
                        }
4340

    
4341
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4342
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4343
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4344
                        zoomAndPanControl2.ApplyTemplate();
4345
                        zoomAndPanControl2.UpdateLayout();
4346

    
4347
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4348
                        {
4349
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4350
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4351
                        }
4352

    
4353
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4354
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4355
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4356

    
4357
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4358
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4359
                        gridViewHistory_Busy.IsBusy = false;
4360
                    }
4361

    
4362
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4363
                };
4364
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4365
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4366
            }
4367
        }
4368

    
4369
        public void Sync_Event(VPRevision Currnet_Rev)
4370
        {
4371
            CurrentRev = Currnet_Rev;
4372

    
4373
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4374
            {
4375
                if (ea.Error == null && ea.Result != null)
4376
                {
4377
                    testPanel2.IsHidden = false;
4378

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

    
4395
                    string uri = "";
4396
                    if (userData.COMPANY != "EXT")
4397
                    {
4398
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4399
                    }
4400
                    else
4401
                    {
4402
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4403
                    }
4404

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

    
4407
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4408

    
4409
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4410
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4411
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4412

    
4413
                    if (defaultBitmapImage_Compare.IsDownloading)
4414
                    {
4415
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4416
                        {
4417
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4418
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4419
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4420
                        };
4421
                    }
4422

    
4423

    
4424
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4425
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4426
                    zoomAndPanControl2.ApplyTemplate();
4427
                    zoomAndPanControl2.UpdateLayout();
4428

    
4429
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4430
                    {
4431
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4432
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4433
                    }
4434
                    //}
4435

    
4436
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4437
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4438
                    gridViewHistory_Busy.IsBusy = false;
4439
                }
4440
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4441

    
4442
            };
4443
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4444
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4445
        }
4446

    
4447
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4448
        {
4449
            if (sender is Image)
4450
            {
4451
                if ((sender as Image).Tag != null)
4452
                {
4453
                    var pdfUrl = (sender as Image).Tag.ToString();
4454
                    System.Diagnostics.Process.Start(pdfUrl);
4455
                }
4456
                else
4457
                {
4458
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4459
                }
4460
            }
4461
        }
4462

    
4463
        private void Create_Symbol(object sender, RoutedEventArgs e)
4464
        {
4465
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4466

    
4467
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4468
            {
4469
                DialogMessage_Alert("Please Select Controls", "Alert");
4470
            }
4471
            else //선택된 것이 있으면
4472
            {
4473
                string MarkupData = "";
4474
                adorner_ = new AdornerFinal();
4475

    
4476
                foreach (var item in SelectLayer.Children)
4477
                {
4478
                    if (item.GetType().Name == "AdornerFinal")
4479
                    {
4480
                        adorner_ = (item as Controls.AdornerFinal);
4481
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4482
                        {
4483
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4484
                            {
4485
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4486
                                MarkupData += markupReturn.ConvertData;
4487
                            }
4488
                        }
4489
                    }
4490
                }
4491
                DialogParameters parameters = new DialogParameters()
4492
                {
4493
                    Owner = Application.Current.MainWindow,
4494
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4495
                    DefaultPromptResultValue = "Custom State",
4496
                    Content = "Name :",
4497
                    Header = "Insert Custom Symbol Name",
4498
                    Theme = new VisualStudio2013Theme(),
4499
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4500
                };
4501
                RadWindow.Prompt(parameters);
4502
            }
4503

    
4504
        }
4505
        public int symbolselectindex = 0;
4506
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4507
        {
4508
            //Save save = new Save();
4509
            try
4510
            {
4511
                string svgfilename = null;
4512
                if (symbolname != null)
4513
                {
4514
                    if (symbolpng == true || symbolsvg == true)
4515
                    {
4516
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4517
                        string guid = Commons.shortGuid();
4518

    
4519
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4520
                        //Check_Uri.UriCheck();
4521
                        fileUploader.RunCompleted += (ex, arg) =>
4522
                        {
4523
                            filename = arg.Result;
4524
                            if (symbolpng == true)
4525
                            {
4526
                                if (filename != null)
4527
                                { 
4528
                                    if (symbolselectindex == 0)
4529
                                    {
4530
                                        SymbolSave(symbolname, filename, data);
4531
                                    }
4532
                                    else
4533
                                    {
4534
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4535
                                    }
4536
                                    DataBind();
4537
                                }                                
4538
                            }
4539

    
4540
                            if (symbolsvg == true)
4541
                            {
4542
                                try
4543
                                {
4544
                                    var defaultBitmapImage = new BitmapImage();
4545
                                    defaultBitmapImage.BeginInit();
4546
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4547
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4548
                                    Check_Uri.UriCheck(filename);
4549
                                    defaultBitmapImage.UriSource = new Uri(filename);
4550
                                    defaultBitmapImage.EndInit();
4551

    
4552
                                    System.Drawing.Bitmap image;
4553

    
4554
                                    if (defaultBitmapImage.IsDownloading)
4555
                                    {
4556
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4557
                                        {
4558
                                            defaultBitmapImage.Freeze();
4559
                                            image = GetBitmap(defaultBitmapImage);
4560
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4561
                                            Process potrace = new Process
4562
                                            {
4563
                                                StartInfo = new ProcessStartInfo
4564
                                                {
4565
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4566
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4567
                                                    RedirectStandardInput = true,
4568
                                                    RedirectStandardOutput = true,
4569
                                                    RedirectStandardError = true,
4570
                                                    UseShellExecute = false,
4571
                                                    CreateNoWindow = true,
4572
                                                    WindowStyle = ProcessWindowStyle.Hidden
4573
                                                },
4574
                                            };
4575

    
4576
                                            StringBuilder svgBuilder = new StringBuilder();
4577
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4578
                                            {
4579
                                                svgBuilder.AppendLine(e2.Data);
4580
                                            };
4581

    
4582
                                            potrace.EnableRaisingEvents = true;
4583
                                            potrace.Start();
4584
                                            potrace.Exited += (sender, e) =>
4585
                                            {
4586
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4587
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4588
                                                Check_Uri.UriCheck(svgfilename);
4589
                                                if (symbolselectindex == 0)
4590
                                                {
4591
                                                    SymbolSave(symbolname, svgfilename, data);
4592
                                                }
4593
                                                else
4594
                                                {
4595
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4596
                                                }
4597

    
4598
                                                DataBind();
4599
                                            };
4600
                                            potrace.WaitForExit();
4601
                                        };
4602
                                    }
4603
                                    else
4604
                                    {
4605
                                        //GC.Collect();
4606
                                    }
4607
                                }
4608
                                catch(Exception ee)
4609
                                {
4610
                                    DialogMessage_Alert("" + ee, "Alert");
4611
                                }
4612
                            }
4613
                        };                                             
4614
                    }
4615
                }
4616
            }
4617
            catch (Exception e)
4618
            {
4619
                //DialogMessage_Alert(e + "", "Alert");
4620
            }            
4621
        }
4622

    
4623
        public void SymbolSave(string Name, string Url, string Data)
4624
        {
4625
            try
4626
            {
4627
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4628
                {
4629
                    ID = Commons.shortGuid(),
4630
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4631
                    NAME = Name,
4632
                    IMAGE_URL = Url,
4633
                    DATA = Data
4634
                };
4635

    
4636
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4637
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4638
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4639
            }
4640
            catch (Exception)
4641
            {
4642
                throw;
4643
            }
4644
        }
4645

    
4646
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4647
        {
4648
            try
4649
            {
4650
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4651
                {
4652
                    ID = Commons.shortGuid(),
4653
                    DEPARTMENT = Department,
4654
                    NAME = Name,
4655
                    IMAGE_URL = Url,
4656
                    DATA = Data
4657
                };
4658
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4659
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4660
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4661
            }
4662
            catch (Exception)
4663
            {
4664
                throw;
4665
            }
4666
        }
4667

    
4668
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4669
        {           
4670
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4671
            DataBind();
4672
        }
4673

    
4674
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4675
        {
4676
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4677
            DataBind();
4678
        }
4679
        private void DataBind()
4680
        {
4681
            try
4682
            {
4683
                Symbol_Custom Custom = new Symbol_Custom();
4684
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4685
                
4686
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4687
                foreach (var item in symbol_Private)
4688
                {
4689
                    Custom.Name = item.NAME;
4690
                    Custom.ImageUri = item.IMAGE_URL;
4691
                    Custom.ID = item.ID;
4692
                    Custom_List.Add(Custom);
4693
                    Custom = new Symbol_Custom();
4694
                }
4695
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4696
                
4697
                Custom = new Symbol_Custom();
4698
                Custom_List = new List<Symbol_Custom>();
4699

    
4700
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4701

    
4702
                List<SYMBOL_PUBLIC> symbol_Public;
4703

    
4704
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4705
                {
4706
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4707
                }
4708
                else
4709
                {
4710
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4711
                }
4712
                foreach (var item in symbol_Public)
4713
                {
4714
                    Custom.Name = item.NAME;
4715
                    Custom.ImageUri = item.IMAGE_URL;
4716
                    Custom.ID = item.ID;
4717
                    Custom_List.Add(Custom);
4718
                    Custom = new Symbol_Custom();
4719
                }
4720
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4721
                BaseClient.Close();                
4722
            }
4723
            catch(Exception e)
4724
            {
4725
                //DialogMessage_Alert("DataBind", "Alert");
4726
            }
4727
            
4728
        }
4729
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4730
        {
4731
            try
4732
            {
4733
                if (args.PromptResult != null)
4734
                {
4735
                    if (args.DialogResult.Value)
4736
                    {
4737
                        PngBitmapEncoder _Encoder = symImage(data);
4738

    
4739
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4740
                        _Encoder.Save(fs);
4741
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4742

    
4743
                        byte[] Img_byte = fs.ToArray();
4744

    
4745
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4746
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4747
                        Check_Uri.UriCheck(filename);
4748
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4749
                        {
4750
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4751
                        }
4752
                        else
4753
                        {
4754
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4755
                        }
4756
                        DataBind();
4757
                    }
4758
                }
4759
            }
4760
            catch(Exception ex)
4761
            {
4762
                DialogMessage_Alert("" + ex, "Alert");
4763
            }
4764
        }
4765

    
4766
        public PngBitmapEncoder symImage(string data)
4767
        {
4768

    
4769
            Canvas _canvas = new Canvas();
4770
            _canvas.Background = Brushes.White;
4771
            _canvas.Width = adorner_.BorderSize.Width;
4772
            _canvas.Height = adorner_.BorderSize.Height;
4773
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4774

    
4775
            BitmapEncoder encoder = new PngBitmapEncoder();
4776

    
4777

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

    
4780
            DrawingVisual dv = new DrawingVisual();
4781

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

    
4785
            using (DrawingContext ctx = dv.RenderOpen())
4786
            {
4787
                VisualBrush vb = new VisualBrush(_canvas);
4788
                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)));
4789
            }
4790

    
4791
            try
4792
            {
4793
                renderBitmap.Render(dv);
4794

    
4795
                //GC.Collect();
4796
                GC.WaitForPendingFinalizers();
4797
                //GC.Collect();
4798
                // encode png data
4799
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4800
                // puch rendered bitmap into it
4801
                pngEncoder.Interlace = PngInterlaceOption.Off;
4802
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4803
                return pngEncoder;
4804

    
4805
            }
4806
            catch //(Exception ex)
4807
            {
4808
                return null;
4809
            }
4810

    
4811
        }
4812

    
4813
        public void DialogMessage_Alert(string content, string header)
4814
        {
4815
            var box = new TextBlock();
4816
            box.MinWidth = 400;
4817
            box.FontSize = 11;
4818
            //box.FontSize = 12;
4819
            box.Text = content;
4820
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4821

    
4822
            DialogParameters parameters = new DialogParameters()
4823
            {
4824
                Owner = Application.Current.MainWindow,
4825
                Content = box,
4826
                Header = header,
4827
                Theme = new VisualStudio2013Theme(),
4828
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4829
            };            
4830
            RadWindow.Alert(parameters);
4831
        }
4832

    
4833
        #region 캡쳐 기능
4834

    
4835
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4836
        {
4837
            if (x < 0)
4838
            {
4839
                width += x;
4840
                x = 0;
4841
            }
4842
            if (y < 0)
4843
            {
4844
                height += y;
4845
                y = 0;
4846

    
4847
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4848
            }
4849
            if (x + width > zoomAndPanCanvas.ActualWidth)
4850
            {
4851
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4852
            }
4853
            if (y + height > zoomAndPanCanvas.ActualHeight)
4854
            {
4855
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4856
            }
4857

    
4858
            byte[] pixels = CopyPixels(x, y, width, height);
4859

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

    
4862
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4863
        }
4864

    
4865
        public byte[] CopyPixels(int x, int y, int width, int height)
4866
        {
4867
            byte[] pixels = new byte[width * height * 4];
4868
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4869

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

    
4873
            return pixels;
4874
        }
4875

    
4876
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4877
        {
4878
            DrawingVisual drawingVisual = new DrawingVisual();
4879
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4880

    
4881
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4882
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4883
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4884
            drawingContext.Close();
4885

    
4886
            // 비트맵으로 변환합니다.
4887
            RenderTargetBitmap target =
4888
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4889
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4890

    
4891
            target.Render(drawingVisual);
4892
            return target;
4893
        }
4894

    
4895
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4896
        {
4897
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4898
            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);
4899
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4900
            bmp.UnlockBits(data);
4901
            return bmp;
4902
        }
4903
        public string symbolname = null;
4904
        public bool symbolsvg = true;
4905
        public bool symbolpng = true;
4906

    
4907
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4908
        {
4909
            System.Drawing.Bitmap image = GetBitmap(source);
4910
            //흰색 제거
4911
            //image.MakeTransparent(System.Drawing.Color.White);
4912

    
4913
            var imageStream = new System.IO.MemoryStream();
4914
            byte[] imageBytes = null;
4915
            using (imageStream)
4916
            {
4917
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4918
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4919
                imageStream.Position = 0;
4920
                imageBytes = imageStream.ToArray();
4921
            }
4922

    
4923
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4924

    
4925
            RadWindow CheckPop = new RadWindow();
4926
            //Alert check = new Alert(Msg);
4927

    
4928
            CheckPop = new RadWindow
4929
            {
4930
                MinWidth = 400,
4931
                MinHeight = 100,
4932
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4933
                Header = "Alert",
4934
                Content = symbolPrompt,
4935
                //DialogResult = 
4936
                ResizeMode = System.Windows.ResizeMode.NoResize,
4937
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4938
                IsTopmost = true,
4939
            };
4940
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4941
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4942
            CheckPop.ShowDialog();
4943

    
4944
            /*
4945
            DialogParameters parameters = new DialogParameters()
4946
            {
4947
                Owner = Application.Current.MainWindow,
4948
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4949
                DefaultPromptResultValue = "Custom State",
4950
                Content = "Name :",
4951
                Header = "Insert Custom Symbol Name",
4952
                Theme = new VisualStudio2013Theme(),
4953
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4954
            };            
4955
            RadWindow.Prompt(parameters);
4956
            */
4957
        }
4958

    
4959
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4960
        {
4961
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4962
            KCOMDataModel.DataModel.CHECK_LIST check_;
4963
            string Result = streamToBase64.ImageToBase64(source);
4964
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4965
            string projectno = App.ViewInfo.ProjectNO;
4966
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4967

    
4968
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4969
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4970
            if (Item != null)
4971
            {
4972
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4973
            }
4974
            else
4975
            {
4976
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4977
            }
4978

    
4979
            if (Item == null)
4980
            {
4981
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
4982
                {
4983
                    ID = Commons.shortGuid(),
4984
                    USER_ID = App.ViewInfo.UserID,
4985
                    IMAGE_URL = Result,
4986
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4987
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4988
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4989
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4990
                    PROJECT_NO = App.ViewInfo.ProjectNO,
4991
                    STATUS = "False",
4992
                    CREATE_TIME = DateTime.Now,
4993
                    UPDATE_TIME = DateTime.Now,
4994
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4995
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
4996
                };
4997
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
4998
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
4999
                //this.BaseClient.AddCheckList(projectno, check_);
5000
            }
5001
            else
5002
            {
5003
                Item.IMAGE_URL = Result;
5004
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5005
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5006
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5007
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5008
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5009
            }
5010

    
5011
        }
5012

    
5013
        public void Set_Capture()
5014
        {
5015
            double x = canvasDrawingMouseDownPoint.X;
5016
            double y = canvasDrawingMouseDownPoint.Y;
5017
            double width = dragCaptureBorder.Width;
5018
            double height = dragCaptureBorder.Height;
5019

    
5020
            if (width > 5 || height > 5)
5021
            {
5022
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5023
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5024
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5025
            }
5026
        }
5027
        #endregion
5028

    
5029
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5030
        {
5031
            multi_Undo_Data = new Multi_Undo_data();
5032

    
5033
            multi_Undo_Data.Markup = control;
5034

    
5035
            if ((control as IShapeControl) != null)
5036
            {
5037
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5038
            }
5039
            if ((control as IDashControl) != null)
5040
            {
5041
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5042
            }
5043
            if ((control as IPath) != null)
5044
            {
5045
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5046
            }
5047
            if ((control as UIElement) != null)
5048
            {
5049
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5050
            }
5051

    
5052
            return multi_Undo_Data;
5053
        }
5054

    
5055
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5056
        {
5057
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5058
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5059
            {
5060
                if (items.UserID == Select_ID)
5061
                {
5062
                    foreach (var item in items.MarkupList)
5063
                    {
5064
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5065
                        {
5066
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5067
                                items.MarkupInfoID, Commons.shortGuid());
5068
                        }
5069
                    }
5070
                }
5071
            }
5072
        }
5073

    
5074
        /// <summary>
5075
        /// convert inkcontrol to polygoncontrol
5076
        /// </summary>
5077
        public void ConvertInkControlToPolygon()
5078
        {
5079
            if (inkBoard.Strokes.Count > 0)
5080
            {
5081
                inkBoard.Strokes.ToList().ForEach(stroke =>
5082
                {
5083
                    InkToPath ip = new InkToPath();
5084

    
5085
                    List<Point> inkPointSet = new List<Point>();
5086
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5087

    
5088
                    PolygonControl pc = new PolygonControl()
5089
                    {
5090
                        Angle = 0,
5091
                        PointSet = inkPointSet,
5092
                        ControlType = ControlType.Ink
5093
                    };
5094
                    pc.StartPoint = inkPointSet[0];
5095
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5096
                    pc.LineSize = 3;
5097
                    pc.CommentID = Commons.shortGuid();
5098
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5099

    
5100
                    if (pc.PointSet.Count > 0)
5101
                    {
5102
                        CreateCommand.Instance.Execute(pc);
5103
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5104
                    }
5105
                });
5106
                inkBoard.Strokes.Clear();
5107
            }
5108
        }
5109

    
5110
        /// <summary>
5111
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5112
        /// </summary>
5113
        /// <author>ingu</author>
5114
        /// <date>2018.06.05</date>
5115
        /// <param name="getPoint"></param>
5116
        /// <returns></returns>
5117
        private bool IsGetoutpoint(Point getPoint)
5118
        {
5119
            if (getPoint == new Point())
5120
            {
5121
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5122
                currentControl = null;
5123
                return true;
5124
            }
5125

    
5126
            return false;
5127
        }
5128

    
5129
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5130
        {
5131
            e.Effects = DragDropEffects.Copy;
5132
        }
5133

    
5134
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5135
        {
5136
            e.Effects = DragDropEffects.Copy;
5137
        }
5138

    
5139
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5140
        {
5141
            e.Effects = DragDropEffects.None;
5142
        }
5143

    
5144
        /*
5145
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5146
        {
5147
            try
5148
            {
5149
                if (e.Data.GetDataPresent(typeof(string)))
5150
                {
5151
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5152
                    string dragData = e.Data.GetData(typeof(string)) as string;
5153
                    Move_Symbol(sender, dragData);
5154
                }
5155
            }
5156
            catch (Exception ex)
5157
            {
5158
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5159
            }            
5160
        }
5161
        */
5162
    }
5163
}
클립보드 이미지 추가 (최대 크기: 500 MB)