프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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
                                (control as ArrowTextControl).EnableEditing = true;
2274
                            }
2275
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2276
                            {
2277
                                ViewerDataModel.Instance.checkTextStyle = true;
2278
                            }
2279
                            else
2280
                            {
2281
                                ViewerDataModel.Instance.checkTextStyle = false;
2282
                            }
2283

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

    
2326
                        Control_Style(control);
2327

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

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

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

    
2387
                                    CreateCommand.Instance.Execute(currentControl);
2388

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

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

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

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

    
2435
                                    CreateCommand.Instance.Execute(currentControl);
2436

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

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

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

    
2470
                                    CreateCommand.Instance.Execute(currentControl);
2471

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

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

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

    
2505
                                    CreateCommand.Instance.Execute(currentControl);
2506

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

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

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

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

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

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

    
2576
                                    CreateCommand.Instance.Execute(currentControl);
2577

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

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

    
2611
                                    CreateCommand.Instance.Execute(currentControl);
2612

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

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

    
2651
                                        CreateCommand.Instance.Execute(currentControl);
2652

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

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

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

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

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

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

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

    
2738
                                    control.ApplyOverViewData();
2739

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

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

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

    
2783
                                    CreateCommand.Instance.Execute(currentControl);
2784

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

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

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

    
2840
                                    CreateCommand.Instance.Execute(currentControl);
2841

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

    
2883
                                    CreateCommand.Instance.Execute(currentControl);
2884

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

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

    
2943
                                            CreateCommand.Instance.Execute(currentControl);
2944

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

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

    
2988
                                    CreateCommand.Instance.Execute(currentControl);
2989

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3248
                                    CreateCommand.Instance.Execute(currentControl);
3249

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

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

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

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

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

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

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

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

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

    
3359
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3360

    
3361
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3362

    
3363
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3364
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3365
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3366

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

    
3400
                                    currentControl = new ArrowTextControl()
3401
                                        {
3402
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3403
                                        };
3404
                                        currentControl.CommentID = Commons.shortGuid();
3405
                                        currentControl.IsNew = true;
3406
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3407
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3408

    
3409
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3410

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

    
3421
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3422
                                        this.MainAngle.Visibility = Visibility.Visible;
3423
                                    
3424
                                    //20180911 LJY
3425
                                        (currentControl as ArrowTextControl).isTrans = true;
3426
                                    
3427

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

    
3463
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3464
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3465
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3466
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3467
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3468

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

    
3511
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3512
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3513
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3514
                                        (currentControl as ArrowTextControl).isFixed = true;
3515
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3516

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

    
3520
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3521
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3522
                                        this.MainAngle.Visibility = Visibility.Visible;  
3523
                                    
3524
                                    //20180911 LJY
3525
                                        (currentControl as ArrowTextControl).isTrans = true;
3526
                                    //}
3527
                                }
3528
                            }
3529
                        }
3530
                        break;
3531
                    //강인구 추가
3532
                    case ControlType.Sign:
3533
                        {
3534
                            if (e.LeftButton == MouseButtonState.Pressed)
3535
                            {
3536
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3537
                                //{
3538
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3539

    
3540
                                    if (_sign == null)
3541
                                    {
3542
                                        txtBatch.Visibility = Visibility.Collapsed;
3543
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3544
                                        controlType = ControlType.None;
3545

    
3546
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3547
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3548
                                        return;
3549
                                    }
3550

    
3551
                                    if (currentControl is SignControl)
3552
                                    {
3553
                                        //20180906 LJY TEST IsRotationDrawingEnable
3554
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3555
                                        {
3556
                                            return;
3557
                                        }
3558

    
3559
                                        CreateCommand.Instance.Execute(currentControl);
3560
                                        currentControl = null;
3561
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3562
                                        {
3563
                                            txtBatch.Text = "Place Date";
3564
                                            controlType = ControlType.Date;
3565
                                        }
3566
                                    }
3567
                                    else
3568
                                    {
3569
                                        currentControl = new SignControl
3570
                                        {
3571
                                            Background = new SolidColorBrush(Colors.Black),
3572
                                            UserNumber = App.ViewInfo.UserID,
3573
                                            ProjectNO = App.ViewInfo.ProjectNO,
3574
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3575
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3576
                                            ControlType = ControlType.Sign
3577
                                        };
3578

    
3579
                                        currentControl.CommentID = Commons.shortGuid();
3580
                                        currentControl.IsNew = true;
3581
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3582
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3583

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

    
3605
                                        CreateCommand.Instance.Execute(currentControl);
3606
                                        (currentControl as RectangleControl).ApplyOverViewData();
3607
                                        currentControl = null;
3608
                                    
3609
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3610

    
3611
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3612
                                        {
3613
                                            txtBatch.Text = "Place Signature";
3614
                                            controlType = ControlType.Sign;
3615
                                        }
3616
                                    }
3617
                                    else
3618
                                    {
3619
                                        currentControl = new RectangleControl
3620
                                        {
3621
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3622
                                            Background = new SolidColorBrush(Colors.Black),
3623
                                            ControlType = ControlType.Mark ,
3624
                                            Paint = PaintSet.Fill
3625
                                        };
3626

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

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

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

    
3689
                                        CreateCommand.Instance.Execute(currentControl);
3690
                                        currentControl = null;
3691
                                   
3692

    
3693
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3694
                                    }
3695
                                    else
3696
                                    {
3697
                                        currentControl = new SymControlN
3698
                                        {
3699
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3700
                                            Background = new SolidColorBrush(Colors.Black),
3701
                                            STAMP = App.SystemInfo.STAMP,
3702
                                            ControlType = ControlType.Stamp
3703
                                        };
3704

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

    
3753
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3754
                            if (over != null)
3755
                            {
3756
                                mouseOff = true;
3757
                            }
3758
                        }
3759
                    }
3760

    
3761
                    if (!mouseOff)
3762
                    {
3763
                        SelectionSet.Instance.UnSelect(this);
3764
                    }
3765
                }
3766
                zoomAndPanControl.CaptureMouse();
3767
                e.Handled = true;
3768
            }
3769
        }
3770

    
3771
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3772
        {
3773
            ///mouseButtonDown = e.ChangedButton;
3774
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3775
        }
3776

    
3777
        private void RemoveLineStroke(Point P)
3778
        {
3779
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3780
            if (control != null)
3781
            {
3782
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3783
            }
3784
        }
3785

    
3786
        private void RemovePointStroke(Point P)
3787
        {
3788
            foreach (Stroke hits in inkBoard.Strokes)
3789
            {
3790
                foreach (StylusPoint sty in hits.StylusPoints)
3791
                {
3792

    
3793
                }
3794
                if (hits.HitTest(P))
3795
                {
3796
                    inkBoard.Strokes.Remove(hits);
3797
                    return;
3798
                }
3799
            }
3800
        }
3801

    
3802
        private void StartNewStroke(Point P)
3803
        {
3804
            strokePoints = new StylusPointCollection();
3805
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3806
            strokePoints.Add(segment1Start);
3807
            stroke = new Stroke(strokePoints);
3808

    
3809
            stroke.DrawingAttributes.Color = Colors.Red;
3810
            stroke.DrawingAttributes.Width = 4;
3811
            stroke.DrawingAttributes.Height = 4;
3812

    
3813
            inkBoard.Strokes.Add(stroke);
3814

    
3815
        }
3816

    
3817
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3818
        {
3819
            ConsolidationMethod();
3820
        }
3821

    
3822
        /// <summary>
3823
        /// execute TeamConsolidationCommand
3824
        /// </summary>
3825
        public void TeamConsolidationMethod()
3826
        {
3827
            this.UpdateMyMarkupList();
3828
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3829
            {
3830
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3831
            }
3832
            else
3833
            {
3834

    
3835
                ViewerDataModel.Instance.IsConsolidate = true;
3836
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3837

    
3838
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3839
                {
3840
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3841
                    {
3842
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3843
                        return;
3844
                    }                    
3845
                }
3846
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3847
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3848
                {
3849
                    MarkupInfoList.Add(item);
3850
                }
3851
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3852
            }
3853
        }
3854

    
3855
        public void ConsolidationMethod()
3856
        {
3857
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3858
            {
3859
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3860
            }
3861
            else
3862
            {
3863
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3864
                foreach (var item in this.gridViewMarkup.SelectedItems)
3865
                {
3866
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3867
                }
3868
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3869
                
3870
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3871
            }
3872
        }
3873

    
3874
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3875
        {
3876
            if (App.ViewInfo != null)
3877
            {
3878
                btnConsolidate = (sender as RadRibbonButton);
3879
                if (!App.ViewInfo.NewCommentPermission)
3880
                {
3881
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3882
                }
3883
            }
3884
        }
3885

    
3886
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3887
        {
3888
            TeamConsolidationMethod();
3889
        }
3890

    
3891
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3892
        {
3893
            btnTeamConsolidate = sender as RadRibbonButton;
3894
            if (App.ViewInfo != null)
3895
            {
3896
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3897
                {
3898
                    if (btnConsolidate != null)
3899
                    {
3900
                        btnConsolidate.Visibility = Visibility.Collapsed;
3901
                    }
3902

    
3903
                    if (!App.ViewInfo.NewCommentPermission)
3904
                    {
3905
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3906
                    }
3907
                }
3908
                else
3909
                {
3910
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3911
                }
3912
            }
3913
        }
3914

    
3915
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3916
        {
3917
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3918
            if (item != null)
3919
            {
3920
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3921

    
3922
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3923
            }
3924
            else
3925
            {
3926
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3927
            }
3928
        }
3929

    
3930
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3931
        {
3932
            btnFinalPDF = sender as RadRibbonButton;
3933
            if (App.ViewInfo != null)
3934
            {
3935
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3936
                {
3937
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3938
                    if (btnConsolidate != null)
3939
                    {
3940
                        btnConsolidate.Visibility = Visibility.Collapsed;
3941
                    }
3942
                }
3943
            }
3944
        }
3945

    
3946
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3947
        {
3948
            UpdateMyMarkupList();
3949

    
3950
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3951
            {
3952
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3953
            }
3954
            else
3955
            {
3956
                ViewerDataModel.Instance.IsConsolidate = true;
3957
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3958
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3959

    
3960
                string project_no = App.ViewInfo.ProjectNO;
3961
                string doc_id = _DocInfo.ID;
3962
                string user_id = App.ViewInfo.UserID;
3963
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3964
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3965
                {
3966
                    markupInfoItems.Add(item);
3967
                }
3968
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3969
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3970
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3971
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3972

    
3973
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3974
                if (item2 != null)
3975
                {
3976
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3977

    
3978
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
3979
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
3980
                }
3981
                else
3982
                {
3983
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3984
                }
3985
            }
3986
        }
3987

    
3988
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
3989
        {
3990
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
3991

    
3992
            if (App.ViewInfo != null)
3993
            {
3994
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
3995
                {
3996
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3997
                }
3998
            }
3999
        }
4000

    
4001
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4002
        {
4003
            if (CompareMode.IsChecked)
4004
            {
4005
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4006
                {
4007
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4008
                }
4009
                if (ViewerDataModel.Instance.PageNumber == 0)
4010
                {
4011
                    ViewerDataModel.Instance.PageNumber = 1;
4012
                }
4013

    
4014
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4015
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4016
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4017

    
4018
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4019
            }
4020
            else
4021
            {
4022
                da.From = 1;
4023
                da.To = 1;
4024
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4025
                da.AutoReverse = false;
4026
                canvas_compareBorder.Children.Clear();
4027
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4028
            }
4029
        }
4030

    
4031
        private void Sync_Click(object sender, RoutedEventArgs e)
4032
        {
4033
            if (Sync.IsChecked)
4034
            {
4035
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4036
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4037
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4038
            }
4039
        }
4040

    
4041
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4042
        {
4043
            if (UserList.IsChecked)
4044
            {
4045
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4046
            }
4047
            else
4048
            {
4049
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4050
            }
4051
        }
4052

    
4053
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4054
        {
4055

    
4056
            if (BalanceMode.IsChecked)
4057
            {
4058
                ViewerDataModel.Instance.PageBalanceMode = true;
4059
            }
4060
            else
4061
            {
4062
                ViewerDataModel.Instance.PageBalanceMode = false;
4063
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4064
            }
4065
        }
4066

    
4067
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4068
        {
4069
            //초기화
4070
            testPanel2.IsHidden = true;
4071
            ViewerDataModel.Instance.PageBalanceMode = false;
4072
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4073
            ViewerDataModel.Instance.PageNumber = 0;
4074
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4075
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4076
            UserList.IsChecked = false;
4077
            BalanceMode.IsChecked = false;
4078
        }
4079

    
4080
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4081
        {
4082
            if ((sender as System.Windows.Controls.Control).Tag != null)
4083
            {
4084
                //Compare 초기화
4085
                CompareMode.IsChecked = false;
4086
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4087

    
4088
                if (ViewerDataModel.Instance.PageNumber == 0)
4089
                {
4090
                    ViewerDataModel.Instance.PageNumber = 1;
4091
                }
4092

    
4093
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4094
                {
4095
                }
4096
                else
4097
                {
4098
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4099
                }
4100

    
4101
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4102
                {
4103

    
4104
                }
4105
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4106
                {
4107
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4108
                }
4109

    
4110
                if (!testPanel2.IsHidden)
4111
                {
4112
                    if (IsSyncPDFMode)
4113
                    {
4114
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4115
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4116

    
4117
                        if (pdfpath.IsDownloading)
4118
                        {
4119
                            pdfpath.DownloadCompleted += (ex, arg) =>
4120
                            {
4121
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4122
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4123
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4124
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4125
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4126
                            };
4127
                        }
4128
                        else
4129
                        {
4130
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4131
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4132
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4133

    
4134
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4135
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4136
                        }
4137

    
4138
                    }
4139
                    else
4140
                    {
4141
                        string uri = "";
4142

    
4143
                        if (userData.COMPANY != "EXT")
4144
                        {
4145
                            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);
4146
                        }
4147
                        else
4148
                        {
4149
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4150
                        }
4151

    
4152
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4153

    
4154
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4155
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4156
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4157

    
4158
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4159
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4160

    
4161
                        if (defaultBitmapImage_Compare.IsDownloading)
4162
                        {
4163
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4164
                            {
4165
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4166
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4167
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4168

    
4169
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4170
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4171
                            };
4172
                        }
4173
                    }
4174

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

    
4179
                    foreach (var item in gridSelectionRevItem)
4180
                    {
4181
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4182
                        {
4183
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4184
                        });
4185
                    }
4186

    
4187
                    //강인구 추가
4188
                    zoomAndPanControl2.ZoomTo(new Rect
4189
                    {
4190
                        X = 0,
4191
                        Y = 0,
4192
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4193
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4194
                    });
4195

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

    
4198
                }
4199
            }
4200
        }
4201

    
4202
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4203
        {
4204
            if (MarkupMode.IsChecked)
4205
            {
4206
                IsSyncPDFMode = true;
4207

    
4208
                var uri = CurrentRev.TO_VENDOR;
4209

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

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

    
4219
                if (pdfpath.IsDownloading)
4220
                {
4221
                    pdfpath.DownloadCompleted += (ex, arg) =>
4222
                    {
4223
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4224
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4225
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4226
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4227
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4228
                    };
4229
                }
4230
                else
4231
                {
4232
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4233
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4234
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4235

    
4236
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4237
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4238
                }
4239
            }
4240
            else
4241
            {
4242
                IsSyncPDFMode = false;
4243
                string uri = "";
4244
                if (userData.COMPANY != "EXT")
4245
                {
4246
                    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);
4247
                }
4248
                else
4249
                {
4250
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4251
                }
4252

    
4253
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4254

    
4255
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4256
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4257
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4258

    
4259
                if (defaultBitmapImage_Compare.IsDownloading)
4260
                {
4261
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                }
4268
                zoomAndPanControl2.ApplyTemplate();
4269
                zoomAndPanControl2.UpdateLayout();
4270
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4271
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4272
            }
4273
        }
4274

    
4275
        private void RadButton_Click(object sender, RoutedEventArgs e)
4276
        {
4277
            gridViewHistory_Busy.IsBusy = true;
4278

    
4279
            RadButton instance = sender as RadButton;
4280
            if (instance.CommandParameter != null)
4281
            {
4282
                CurrentRev = instance.CommandParameter as VPRevision;
4283
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4284
                {
4285
                    if (ea.Error == null && ea.Result != null)
4286
                    {
4287
                        testPanel2.IsHidden = false;
4288

    
4289
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4290
                        foreach(var info in ea.Result)
4291
                        {
4292
                            if(info.UserID == App.ViewInfo.UserID)
4293
                            {
4294
                                info.userDelete = true;
4295
                                info.DisplayColor = "FFFF0000";
4296
                            }
4297
                            else
4298
                            {
4299
                                info.userDelete = false;
4300
                            }
4301
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4302
                        }
4303
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4304

    
4305
                        string uri = "";
4306
                        if (userData.COMPANY != "EXT")
4307
                        {
4308
                            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);
4309
                        }
4310
                        else
4311
                        {
4312
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4313
                        }
4314

    
4315
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4316

    
4317
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4318

    
4319
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4320
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4321
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4322

    
4323
                        if (defaultBitmapImage_Compare.IsDownloading)
4324
                        {
4325
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                        }
4332

    
4333
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4334
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4335
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4336
                        zoomAndPanControl2.ApplyTemplate();
4337
                        zoomAndPanControl2.UpdateLayout();
4338

    
4339
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4340
                        {
4341
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4342
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4343
                        }
4344

    
4345
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4346
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4347
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4348

    
4349
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4350
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4351
                        gridViewHistory_Busy.IsBusy = false;
4352
                    }
4353

    
4354
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4355
                };
4356
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4357
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4358
            }
4359
        }
4360

    
4361
        public void Sync_Event(VPRevision Currnet_Rev)
4362
        {
4363
            CurrentRev = Currnet_Rev;
4364

    
4365
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4366
            {
4367
                if (ea.Error == null && ea.Result != null)
4368
                {
4369
                    testPanel2.IsHidden = false;
4370

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

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

    
4397
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4398

    
4399
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4400

    
4401
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4402
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4403
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4404

    
4405
                    if (defaultBitmapImage_Compare.IsDownloading)
4406
                    {
4407
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                    }
4414

    
4415

    
4416
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4417
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4418
                    zoomAndPanControl2.ApplyTemplate();
4419
                    zoomAndPanControl2.UpdateLayout();
4420

    
4421
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4422
                    {
4423
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4424
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4425
                    }
4426
                    //}
4427

    
4428
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4429
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4430
                    gridViewHistory_Busy.IsBusy = false;
4431
                }
4432
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4433

    
4434
            };
4435
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4436
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4437
        }
4438

    
4439
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4440
        {
4441
            if (sender is Image)
4442
            {
4443
                if ((sender as Image).Tag != null)
4444
                {
4445
                    var pdfUrl = (sender as Image).Tag.ToString();
4446
                    System.Diagnostics.Process.Start(pdfUrl);
4447
                }
4448
                else
4449
                {
4450
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4451
                }
4452
            }
4453
        }
4454

    
4455
        private void Create_Symbol(object sender, RoutedEventArgs e)
4456
        {
4457
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4458

    
4459
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4460
            {
4461
                DialogMessage_Alert("Please Select Controls", "Alert");
4462
            }
4463
            else //선택된 것이 있으면
4464
            {
4465
                string MarkupData = "";
4466
                adorner_ = new AdornerFinal();
4467

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

    
4496
        }
4497
        public int symbolselectindex = 0;
4498
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4499
        {
4500
            //Save save = new Save();
4501
            try
4502
            {
4503
                string svgfilename = null;
4504
                if (symbolname != null)
4505
                {
4506
                    if (symbolpng == true || symbolsvg == true)
4507
                    {
4508
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4509
                        string guid = Commons.shortGuid();
4510

    
4511
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4512
                        //Check_Uri.UriCheck();
4513
                        fileUploader.RunCompleted += (ex, arg) =>
4514
                        {
4515
                            filename = arg.Result;
4516
                            if (symbolpng == true)
4517
                            {
4518
                                if (filename != null)
4519
                                { 
4520
                                    if (symbolselectindex == 0)
4521
                                    {
4522
                                        SymbolSave(symbolname, filename, data);
4523
                                    }
4524
                                    else
4525
                                    {
4526
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4527
                                    }
4528
                                    DataBind();
4529
                                }                                
4530
                            }
4531

    
4532
                            if (symbolsvg == true)
4533
                            {
4534
                                try
4535
                                {
4536
                                    var defaultBitmapImage = new BitmapImage();
4537
                                    defaultBitmapImage.BeginInit();
4538
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4539
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4540
                                    Check_Uri.UriCheck(filename);
4541
                                    defaultBitmapImage.UriSource = new Uri(filename);
4542
                                    defaultBitmapImage.EndInit();
4543

    
4544
                                    System.Drawing.Bitmap image;
4545

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

    
4568
                                            StringBuilder svgBuilder = new StringBuilder();
4569
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4570
                                            {
4571
                                                svgBuilder.AppendLine(e2.Data);
4572
                                            };
4573

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

    
4590
                                                DataBind();
4591
                                            };
4592
                                            potrace.WaitForExit();
4593
                                        };
4594
                                    }
4595
                                    else
4596
                                    {
4597
                                        //GC.Collect();
4598
                                    }
4599
                                }
4600
                                catch(Exception ee)
4601
                                {
4602
                                    DialogMessage_Alert("" + ee, "Alert");
4603
                                }
4604
                            }
4605
                        };                                             
4606
                    }
4607
                }
4608
            }
4609
            catch (Exception e)
4610
            {
4611
                //DialogMessage_Alert(e + "", "Alert");
4612
            }            
4613
        }
4614

    
4615
        public void SymbolSave(string Name, string Url, string Data)
4616
        {
4617
            try
4618
            {
4619
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4620
                {
4621
                    ID = Commons.shortGuid(),
4622
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4623
                    NAME = Name,
4624
                    IMAGE_URL = Url,
4625
                    DATA = Data
4626
                };
4627

    
4628
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4629
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4630
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4631
            }
4632
            catch (Exception)
4633
            {
4634
                throw;
4635
            }
4636
        }
4637

    
4638
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4639
        {
4640
            try
4641
            {
4642
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4643
                {
4644
                    ID = Commons.shortGuid(),
4645
                    DEPARTMENT = Department,
4646
                    NAME = Name,
4647
                    IMAGE_URL = Url,
4648
                    DATA = Data
4649
                };
4650
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4651
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4652
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4653
            }
4654
            catch (Exception)
4655
            {
4656
                throw;
4657
            }
4658
        }
4659

    
4660
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4661
        {           
4662
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4663
            DataBind();
4664
        }
4665

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

    
4692
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4693

    
4694
                List<SYMBOL_PUBLIC> symbol_Public;
4695

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

    
4731
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4732
                        _Encoder.Save(fs);
4733
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4734

    
4735
                        byte[] Img_byte = fs.ToArray();
4736

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

    
4758
        public PngBitmapEncoder symImage(string data)
4759
        {
4760

    
4761
            Canvas _canvas = new Canvas();
4762
            _canvas.Background = Brushes.White;
4763
            _canvas.Width = adorner_.BorderSize.Width;
4764
            _canvas.Height = adorner_.BorderSize.Height;
4765
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4766

    
4767
            BitmapEncoder encoder = new PngBitmapEncoder();
4768

    
4769

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

    
4772
            DrawingVisual dv = new DrawingVisual();
4773

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

    
4777
            using (DrawingContext ctx = dv.RenderOpen())
4778
            {
4779
                VisualBrush vb = new VisualBrush(_canvas);
4780
                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)));
4781
            }
4782

    
4783
            try
4784
            {
4785
                renderBitmap.Render(dv);
4786

    
4787
                //GC.Collect();
4788
                GC.WaitForPendingFinalizers();
4789
                //GC.Collect();
4790
                // encode png data
4791
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4792
                // puch rendered bitmap into it
4793
                pngEncoder.Interlace = PngInterlaceOption.Off;
4794
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4795
                return pngEncoder;
4796

    
4797
            }
4798
            catch //(Exception ex)
4799
            {
4800
                return null;
4801
            }
4802

    
4803
        }
4804

    
4805
        public void DialogMessage_Alert(string content, string header)
4806
        {
4807
            var box = new TextBlock();
4808
            box.MinWidth = 400;
4809
            box.FontSize = 11;
4810
            //box.FontSize = 12;
4811
            box.Text = content;
4812
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4813

    
4814
            DialogParameters parameters = new DialogParameters()
4815
            {
4816
                Owner = Application.Current.MainWindow,
4817
                Content = box,
4818
                Header = header,
4819
                Theme = new VisualStudio2013Theme(),
4820
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4821
            };            
4822
            RadWindow.Alert(parameters);
4823
        }
4824

    
4825
        #region 캡쳐 기능
4826

    
4827
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4828
        {
4829
            if (x < 0)
4830
            {
4831
                width += x;
4832
                x = 0;
4833
            }
4834
            if (y < 0)
4835
            {
4836
                height += y;
4837
                y = 0;
4838

    
4839
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4840
            }
4841
            if (x + width > zoomAndPanCanvas.ActualWidth)
4842
            {
4843
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4844
            }
4845
            if (y + height > zoomAndPanCanvas.ActualHeight)
4846
            {
4847
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4848
            }
4849

    
4850
            byte[] pixels = CopyPixels(x, y, width, height);
4851

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

    
4854
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4855
        }
4856

    
4857
        public byte[] CopyPixels(int x, int y, int width, int height)
4858
        {
4859
            byte[] pixels = new byte[width * height * 4];
4860
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4861

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

    
4865
            return pixels;
4866
        }
4867

    
4868
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4869
        {
4870
            DrawingVisual drawingVisual = new DrawingVisual();
4871
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4872

    
4873
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4874
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4875
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4876
            drawingContext.Close();
4877

    
4878
            // 비트맵으로 변환합니다.
4879
            RenderTargetBitmap target =
4880
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4881
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4882

    
4883
            target.Render(drawingVisual);
4884
            return target;
4885
        }
4886

    
4887
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4888
        {
4889
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4890
            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);
4891
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4892
            bmp.UnlockBits(data);
4893
            return bmp;
4894
        }
4895
        public string symbolname = null;
4896
        public bool symbolsvg = true;
4897
        public bool symbolpng = true;
4898

    
4899
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4900
        {
4901
            System.Drawing.Bitmap image = GetBitmap(source);
4902
            //흰색 제거
4903
            //image.MakeTransparent(System.Drawing.Color.White);
4904

    
4905
            var imageStream = new System.IO.MemoryStream();
4906
            byte[] imageBytes = null;
4907
            using (imageStream)
4908
            {
4909
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4910
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4911
                imageStream.Position = 0;
4912
                imageBytes = imageStream.ToArray();
4913
            }
4914

    
4915
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4916

    
4917
            RadWindow CheckPop = new RadWindow();
4918
            //Alert check = new Alert(Msg);
4919

    
4920
            CheckPop = new RadWindow
4921
            {
4922
                MinWidth = 400,
4923
                MinHeight = 100,
4924
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4925
                Header = "Alert",
4926
                Content = symbolPrompt,
4927
                //DialogResult = 
4928
                ResizeMode = System.Windows.ResizeMode.NoResize,
4929
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4930
                IsTopmost = true,
4931
            };
4932
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4933
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4934
            CheckPop.ShowDialog();
4935

    
4936
            /*
4937
            DialogParameters parameters = new DialogParameters()
4938
            {
4939
                Owner = Application.Current.MainWindow,
4940
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4941
                DefaultPromptResultValue = "Custom State",
4942
                Content = "Name :",
4943
                Header = "Insert Custom Symbol Name",
4944
                Theme = new VisualStudio2013Theme(),
4945
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4946
            };            
4947
            RadWindow.Prompt(parameters);
4948
            */
4949
        }
4950

    
4951
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4952
        {
4953
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4954
            KCOMDataModel.DataModel.CHECK_LIST check_;
4955
            string Result = streamToBase64.ImageToBase64(source);
4956
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4957
            string projectno = App.ViewInfo.ProjectNO;
4958
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4959

    
4960
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4961
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4962
            if (Item != null)
4963
            {
4964
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4965
            }
4966
            else
4967
            {
4968
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4969
            }
4970

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

    
5003
        }
5004

    
5005
        public void Set_Capture()
5006
        {
5007
            double x = canvasDrawingMouseDownPoint.X;
5008
            double y = canvasDrawingMouseDownPoint.Y;
5009
            double width = dragCaptureBorder.Width;
5010
            double height = dragCaptureBorder.Height;
5011

    
5012
            if (width > 5 || height > 5)
5013
            {
5014
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5015
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5016
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5017
            }
5018
        }
5019
        #endregion
5020

    
5021
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5022
        {
5023
            multi_Undo_Data = new Multi_Undo_data();
5024

    
5025
            multi_Undo_Data.Markup = control;
5026

    
5027
            if ((control as IShapeControl) != null)
5028
            {
5029
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5030
            }
5031
            if ((control as IDashControl) != null)
5032
            {
5033
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5034
            }
5035
            if ((control as IPath) != null)
5036
            {
5037
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5038
            }
5039
            if ((control as UIElement) != null)
5040
            {
5041
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5042
            }
5043

    
5044
            return multi_Undo_Data;
5045
        }
5046

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

    
5066
        /// <summary>
5067
        /// convert inkcontrol to polygoncontrol
5068
        /// </summary>
5069
        public void ConvertInkControlToPolygon()
5070
        {
5071
            Logger.sendCheckLog("pageNavigator_PageChanging_ConvertInkControlToPolygon", 1);
5072
            if (inkBoard.Strokes.Count > 0)
5073
            {
5074
                inkBoard.Strokes.ToList().ForEach(stroke =>
5075
                {
5076
                    InkToPath ip = new InkToPath();
5077

    
5078
                    List<Point> inkPointSet = new List<Point>();
5079
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5080

    
5081
                    PolygonControl pc = new PolygonControl()
5082
                    {
5083
                        Angle = 0,
5084
                        PointSet = inkPointSet,
5085
                        ControlType = ControlType.Ink
5086
                    };
5087
                    pc.StartPoint = inkPointSet[0];
5088
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5089
                    pc.LineSize = 3;
5090
                    pc.CommentID = Commons.shortGuid();
5091
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5092

    
5093
                    if (pc.PointSet.Count > 0)
5094
                    {
5095
                        CreateCommand.Instance.Execute(pc);
5096
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5097
                    }
5098
                });
5099
                inkBoard.Strokes.Clear();
5100
            }
5101
        }
5102

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

    
5119
            return false;
5120
        }
5121

    
5122
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5123
        {
5124
            e.Effects = DragDropEffects.Copy;
5125
        }
5126

    
5127
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5128
        {
5129
            e.Effects = DragDropEffects.Copy;
5130
        }
5131

    
5132
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5133
        {
5134
            e.Effects = DragDropEffects.None;
5135
        }
5136

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