프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (310 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 Undo_data UndoData { get; set; }
126
        public CommentUserInfo currentControl { get; set; }
127
        public ControlType controlType { get; set; }
128
        private Move move = new Move();
129
        private double[] rotateValue = { 0, 90, 180, 270 };
130
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
131
        private static readonly double DragThreshold = 5;
132
        private System.Windows.Input.Cursor cursor { get; set; }
133
        private Point canvasDrawingMouseDownPoint;
134
        public string filename { get; set; }
135
        private Point canvasZoomPanningMouseDownPoint;
136
        public Point getCurrentPoint;
137
        private Point canvasZoommovingMouseDownPoint;
138
        List<object> ControlList = new List<object>();
139
        private ListBox listBox = new ListBox();
140
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
141
        private bool isDraggingSelectionRect = false;
142
        DrawingAttributes inkDA = new DrawingAttributes();
143
        private VPRevision CurrentRev { get; set; }
144
        public RadRibbonButton btnConsolidate { get; set; }
145
        public RadRibbonButton btnFinalPDF { get; set; }
146
        public RadRibbonButton btnTeamConsolidate { get; set; }
147
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
148

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

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

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

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

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

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

    
271
            return false;
272
        }
273

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

    
297
            return false;
298
        }
299

    
300

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

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

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

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

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

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

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

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

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

    
374
            DeleteItem(item);
375
        }
376

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

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

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

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

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

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

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

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

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

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

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

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

    
496
        bool ComingNewBieEnd = false;
497

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

    
509
            InkControl_Convert();
510

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

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

    
518

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

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

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

    
533
            #endregion
534

    
535
            ViewerDataModel.Instance.PageNumber = BalancePoint;
536

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

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

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

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

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

    
576

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

    
582

    
583

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

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

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

    
630
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
631
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
632

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

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

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

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

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

    
675
            this.pageNavigator.SetNextPage();
676

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

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

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

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

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

    
704

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

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

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

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

    
726

    
727
        
728

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

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

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

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

    
789
        #region ZoomIn & ZoomOut
790

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

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

    
803

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

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

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

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

    
839
        }
840

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

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

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

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

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

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

    
893
        #endregion
894

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

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

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

    
907
        }
908

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

    
916
            if (element == null)
917
            {
918
                return HitTestResultBehavior.Stop;
919
            }
920
            else
921
            {
922
                if (element is CommentUserInfo)
923
                {
924
                    if (!hitList.Contains(element))
925
                    {
926
                        hitList.Add((CommentUserInfo)element);
927
                    }
928
                    else
929
                    {
930
                        return HitTestResultBehavior.Stop;
931
                    }
932
                    //IntersectionDetail intersectionDetail =
933
                    //((GeometryHitTestResult)result).IntersectionDetail;
934
                    //switch (intersectionDetail)
935
                    //{
936
                    //    case IntersectionDetail.FullyContains:
937
                    //        // Add the hit test result to the list:
938
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
939
                    //        return HitTestResultBehavior.Continue;
940
                    //    case IntersectionDetail.Intersects:
941
                    //        // Set the behavior to return visuals at all z-order levels:
942
                    //        return HitTestResultBehavior.Continue;
943
                    //    case IntersectionDetail.FullyInside:
944
                    //        // Set the behavior to return visuals at all z-order levels:
945
                    //        return HitTestResultBehavior.Continue;
946
                    //    default:
947
                    //        return HitTestResultBehavior.Stop;
948
                    //}
949
                }
950
            }
951
            return HitTestResultBehavior.Continue;
952
        }
953

    
954
        public void ReleaseSelectPath()
955
        {
956
            if (SelectionPath == null)
957
            {
958
                SelectionPath = new Path();
959
                SelectionPath.Name = "";
960
            }
961
            if (SelectionPath.Name != "")
962
            {
963
                SelectionPath.Name = "None";
964
            }
965
            SelectionPath.Opacity = 0.01;
966
            SelectionPath.RenderTransform = null;
967
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
968
        }
969

    
970
        #region 컨트롤 초기화 
971
        public void Control_Init(object control)
972
        {
973
            if (L_Size != 0 && (control as IPath) != null)
974
            {
975
                (control as IPath).LineSize = L_Size;
976
                L_Size = 0;
977
            }
978

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

    
1065
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1066
        {
1067
            //Control_Init(e.Source);
1068
        }
1069
        private Window _dragdropWindow = null;
1070

    
1071
        [DllImport("user32.dll")]
1072
        [return: MarshalAs(UnmanagedType.Bool)]
1073
        internal static extern bool GetCursorPos(ref Win32Point pt);
1074

    
1075
        [StructLayout(LayoutKind.Sequential)]
1076
        internal struct Win32Point
1077
        {
1078
            public Int32 X;
1079
            public Int32 Y;
1080
        };
1081
        public string symbol_id = null;
1082
        public long symbol_group_id;
1083
        public int symbol_SelectedIndex;
1084
        public ImageSource symbol_img;
1085
        public string symbol_Data = null;
1086
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1087
        {
1088
            if (this._dragdropWindow != null)
1089
            {
1090
                this._dragdropWindow.Close();
1091
                this._dragdropWindow = null;
1092
            }
1093

    
1094
            symbol_id = id;
1095
            symbol_group_id = group_id;
1096
            symbol_SelectedIndex = SelectedIndex;
1097
            symbol_Data = Data_;
1098
            symbol_img = img;
1099

    
1100
      
1101
            CreateDragDropWindow2(img);
1102
        }
1103

    
1104
        private void CreateDragDropWindow2(ImageSource image)
1105
        {
1106
            this._dragdropWindow = new Window();
1107
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1108
            _dragdropWindow.WindowStyle = WindowStyle.None;
1109
            _dragdropWindow.AllowsTransparency = true;           
1110
            _dragdropWindow.AllowDrop = false;
1111
            _dragdropWindow.Background = null;
1112
            _dragdropWindow.IsHitTestVisible = false;
1113
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1114
            _dragdropWindow.Topmost = true;
1115
            _dragdropWindow.ShowInTaskbar = false;
1116
            
1117
            Rectangle r = new Rectangle();
1118
            r.Width = image.Width;
1119
            r.Height = image.Height;
1120
            r.Opacity = 0.5;            
1121
            r.Fill = new ImageBrush(image);
1122
            this._dragdropWindow.Content = r;
1123

    
1124
            Win32Point w32Mouse = new Win32Point();
1125
            GetCursorPos(ref w32Mouse);
1126

    
1127
            //w32Mouse.X = getCurrentPoint.X;
1128
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1129
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1130
            this._dragdropWindow.Show();
1131
        }
1132

    
1133
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1134
        {
1135
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1136
            {
1137
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1138

    
1139
                Point currentPos = e.GetPosition(rect);
1140

    
1141
                floatingTip.HorizontalOffset = currentPos.X + 20;
1142
                floatingTip.VerticalOffset = currentPos.Y;
1143
            }
1144

    
1145
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1146
            
1147
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1148
            {
1149
                SetCursor();
1150
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1151
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1152

    
1153
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1154
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1155
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1156

    
1157
                if (Sync.IsChecked)
1158
                {
1159
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1160
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1161
                }
1162
            }
1163

    
1164
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1165
            {
1166
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1167
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1168
                SetCursor();
1169

    
1170
                if (currentControl != null)
1171
                {
1172
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1173
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1174
                    //강인구 추가
1175
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1176

    
1177
                    if ((currentControl as IPath) != null)
1178
                    {
1179
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1180
                    }
1181
                    if ((currentControl as LineControl) != null)
1182
                    {
1183
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1184
                    }
1185

    
1186
                    if ((currentControl as IShapeControl) != null)
1187
                    {
1188
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1189
                    }
1190
                    if ((currentControl as TextControl) != null)
1191
                    {
1192
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1193
                        {
1194
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1195
                        }
1196
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1197
                        {
1198
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1199
                        }
1200
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1201
                        {
1202
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1203
                        }
1204
                    }
1205
                    else if ((currentControl as ArrowTextControl) != null)
1206
                    {
1207
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1208
                        {
1209
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1210
                        }
1211
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1212
                        {
1213
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1214
                        }
1215
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1216
                        {
1217
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1218
                        }
1219
                    }
1220
                    else if ((currentControl as RectCloudControl) != null)
1221
                    {
1222
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1223
                    }
1224
                    else if ((currentControl as CloudControl) != null)
1225
                    {
1226
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1227
                    }
1228

    
1229
                    switch (controlType)
1230
                    {
1231
                        case (ControlType.Coordinate):
1232
                            {
1233
                                var control = currentControl as CoordinateControl;
1234

    
1235
                                if (control != null)
1236
                                {
1237
                                    if (move.mousemode == MouseMode.Drawing)
1238
                                    {
1239
                                        //move.control_Move(ControlList, true, moveX, moveY);
1240
                                    }
1241
                                    else
1242
                                    {
1243
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1244
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1245
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1246
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1247

    
1248

    
1249
                                        if (ViewerDataModel.Instance.IsPressShift)
1250
                                        {
1251
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1252
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1253
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1254
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1255
                                        }
1256

    
1257
                                        control.PointSet = new List<Point>
1258
                                        {
1259
                                            control.StartPoint,
1260
                                            control.LeftBottomPoint,
1261
                                            control.EndPoint,
1262
                                            control.TopRightPoint,
1263
                                        };
1264
                                        control.updateControl();
1265
                                    }
1266

    
1267
                                    //강인구 추가
1268
                                    control.ControlType = controlType;
1269
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1270
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1271
                                    //  control.Paint = PaintSet.Fill;
1272
                                }
1273
                            }
1274
                            break;
1275
                        case (ControlType.InsideWhite):
1276
                            {
1277
                                var control = currentControl as InsideWhiteControl;
1278

    
1279
                                if (control != null)
1280
                                {
1281
                                    if (move.mousemode == MouseMode.Drawing)
1282
                                    {
1283
                                        //move.control_Move(ControlList, true, moveX, moveY);
1284
                                    }
1285
                                    else
1286
                                    {
1287
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1288
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1289
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1290
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1291

    
1292

    
1293
                                        if (ViewerDataModel.Instance.IsPressShift)
1294
                                        {
1295
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1296
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1297
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1298
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1299
                                        }
1300

    
1301
                                        control.PointSet = new List<Point>
1302
                                        {
1303
                                            control.StartPoint,
1304
                                            control.LeftBottomPoint,
1305
                                            control.EndPoint,
1306
                                            control.TopRightPoint,
1307
                                        };
1308
                                        control.updateControl();
1309
                                    }
1310

    
1311
                                    //강인구 추가
1312
                                    control.ControlType = controlType;
1313
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1314
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1315
                                    control.Paint = PaintSet.Fill;
1316
                                }
1317
                            }
1318
                            break;
1319
                        case (ControlType.OverlapWhite):
1320
                            {
1321
                                var control = currentControl as OverlapWhiteControl;
1322

    
1323
                                if (control != null)
1324
                                {
1325
                                    if (move.mousemode == MouseMode.Drawing)
1326
                                    {
1327
                                        //move.control_Move(ControlList, true, moveX, moveY);
1328
                                    }
1329
                                    else
1330
                                    {
1331
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1332
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1333
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1334
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1335

    
1336

    
1337
                                        if (ViewerDataModel.Instance.IsPressShift)
1338
                                        {
1339
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1340
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1341
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1342
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1343
                                        }
1344

    
1345
                                        control.PointSet = new List<Point>
1346
                                        {
1347
                                            control.StartPoint,
1348
                                            control.LeftBottomPoint,
1349
                                            control.EndPoint,
1350
                                            control.TopRightPoint,
1351
                                        };
1352
                                        control.updateControl();
1353
                                    }
1354

    
1355
                                    //강인구 추가
1356
                                    control.ControlType = controlType;
1357
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1358
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1359
                                    control.Paint = PaintSet.Fill;
1360
                                }
1361
                            }
1362
                            break;
1363
                        case (ControlType.ClipWhite):
1364
                            {
1365
                                var control = currentControl as ClipWhiteControl;
1366

    
1367
                                if (control != null)
1368
                                {
1369
                                    if (move.mousemode == MouseMode.Drawing)
1370
                                    {
1371
                                        //move.control_Move(ControlList, true, moveX, moveY);
1372
                                    }
1373
                                    else
1374
                                    {
1375
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1376
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1377
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1378
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1379

    
1380

    
1381
                                        if (ViewerDataModel.Instance.IsPressShift)
1382
                                        {
1383
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1384
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1385
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1386
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1387
                                        }
1388

    
1389
                                        control.PointSet = new List<Point>
1390
                                        {
1391
                                            control.StartPoint,
1392
                                            control.LeftBottomPoint,
1393
                                            control.EndPoint,
1394
                                            control.TopRightPoint,
1395
                                        };
1396
                                        control.updateControl();
1397
                                    }
1398

    
1399
                                    //강인구 추가
1400
                                    control.ControlType = controlType;
1401
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1402
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1403
                                    control.Paint = PaintSet.Fill;
1404
                                }
1405
                            }
1406
                            break;
1407
                        case ControlType.Rectangle:
1408
                            {
1409
                                var control = currentControl as RectangleControl;
1410

    
1411
                                if (control != null)
1412
                                {
1413
                                    if (move.mousemode == MouseMode.Drawing)
1414
                                    {
1415
                                        //move.control_Move(ControlList, true, moveX, moveY);
1416
                                    }
1417
                                    else
1418
                                    {
1419
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1420
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1421
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1422
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1423

    
1424

    
1425
                                        if (ViewerDataModel.Instance.IsPressShift)
1426
                                        {
1427
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1428
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1429
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1430
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1431
                                        }
1432

    
1433
                                        control.PointSet = new List<Point>
1434
                                        {
1435
                                            control.StartPoint,
1436
                                            control.LeftBottomPoint,
1437
                                            control.EndPoint,
1438
                                            control.TopRightPoint,
1439
                                        };
1440
                                        control.updateControl();
1441
                                    }
1442

    
1443
                                    //강인구 추가
1444
                                    control.ControlType = controlType;
1445
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1446
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1447
                                }
1448
                            }
1449
                            break;
1450

    
1451
                        case ControlType.RectCloud:
1452
                            {
1453
                                var control = currentControl as RectCloudControl;
1454

    
1455
                                if (control != null)
1456
                                {
1457
                                    if (move.mousemode == MouseMode.Drawing)
1458
                                    {
1459
                                        //move.control_Move(ControlList, true, moveX, moveY);
1460
                                    }
1461
                                    else
1462
                                    {
1463
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1464
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1465
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1466
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1467

    
1468
                                        if (ViewerDataModel.Instance.IsPressShift)
1469
                                        {
1470
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1471
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1472
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1473
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1474
                                        }
1475

    
1476
                                        control.PointSet = new List<Point>
1477
                                        {
1478
                                            control.StartPoint,
1479
                                            control.LeftBottomPoint,
1480
                                            control.EndPoint,
1481
                                            control.TopRightPoint,
1482
                                        };
1483
                                    }
1484

    
1485
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1486
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1487
                                }
1488
                            }
1489
                            break;
1490

    
1491
                        case ControlType.SingleLine:
1492
                            {
1493
                                var control = currentControl as LineControl;
1494
                                if (control != null)
1495
                                {
1496
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1497
                                    control.ControlType = controlType;
1498
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1499
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1500
                                    Point tempPoint = control.EndPoint;
1501

    
1502
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1503
                                    {
1504
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1505
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1506
                                        control.EndPoint = tempPoint;
1507
                                    }
1508
                                    else
1509
                                    {
1510
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1511
                                    }
1512

    
1513
                                    control.PointSet = new List<Point>
1514
                                        {
1515
                                            control.StartPoint,
1516
                                            control.EndPoint,
1517
                                        };
1518

    
1519
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1520
                                }
1521

    
1522
                            }
1523
                            break;
1524

    
1525
                        case ControlType.CancelLine:
1526
                            {
1527
                                var control = currentControl as LineControl;
1528
                                if (control != null)
1529
                                {
1530
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1531
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1532
                                    control.ControlType = controlType;
1533
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1534
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1535
                                    Point tempPoint = control.EndPoint;
1536

    
1537
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1538
                                    {
1539
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1540
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1541
                                        control.EndPoint = tempPoint;
1542
                                    }
1543
                                    else
1544
                                    {
1545
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1546
                                    }
1547

    
1548

    
1549
                                    control.PointSet = new List<Point>
1550
                                            {
1551
                                                control.StartPoint,
1552
                                                control.EndPoint,
1553
                                            };
1554
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1555
                                }
1556

    
1557

    
1558
                            }
1559
                            break;
1560

    
1561
                        case ControlType.ArrowLine:
1562
                            {
1563
                                var control = currentControl as LineControl;
1564
                                if (control != null)
1565
                                {
1566
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1567
                                    control.ControlType = controlType;
1568
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1569
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1570
                                    Point tempPoint = control.EndPoint;
1571

    
1572
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1573
                                    {
1574
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1575
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1576
                                        control.EndPoint = tempPoint;
1577
                                    }
1578
                                    else
1579
                                    {
1580
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1581
                                    }
1582

    
1583

    
1584
                                    control.PointSet = new List<Point>
1585
                                            {
1586
                                                control.StartPoint,
1587
                                                control.EndPoint,
1588
                                            };
1589
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1590
                                }
1591
                            }
1592
                            break;
1593

    
1594
                        case ControlType.TwinLine:
1595
                            {
1596
                                var control = currentControl as LineControl;
1597
                                if (control != null)
1598
                                {
1599
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1600
                                    control.ControlType = controlType;
1601
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1602
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1603
                                    Point tempPoint = control.EndPoint;
1604

    
1605
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1606
                                    {
1607
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1608
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1609
                                        control.EndPoint = tempPoint;
1610
                                    }
1611
                                    else
1612
                                    {
1613
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1614
                                    }
1615

    
1616

    
1617
                                    control.PointSet = new List<Point>
1618
                                            {
1619
                                                control.StartPoint,
1620
                                                control.EndPoint,
1621
                                            };
1622
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1623
                                }
1624
                            }
1625
                            break;
1626

    
1627
                        case ControlType.DimLine:
1628
                            {
1629
                                var control = currentControl as LineControl;
1630
                                if (control != null)
1631
                                {
1632
                                    control.LineStyleSet = LineStyleSet.DimLine;
1633
                                    control.ControlType = controlType;
1634
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1635
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1636
                                    Point tempPoint = control.EndPoint;
1637

    
1638
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1639
                                    {
1640
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1641
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1642
                                        control.EndPoint = tempPoint;
1643
                                    }
1644
                                    else
1645
                                    {
1646
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1647
                                    }
1648

    
1649
                                    control.PointSet = new List<Point>
1650
                                            {
1651
                                                control.StartPoint,
1652
                                                control.EndPoint,
1653
                                            };
1654
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1655
                                }
1656
                            }
1657
                            break;
1658

    
1659
                        case ControlType.ArcLine:
1660
                            {
1661
                                var control = currentControl as ArcControl;
1662
                                if (control != null)
1663
                                {
1664
                                    control.isTransOn = false;
1665
                                    control.ControlType = controlType;
1666
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1667
                                    control.MidPoint = new Point(0, 0);
1668
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1669
                                    Point tempPoint = control.EndPoint;
1670

    
1671
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1672
                                    {
1673
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1674
                                        control.EndPoint = tempPoint;
1675
                                    }
1676
                                    else
1677
                                    {
1678
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1679
                                    }
1680

    
1681

    
1682
                                    control.PointSet = new List<Point>
1683
                                            {
1684
                                                control.StartPoint,
1685
                                                control.MidPoint,
1686
                                                control.EndPoint,
1687
                                            };
1688
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1689
                                }
1690
                            }
1691
                            break;
1692

    
1693
                        case ControlType.ArcArrow:
1694
                            {
1695
                                var control = currentControl as ArrowArcControl;
1696
                                if (control != null)
1697
                                {
1698
                                    control.isTransOn = false;
1699
                                    control.ControlType = controlType;
1700
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1701
                                    control.MidPoint = new Point(0, 0);
1702
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1703
                                    Point tempPoint = control.EndPoint;
1704

    
1705
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1706
                                    {
1707
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1708
                                        control.EndPoint = tempPoint;
1709
                                    }
1710
                                    else
1711
                                    {
1712
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1713
                                    }
1714

    
1715

    
1716
                                    control.PointSet = new List<Point>
1717
                                            {
1718
                                                control.StartPoint,
1719
                                                control.MidPoint,
1720
                                                control.EndPoint,
1721
                                            };
1722
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1723
                                }
1724
                            }
1725
                            break;
1726

    
1727
                        case ControlType.ArrowMultiLine:
1728
                            {
1729
                                var control = currentControl as ArrowControl_Multi;
1730
                                if (control != null)
1731
                                {
1732
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1733
                                    Point tempPoint = control.EndPoint;
1734
                                    if (control.MiddlePoint == new Point(0, 0))
1735
                                    {
1736
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1737
                                        {
1738
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1739
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1740
                                            control.EndPoint = tempPoint;
1741
                                        }
1742
                                        else
1743
                                        {
1744
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1745
                                        }
1746
                                    }
1747
                                    else
1748
                                    {
1749
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1750
                                        {
1751
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1752
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1753
                                            control.EndPoint = tempPoint;
1754
                                        }
1755
                                        else
1756
                                        {
1757
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1758
                                        }
1759

    
1760
                                    }
1761

    
1762
                                    control.PointSet = new List<Point>
1763
                                            {
1764
                                                control.StartPoint,
1765
                                                control.MiddlePoint,
1766
                                                control.EndPoint,
1767
                                            };
1768
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1769
                                }
1770
                            }
1771
                            break;
1772

    
1773
                        case ControlType.Circle:
1774
                            {
1775
                                var control = currentControl as CircleControl;
1776

    
1777
                                if (control != null)
1778
                                {
1779
                                    if (move.mousemode == MouseMode.Drawing)
1780
                                    {
1781
                                        //move.control_Move(ControlList, true, moveX, moveY);
1782
                                    }
1783
                                    else
1784
                                    {
1785
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1786
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1787
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1788
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1789

    
1790
                                        if (ViewerDataModel.Instance.IsPressShift)
1791
                                        {
1792
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1793
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1794
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1795
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1796
                                        }
1797

    
1798
                                        control.PointSet = new List<Point>
1799
                                        {
1800
                                            control.StartPoint,
1801
                                            control.LeftBottomPoint,
1802
                                            control.EndPoint,
1803
                                            control.TopRightPoint,
1804
                                        };
1805
                                    }
1806

    
1807
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1808
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1809

    
1810
                                }
1811
                            }
1812
                            break;
1813

    
1814
                        case ControlType.PolygonCloud:
1815
                            {
1816
                                var control = currentControl as CloudControl;
1817

    
1818
                                if (control != null)
1819
                                {
1820
                                    control.isTransOn = true;
1821
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1822

    
1823
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1824

    
1825
                                    control.SetCloud();
1826
                                    //강인구 추가
1827
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1828
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1829
                                }
1830
                            }
1831
                            break;
1832

    
1833
                        case ControlType.Triangle:
1834
                            {
1835
                                var control = currentControl as TriControl;
1836

    
1837
                                if (control != null)
1838
                                {
1839
                                    if (move.mousemode == MouseMode.Drawing)
1840
                                    {
1841
                                        //move.control_Move(ControlList, true, moveX, moveY);
1842
                                    }
1843
                                    else
1844
                                    {
1845
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1846
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1847

    
1848
                                        if (ViewerDataModel.Instance.checkAxis)
1849
                                        {
1850
                                            Point tempPoint = control.EndPoint;
1851
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1852
                                            control.EndPoint = tempPoint;
1853
                                        }
1854

    
1855

    
1856
                                        if (ViewerDataModel.Instance.IsPressShift)
1857
                                        {
1858
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1859
                                            if (2 == Points.Count())
1860
                                            {
1861
                                                control.MidPoint = Points[0];
1862
                                                control.EndPoint = Points[1];
1863
                                            }
1864
                                        }
1865

    
1866
                                        control.PointSet = new List<Point>
1867
                                            {
1868
                                                control.StartPoint,
1869
                                                control.MidPoint,
1870
                                                control.EndPoint,
1871
                                            };
1872
                                    }
1873

    
1874
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1875
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1876
                                }
1877
                            }
1878
                            break;
1879

    
1880
                        case ControlType.ImgControl:
1881
                            {
1882
                                var control = currentControl as ImgControl;
1883

    
1884
                                if (control != null)
1885
                                {
1886
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1887
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1888
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1889
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1890

    
1891
                                    control.PointSet = new List<Point>
1892
                                        {
1893
                                            control.StartPoint,
1894
                                            control.LeftBottomPoint,
1895
                                            control.EndPoint,
1896
                                            control.TopRightPoint,
1897
                                        };
1898
                                }
1899
                            }
1900
                            break;
1901

    
1902
                        case ControlType.Date:
1903
                            {
1904
                                var control = currentControl as DateControl;
1905

    
1906
                                if (control != null)
1907
                                {
1908
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1909
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1910
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1911
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1912
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1913

    
1914
                                    control.PointSet = new List<Point>
1915
                                        {
1916
                                            control.StartPoint,
1917
                                            control.LeftBottomPoint,
1918
                                            control.EndPoint,
1919
                                            control.TopRightPoint,
1920
                                        };
1921
                                }
1922
                            }
1923
                            break;
1924

    
1925
                        case ControlType.ArrowTextControl:
1926
                            {
1927
                                var control = currentControl as ArrowTextControl;
1928

    
1929
                                if (control != null)
1930
                                {
1931
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1932
                                    Point tempPoint = control.EndPoint;
1933

    
1934
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1935

    
1936
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1937
                                    {
1938
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1939
                                        control.EndPoint = tempPoint;
1940
                                    }
1941
                                    else
1942
                                    {
1943
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1944
                                    }
1945
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1946

    
1947
                                    control.PointSet = new List<Point>
1948
                                            {
1949
                                                control.StartPoint,
1950
                                                control.MidPoint,
1951
                                                control.EndPoint,
1952
                                            };
1953
                                }
1954
                            }
1955
                            break;
1956

    
1957
                        case ControlType.ArrowTransTextControl:
1958
                            {
1959
                                var control = currentControl as ArrowTextControl;
1960

    
1961
                                if (control != null)
1962
                                {
1963
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1964
                                    Point tempPoint = control.EndPoint;
1965
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1966

    
1967
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1968
                                    {
1969
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1970
                                        control.EndPoint = tempPoint;
1971
                                    }
1972
                                    else
1973
                                    {
1974
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1975
                                    }
1976
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1977
                                    control.isFixed = true;
1978

    
1979
                                    control.PointSet = new List<Point>
1980
                                            {
1981
                                                control.StartPoint,
1982
                                                control.MidPoint,
1983
                                                control.EndPoint,
1984
                                            };
1985
                                }
1986
                            }
1987
                            break;
1988

    
1989
                        case ControlType.ArrowTextBorderControl:
1990
                            {
1991
                                var control = currentControl as ArrowTextControl;
1992

    
1993
                                if (control != null)
1994
                                {
1995
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1996
                                    Point tempPoint = control.EndPoint;
1997
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1998
                                    {
1999
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2000
                                        control.EndPoint = tempPoint;
2001
                                    }
2002
                                    else
2003
                                    {
2004
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2005
                                    }
2006
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2007
                                    control.PointSet = new List<Point>
2008
                                            {
2009
                                                control.StartPoint,
2010
                                                control.MidPoint,
2011
                                                control.EndPoint,
2012
                                            };
2013
                                }
2014

    
2015
                            }
2016
                            break;
2017
                        case ControlType.ArrowTransTextBorderControl:
2018
                            {
2019
                                var control = currentControl as ArrowTextControl;
2020

    
2021
                                if (control != null)
2022
                                {
2023
                                    control.isFixed = true;
2024
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2025
                                    Point tempPoint = control.EndPoint;
2026
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2027
                                    {
2028
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2029
                                        control.EndPoint = tempPoint;
2030
                                    }
2031
                                    else
2032
                                    {
2033
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2034
                                    }
2035

    
2036
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2037
                                    control.PointSet = new List<Point>
2038
                                            {
2039
                                                control.StartPoint,
2040
                                                control.MidPoint,
2041
                                                control.EndPoint,
2042
                                            };
2043
                                }
2044

    
2045
                            }
2046
                            break;
2047
                        case ControlType.ArrowTextCloudControl:
2048
                            {
2049
                                var control = currentControl as ArrowTextControl;
2050

    
2051
                                if (control != null)
2052
                                {
2053
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2054
                                    Point tempPoint = control.EndPoint;
2055
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2056
                                    {
2057
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2058
                                        control.EndPoint = tempPoint;
2059
                                    }
2060
                                    else
2061
                                    {
2062
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2063
                                    }
2064
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2065
                                    control.PointSet = new List<Point>
2066
                                            {
2067
                                                control.StartPoint,
2068
                                                control.MidPoint,
2069
                                                control.EndPoint,
2070
                                            };
2071
                                }
2072

    
2073
                            }
2074
                            break;
2075
                        case ControlType.ArrowTransTextCloudControl:
2076
                            {
2077
                                var control = currentControl as ArrowTextControl;
2078

    
2079
                                if (control != null)
2080
                                {
2081
                                    control.isFixed = true;
2082
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2083
                                    Point tempPoint = control.EndPoint;
2084
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2085
                                    {
2086
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2087
                                        control.EndPoint = tempPoint;
2088
                                    }
2089
                                    else
2090
                                    {
2091
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2092
                                    }
2093
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2094
                                    control.PointSet = new List<Point>
2095
                                            {
2096
                                                control.StartPoint,
2097
                                                control.MidPoint,
2098
                                                control.EndPoint,
2099
                                            };
2100
                                }
2101

    
2102
                            }
2103
                            break;
2104
                        case ControlType.PolygonControl:
2105
                        case ControlType.ChainLine:
2106
                            {
2107
                                var control = currentControl as PolygonControl;
2108

    
2109
                                if (control != null)
2110
                                {
2111
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2112
                                    Point tempPoint = currentCanvasDrawingMouseMovePoint;
2113
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2114
                                    {
2115
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 1], ref tempPoint, true);
2116
                                    }
2117
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2118

    
2119
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2120
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2121
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2122
                                    control.updateControl();
2123
                                }
2124
                            }
2125
                            break;
2126
                        //강인구 추가
2127
                        case ControlType.Sign:
2128
                            {
2129
                                var control = currentControl as SignControl;
2130

    
2131
                                if (control != null)
2132
                                {
2133
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2134
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2135
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2136
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2137

    
2138
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2139
                                    {
2140
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2141
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2142
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2143
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2144
                                        stream.Position = 0;
2145
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2146
                                        BitmapImage returnImage = new BitmapImage();
2147
                                        returnImage.BeginInit();
2148
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2149
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2150
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2151
                                        returnImage.StreamSource = ms;
2152
                                        returnImage.EndInit();
2153
                                        stream.Close();
2154

    
2155
                                        control.SignImage = returnImage;
2156
                                    }
2157
                                    control.PointSet = new List<Point>
2158
                                        {
2159
                                            control.StartPoint,
2160
                                            control.LeftBottomPoint,
2161
                                            control.EndPoint,
2162
                                            control.TopRightPoint,
2163
                                        };
2164
                                }
2165
                            }
2166
                            break;
2167
                        //TODO: 강인구 추가
2168
                        case ControlType.Symbol:
2169
                            {
2170
                                var control = currentControl as SymControl;
2171

    
2172
                                if (control != null)
2173
                                {
2174
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2175
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2176
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2177
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2178
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2179
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2180

    
2181
                                    if (control.StartPoint != control.EndPoint)
2182
                                    {
2183
                                        if (control.PathData == null)
2184
                                        {
2185
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2186
                                            {
2187
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2188
                                            }
2189
                                        }
2190
                                    }
2191

    
2192
                                    control.PointSet = new List<Point>
2193
                                        {
2194
                                            control.StartPoint,
2195
                                            control.LeftBottomPoint,
2196
                                            control.EndPoint,
2197
                                            control.TopRightPoint,
2198
                                        };
2199
                                }
2200
                            }
2201
                            break;
2202
                        ///TODO: 
2203
                        case ControlType.Stamp:
2204
                            {
2205
                                var control = currentControl as SymControlN;
2206

    
2207
                                if (control != null)
2208
                                {
2209

    
2210
                                    if (control.StartPoint == control.EndPoint)
2211
                                    {
2212
                                        //string appovalData = "";
2213

    
2214
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2215
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2216

    
2217

    
2218
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2219

    
2220
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2221
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2222
                                        writer.Write(xamlData);
2223
                                        writer.Flush();
2224
                                        stream.Position = 0;
2225

    
2226
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2227
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2228
                                        UIElement ob = obj as UIElement;
2229

    
2230
                                        //control.ApplyTemplate();
2231

    
2232
                                        control.SetViewBox();
2233
                                        control.PathXathData = App.SystemInfo.STAMP;
2234
                                        control.Base_ViewBox.Child = ob;
2235
                                    }
2236

    
2237
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2238
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2239
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2240
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2241
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2242

    
2243

    
2244
                                    control.PointSet = new List<Point>
2245
                                    {
2246
                                        control.StartPoint,
2247
                                        control.LeftBottomPoint,
2248
                                        control.EndPoint,
2249
                                        control.TopRightPoint,
2250
                                    };
2251
                                }
2252
                            }
2253
                            break;
2254
                        case ControlType.Mark:
2255
                            {
2256
                                var control = currentControl as RectangleControl;
2257

    
2258
                                if (control != null)
2259
                                {
2260
                                    if (move.mousemode == MouseMode.Drawing)
2261
                                    {
2262
                                        //move.control_Move(ControlList, true, moveX, moveY);
2263
                                    }
2264
                                    else
2265
                                    {
2266
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2267
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2268
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2269
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2270

    
2271

    
2272
                                        control.PointSet = new List<Point>
2273
                                    {
2274
                                        control.StartPoint,
2275
                                        control.LeftBottomPoint,
2276
                                        control.EndPoint,
2277
                                        control.TopRightPoint,
2278
                                    };
2279
                                    }
2280

    
2281
                                    //강인구 추가
2282
                                    control.Paint = PaintSet.Fill;
2283
                                }
2284
                            }
2285
                            break;
2286
                        case ControlType.PenControl:
2287
                            {
2288
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2289
                                //inkBoard.Strokes.Add(stroke);
2290
                            }
2291
                            break;
2292
                        default:
2293
                            break;
2294
                    }
2295
                }
2296
            }
2297
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2298
            {
2299
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2300
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2301
                SetCursor();
2302
                if (currentControl == null)
2303
                {
2304
                    switch (controlType)
2305
                    {
2306
                        case ControlType.PenControl:
2307
                            {
2308
                                if (inkBoard.Tag.ToString() == "Ink")
2309
                                {
2310
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2311
                                }
2312
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2313
                                {
2314
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2315
                                }
2316
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2317
                                {
2318
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2319
                                }
2320

    
2321
                                //inkBoard.Strokes.Add(stroke);
2322
                            }
2323
                            break;
2324
                    }
2325
                    return;
2326
                }
2327
            }
2328
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
2329
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
2330
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2331
            {
2332
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2333

    
2334
                if (isDraggingSelectionRect)
2335
                {
2336
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2337
                    e.Handled = true;
2338
                }
2339
                else if (isLeftMouseButtonDownOnWindow)
2340
                {
2341
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2342
                    double dragDistance = Math.Abs(dragDelta.Length);
2343

    
2344
                    if (dragDistance > DragThreshold)
2345
                    {
2346
                        isDraggingSelectionRect = true;
2347
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2348
                    }
2349

    
2350
                    e.Handled = true;
2351
                }
2352

    
2353
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2354
                {
2355
                }
2356
                else
2357
                {
2358
                    e.Handled = true;
2359
                }
2360
            }
2361
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2362
            { //symbol      
2363
                if(_dragdropWindow != null)
2364
                {
2365
                    Win32Point w32Mouse = new Win32Point();
2366
                    GetCursorPos(ref w32Mouse);
2367

    
2368
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2369
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2370
                }                
2371
            }
2372
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
2373
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2374
            {
2375
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2376
                if(control != null)
2377
                {
2378
                    this.cursor = Cursors.Hand;
2379
                    SetCursor();
2380
                }
2381
                else
2382
                {
2383
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2384
                    SetCursor();
2385
                }
2386
            }
2387
            else
2388
            {
2389
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2390

    
2391
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2392
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2393

    
2394
                //if (hitList.Count > 0)
2395
                //{
2396

    
2397
                //}
2398

    
2399
                #region 조건 설정 : firstCondition
2400
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2401
                //pnts = generalTransform.Transform(pnts);
2402
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2403
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2404
                //                               this.DeepLayer._BaseLayer).ToObservable()
2405
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2406
                //                      select kkk).FirstOrDefault();
2407

    
2408
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2409
                //if (canvas !=null)
2410
                //{
2411
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2412
                //    {
2413
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2414
                //        if (uiElement!=null)
2415
                //        {
2416
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2417
                //        }
2418
                //    }
2419
                //}
2420

    
2421
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2422
                //hitResultsList.Clear();
2423

    
2424
                #endregion
2425
            }
2426
        }
2427

    
2428
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2429
        {
2430
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2431
            {
2432
                SetCursor();
2433
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2434
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2435

    
2436
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2437

    
2438
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2439
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2440

    
2441
                if (Sync.IsChecked)
2442
                {
2443
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2444
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2445
                }
2446
            }
2447
        }
2448

    
2449
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2450

    
2451
        private EllipseGeometry hitArea = new EllipseGeometry();
2452

    
2453
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2454
        {
2455
            IsDrawing = false;
2456

    
2457
            if (mouseHandlingMode != MouseHandlingMode.None)
2458
            {
2459
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2460
                {
2461
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2462

    
2463
                    SetCursor();
2464

    
2465
                    switch (controlType)
2466
                    {
2467
                        case ControlType.None:
2468
                            break;
2469
                        case ControlType.Rectangle:
2470
                            {
2471

    
2472
                            }
2473
                            break;
2474
                        case ControlType.PenControl:
2475
                            {
2476

    
2477
                            }
2478
                            break;
2479
                        default:
2480
                            break;
2481
                    }
2482
                }
2483
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2484
                {
2485
                    if (isLeftMouseButtonDownOnWindow)
2486
                    {
2487
                        bool wasDragSelectionApplied = false;
2488

    
2489
                        if (isDraggingSelectionRect)
2490
                        {
2491
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2492
                            {
2493
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2494
                                mouseHandlingMode = MouseHandlingMode.None;
2495
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2496
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2497
                                Set_Symbol_Capture(endPoint);
2498
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2499
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2500
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2501
                            }
2502
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2503
                            {
2504
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2505
                                mouseHandlingMode = MouseHandlingMode.None;
2506
                                Set_Capture();
2507

    
2508
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2509
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2510
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2511
                            }
2512
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2513
                            {
2514
                                ApplyDragSelectionRect();
2515
                            }
2516
                            else
2517
                            {
2518
                                double x = Canvas.GetLeft(dragZoomBorder);
2519
                                double y = Canvas.GetTop(dragZoomBorder);
2520
                                double width = dragZoomBorder.Width;
2521
                                double height = dragZoomBorder.Height;
2522
                                Rect dragRect = new Rect(x, y, width, height);
2523

    
2524
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2525

    
2526
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2527
                            }
2528

    
2529
                            isDraggingSelectionRect = false;
2530
                            e.Handled = true;
2531
                            wasDragSelectionApplied = true;
2532
                        }
2533

    
2534
                        if (isLeftMouseButtonDownOnWindow)
2535
                        {
2536
                            isLeftMouseButtonDownOnWindow = false;
2537
                            this.ReleaseMouseCapture();
2538
                            e.Handled = true;
2539
                        }
2540

    
2541
                        if (!wasDragSelectionApplied)
2542
                        {
2543
                            init();
2544
                        }
2545
                    }
2546
                }
2547
                else if (e.RightButton == MouseButtonState.Pressed)
2548
                {
2549
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2550
                    SetCursor();
2551
                }
2552

    
2553
                zoomAndPanControl.ReleaseMouseCapture();
2554

    
2555

    
2556
                e.Handled = true;
2557
            }
2558
            else
2559
            {
2560
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2561
                SetCursor();
2562
            }
2563

    
2564
            ///mouseButtonDown = MouseButton.Left;
2565
            //controlType = ControlType.SingleLine;
2566
        }
2567

    
2568
        public void Set_Symbol_Capture(Point endPoint)
2569
        {       
2570
            double x = canvasDrawingMouseDownPoint.X;
2571
            double y = canvasDrawingMouseDownPoint.Y;
2572
            if(x > endPoint.X)
2573
            {
2574
                x = endPoint.X;
2575
                y = endPoint.Y;
2576
            }
2577

    
2578
            double width = dragCaptureBorder.Width;
2579
            double height = dragCaptureBorder.Height;
2580

    
2581
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2582

    
2583
            if (x < 0)
2584
            {
2585
                width += x;
2586
                x = 0;
2587
            }
2588
            if (y < 0)
2589
            {
2590
                height += y;
2591
                y = 0;
2592

    
2593
                width = (int)canvasImage.PixelWidth - x;
2594
            }
2595
            if (x + width > canvasImage.PixelWidth)
2596
            {
2597
                width = (int)canvasImage.PixelWidth - x;
2598
            }
2599
            if (y + height > canvasImage.PixelHeight)
2600
            {
2601
                height = (int)canvasImage.PixelHeight - y;
2602
            }
2603
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2604

    
2605
            string uri = "";
2606
            if (userData.COMPANY != "EXT")
2607
            {
2608
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
2609
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2610
            }
2611
            else
2612
            {
2613
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2614
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2615
            }
2616

    
2617
            var defaultBitmapImage = new BitmapImage();
2618
            defaultBitmapImage.BeginInit();
2619
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2620
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2621
            defaultBitmapImage.UriSource = new Uri(uri);
2622
            defaultBitmapImage.EndInit();
2623

    
2624
            //GC.Collect();
2625

    
2626
            if (defaultBitmapImage.IsDownloading)
2627
            {
2628
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2629
                {
2630
                    defaultBitmapImage.Freeze();
2631
                    //GC.Collect();
2632
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2633
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2634
                };
2635
            }
2636
        }
2637

    
2638
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2639
        {
2640
            ///mouseButtonDown = MouseButton.Left;
2641
        }
2642

    
2643
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2644
        {
2645
            ///mouseButtonDown = MouseButton.Left;
2646
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2647
        }
2648

    
2649
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2650
        {
2651

    
2652
        }
2653

    
2654
        /// <summary>
2655
        /// select items by dragging
2656
        /// </summary>
2657
        private void ApplyDragSelectionRect()
2658
        {
2659
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2660

    
2661
            double x = Canvas.GetLeft(dragSelectionBorder);
2662
            double y = Canvas.GetTop(dragSelectionBorder);
2663
            double width = dragSelectionBorder.Width;
2664
            double height = dragSelectionBorder.Height;
2665
            Boolean Flag = false;
2666
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2667
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2668

    
2669
            Rect dragRect = new Rect(x, y, width, height);
2670
            ///dragRect.Inflate(width / 10, height / 10);
2671

    
2672
            foreach (var item in Items)
2673
            {
2674
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2675

    
2676
                if (Flag)
2677
                {
2678
                    adornerSet.Add(item);
2679
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2680
                    Control_Style(item);
2681
                }
2682
            }
2683
            if (adornerSet.Count > 0)
2684
            {
2685
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2686
                SelectLayer.Children.Add(final);
2687
            }
2688
        }
2689

    
2690
        private void InitDragSelectionRect(Point pt1, Point pt2)
2691
        {
2692
            //캡쳐 중
2693
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2694
            {
2695
                dragCaptureBorder.Visibility = Visibility.Visible;
2696
            }
2697
            //선택 중
2698
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2699
            {
2700

    
2701
                dragSelectionBorder.Visibility = Visibility.Visible;
2702
            }
2703
            else
2704
            {
2705
                dragZoomBorder.Visibility = Visibility.Visible;
2706
            }
2707
            UpdateDragSelectionRect(pt1, pt2);
2708
        }
2709

    
2710
        /// <summary>
2711
        /// Update the position and size of the rectangle used for drag selection.
2712
        /// </summary>
2713
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2714
        {
2715
            double x, y, width, height;
2716

    
2717
            //
2718
            // Determine x,y,width and height of the rect inverting the points if necessary.
2719
            // 
2720

    
2721
            if (pt2.X < pt1.X)
2722
            {
2723
                x = pt2.X;
2724
                width = pt1.X - pt2.X;
2725
            }
2726
            else
2727
            {
2728
                x = pt1.X;
2729
                width = pt2.X - pt1.X;
2730
            }
2731

    
2732
            if (pt2.Y < pt1.Y)
2733
            {
2734
                y = pt2.Y;
2735
                height = pt1.Y - pt2.Y;
2736
            }
2737
            else
2738
            {
2739
                y = pt1.Y;
2740
                height = pt2.Y - pt1.Y;
2741
            }
2742

    
2743
            //
2744
            // Update the coordinates of the rectangle used for drag selection.
2745
            //
2746
            //캡쳐 중
2747
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2748
            {
2749
                Canvas.SetLeft(dragCaptureBorder, x);
2750
                Canvas.SetTop(dragCaptureBorder, y);
2751
                dragCaptureBorder.Width = width;
2752
                dragCaptureBorder.Height = height;
2753
            }
2754
            //선택 중
2755
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2756
            {
2757
                Canvas.SetLeft(dragSelectionBorder, x);
2758
                Canvas.SetTop(dragSelectionBorder, y);
2759
                dragSelectionBorder.Width = width;
2760
                dragSelectionBorder.Height = height;
2761
            }
2762
            else
2763
            {
2764
                Canvas.SetLeft(dragZoomBorder, x);
2765
                Canvas.SetTop(dragZoomBorder, y);
2766
                dragZoomBorder.Width = width;
2767
                dragZoomBorder.Height = height;
2768
            }
2769
        }
2770

    
2771
        private void drawingPannelRotate(double angle)
2772
        {
2773
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2774
            rotate.Angle = angle;
2775
            var rotationNum = Math.Abs((rotate.Angle / 90));
2776

    
2777
            if (angle == 90 || angle == 270)
2778
            {
2779
                double emptySize = zoomAndPanCanvas.Width;
2780
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2781
                zoomAndPanCanvas.Height = emptySize;
2782
            }
2783
            if (angle == 0)
2784
            {
2785
                translate.X = 0;
2786
                translate.Y = 0;
2787
            }
2788
            else if (angle == 90)
2789
            {
2790
                translate.X = zoomAndPanCanvas.Width;
2791
                translate.Y = 0;
2792
            }
2793
            else if (angle == 180)
2794
            {
2795
                translate.X = zoomAndPanCanvas.Width;
2796
                translate.Y = zoomAndPanCanvas.Height;
2797
            }
2798
            else
2799
            {
2800
                translate.X = 0;
2801
                translate.Y = zoomAndPanCanvas.Height;
2802
            }
2803

    
2804
            zoomAndPanControl.RotationAngle = rotate.Angle;
2805

    
2806

    
2807
            if (!testPanel2.IsHidden)
2808
            {
2809
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2810
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2811
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2812
            }
2813

    
2814
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2815
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2816
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2817
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2818
            ViewerDataModel.Instance.Angle = rotate.Angle;
2819
        }
2820

    
2821
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2822
        {
2823
            string Data_ = "";
2824

    
2825
            try
2826
            {
2827
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2828
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2829
                if (Data_ != null || Data_ != "")
2830
                {
2831
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2832
                }
2833
                else
2834
                {
2835
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2836
                }
2837

    
2838
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2839
                //{
2840
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2841
                //    STATE = 0,
2842
                //};
2843
                if (Data_ != null)
2844
                {
2845
                    Image img = new Image();
2846
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2847
                    if (Data_.Contains(".svg"))
2848
                    {
2849
                        byte[] imageData = null;
2850
                        DrawingImage image = null;
2851
                        using (System.Net.WebClient web = new System.Net.WebClient())
2852
                        {
2853
                            imageData = web.DownloadData(new Uri(Data_));
2854
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2855
                            image = SvgReader.Load(stream);
2856
                        }
2857
                        img.Source = image;
2858
                    }
2859
                    else
2860
                    {
2861
                        img.Source = new BitmapImage(new Uri(Data_));
2862
                    }
2863

    
2864
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2865
                    {
2866
                        PointSet = new List<Point>(),
2867
                        FilePath = Data_,
2868
                        ImageData = img.Source,
2869
                        StartPoint = canvasZoomPanningMouseDownPoint,
2870
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2871
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2872
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2873
                        canvasZoomPanningMouseDownPoint.Y),
2874
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2875
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2876
                    };
2877

    
2878
                    currentControl.PointSet = new List<Point>
2879
                                        {
2880
                                            currentControl.StartPoint,
2881
                                            currentControl.LeftBottomPoint,
2882
                                            currentControl.EndPoint,
2883
                                            currentControl.TopRightPoint,
2884
                                        };
2885
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2886
                    UndoData = new Undo_data()
2887
                    {
2888
                        IsUndo = false,
2889
                        Event = Event_Type.Create,
2890
                        EventTime = DateTime.Now,
2891
                        Markup_List = new List<Multi_Undo_data>()
2892
                    };
2893
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2894
                    {
2895
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2896
                    });
2897

    
2898
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2899
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2900
                    UndoData.Markup_List.Add(multi_Undo_Data);
2901
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2902

    
2903
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2904
                    currentControl.CommentID = Commons.shortGuid();
2905
                    currentControl.SymbolID = id;
2906
                    currentControl.GroupID = group_id;
2907
                    currentControl.ApplyTemplate();
2908
                    currentControl.SetImage();
2909

    
2910
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2911
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2912
                    SelectLayer.Children.Add(final);
2913
                }
2914
            }
2915
            catch (Exception ex)
2916
            {
2917
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2918
            }
2919
        }
2920

    
2921
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2922
        {            
2923
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2924
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2925
            {
2926
                set_option.Value = double.Parse(set_option.ContentText);
2927
            }
2928

    
2929
            InkControl_Convert();
2930

    
2931
            ///TODO:
2932
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2933
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2934

    
2935
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2936
            {
2937
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2938
            }
2939
            /// up to here
2940

    
2941
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2942
            {
2943
                if (arrow_text as ArrowTextControl != null)
2944
                {
2945
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2946
                }
2947
            }
2948

    
2949
            //if (currentControl != null)
2950
            {
2951
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2952
                if (text_item_ != null)
2953
                {
2954
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2955
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2956
                    (text_item_ as TextControl).IsEditing = false;
2957
                    (text_item_ as TextControl).EnableEditing = false;
2958
                    currentControl = null;
2959
                }
2960

    
2961
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2962
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2963
                {
2964
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2965
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2966
                    currentControl = null;
2967
                }
2968
            }
2969

    
2970
            double Ang = 0;                                          
2971
            if (rotate.Angle != 0)
2972
            {
2973
                Ang = 360 - rotate.Angle;
2974
            }
2975

    
2976
            if (e.OriginalSource is System.Windows.Controls.Image)
2977
            {
2978
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2979
            }
2980

    
2981
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2982
            {                
2983
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2984
                if(symbol_id != null)
2985
                {
2986
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2987
                }                
2988
            }
2989

    
2990
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2991
            {
2992
                if (this._dragdropWindow != null)
2993
                {
2994
                    this._dragdropWindow.Close();
2995
                    this._dragdropWindow = null;
2996
                    symbol_id = null;
2997
                }
2998
            }
2999

    
3000
            if (e.LeftButton == MouseButtonState.Pressed)
3001
            {
3002
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3003
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3004

    
3005
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3006
                SetCursor();
3007

    
3008
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
3009
            }
3010

    
3011
            if (e.MiddleButton == MouseButtonState.Pressed)
3012
            {
3013
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3014
                cursor = Cursors.SizeAll;
3015
                SetCursor();
3016
            }
3017
            if (e.RightButton == MouseButtonState.Pressed)
3018
            {
3019
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3020
                cursor = Cursors.SizeAll;
3021
                SetCursor();
3022
            }
3023
            else if (e.XButton1 == MouseButtonState.Pressed)
3024
            {
3025
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3026
                {
3027
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3028
                }
3029

    
3030
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3031

    
3032
            }
3033
            else if (e.XButton2 == MouseButtonState.Pressed)
3034
            {
3035
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3036
                {
3037
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3038
                }
3039
            }
3040

    
3041
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3042
            {
3043
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3044
                {
3045
                    if (SelectLayer.Children.Count == 0)
3046
                    {
3047
                        isLeftMouseButtonDownOnWindow = true;
3048
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3049
                    }
3050

    
3051
                    if (controlType == ControlType.None)
3052
                    {
3053
                        isLeftMouseButtonDownOnWindow = true;
3054
                    }
3055
                }
3056

    
3057
                /// 캡쳐 모드 설정
3058
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3059
                {
3060
                    dragCaptureBorder.Visibility = Visibility.Visible;
3061
                    isLeftMouseButtonDownOnWindow = true;
3062
                }
3063

    
3064
                /// 줌 모드 설정
3065
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3066
                {
3067
                    isLeftMouseButtonDownOnWindow = true;
3068
                }
3069

    
3070
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3071
                if (control != null)
3072
                {
3073
                    AdornerFinal final = null;
3074

    
3075
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3076
                    {
3077
                        /// 기존 selection 해제
3078
                        SelectionSet.Instance.UnSelect(this);
3079

    
3080
                        final = new AdornerFinal(control);
3081

    
3082
                        this.Control_Style(control);
3083

    
3084
                        if ((control as IPath) != null)
3085
                        {
3086
                            if ((control as IPath).LineSize != 0)
3087
                            {
3088
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3089
                            }
3090
                        }
3091
                        if ((control as IShapeControl) != null)
3092
                        {
3093
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3094
                            {
3095
                                ViewerDataModel.Instance.checkHatchShape = true;
3096
                            }
3097
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3098
                            {
3099
                                ViewerDataModel.Instance.checkFillShape = true;
3100
                            }
3101
                            else
3102
                            {
3103
                                ViewerDataModel.Instance.checkHatchShape = false;
3104
                                ViewerDataModel.Instance.checkFillShape = false;
3105
                            }
3106
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3107
                        }
3108

    
3109
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3110

    
3111
                        if ((control as TextControl) != null)
3112
                        {
3113
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3114
                            {
3115
                                ViewerDataModel.Instance.checkTextStyle = true;
3116
                            }
3117
                            else
3118
                            {
3119
                                ViewerDataModel.Instance.checkTextStyle = false;
3120
                            }
3121

    
3122
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3123
                            {
3124
                                ViewerDataModel.Instance.checkTextStyle = true;
3125
                            }
3126
                            else
3127
                            {
3128
                                ViewerDataModel.Instance.checkTextStyle = false;
3129
                            }
3130
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3131
                            {
3132
                                ViewerDataModel.Instance.checkTextWeight = true;
3133
                            }
3134
                            else
3135
                            {
3136
                                ViewerDataModel.Instance.checkTextWeight = false;
3137
                            }
3138
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3139
                            {
3140
                                ViewerDataModel.Instance.checkUnderLine = true;
3141
                            }
3142
                            else
3143
                            {
3144
                                ViewerDataModel.Instance.checkUnderLine = false;
3145
                            }
3146
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3147
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3148

    
3149
                        }
3150
                        else if ((control as ArrowTextControl) != null)
3151
                        {
3152
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3153
                            {
3154
                                ViewerDataModel.Instance.checkTextStyle = true;
3155
                            }
3156
                            else
3157
                            {
3158
                                ViewerDataModel.Instance.checkTextStyle = false;
3159
                            }
3160

    
3161
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3162
                            {
3163
                                ViewerDataModel.Instance.checkTextStyle = true;
3164
                            }
3165
                            else
3166
                            {
3167
                                ViewerDataModel.Instance.checkTextStyle = false;
3168
                            }
3169
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3170
                            {
3171
                                ViewerDataModel.Instance.checkTextWeight = true;
3172
                            }
3173
                            else
3174
                            {
3175
                                ViewerDataModel.Instance.checkTextWeight = false;
3176
                            }
3177
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3178
                            {
3179
                                ViewerDataModel.Instance.checkUnderLine = true;
3180
                            }
3181
                            else
3182
                            {
3183
                                ViewerDataModel.Instance.checkUnderLine = false;
3184
                            }
3185
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3186
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3187
                        }
3188
                        else if ((control as RectCloudControl) != null)
3189
                        {
3190
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3191
                        }
3192
                        else if ((control as CloudControl) != null)
3193
                        {
3194
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3195
                        }
3196
                    }
3197
                    else
3198
                    {
3199
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3200
                        SelectionSet.Instance.UnSelect(this);
3201
                        comment.Add(control);
3202

    
3203
                        Control_Style(control);
3204

    
3205
                        final = new AdornerFinal(comment);
3206
                    }
3207

    
3208
                    if (final != null)
3209
                    {
3210
                        this.SelectLayer.Children.Add(final);
3211
                    }
3212
                }              
3213
            }
3214
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3215
            {               
3216
                init();
3217
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3218
                if (cursor != Cursors.SizeAll)
3219
                {
3220
                    cursor = Cursors.Cross;
3221
                    SetCursor();
3222
                }
3223
                bool init_user = false;
3224
                foreach (var user in gridViewMarkup.Items)
3225
                {
3226
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3227
                    {
3228
                        init_user = true;
3229
                    }
3230
                }
3231
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3232
                {
3233
                    RadWindow.Alert(new DialogParameters
3234
                    {
3235
                        Owner = Application.Current.MainWindow,
3236
                        Theme = new VisualStudio2013Theme(),
3237
                        Header = "안내",
3238
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3239
                    });
3240
                    return;
3241
                }
3242
                else
3243
                {
3244
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3245
                    if (item != null)
3246
                    {
3247
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3248
                    }
3249
                }
3250

    
3251
                switch (controlType)
3252
                {
3253
                    case ControlType.Coordinate:
3254
                        {
3255
                            if (e.LeftButton == MouseButtonState.Pressed)
3256
                            {
3257
                                if (currentControl is CoordinateControl)
3258
                                {
3259
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3260
                                    {
3261
                                        return;
3262
                                    }
3263

    
3264
                                    CreateCommand.Instance.Execute(currentControl);
3265

    
3266
                                    currentControl = null;
3267
                                    this.cursor = Cursors.Arrow;
3268
                                }
3269
                                else
3270
                                {
3271
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3272
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3273
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3274
                                    {
3275
                                        currentControl = null;
3276
                                        this.cursor = Cursors.Arrow;
3277
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3278
                                        return;
3279
                                    }
3280
                                    else
3281
                                    {
3282
                                        currentControl = new CoordinateControl
3283
                                        {
3284
                                            Background = new SolidColorBrush(Colors.Black),
3285
                                            ControlType = ControlType.Coordinate
3286
                                        };
3287

    
3288
                                        currentControl.CommentID = Commons.shortGuid();
3289
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3290
                                        currentControl.IsNew = true;
3291

    
3292
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3293

    
3294
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3295
                                    }
3296
                                }
3297
                            }
3298
                        }
3299
                        break;
3300
                    case ControlType.InsideWhite:
3301
                        {
3302
                            if (e.LeftButton == MouseButtonState.Pressed)
3303
                            {
3304
                                if (currentControl is InsideWhiteControl)
3305
                                {
3306
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3307
                                    {
3308
                                        return;
3309
                                    }
3310

    
3311
                                    CreateCommand.Instance.Execute(currentControl);
3312

    
3313
                                    currentControl = null;
3314
                                    this.cursor = Cursors.Arrow;
3315
                                }
3316
                                else
3317
                                {
3318
                                    currentControl = new InsideWhiteControl
3319
                                    {
3320
                                        Background = new SolidColorBrush(Colors.Black),
3321
                                        ControlType = ControlType.InsideWhite
3322
                                    };
3323

    
3324
                                    currentControl.CommentID = Commons.shortGuid();
3325
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3326
                                    currentControl.IsNew = true;
3327
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3328

    
3329
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3330
                                }
3331
                            }
3332
                        }
3333
                        break;
3334
                    case ControlType.OverlapWhite:
3335
                        {
3336
                            if (e.LeftButton == MouseButtonState.Pressed)
3337
                            {
3338
                                if (currentControl is OverlapWhiteControl)
3339
                                {
3340
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3341
                                    {
3342
                                        return;
3343
                                    }
3344

    
3345
                                    CreateCommand.Instance.Execute(currentControl);
3346

    
3347
                                    currentControl = null;
3348
                                    this.cursor = Cursors.Arrow;
3349
                                }
3350
                                else
3351
                                {
3352
                                    currentControl = new OverlapWhiteControl
3353
                                    {
3354
                                        Background = new SolidColorBrush(Colors.Black),
3355
                                        ControlType = ControlType.OverlapWhite
3356
                                    };
3357

    
3358
                                    currentControl.CommentID = Commons.shortGuid();
3359
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3360
                                    currentControl.IsNew = true;
3361
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3362

    
3363
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3364
                                }
3365
                            }
3366
                        }
3367
                        break;
3368
                    case ControlType.ClipWhite:
3369
                        {
3370
                            if (e.LeftButton == MouseButtonState.Pressed)
3371
                            {
3372
                                if (currentControl is ClipWhiteControl)
3373
                                {
3374
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3375
                                    {
3376
                                        return;
3377
                                    }
3378

    
3379
                                    CreateCommand.Instance.Execute(currentControl);
3380

    
3381
                                    currentControl = null;
3382
                                    this.cursor = Cursors.Arrow;
3383
                                }
3384
                                else
3385
                                {
3386
                                    currentControl = new ClipWhiteControl
3387
                                    {
3388
                                        Background = new SolidColorBrush(Colors.Black),
3389
                                        ControlType = ControlType.ClipWhite
3390
                                    };
3391

    
3392
                                    currentControl.CommentID = Commons.shortGuid();
3393
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3394
                                    currentControl.IsNew = true;
3395
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3396

    
3397
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3398
                                }
3399
                            }
3400
                        }
3401
                        break;
3402
                    case ControlType.Rectangle:
3403
                        {
3404
                            if (e.LeftButton == MouseButtonState.Pressed)
3405
                            {
3406
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3407
                                //{
3408
                                    if (currentControl is RectangleControl)
3409
                                    {
3410
                                        //20180906 LJY TEST IsRotationDrawingEnable
3411
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3412
                                        {
3413
                                            return;
3414
                                        }
3415

    
3416
                                        CreateCommand.Instance.Execute(currentControl);
3417

    
3418
                                        currentControl = null;
3419
                                    
3420
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3421
                                    }
3422
                                    else
3423
                                    {
3424
                                        currentControl = new RectangleControl
3425
                                        {
3426
                                            Background = new SolidColorBrush(Colors.Black),
3427
                                            ControlType = ControlType.Rectangle
3428
                                        };
3429

    
3430
                                        currentControl.CommentID = Commons.shortGuid();
3431
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3432
                                        currentControl.IsNew = true;
3433
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3434

    
3435
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3436
                                    }
3437
                                //}
3438
                            }
3439
                        }
3440
                        break;
3441
                    case ControlType.RectCloud:
3442
                        {
3443
                            if (e.LeftButton == MouseButtonState.Pressed)
3444
                            {
3445
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3446
                                //{
3447
                                    if (currentControl is RectCloudControl)
3448
                                    {
3449
                                        //20180906 LJY TEST IsRotationDrawingEnable
3450
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3451
                                        {
3452
                                            return;
3453
                                        }
3454

    
3455
                                        CreateCommand.Instance.Execute(currentControl);
3456

    
3457
                                        currentControl = null;
3458
                                    
3459
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3460
                                    }
3461
                                    else
3462
                                    {
3463
                                        currentControl = new RectCloudControl
3464
                                        {
3465
                                            Background = new SolidColorBrush(Colors.Black)
3466
                                        };
3467

    
3468
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3469
                                        currentControl.CommentID = Commons.shortGuid();
3470
                                        currentControl.IsNew = true;
3471
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3472
                                    }
3473
                                //}
3474
                            }
3475
                        }
3476
                        break;
3477
                    case ControlType.Circle:
3478
                        {
3479
                            if (e.LeftButton == MouseButtonState.Pressed)
3480
                            {
3481
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3482
                                //{
3483
                                    if (currentControl is CircleControl)
3484
                                    {
3485
                                        //20180906 LJY TEST IsRotationDrawingEnable
3486
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3487
                                        {
3488
                                            return;
3489
                                        }
3490

    
3491
                                        CreateCommand.Instance.Execute(currentControl);
3492

    
3493
                                        currentControl = null;
3494
                                    }
3495
                                    else
3496
                                    {
3497
                                        currentControl = new CircleControl
3498
                                        {
3499
                                            Background = new SolidColorBrush(Colors.Black)
3500
                                        };
3501

    
3502
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3503
                                        currentControl.CommentID = Commons.shortGuid();
3504
                                        currentControl.IsNew = true;
3505
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3506
                                    }
3507
                                //}
3508
                            }
3509
                        }
3510
                        break;
3511
                    case ControlType.Triangle:
3512
                        {
3513
                            if (e.LeftButton == MouseButtonState.Pressed)
3514
                            {
3515
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3516
                                //{
3517
                                    if (currentControl is TriControl)
3518
                                    {
3519
                                        var content = currentControl as TriControl;
3520
                                        if (content.MidPoint == new Point(0, 0))
3521
                                        {
3522
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3523
                                        }
3524
                                        else
3525
                                        {
3526
                                            //20180906 LJY TEST IsRotationDrawingEnable
3527
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3528
                                            {
3529
                                                return;
3530
                                            }
3531

    
3532
                                            CreateCommand.Instance.Execute(currentControl);
3533

    
3534
                                            currentControl = null;
3535
                                        }
3536
                                    }
3537
                                    else
3538
                                    {
3539
                                        currentControl = new TriControl
3540
                                        {
3541
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3542
                                            Background = new SolidColorBrush(Colors.Black),
3543
                                        };
3544

    
3545
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3546
                                        currentControl.CommentID = Commons.shortGuid();
3547
                                        currentControl.IsNew = true;
3548
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3549
                                    }
3550
                                //}
3551
                            }
3552
                        }
3553
                        break;
3554
                    case ControlType.SingleLine:
3555
                        {
3556
                            if (e.LeftButton == MouseButtonState.Pressed)
3557
                            {
3558
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3559
                                //{
3560
                                    if (currentControl is LineControl)
3561
                                    {
3562
                                        //20180906 LJY TEST IsRotationDrawingEnable
3563
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3564
                                        {
3565
                                            return;
3566
                                        }
3567

    
3568
                                        CreateCommand.Instance.Execute(currentControl);
3569

    
3570
                                        currentControl = null;
3571
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3572
                                    }
3573
                                    else
3574
                                    {
3575
                                        currentControl = new LineControl
3576
                                        {
3577
                                            Background = new SolidColorBrush(Colors.Black)
3578
                                        };
3579

    
3580
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3581
                                        currentControl.CommentID = Commons.shortGuid();
3582
                                        currentControl.IsNew = true;
3583
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3584
                                        this.MainAngle.Visibility = Visibility.Visible;
3585
                                    }
3586
                                //}
3587
                            }
3588
                        }
3589
                        break;
3590
                    case ControlType.CancelLine:
3591
                        {
3592
                            if (e.LeftButton == MouseButtonState.Pressed)
3593
                            {
3594
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3595
                                //{
3596
                                    if (currentControl is LineControl)
3597
                                    {
3598
                                        //20180906 LJY TEST IsRotationDrawingEnable
3599
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3600
                                        {
3601
                                            return;
3602
                                        }
3603

    
3604
                                        CreateCommand.Instance.Execute(currentControl);
3605

    
3606
                                        currentControl = null;
3607
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3608
                                    }
3609
                                    else
3610
                                    {
3611
                                        currentControl = new LineControl
3612
                                        {
3613
                                            Background = new SolidColorBrush(Colors.Black)
3614
                                        };
3615

    
3616
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3617
                                        currentControl.CommentID = Commons.shortGuid();
3618
                                        currentControl.IsNew = true;
3619
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3620
                                        this.MainAngle.Visibility = Visibility.Visible;
3621
                                    }
3622
                                //}
3623
                            }
3624
                        }
3625
                        break;
3626
                    case ControlType.ArrowLine:
3627
                        {
3628
                            if (e.LeftButton == MouseButtonState.Pressed)
3629
                            {
3630
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3631
                                //{
3632
                                    if (currentControl is LineControl)
3633
                                    {
3634
                                        //20180906 LJY TEST IsRotationDrawingEnable
3635
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3636
                                        {
3637
                                            return;
3638
                                        }
3639

    
3640
                                        CreateCommand.Instance.Execute(currentControl);
3641

    
3642
                                        currentControl = null;
3643
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3644
                                    }
3645
                                    else
3646
                                    {
3647
                                        currentControl = new LineControl
3648
                                        {
3649
                                            Background = new SolidColorBrush(Colors.Black)
3650
                                        };
3651

    
3652
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3653
                                        currentControl.CommentID = Commons.shortGuid();
3654
                                        currentControl.IsNew = true;
3655
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3656
                                        this.MainAngle.Visibility = Visibility.Visible;
3657
                                    }
3658
                                //}
3659
                            }
3660
                        }
3661
                        break;
3662
                    case ControlType.TwinLine:
3663
                        {
3664
                            if (e.LeftButton == MouseButtonState.Pressed)
3665
                            {
3666
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3667
                                //{
3668
                                    if (currentControl is LineControl)
3669
                                    {
3670
                                        //20180906 LJY TEST IsRotationDrawingEnable
3671
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3672
                                        {
3673
                                            return;
3674
                                        }
3675

    
3676
                                        CreateCommand.Instance.Execute(currentControl);
3677

    
3678
                                        currentControl = null;
3679
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3680
                                    }
3681
                                    else
3682
                                    {
3683
                                        currentControl = new LineControl
3684
                                        {
3685
                                            Background = new SolidColorBrush(Colors.Black)
3686
                                        };
3687
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3688
                                        currentControl.CommentID = Commons.shortGuid();
3689
                                        currentControl.IsNew = true;
3690
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3691
                                        this.MainAngle.Visibility = Visibility.Visible;
3692
                                    }
3693
                                //}
3694
                            }
3695
                        }
3696
                        break;
3697
                    case ControlType.DimLine:
3698
                        {
3699
                            if (e.LeftButton == MouseButtonState.Pressed)
3700
                            {
3701
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3702
                                //{
3703
                                    if (currentControl is LineControl)
3704
                                    {
3705
                                        //20180906 LJY TEST IsRotationDrawingEnable
3706
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3707
                                        {
3708
                                            return;
3709
                                        }
3710
                                        CreateCommand.Instance.Execute(currentControl);
3711

    
3712
                                        currentControl = null;
3713
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3714
                                    }
3715
                                    else
3716
                                    {
3717
                                        currentControl = new LineControl
3718
                                        {
3719
                                            Background = new SolidColorBrush(Colors.Black)
3720
                                        };
3721
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3722
                                        currentControl.CommentID = Commons.shortGuid();
3723
                                        currentControl.IsNew = true;
3724
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3725
                                        this.MainAngle.Visibility = Visibility.Visible;
3726
                                    }
3727
                                //}
3728
                            }
3729
                        }
3730
                        break;
3731
                    case ControlType.ChainLine:
3732
                        {
3733
                            if (currentControl is PolygonControl)
3734
                            {
3735
                                var control = currentControl as PolygonControl;
3736

    
3737
                                if (e.RightButton == MouseButtonState.Pressed)
3738
                                {
3739
                                    //20180906 LJY TEST IsRotationDrawingEnable
3740
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3741
                                    {
3742
                                        return;
3743
                                    }
3744

    
3745
                                    CreateCommand.Instance.Execute(currentControl);
3746

    
3747
                                    currentControl = null;
3748
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3749
                                    return;
3750
                                }
3751

    
3752
                                if (!control.IsCompleted)
3753
                                {
3754
                                    control.PointSet.Add(control.EndPoint);
3755
                                    this.MainAngle.Visibility = Visibility.Visible;
3756
                                }
3757
                            }
3758
                            else
3759
                            {
3760
                                if (e.LeftButton == MouseButtonState.Pressed)
3761
                                {
3762
                                    MainAngle.Visibility = Visibility.Visible;
3763
                                    currentControl = new PolygonControl
3764
                                    {
3765
                                        PointSet = new List<Point>(),
3766
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3767
                                        ControlType = ControlType.ChainLine,
3768
                                        DashSize = ViewerDataModel.Instance.DashSize,
3769
                                        LineSize = ViewerDataModel.Instance.LineSize,
3770
                                        //PointC = new StylusPointSet()
3771
                                    };
3772

    
3773
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3774
                                    //{
3775
                                        var polygonControl = (currentControl as PolygonControl);
3776
                                        currentControl.CommentID = Commons.shortGuid();
3777
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3778
                                        currentControl.IsNew = true;
3779
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3780
                                        //currentControl.OnApplyTemplate();
3781
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3782
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3783
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3784
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3785
                                    //}
3786
                                }
3787
                            }
3788
                        }
3789
                        break;
3790
                    case ControlType.ArcLine:
3791
                        {
3792
                            if (e.LeftButton == MouseButtonState.Pressed)
3793
                            {
3794
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3795
                                //{
3796
                                    if (currentControl is ArcControl)
3797
                                    {
3798
                                        //20180906 LJY TEST IsRotationDrawingEnable
3799
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3800
                                        {
3801
                                            return;
3802
                                        }
3803

    
3804
                                        CreateCommand.Instance.Execute(currentControl);
3805

    
3806
                                        currentControl = null;
3807
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3808
                                    }
3809
                                    else
3810
                                    {
3811
                                        currentControl = new ArcControl
3812
                                        {
3813
                                            Background = new SolidColorBrush(Colors.Black)
3814
                                        };
3815
                                        currentControl.CommentID = Commons.shortGuid();
3816
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3817
                                        currentControl.IsNew = true;
3818
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3819
                                        this.MainAngle.Visibility = Visibility.Visible;
3820
                                    }
3821
                                //}
3822
                            }
3823
                            else if (e.RightButton == MouseButtonState.Pressed)
3824
                            {
3825
                                if (currentControl != null)
3826
                                {
3827
                                    (currentControl as ArcControl).setClock();
3828
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3829
                                    //(currentControl as ArcControl).ApplyTemplate();
3830
                                }
3831
                            }
3832
                        }
3833
                        break;
3834
                    case ControlType.ArcArrow:
3835
                        {
3836
                            if (e.LeftButton == MouseButtonState.Pressed)
3837
                            {
3838
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3839
                                //{
3840
                                if (currentControl is ArrowArcControl)
3841
                                {
3842
                                    //20180906 LJY TEST IsRotationDrawingEnable
3843
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3844
                                    {
3845
                                        return;
3846
                                    }
3847

    
3848
                                    CreateCommand.Instance.Execute(currentControl);
3849

    
3850
                                    currentControl = null;
3851
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3852
                                }
3853
                                else
3854
                                {
3855
                                    currentControl = new ArrowArcControl
3856
                                    {
3857
                                        Background = new SolidColorBrush(Colors.Black)
3858
                                    };
3859
                                    currentControl.CommentID = Commons.shortGuid();
3860
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3861
                                    currentControl.IsNew = true;
3862
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3863
                                    this.MainAngle.Visibility = Visibility.Visible;
3864
                                }
3865
                                //}
3866
                            }
3867
                            else if (e.RightButton == MouseButtonState.Pressed)
3868
                            {
3869
                                if (currentControl != null)
3870
                                {
3871
                                    (currentControl as ArrowArcControl).setClock();
3872
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3873
                                    //(currentControl as ArcControl).ApplyTemplate();
3874
                                }
3875
                            }
3876
                        }
3877
                        break;
3878
                    case ControlType.ArrowMultiLine:
3879
                        {
3880
                            if (e.LeftButton == MouseButtonState.Pressed)
3881
                            {
3882
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3883
                                //{
3884

    
3885
                                    if (currentControl is ArrowControl_Multi)
3886
                                    {
3887
                                        var content = currentControl as ArrowControl_Multi;
3888
                                        if (content.MiddlePoint == new Point(0, 0))
3889
                                        {
3890
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3891
                                            {
3892
                                                content.MiddlePoint = content.EndPoint;
3893
                                            }
3894
                                            else
3895
                                            {
3896
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3897
                                            }
3898
                                        }
3899
                                        else
3900
                                        {
3901
                                            //20180906 LJY TEST IsRotationDrawingEnable
3902
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3903
                                            {
3904
                                                return;
3905
                                            }
3906

    
3907
                                            CreateCommand.Instance.Execute(currentControl);
3908

    
3909
                                            currentControl = null;
3910
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3911
                                        }
3912
                                    }
3913
                                    else
3914
                                    {
3915
                                        currentControl = new ArrowControl_Multi
3916
                                        {
3917
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3918
                                            Background = new SolidColorBrush(Colors.Black)
3919
                                        };
3920
                                        currentControl.CommentID = Commons.shortGuid();
3921
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3922
                                        currentControl.IsNew = true;
3923
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3924
                                        this.MainAngle.Visibility = Visibility.Visible;
3925
                                    }
3926
                                //}
3927
                            }
3928
                        }
3929
                        break;
3930
                    case ControlType.PolygonCloud:
3931
                        {
3932
                            if (currentControl is CloudControl)
3933
                            {
3934
                                var control = currentControl as CloudControl;
3935
                                if (e.RightButton == MouseButtonState.Pressed)
3936
                                {
3937
                                    control.IsCompleted = true;
3938
                                }
3939

    
3940
                                if (!control.IsCompleted)
3941
                                {
3942
                                    control.PointSet.Add(control.EndPoint);
3943
                                }
3944
                                else
3945
                                {
3946
                                    //20180906 LJY TEST IsRotationDrawingEnable
3947
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3948
                                    {
3949
                                        return;
3950
                                    }
3951

    
3952
                                    CreateCommand.Instance.Execute(currentControl);
3953

    
3954
                                    control.isTransOn = true;
3955
                                    var firstPoint = control.PointSet.First();
3956

    
3957
                                    control.PointSet.Add(firstPoint);
3958
                                    control.DrawingCloud();
3959
                                    control.ApplyOverViewData();
3960

    
3961
                                    currentControl = null;
3962
                                }
3963
                            }
3964
                            else
3965
                            {
3966
                                if (e.LeftButton == MouseButtonState.Pressed)
3967
                                {
3968
                                    currentControl = new CloudControl
3969
                                    {
3970
                                        PointSet = new List<Point>(),
3971
                                        PointC = new StylusPointSet()
3972
                                    };
3973

    
3974
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3975
                                    //{
3976
                                        var polygonControl = (currentControl as CloudControl);
3977
                                        currentControl.CommentID = Commons.shortGuid();
3978
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3979
                                        currentControl.IsNew = true;
3980
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3981

    
3982
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3983
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3984
                                    
3985
                                    //}
3986
                                }
3987
                            }
3988
                        }
3989
                        break;
3990
                    case ControlType.ImgControl:
3991
                        {
3992
                            if (e.LeftButton == MouseButtonState.Pressed)
3993
                            {
3994
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3995
                                //{
3996
                                    if (currentControl is ImgControl)
3997
                                    {
3998
                                        //20180906 LJY TEST IsRotationDrawingEnable
3999
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4000
                                        {
4001
                                            return;
4002
                                        }
4003

    
4004
                                        CreateCommand.Instance.Execute(currentControl);
4005
                                        controlType = ControlType.ImgControl;
4006
                                        currentControl = null;
4007
                                    }
4008
                                    else
4009
                                    {
4010
                                        
4011
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4012
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4013
                                        {
4014
                                            Image img = new Image();
4015
                                            //img.Source = new BitmapImage(new Uri(filename));
4016
                                            if (filename.Contains(".svg"))
4017
                                            {
4018
                                                byte[] imageData = null;
4019
                                                DrawingImage image = null;
4020
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4021
                                                {
4022
                                                    imageData = web.DownloadData(new Uri(filename));
4023
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4024
                                                    image = SvgReader.Load(stream);
4025
                                                }
4026
                                                img.Source = image;
4027
                                            }
4028
                                            else
4029
                                            {
4030
                                                img.Source = new BitmapImage(new Uri(filename));
4031
                                            }
4032

    
4033
                                            currentControl = new ImgControl
4034
                                            {
4035
                                                    Background = new SolidColorBrush(Colors.Black),
4036
                                                    PointSet = new List<Point>(),
4037
                                                    FilePath = filename,
4038
                                                    ImageData = img.Source,
4039
                                                    StartPoint = canvasDrawingMouseDownPoint,
4040
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4041
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4042
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4043
                                                    ControlType = ControlType.ImgControl
4044
                                                };
4045

    
4046
                                        
4047
                                                currentControl.CommentID = Commons.shortGuid();                                            
4048
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4049
                                                currentControl.IsNew = true;
4050
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4051

    
4052
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4053
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4054
                                        }
4055
                                    }
4056
                                //}
4057
                            }
4058
                        }
4059
                        break;
4060
                    case ControlType.Date:
4061
                        {
4062
                            if (e.LeftButton == MouseButtonState.Pressed)
4063
                            {
4064
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4065
                                //{
4066
                                    if (currentControl is DateControl)
4067
                                    {
4068
                                        //20180906 LJY TEST IsRotationDrawingEnable
4069
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4070
                                        {
4071
                                            return;
4072
                                        }
4073

    
4074
                                        CreateCommand.Instance.Execute(currentControl);
4075
                                        currentControl = null;
4076

    
4077
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4078
                                        {
4079
                                            controlType = ControlType.None;
4080
                                            IsSwingMode = false;
4081
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4082
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4083
                                            mouseHandlingMode = MouseHandlingMode.None;
4084
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4085
                                            txtBatch.Visibility = Visibility.Collapsed;
4086

    
4087
                                        }
4088
                                    }
4089
                                    else
4090
                                    {
4091
                                        currentControl = new DateControl
4092
                                        {
4093
                                            Background = new SolidColorBrush(Colors.Black)
4094
                                        };
4095
                                        currentControl.CommentID = Commons.shortGuid();
4096
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4097
                                        currentControl.IsNew = true;
4098
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4099

    
4100
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4101
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4102
                                }
4103
                                //}
4104
                            }
4105
                        }
4106
                        break;
4107
                    case ControlType.TextControl:
4108
                        {
4109
                            if (e.LeftButton == MouseButtonState.Pressed)
4110
                            {
4111
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4112
                                {
4113
                                    currentControl = new TextControl
4114
                                    {
4115
                                        ControlType = controlType
4116
                                    };
4117
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4118
                                    currentControl.CommentID = Commons.shortGuid();
4119
                                    currentControl.IsNew = true;
4120
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4121
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4122
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4123

    
4124
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4125
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4126
                                    
4127
                                    (currentControl as TextControl).ControlType_No = 0;
4128
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4129
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4130
                                    (currentControl as TextControl).ApplyTemplate();
4131
                                    (currentControl as TextControl).Base_TextBox.Focus();
4132

    
4133
                                    //System.Diagnostics.Debug.WriteLine("CanvasX" + (currentControl as TextControl).CanvasX);
4134
                                    //System.Diagnostics.Debug.WriteLine("CanvasY" + (currentControl as TextControl).CanvasY);
4135

    
4136
                                    CreateCommand.Instance.Execute(currentControl);
4137

    
4138
                                }
4139
                            }
4140
                        }
4141
                        break;
4142
                    case ControlType.TextBorder:
4143
                        {
4144
                            if (e.LeftButton == MouseButtonState.Pressed)
4145
                            {
4146
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4147
                                {
4148
                                    currentControl = new TextControl
4149
                                    {
4150
                                        ControlType = controlType
4151
                                    };
4152

    
4153
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4154
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4155
                                    currentControl.CommentID = Commons.shortGuid();
4156
                                    currentControl.IsNew = true;
4157
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4158
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4159
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4160
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4161
                                    
4162
                                    (currentControl as TextControl).ControlType_No = 1;
4163
                                    (currentControl as TextControl).Angle = Ang;
4164
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4165
                                    (currentControl as TextControl).ApplyTemplate();
4166
                                    (currentControl as TextControl).Base_TextBox.Focus();
4167
                                    CreateCommand.Instance.Execute(currentControl);
4168

    
4169
                                    //currentControl = null;
4170
                                }
4171
                            }
4172
                        }
4173
                        break;
4174
                    case ControlType.TextCloud:
4175
                        {
4176
                            if (e.LeftButton == MouseButtonState.Pressed)
4177
                            {
4178
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4179
                                {
4180
                                    currentControl = new TextControl
4181
                                    {
4182
                                        ControlType = controlType
4183
                                    };
4184

    
4185
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4186
                                    currentControl.CommentID = Commons.shortGuid();
4187
                                    currentControl.IsNew = true;
4188
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4189
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4190

    
4191
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4192
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4193
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4194

    
4195
                                    (currentControl as TextControl).Angle = Ang;
4196
                                    (currentControl as TextControl).ControlType_No = 2;
4197
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4198
                                    (currentControl as TextControl).ApplyTemplate();
4199
                                    (currentControl as TextControl).Base_TextBox.Focus();
4200
                                    CreateCommand.Instance.Execute(currentControl);
4201
                                    //currentControl = null;
4202
                                }
4203
                            }
4204
                        }
4205
                        break;
4206
                    case ControlType.ArrowTextControl:
4207
                         {
4208
                            if (e.LeftButton == MouseButtonState.Pressed)
4209
                            {
4210
                                if (currentControl is ArrowTextControl)
4211
                                {
4212
                                    //20180906 LJY TEST IsRotationDrawingEnable
4213
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4214
                                    {
4215
                                        return;
4216
                                    }
4217

    
4218
                                    CreateCommand.Instance.Execute(currentControl);
4219

    
4220
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4221
                                    (currentControl as ArrowTextControl).IsEditing = false;
4222
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4223
                                    (currentControl as ArrowTextControl).IsNew = false;
4224
                                    currentControl = null;
4225
                                }
4226
                                else
4227
                                {
4228
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4229
                                    //{
4230
                                        currentControl = new ArrowTextControl();
4231
                                        currentControl.CommentID = Commons.shortGuid();
4232
                                        currentControl.IsNew = true;
4233
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4234
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4235

    
4236
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4237
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4238
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4239
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4240
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4241

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

    
4245
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4246
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4247
                                        this.MainAngle.Visibility = Visibility.Visible;
4248

    
4249
                                    
4250
                                    //}
4251
                                }
4252
                            }
4253
                        }
4254
                        break;
4255
                    case ControlType.ArrowTransTextControl:
4256
                        {
4257
                            if (e.LeftButton == MouseButtonState.Pressed)
4258
                            {
4259
                                if (currentControl is ArrowTextControl)
4260
                                {
4261
                                    //20180906 LJY TEST IsRotationDrawingEnable
4262
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4263
                                    {
4264
                                        return;
4265
                                    }
4266

    
4267
                                    CreateCommand.Instance.Execute(currentControl);
4268
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4269
                                    currentControl.IsNew = false;
4270
                                    currentControl = null;
4271
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4272
                                }
4273
                                else
4274
                                {
4275
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4276
                                    //{
4277
                                         currentControl = new ArrowTextControl();
4278
                                        currentControl.CommentID = Commons.shortGuid();
4279
                                        currentControl.IsNew = true;
4280
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4281
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4282
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4283
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4284
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4285
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4286
                                        (currentControl as ArrowTextControl).isFixed = true;
4287
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4288

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

    
4292
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4293
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4294
                                        (currentControl as ArrowTextControl).isTrans = true;
4295
                                }
4296
                            }
4297
                        }
4298
                        break;
4299
                    case ControlType.ArrowTextBorderControl:
4300
                         {
4301
                            if (e.LeftButton == MouseButtonState.Pressed)
4302
                            {
4303
                                if (currentControl is ArrowTextControl)
4304
                                {
4305
                                    //20180906 LJY TEST IsRotationDrawingEnable
4306
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4307
                                    {
4308
                                        return;
4309
                                    }
4310

    
4311
                                    CreateCommand.Instance.Execute(currentControl);
4312
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4313
                                    currentControl.IsNew = false;
4314
                                    currentControl = null;
4315
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4316
                                }
4317
                                else
4318
                                {
4319
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4320
                                    //{
4321
                                        currentControl = new ArrowTextControl()
4322
                                        {
4323
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4324
                                        };
4325
                                        currentControl.CommentID = Commons.shortGuid();
4326
                                        currentControl.IsNew = true;
4327
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4328
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4329

    
4330
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4331

    
4332
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4333

    
4334
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4335
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4336
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4337

    
4338
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4339
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4340
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4341
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4342
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4343
                                    //}
4344
                                }
4345
                            }
4346
                        }
4347
                        break;
4348
                    case ControlType.ArrowTransTextBorderControl:
4349
                        {
4350
                            if (e.LeftButton == MouseButtonState.Pressed)
4351
                            {
4352
                                if (currentControl is ArrowTextControl)
4353
                                {
4354
                                    //20180906 LJY TEST IsRotationDrawingEnable
4355
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4356
                                    {
4357
                                        return;
4358
                                    }
4359
                                    CreateCommand.Instance.Execute(currentControl);
4360
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4361
                                    currentControl.IsNew = false;
4362
                                    currentControl = null;
4363
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4364
                                }
4365
                                else
4366
                                {
4367
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4368
                                    //{
4369
                                    
4370

    
4371
                                    currentControl = new ArrowTextControl()
4372
                                        {
4373
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4374
                                        };
4375
                                        currentControl.CommentID = Commons.shortGuid();
4376
                                        currentControl.IsNew = true;
4377
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4378
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4379

    
4380
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4381

    
4382
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4383
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4384
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4385
                                        (currentControl as ArrowTextControl).isFixed = true;
4386
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4387
                                     
4388
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4389
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4390
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4391

    
4392
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4393
                                        this.MainAngle.Visibility = Visibility.Visible;
4394
                                    
4395
                                    //20180911 LJY
4396
                                        (currentControl as ArrowTextControl).isTrans = true;
4397
                                    
4398

    
4399
                                    //}
4400
                                }
4401
                            }
4402
                        }
4403
                        break;
4404
                    case ControlType.ArrowTextCloudControl:
4405
                        {
4406
                            if (e.LeftButton == MouseButtonState.Pressed)
4407
                            {
4408
                                if (currentControl is ArrowTextControl)
4409
                                {
4410
                                    //20180906 LJY TEST IsRotationDrawingEnable
4411
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4412
                                    {
4413
                                        return;
4414
                                    }
4415
                                    CreateCommand.Instance.Execute(currentControl);
4416
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4417
                                    currentControl.IsNew = false;
4418
                                    currentControl = null;
4419
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4420
                                }
4421
                                else
4422
                                {
4423
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4424
                                    //{
4425
                                        currentControl = new ArrowTextControl()
4426
                                        {
4427
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4428
                                        };
4429
                                        currentControl.CommentID = Commons.shortGuid();
4430
                                        currentControl.IsNew = true;
4431
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4432
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4433

    
4434
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4435
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4436
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4437
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4438
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4439

    
4440
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4441
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4442
                                    
4443
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4444
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4445
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4446
                                    //}
4447
                                }
4448
                            }
4449
                        }
4450
                        break;
4451
                    case ControlType.ArrowTransTextCloudControl:
4452
                        {
4453
                            if (e.LeftButton == MouseButtonState.Pressed)
4454
                            {
4455
                                if (currentControl is ArrowTextControl)
4456
                                {
4457
                                    //20180906 LJY TEST IsRotationDrawingEnable
4458
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4459
                                    {
4460
                                        return;
4461
                                    }
4462
                                    CreateCommand.Instance.Execute(currentControl);
4463
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4464
                                    currentControl.IsNew = false;
4465
                                    currentControl = null;
4466
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4467
                                }
4468
                                else
4469
                                {
4470
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4471
                                    //{
4472
                                        currentControl = new ArrowTextControl()
4473
                                        {
4474
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4475
                                        };
4476
                                        currentControl.CommentID = Commons.shortGuid();
4477
                                        currentControl.IsNew = true; 
4478
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4479
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4480
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4481

    
4482
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4483
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4484
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4485
                                        (currentControl as ArrowTextControl).isFixed = true;
4486
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4487

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

    
4491
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4492
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4493
                                        this.MainAngle.Visibility = Visibility.Visible;  
4494
                                    
4495
                                    //20180911 LJY
4496
                                        (currentControl as ArrowTextControl).isTrans = true;
4497
                                    //}
4498
                                }
4499
                            }
4500
                        }
4501
                        break;
4502
                    case ControlType.PolygonControl:
4503
                        {
4504
                            if (currentControl is PolygonControl)
4505
                            {
4506
                                var control = currentControl as PolygonControl;
4507

    
4508
                                if (e.RightButton == MouseButtonState.Pressed)
4509
                                {
4510
                                    control.IsCompleted = true;
4511
                                }
4512

    
4513
                                if (!control.IsCompleted)
4514
                                {
4515
                                    control.PointSet.Add(control.EndPoint);
4516
                                }
4517
                                else
4518
                                {
4519
                                    //20180906 LJY TEST IsRotationDrawingEnable
4520
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4521
                                    {
4522
                                        return;
4523
                                    }
4524

    
4525
                                    var firstPoint = control.PointSet.First();
4526
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4527
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4528
                                    control.PointSet.Add(firstPoint);
4529

    
4530
                                    control.ApplyOverViewData();
4531

    
4532
                                    CreateCommand.Instance.Execute(currentControl);
4533
                                    control.updateControl();
4534
                                    currentControl = null;
4535
                                }
4536
                            }
4537
                            else
4538
                            {
4539
                                if (e.LeftButton == MouseButtonState.Pressed)
4540
                                {
4541
                                    currentControl = new PolygonControl
4542
                                    {
4543
                                        PointSet = new List<Point>(),
4544
                                    };
4545

    
4546
                                    var polygonControl = (currentControl as PolygonControl);
4547
                                    currentControl.CommentID = Commons.shortGuid();
4548
                                    currentControl.IsNew = true;
4549
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4550
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
4551
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
4552
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4553
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4554
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4555
                                    polygonControl.ApplyTemplate();
4556
                                    polygonControl.Visibility = Visibility.Visible;
4557
                                }
4558
                            }
4559
                        }
4560
                        break;
4561
                    //강인구 추가
4562
                    case ControlType.Sign:
4563
                        {
4564
                            if (e.LeftButton == MouseButtonState.Pressed)
4565
                            {
4566
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4567
                                //{
4568
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4569

    
4570
                                    if (_sign == null)
4571
                                    {
4572
                                        txtBatch.Visibility = Visibility.Collapsed;
4573
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4574
                                        controlType = ControlType.None;
4575

    
4576
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4577
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4578
                                        return;
4579
                                    }
4580

    
4581
                                    if (currentControl is SignControl)
4582
                                    {
4583
                                        //20180906 LJY TEST IsRotationDrawingEnable
4584
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4585
                                        {
4586
                                            return;
4587
                                        }
4588

    
4589
                                        CreateCommand.Instance.Execute(currentControl);
4590
                                        currentControl = null;
4591
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4592
                                        {
4593
                                            txtBatch.Text = "Place Date";
4594
                                            controlType = ControlType.Date;
4595
                                        }
4596
                                    }
4597
                                    else
4598
                                    {
4599
                                        currentControl = new SignControl
4600
                                        {
4601
                                            Background = new SolidColorBrush(Colors.Black),
4602
                                            UserNumber = App.ViewInfo.UserID,
4603
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4604
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4605
                                            ControlType = ControlType.Sign
4606
                                        };
4607

    
4608
                                        currentControl.CommentID = Commons.shortGuid();
4609
                                        currentControl.IsNew = true;
4610
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4611
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4612

    
4613
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4614
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4615
                                }
4616
                                //}
4617
                            }
4618
                        }
4619
                        break;
4620
                    case ControlType.Mark:
4621
                        {
4622
                            if (e.LeftButton == MouseButtonState.Pressed)
4623
                            {
4624
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4625
                                //{
4626
                                    if (currentControl is RectangleControl)
4627
                                    {
4628
                                        //20180906 LJY TEST IsRotationDrawingEnable
4629
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4630
                                        {
4631
                                            return;
4632
                                        }
4633

    
4634
                                        CreateCommand.Instance.Execute(currentControl);
4635
                                        (currentControl as RectangleControl).ApplyOverViewData();
4636
                                        currentControl = null;
4637
                                    
4638
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4639

    
4640
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4641
                                        {
4642
                                            txtBatch.Text = "Place Signature";
4643
                                            controlType = ControlType.Sign;
4644
                                        }
4645
                                    }
4646
                                    else
4647
                                    {
4648
                                        currentControl = new RectangleControl
4649
                                        {
4650
                                            Background = new SolidColorBrush(Colors.Black),
4651
                                            Paint = PaintSet.Fill
4652
                                        };
4653

    
4654
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4655
                                        currentControl.CommentID = Commons.shortGuid();
4656
                                        currentControl.IsNew = true;
4657
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4658
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4659
                                    }
4660
                                //}
4661
                            }
4662
                        }
4663
                        break;
4664
                    case ControlType.Symbol:
4665
                        {
4666
                            if (e.LeftButton == MouseButtonState.Pressed)
4667
                            {
4668
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4669
                                //{
4670
                                    if (currentControl is SymControl)
4671
                                    {
4672
                                        //20180906 LJY TEST IsRotationDrawingEnable
4673
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4674
                                        {
4675
                                            return;
4676
                                        }
4677
                                        CreateCommand.Instance.Execute(currentControl);
4678
                                        currentControl = null;
4679
                                    
4680
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4681
                                    }
4682
                                    else
4683
                                    {
4684
                                        currentControl = new SymControl
4685
                                        {
4686
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4687
                                            Background = new SolidColorBrush(Colors.Black),
4688
                                            ControlType = ControlType.Symbol
4689
                                        };
4690

    
4691
                                        currentControl.IsNew = true;
4692
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4693
                                        currentControl.CommentID = Commons.shortGuid();
4694
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4695

    
4696
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4697
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4698
                                }
4699
                                //}
4700
                            }
4701
                        }
4702
                        break;
4703
                    case ControlType.Stamp:
4704
                        {
4705
                            if (e.LeftButton == MouseButtonState.Pressed)
4706
                            {
4707
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4708
                                //{
4709
                                    if (currentControl is SymControlN)
4710
                                    {
4711
                                        //20180906 LJY TEST IsRotationDrawingEnable
4712
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4713
                                        {
4714
                                            return;
4715
                                        }
4716

    
4717
                                        CreateCommand.Instance.Execute(currentControl);
4718
                                        currentControl = null;
4719
                                   
4720

    
4721
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4722
                                    }
4723
                                    else
4724
                                    {
4725
                                        currentControl = new SymControlN
4726
                                        {
4727
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4728
                                            Background = new SolidColorBrush(Colors.Black),
4729
                                            ControlType = ControlType.Stamp
4730
                                        };
4731

    
4732
                                        currentControl.IsNew = true;
4733
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4734
                                        currentControl.CommentID = Commons.shortGuid();
4735
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4736
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4737
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4738
                                }                                    
4739
                                //}
4740
                            }
4741
                        }
4742
                        break;
4743
                    case ControlType.PenControl:
4744
                        {
4745
                            if (inkBoard.Tag.ToString() == "Ink")
4746
                            {
4747
                                inkBoard.IsEnabled = true;
4748
                                StartNewStroke(canvasDrawingMouseDownPoint);
4749
                            }
4750
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4751
                            {
4752
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4753
                            }
4754
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4755
                            {
4756
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4757
                            }
4758
                            IsDrawing = true;
4759
                            return;
4760
                        }
4761
                    default:
4762
                        if (currentControl != null)
4763
                        {
4764
                            currentControl.CommentID = null;
4765
                            currentControl.IsNew = false;
4766
                        }
4767
                        break;
4768
                }
4769
            }
4770
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4771
            {
4772
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4773
                {
4774
                    bool mouseOff = false;
4775
                    foreach (var item in SelectLayer.Children)
4776
                    {
4777
                        if (item is AdornerFinal)
4778
                        {
4779

    
4780
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4781
                            if (over != null)
4782
                            {
4783
                                mouseOff = true;
4784
                            }
4785
                        }
4786
                    }
4787

    
4788
                    if (!mouseOff)
4789
                    {
4790
                        SelectionSet.Instance.UnSelect(this);
4791
                    }
4792
                }
4793
                zoomAndPanControl.CaptureMouse();
4794
                e.Handled = true;
4795
            }
4796
        }
4797

    
4798
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4799
        {
4800
            ///mouseButtonDown = e.ChangedButton;
4801
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4802
        }
4803

    
4804
        private void RemoveLineStroke(Point P)
4805
        {
4806
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4807
            if (control != null)
4808
            {
4809
                UndoData = new Undo_data()
4810
                {
4811
                    IsUndo = false,
4812
                    Event = Event_Type.Delete,
4813
                    EventTime = DateTime.Now,
4814
                    Markup_List = new List<Multi_Undo_data>()
4815
                };
4816

    
4817

    
4818
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4819
                UndoData.Markup_List.Add(multi_Undo_Data);
4820
                multi_Undo_Data = new Multi_Undo_data();
4821

    
4822
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4823
                var Item_ = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4824
                ViewerDataModel.Instance.MyMarkupList.Remove(Item_);
4825
                
4826
                //임시파일에서도 삭제한다.
4827
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
4828
                
4829
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4830
                {
4831
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4832
                });
4833
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4834

    
4835
            }
4836
        }
4837

    
4838
        private void RemovePointStroke(Point P)
4839
        {
4840
            foreach (Stroke hits in inkBoard.Strokes)
4841
            {
4842
                foreach (StylusPoint sty in hits.StylusPoints)
4843
                {
4844

    
4845
                }
4846
                if (hits.HitTest(P))
4847
                {
4848
                    inkBoard.Strokes.Remove(hits);
4849
                    return;
4850
                }
4851
            }
4852
        }
4853

    
4854
        private void StartNewStroke(Point P)
4855
        {
4856
            strokePoints = new StylusPointCollection();
4857
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4858
            strokePoints.Add(segment1Start);
4859
            stroke = new Stroke(strokePoints);
4860

    
4861
            stroke.DrawingAttributes.Color = Colors.Red;
4862
            stroke.DrawingAttributes.Width = 4;
4863
            stroke.DrawingAttributes.Height = 4;
4864

    
4865
            inkBoard.Strokes.Add(stroke);
4866

    
4867
        }
4868

    
4869
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4870
        {
4871
            ConsolidationMethod();
4872
        }
4873

    
4874
        /// <summary>
4875
        /// execute TeamConsolidationCommand
4876
        /// </summary>
4877
        public void TeamConsolidationMethod()
4878
        {
4879
            this.UpdateMyMarkupList();
4880
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4881
            {
4882
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4883
            }
4884
            else
4885
            {
4886

    
4887
                ViewerDataModel.Instance.IsConsolidate = true;
4888
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4889

    
4890
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4891
                {
4892
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4893
                    {
4894
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4895
                        return;
4896
                    }                    
4897
                }
4898
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4899
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4900
                {
4901
                    MarkupInfoList.Add(item);
4902
                }
4903
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4904
            }
4905
        }
4906

    
4907
        public void ConsolidationMethod()
4908
        {
4909
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4910
            {
4911
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4912
            }
4913
            else
4914
            {
4915
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4916
                foreach (var item in this.gridViewMarkup.SelectedItems)
4917
                {
4918
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4919
                }
4920
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4921
                
4922
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4923
            }
4924
        }
4925

    
4926
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4927
        {
4928
            if (App.ViewInfo != null)
4929
            {
4930
                btnConsolidate = (sender as RadRibbonButton);
4931
                if (!App.ViewInfo.NewCommentPermission)
4932
                {
4933
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4934
                }
4935
            }
4936
        }
4937

    
4938
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4939
        {
4940
            TeamConsolidationMethod();
4941
        }
4942

    
4943
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4944
        {
4945
            btnTeamConsolidate = sender as RadRibbonButton;
4946
            if (App.ViewInfo != null)
4947
            {
4948
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4949
                {
4950
                    if (btnConsolidate != null)
4951
                    {
4952
                        btnConsolidate.Visibility = Visibility.Collapsed;
4953
                    }
4954

    
4955
                    if (!App.ViewInfo.NewCommentPermission)
4956
                    {
4957
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4958
                    }
4959
                }
4960
                else
4961
                {
4962
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4963
                }
4964
            }
4965
        }
4966

    
4967
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4968
        {
4969
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4970
            if (item != null)
4971
            {
4972
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4973

    
4974
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4975
            }
4976
            else
4977
            {
4978
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4979
            }
4980
        }
4981

    
4982
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4983
        {
4984
            btnFinalPDF = sender as RadRibbonButton;
4985
            if (App.ViewInfo != null)
4986
            {
4987
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4988
                {
4989
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4990
                    if (btnConsolidate != null)
4991
                    {
4992
                        btnConsolidate.Visibility = Visibility.Collapsed;
4993
                    }
4994
                }
4995
            }
4996
        }
4997

    
4998
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4999
        {
5000
            UpdateMyMarkupList();
5001

    
5002
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5003
            {
5004
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5005
            }
5006
            else
5007
            {
5008
                ViewerDataModel.Instance.IsConsolidate = true;
5009
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5010
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5011

    
5012
                string project_no = App.ViewInfo.ProjectNO;
5013
                string doc_id = _DocInfo.ID;
5014
                string user_id = App.ViewInfo.UserID;
5015
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5016
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5017
                {
5018
                    markupInfoItems.Add(item);
5019
                }
5020
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5021
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5022
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5023
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5024

    
5025
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5026
                if (item2 != null)
5027
                {
5028
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5029

    
5030
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5031
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5032
                }
5033
                else
5034
                {
5035
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5036
                }
5037
            }
5038
        }
5039

    
5040
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5041
        {
5042
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5043

    
5044
            if (App.ViewInfo != null)
5045
            {
5046
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5047
                {
5048
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5049
                }
5050
            }
5051
        }
5052

    
5053
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5054
        {
5055
            if (CompareMode.IsChecked)
5056
            {
5057
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5058
                {
5059
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5060
                }
5061
                if (ViewerDataModel.Instance.PageNumber == 0)
5062
                {
5063
                    ViewerDataModel.Instance.PageNumber = 1;
5064
                }
5065

    
5066
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5067
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5068
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5069

    
5070
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5071
            }
5072
            else
5073
            {
5074
                da.From = 1;
5075
                da.To = 1;
5076
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5077
                da.AutoReverse = false;
5078
                canvas_compareBorder.Children.Clear();
5079
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5080
            }
5081
        }
5082

    
5083
        private void Sync_Click(object sender, RoutedEventArgs e)
5084
        {
5085
            if (Sync.IsChecked)
5086
            {
5087
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5088
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5089
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5090
            }
5091
        }
5092

    
5093
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5094
        {
5095
            if (UserList.IsChecked)
5096
            {
5097
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5098
            }
5099
            else
5100
            {
5101
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5102
            }
5103
        }
5104

    
5105
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5106
        {
5107

    
5108
            if (BalanceMode.IsChecked)
5109
            {
5110
                ViewerDataModel.Instance.PageBalanceMode = true;
5111
            }
5112
            else
5113
            {
5114
                ViewerDataModel.Instance.PageBalanceMode = false;
5115
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5116
            }
5117
        }
5118

    
5119
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5120
        {
5121
            //초기화
5122
            testPanel2.IsHidden = true;
5123
            ViewerDataModel.Instance.PageBalanceMode = false;
5124
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5125
            ViewerDataModel.Instance.PageNumber = 0;
5126
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5127
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5128
            UserList.IsChecked = false;
5129
            BalanceMode.IsChecked = false;
5130
        }
5131

    
5132
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5133
        {
5134
            if ((sender as System.Windows.Controls.Control).Tag != null)
5135
            {
5136
                //Compare 초기화
5137
                CompareMode.IsChecked = false;
5138
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5139

    
5140
                if (ViewerDataModel.Instance.PageNumber == 0)
5141
                {
5142
                    ViewerDataModel.Instance.PageNumber = 1;
5143
                }
5144

    
5145
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5146
                {
5147
                }
5148
                else
5149
                {
5150
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5151
                }
5152

    
5153
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5154
                {
5155

    
5156
                }
5157
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5158
                {
5159
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5160
                }
5161

    
5162
                if (!testPanel2.IsHidden)
5163
                {
5164
                    if (IsSyncPDFMode)
5165
                    {
5166
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5167
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5168

    
5169
                        if (pdfpath.IsDownloading)
5170
                        {
5171
                            pdfpath.DownloadCompleted += (ex, arg) =>
5172
                            {
5173
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5174
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5175
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5176
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5177
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5178
                            };
5179
                        }
5180
                        else
5181
                        {
5182
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5183
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5184
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5185

    
5186
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5187
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5188
                        }
5189

    
5190
                    }
5191
                    else
5192
                    {
5193
                        string uri = "";
5194

    
5195
                        if (userData.COMPANY != "EXT")
5196
                        {
5197
                            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);
5198
                        }
5199
                        else
5200
                        {
5201
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5202
                        }
5203

    
5204
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5205

    
5206
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5207
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5208
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5209

    
5210
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5211
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5212

    
5213
                        if (defaultBitmapImage_Compare.IsDownloading)
5214
                        {
5215
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5216
                            {
5217
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5218
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5219
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5220

    
5221
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5222
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5223
                            };
5224
                        }
5225
                    }
5226

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

    
5231
                    foreach (var item in gridSelectionRevItem)
5232
                    {
5233
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5234
                        {
5235
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5236
                        });
5237
                    }
5238

    
5239
                    //강인구 추가
5240
                    zoomAndPanControl2.ZoomTo(new Rect
5241
                    {
5242
                        X = 0,
5243
                        Y = 0,
5244
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5245
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5246
                    });
5247

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

    
5250
                }
5251
            }
5252
        }
5253

    
5254
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5255
        {
5256
            if (MarkupMode.IsChecked)
5257
            {
5258
                IsSyncPDFMode = true;
5259

    
5260
                var uri = CurrentRev.TO_VENDOR;
5261

    
5262
                if (ViewerDataModel.Instance.PageNumber == 0)
5263
                {
5264
                    ViewerDataModel.Instance.PageNumber = 1;
5265
                }
5266

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

    
5271
                if (pdfpath.IsDownloading)
5272
                {
5273
                    pdfpath.DownloadCompleted += (ex, arg) =>
5274
                    {
5275
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5276
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5277
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5278
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5279
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5280
                    };
5281
                }
5282
                else
5283
                {
5284
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5285
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5286
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5287

    
5288
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5289
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5290
                }
5291
            }
5292
            else
5293
            {
5294
                IsSyncPDFMode = false;
5295
                string uri = "";
5296
                if (userData.COMPANY != "EXT")
5297
                {
5298
                    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);
5299
                }
5300
                else
5301
                {
5302
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5303
                }
5304

    
5305
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5306

    
5307
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5308
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5309
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5310

    
5311
                if (defaultBitmapImage_Compare.IsDownloading)
5312
                {
5313
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5314
                    {
5315
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5316
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5317
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5318
                    };
5319
                }
5320
                zoomAndPanControl2.ApplyTemplate();
5321
                zoomAndPanControl2.UpdateLayout();
5322
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5323
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5324
            }
5325
        }
5326

    
5327
        private void RadButton_Click(object sender, RoutedEventArgs e)
5328
        {
5329
            gridViewHistory_Busy.IsBusy = true;
5330

    
5331
            RadButton instance = sender as RadButton;
5332
            if (instance.CommandParameter != null)
5333
            {
5334
                CurrentRev = instance.CommandParameter as VPRevision;
5335
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5336
                {
5337
                    if (ea.Error == null && ea.Result != null)
5338
                    {
5339
                        testPanel2.IsHidden = false;
5340

    
5341
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5342
                        foreach(var info in ea.Result)
5343
                        {
5344
                            if(info.UserID == App.ViewInfo.UserID)
5345
                            {
5346
                                info.userDelete = true;
5347
                                info.DisplayColor = "FFFF0000";
5348
                            }
5349
                            else
5350
                            {
5351
                                info.userDelete = false;
5352
                            }
5353
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5354
                        }
5355
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5356

    
5357
                        string uri = "";
5358
                        if (userData.COMPANY != "EXT")
5359
                        {
5360
                            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);
5361
                        }
5362
                        else
5363
                        {
5364
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5365
                        }
5366

    
5367
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5368

    
5369
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5370

    
5371
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5372
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5373
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5374

    
5375
                        if (defaultBitmapImage_Compare.IsDownloading)
5376
                        {
5377
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5378
                            {
5379
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5380
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5381
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5382
                            };
5383
                        }
5384

    
5385
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5386
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5387
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5388
                        zoomAndPanControl2.ApplyTemplate();
5389
                        zoomAndPanControl2.UpdateLayout();
5390

    
5391
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5392
                        {
5393
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5394
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5395
                        }
5396

    
5397
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5398
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5399
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5400

    
5401
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5402
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5403
                        gridViewHistory_Busy.IsBusy = false;
5404
                    }
5405

    
5406
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5407
                };
5408
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5409
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5410
            }
5411
        }
5412

    
5413
        public void Sync_Event(VPRevision Currnet_Rev)
5414
        {
5415
            CurrentRev = Currnet_Rev;
5416

    
5417
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5418
            {
5419
                if (ea.Error == null && ea.Result != null)
5420
                {
5421
                    testPanel2.IsHidden = false;
5422

    
5423
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5424
                    foreach(var info in ea.Result)
5425
                    {
5426
                        if(info.UserID == App.ViewInfo.UserID)
5427
                        {
5428
                            info.userDelete = true;
5429
                            info.DisplayColor = "FFFF0000";
5430
                        }
5431
                        else
5432
                        {
5433
                            info.userDelete = false;
5434
                        }
5435
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5436
                    }
5437
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5438

    
5439
                    string uri = "";
5440
                    if (userData.COMPANY != "EXT")
5441
                    {
5442
                        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);
5443
                    }
5444
                    else
5445
                    {
5446
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5447
                    }
5448

    
5449
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5450

    
5451
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5452

    
5453
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5454
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5455
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5456

    
5457
                    if (defaultBitmapImage_Compare.IsDownloading)
5458
                    {
5459
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5460
                        {
5461
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5462
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5463
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5464
                        };
5465
                    }
5466

    
5467

    
5468
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5469
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5470
                    zoomAndPanControl2.ApplyTemplate();
5471
                    zoomAndPanControl2.UpdateLayout();
5472

    
5473
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5474
                    {
5475
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5476
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5477
                    }
5478
                    //}
5479

    
5480
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5481
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5482
                    gridViewHistory_Busy.IsBusy = false;
5483
                }
5484
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5485

    
5486
            };
5487
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5488
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5489
        }
5490

    
5491
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5492
        {
5493
            if (sender is Image)
5494
            {
5495
                if ((sender as Image).Tag != null)
5496
                {
5497
                    var pdfUrl = (sender as Image).Tag.ToString();
5498
                    System.Diagnostics.Process.Start(pdfUrl);
5499
                }
5500
                else
5501
                {
5502
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5503
                }
5504
            }
5505
        }
5506

    
5507
        private void Create_Symbol(object sender, RoutedEventArgs e)
5508
        {
5509
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5510

    
5511
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5512
            {
5513
                DialogMessage_Alert("Please Select Controls", "Alert");
5514
            }
5515
            else //선택된 것이 있으면
5516
            {
5517
                string MarkupData = "";
5518
                adorner_ = new AdornerFinal();
5519

    
5520
                foreach (var item in SelectLayer.Children)
5521
                {
5522
                    if (item.GetType().Name == "AdornerFinal")
5523
                    {
5524
                        adorner_ = (item as Controls.AdornerFinal);
5525
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5526
                        {
5527
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5528
                            {
5529
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5530
                                MarkupData += markupReturn.ConvertData;
5531
                            }
5532
                        }
5533
                    }
5534
                }
5535
                DialogParameters parameters = new DialogParameters()
5536
                {
5537
                    Owner = Application.Current.MainWindow,
5538
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5539
                    DefaultPromptResultValue = "Custom State",
5540
                    Content = "Name :",
5541
                    Header = "Insert Custom Symbol Name",
5542
                    Theme = new VisualStudio2013Theme(),
5543
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5544
                };
5545
                RadWindow.Prompt(parameters);
5546
            }
5547

    
5548
        }
5549
        public int symbolselectindex = 0;
5550
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5551
        {
5552
            //Save save = new Save();
5553
            try
5554
            {
5555
                string svgfilename = null;
5556
                if (symbolname != null)
5557
                {
5558
                    if (symbolpng == true || symbolsvg == true)
5559
                    {
5560
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5561
                        string guid = Commons.shortGuid();
5562

    
5563
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5564
                        //Check_Uri.UriCheck();
5565
                        fileUploader.RunCompleted += (ex, arg) =>
5566
                        {
5567
                            filename = arg.Result;
5568
                            if (symbolpng == true)
5569
                            {
5570
                                if (filename != null)
5571
                                { 
5572
                                    if (symbolselectindex == 0)
5573
                                    {
5574
                                        SymbolSave(symbolname, filename, data);
5575
                                    }
5576
                                    else
5577
                                    {
5578
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5579
                                    }
5580
                                    DataBind();
5581
                                }                                
5582
                            }
5583

    
5584
                            if (symbolsvg == true)
5585
                            {
5586
                                try
5587
                                {
5588
                                    var defaultBitmapImage = new BitmapImage();
5589
                                    defaultBitmapImage.BeginInit();
5590
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5591
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5592
                                    Check_Uri.UriCheck(filename);
5593
                                    defaultBitmapImage.UriSource = new Uri(filename);
5594
                                    defaultBitmapImage.EndInit();
5595

    
5596
                                    System.Drawing.Bitmap image;
5597

    
5598
                                    if (defaultBitmapImage.IsDownloading)
5599
                                    {
5600
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5601
                                        {
5602
                                            defaultBitmapImage.Freeze();
5603
                                            image = GetBitmap(defaultBitmapImage);
5604
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5605
                                            Process potrace = new Process
5606
                                            {
5607
                                                StartInfo = new ProcessStartInfo
5608
                                                {
5609
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5610
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5611
                                                    RedirectStandardInput = true,
5612
                                                    RedirectStandardOutput = true,
5613
                                                    RedirectStandardError = true,
5614
                                                    UseShellExecute = false,
5615
                                                    CreateNoWindow = true,
5616
                                                    WindowStyle = ProcessWindowStyle.Hidden
5617
                                                },
5618
                                            };
5619

    
5620
                                            StringBuilder svgBuilder = new StringBuilder();
5621
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5622
                                            {
5623
                                                svgBuilder.AppendLine(e2.Data);
5624
                                            };
5625

    
5626
                                            potrace.EnableRaisingEvents = true;
5627
                                            potrace.Start();
5628
                                            potrace.Exited += (sender, e) =>
5629
                                            {
5630
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5631
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5632
                                                Check_Uri.UriCheck(svgfilename);
5633
                                                if (symbolselectindex == 0)
5634
                                                {
5635
                                                    SymbolSave(symbolname, svgfilename, data);
5636
                                                }
5637
                                                else
5638
                                                {
5639
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5640
                                                }
5641

    
5642
                                                DataBind();
5643
                                            };
5644
                                            potrace.WaitForExit();
5645
                                        };
5646
                                    }
5647
                                    else
5648
                                    {
5649
                                        //GC.Collect();
5650
                                    }
5651
                                }
5652
                                catch(Exception ee)
5653
                                {
5654
                                    DialogMessage_Alert("" + ee, "Alert");
5655
                                }
5656
                            }
5657
                        };                                             
5658
                    }
5659
                }
5660
            }
5661
            catch (Exception e)
5662
            {
5663
                //DialogMessage_Alert(e + "", "Alert");
5664
            }            
5665
        }
5666

    
5667
        public void SymbolSave(string Name, string Url, string Data)
5668
        {
5669
            try
5670
            {
5671
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5672
                {
5673
                    ID = Commons.shortGuid(),
5674
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5675
                    NAME = Name,
5676
                    IMAGE_URL = Url,
5677
                    DATA = Data
5678
                };
5679

    
5680
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5681
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5682
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5683
            }
5684
            catch (Exception)
5685
            {
5686
                throw;
5687
            }
5688
        }
5689

    
5690
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5691
        {
5692
            try
5693
            {
5694
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5695
                {
5696
                    ID = Commons.shortGuid(),
5697
                    DEPARTMENT = Department,
5698
                    NAME = Name,
5699
                    IMAGE_URL = Url,
5700
                    DATA = Data
5701
                };
5702
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5703
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5704
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5705
            }
5706
            catch (Exception)
5707
            {
5708
                throw;
5709
            }
5710
        }
5711

    
5712
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5713
        {           
5714
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5715
            DataBind();
5716
        }
5717

    
5718
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5719
        {
5720
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5721
            DataBind();
5722
        }
5723
        private void DataBind()
5724
        {
5725
            try
5726
            {
5727
                Symbol_Custom Custom = new Symbol_Custom();
5728
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5729
                
5730
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5731
                foreach (var item in symbol_Private)
5732
                {
5733
                    Custom.Name = item.NAME;
5734
                    Custom.ImageUri = item.IMAGE_URL;
5735
                    Custom.ID = item.ID;
5736
                    Custom_List.Add(Custom);
5737
                    Custom = new Symbol_Custom();
5738
                }
5739
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5740
                
5741
                Custom = new Symbol_Custom();
5742
                Custom_List = new List<Symbol_Custom>();
5743

    
5744
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5745

    
5746
                List<SYMBOL_PUBLIC> symbol_Public;
5747

    
5748
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5749
                {
5750
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5751
                }
5752
                else
5753
                {
5754
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5755
                }
5756
                foreach (var item in symbol_Public)
5757
                {
5758
                    Custom.Name = item.NAME;
5759
                    Custom.ImageUri = item.IMAGE_URL;
5760
                    Custom.ID = item.ID;
5761
                    Custom_List.Add(Custom);
5762
                    Custom = new Symbol_Custom();
5763
                }
5764
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5765
                BaseClient.Close();                
5766
            }
5767
            catch(Exception e)
5768
            {
5769
                //DialogMessage_Alert("DataBind", "Alert");
5770
            }
5771
            
5772
        }
5773
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5774
        {
5775
            try
5776
            {
5777
                if (args.PromptResult != null)
5778
                {
5779
                    if (args.DialogResult.Value)
5780
                    {
5781
                        PngBitmapEncoder _Encoder = symImage(data);
5782

    
5783
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5784
                        _Encoder.Save(fs);
5785
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5786

    
5787
                        byte[] Img_byte = fs.ToArray();
5788

    
5789
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5790
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5791
                        Check_Uri.UriCheck(filename);
5792
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5793
                        {
5794
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5795
                        }
5796
                        else
5797
                        {
5798
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5799
                        }
5800
                        DataBind();
5801
                    }
5802
                }
5803
            }
5804
            catch(Exception ex)
5805
            {
5806
                DialogMessage_Alert("" + ex, "Alert");
5807
            }
5808
        }
5809

    
5810
        public PngBitmapEncoder symImage(string data)
5811
        {
5812

    
5813
            Canvas _canvas = new Canvas();
5814
            _canvas.Background = Brushes.White;
5815
            _canvas.Width = adorner_.BorderSize.Width;
5816
            _canvas.Height = adorner_.BorderSize.Height;
5817
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5818

    
5819
            BitmapEncoder encoder = new PngBitmapEncoder();
5820

    
5821

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

    
5824
            DrawingVisual dv = new DrawingVisual();
5825

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

    
5829
            using (DrawingContext ctx = dv.RenderOpen())
5830
            {
5831
                VisualBrush vb = new VisualBrush(_canvas);
5832
                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)));
5833
            }
5834

    
5835
            try
5836
            {
5837
                renderBitmap.Render(dv);
5838

    
5839
                //GC.Collect();
5840
                GC.WaitForPendingFinalizers();
5841
                //GC.Collect();
5842
                // encode png data
5843
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5844
                // puch rendered bitmap into it
5845
                pngEncoder.Interlace = PngInterlaceOption.Off;
5846
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5847
                return pngEncoder;
5848

    
5849
            }
5850
            catch //(Exception ex)
5851
            {
5852
                return null;
5853
            }
5854

    
5855
        }
5856

    
5857
        public void DialogMessage_Alert(string content, string header)
5858
        {
5859
            var box = new TextBlock();
5860
            box.MinWidth = 400;
5861
            box.FontSize = 11;
5862
            //box.FontSize = 12;
5863
            box.Text = content;
5864
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5865

    
5866
            DialogParameters parameters = new DialogParameters()
5867
            {
5868
                Owner = Application.Current.MainWindow,
5869
                Content = box,
5870
                Header = header,
5871
                Theme = new VisualStudio2013Theme(),
5872
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5873
            };            
5874
            RadWindow.Alert(parameters);
5875
        }
5876

    
5877
        #region 캡쳐 기능
5878

    
5879
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5880
        {
5881
            if (x < 0)
5882
            {
5883
                width += x;
5884
                x = 0;
5885
            }
5886
            if (y < 0)
5887
            {
5888
                height += y;
5889
                y = 0;
5890

    
5891
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5892
            }
5893
            if (x + width > zoomAndPanCanvas.ActualWidth)
5894
            {
5895
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5896
            }
5897
            if (y + height > zoomAndPanCanvas.ActualHeight)
5898
            {
5899
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5900
            }
5901

    
5902
            byte[] pixels = CopyPixels(x, y, width, height);
5903

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

    
5906
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5907
        }
5908

    
5909
        public byte[] CopyPixels(int x, int y, int width, int height)
5910
        {
5911
            byte[] pixels = new byte[width * height * 4];
5912
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5913

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

    
5917
            return pixels;
5918
        }
5919

    
5920
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5921
        {
5922
            DrawingVisual drawingVisual = new DrawingVisual();
5923
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5924

    
5925
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5926
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5927
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5928
            drawingContext.Close();
5929

    
5930
            // 비트맵으로 변환합니다.
5931
            RenderTargetBitmap target =
5932
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5933
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5934

    
5935
            target.Render(drawingVisual);
5936
            return target;
5937
        }
5938

    
5939
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5940
        {
5941
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5942
            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);
5943
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5944
            bmp.UnlockBits(data);
5945
            return bmp;
5946
        }
5947
        public string symbolname = null;
5948
        public bool symbolsvg = true;
5949
        public bool symbolpng = true;
5950

    
5951
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5952
        {
5953
            System.Drawing.Bitmap image = GetBitmap(source);
5954
            //흰색 제거
5955
            //image.MakeTransparent(System.Drawing.Color.White);
5956

    
5957
            var imageStream = new System.IO.MemoryStream();
5958
            byte[] imageBytes = null;
5959
            using (imageStream)
5960
            {
5961
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5962
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5963
                imageStream.Position = 0;
5964
                imageBytes = imageStream.ToArray();
5965
            }
5966

    
5967
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5968

    
5969
            RadWindow CheckPop = new RadWindow();
5970
            //Alert check = new Alert(Msg);
5971

    
5972
            CheckPop = new RadWindow
5973
            {
5974
                MinWidth = 400,
5975
                MinHeight = 100,
5976
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5977
                Header = "Alert",
5978
                Content = symbolPrompt,
5979
                //DialogResult = 
5980
                ResizeMode = System.Windows.ResizeMode.NoResize,
5981
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5982
                IsTopmost = true,
5983
            };
5984
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5985
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5986
            CheckPop.ShowDialog();
5987

    
5988
            /*
5989
            DialogParameters parameters = new DialogParameters()
5990
            {
5991
                Owner = Application.Current.MainWindow,
5992
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5993
                DefaultPromptResultValue = "Custom State",
5994
                Content = "Name :",
5995
                Header = "Insert Custom Symbol Name",
5996
                Theme = new VisualStudio2013Theme(),
5997
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5998
            };            
5999
            RadWindow.Prompt(parameters);
6000
            */
6001
        }
6002

    
6003
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6004
        {
6005
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6006
            KCOMDataModel.DataModel.CHECK_LIST check_;
6007
            string Result = streamToBase64.ImageToBase64(source);
6008
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6009
            string projectno = App.ViewInfo.ProjectNO;
6010
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6011

    
6012
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6013
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6014
            if (Item != null)
6015
            {
6016
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6017
            }
6018
            else
6019
            {
6020
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6021
            }
6022

    
6023
            if (Item == null)
6024
            {
6025
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6026
                {
6027
                    ID = Commons.shortGuid(),
6028
                    USER_ID = App.ViewInfo.UserID,
6029
                    IMAGE_URL = Result,
6030
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6031
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6032
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6033
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6034
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6035
                    STATUS = "False",
6036
                    CREATE_TIME = DateTime.Now,
6037
                    UPDATE_TIME = DateTime.Now,
6038
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6039
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6040
                };
6041
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6042
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6043
                //this.BaseClient.AddCheckList(projectno, check_);
6044
            }
6045
            else
6046
            {
6047
                Item.IMAGE_URL = Result;
6048
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6049
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6050
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6051
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6052
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6053
            }
6054

    
6055
        }
6056

    
6057
        public void Set_Capture()
6058
        {
6059
            double x = canvasDrawingMouseDownPoint.X;
6060
            double y = canvasDrawingMouseDownPoint.Y;
6061
            double width = dragCaptureBorder.Width;
6062
            double height = dragCaptureBorder.Height;
6063

    
6064
            if (width > 5 || height > 5)
6065
            {
6066
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6067
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6068
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6069
            }
6070
        }
6071
        #endregion
6072

    
6073
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6074
        {
6075
            multi_Undo_Data = new Multi_Undo_data();
6076

    
6077
            multi_Undo_Data.Markup = control;
6078

    
6079
            if ((control as IShapeControl) != null)
6080
            {
6081
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6082
            }
6083
            if ((control as IDashControl) != null)
6084
            {
6085
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6086
            }
6087
            if ((control as IPath) != null)
6088
            {
6089
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6090
            }
6091
            if ((control as UIElement) != null)
6092
            {
6093
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6094
            }
6095

    
6096
            return multi_Undo_Data;
6097
        }
6098

    
6099
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6100
        {
6101
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6102
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6103
            {
6104
                if (items.UserID == Select_ID)
6105
                {
6106
                    foreach (var item in items.MarkupList)
6107
                    {
6108
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6109
                        {
6110
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6111
                                items.MarkupInfoID, Commons.shortGuid());
6112
                        }
6113
                    }
6114
                }
6115
            }
6116
        }
6117

    
6118
        public void InkControl_Convert()
6119
        {
6120
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6121
            if (inkBoard.Strokes.Count > 0)
6122
            {
6123
                inkBoard.Strokes.ToList().ForEach(stroke =>
6124
                {
6125
                    List<Stroke> removingStroke = new List<Stroke>();
6126
                    StrokeCollection stC = new StrokeCollection();
6127

    
6128
                    removingStroke.Add(stroke);
6129

    
6130
                    InkToPath ip = new InkToPath();
6131
                    List<Point> inkPointSet = new List<Point>();
6132
                    PolygonControl pc = null;
6133
                    pc = new PolygonControl()
6134
                    {
6135
                        Angle = 0,
6136
                        PointSet = new List<Point>(),
6137
                        ControlType = ControlType.Ink
6138
                    };
6139
                    foreach (var item in removingStroke)
6140
                    {
6141
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6142
                        inkBoard.Strokes.Remove(item);
6143
                    }
6144
                    if (inkPointSet.Count != 0)
6145
                    {
6146
                        //강인구 추가(PenControl Undo Redo 추가)
6147
                        UndoData = new Undo_data()
6148
                        {
6149
                            IsUndo = false,
6150
                            Event = Event_Type.Create,
6151
                            EventTime = DateTime.Now,
6152
                            Markup_List = new List<Multi_Undo_data>()
6153
                        };
6154

    
6155
                        pc.StartPoint = inkPointSet[0];
6156
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6157
                        pc.PointSet = inkPointSet;
6158
                        pc.LineSize = 3;
6159
                        pc.CommentID = Commons.shortGuid();
6160
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6161
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6162
                        ///pc.SetPolyPath();
6163

    
6164
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6165
                        {
6166
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6167
                        });
6168
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6169
                        UndoData.Markup_List.Add(multi_Undo_Data);
6170
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6171
                    }
6172
                });
6173
            }
6174
        }
6175

    
6176
        /// <summary>
6177
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6178
        /// </summary>
6179
        /// <param name="StartP">StartPoint</param>
6180
        /// <param name="EndP">EndPoint</param>
6181
        /// <returns>Return_EndPoint</returns>
6182
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6183
        {
6184
            Point Return_Point = new Point();
6185

    
6186
            double dx = EndP.X - StartP.X;
6187
            double dy = EndP.Y - StartP.Y;
6188
            double length;
6189

    
6190
            switch (controlType)
6191
            {
6192
                case ControlType.Triangle:
6193
                    {
6194
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6195
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6196
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6197
                    }
6198
                    break;
6199
                default:
6200
                    {
6201
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6202
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6203
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6204
                    }
6205
                    break;
6206
            }
6207

    
6208
            return Return_Point;
6209
        }
6210

    
6211
        /// <summary>
6212
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6213
        /// </summary>
6214
        /// <author>humkyung</author>
6215
        /// <date>2018.04.26</date>
6216
        /// <param name="StartP"></param>
6217
        /// <param name="EndP"></param>
6218
        /// <returns></returns>
6219
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6220
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6221
        {
6222
            List<Point> res = new List<Point>();
6223

    
6224
            double dx = EndP.X - StartP.X;
6225
            double dy = EndP.Y - StartP.Y;
6226
            double length = Math.Sqrt(dx * dx + dy * dy);
6227
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6228
            dx /= length;
6229
            dy /= length;
6230
            double tmp = dx;
6231
            dx = -dy; dy = tmp; /// rotate by 90 degree
6232

    
6233
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6234
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6235

    
6236
            return res;
6237
        }
6238

    
6239
        /// <summary>
6240
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6241
        /// </summary>
6242
        /// <author>ingu</author>
6243
        /// <date>2018.06.05</date>
6244
        /// <param name="getPoint"></param>
6245
        /// <returns></returns>
6246
        private bool IsGetoutpoint(Point getPoint)
6247
        {
6248
            if (getPoint == new Point())
6249
            {
6250
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6251
                currentControl = null;
6252
                return true;
6253
            }
6254

    
6255
            return false;
6256
        }
6257

    
6258
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6259
        {
6260
            e.Effects = DragDropEffects.Copy;
6261
        }
6262

    
6263
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6264
        {
6265
            e.Effects = DragDropEffects.Copy;
6266
        }
6267

    
6268
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6269
        {
6270
            e.Effects = DragDropEffects.None;
6271
        }
6272

    
6273
        /*
6274
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6275
        {
6276
            try
6277
            {
6278
                if (e.Data.GetDataPresent(typeof(string)))
6279
                {
6280
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6281
                    string dragData = e.Data.GetData(typeof(string)) as string;
6282
                    Move_Symbol(sender, dragData);
6283
                }
6284
            }
6285
            catch (Exception ex)
6286
            {
6287
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6288
            }            
6289
        }
6290
        */
6291
    }
6292
}
클립보드 이미지 추가 (최대 크기: 500 MB)