프로젝트

일반

사용자정보

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

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

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

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

    
52
            T instance = Activator.CreateInstance<T>();
53

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

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

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

    
90
        public TextBox Gui { get; private set; }
91

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

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

    
113
            Gui.Text += line + Environment.NewLine;
114
        }
115
    }
116

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

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

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

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

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

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

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

    
270
            return false;
271
        }
272

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

    
296
            return false;
297
        }
298

    
299

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

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

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

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

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

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

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

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

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

    
373
            DeleteItem(item);
374
        }
375

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

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

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

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

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

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

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

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

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

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

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

    
489
        bool ComingNewBieEnd = false;
490

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

    
502
            InkControl_Convert();
503

    
504
            SelectionSet.Instance.UnSelect(this);
505
            UpdateMyMarkupList();
506

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

    
511

    
512
            #region 페이지가 벗어난 경우
513

    
514
            if (BalancePoint < 1)
515
            {
516
                BalancePoint = 1;
517
                ViewerDataModel.Instance.PageBalanceNumber = 0;
518
            }
519

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

    
526
            #endregion
527

    
528
            ViewerDataModel.Instance.PageNumber = BalancePoint;
529

    
530
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
531
            string uri = "";
532
            if (userData.COMPANY != "EXT")
533
            {
534
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
535
            }
536
            else
537
            {
538
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
539
            }
540

    
541
            var defaultBitmapImage = new BitmapImage();
542
            defaultBitmapImage.BeginInit();
543
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
544
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
545
            defaultBitmapImage.UriSource = new Uri(uri);
546
            defaultBitmapImage.EndInit();
547

    
548
            ViewerDataModel.Instance.ImageViewPath = null;
549
            GC.Collect();
550

    
551
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
552
            if (defaultBitmapImage.IsDownloading)
553
            {
554
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
555
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
556
                {
557
                    defaultBitmapImage.Freeze();
558
                    mainPanel.UpdateLayout();
559
                    GC.Collect();
560
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
561
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
562
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
563
                };
564
            }
565

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

    
569

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

    
575

    
576

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

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

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

    
623
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
624
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
625

    
626
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
627
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
628
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
629
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
630
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
631
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
632

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

    
642
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
643
                    if (defaultBitmapImage_Compare.IsDownloading)
644
                    {
645
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
646
                        {
647
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
648
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
649
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
650
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
651

    
652
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
653
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
654

    
655
                            zoomAndPanControl.ZoomTo(new Rect
656
                            {
657
                                X = 0,
658
                                Y = 0,
659
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
660
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
661
                            });
662
                        };
663
                    }
664
                }
665
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
666
            }
667

    
668
            this.pageNavigator.SetNextPage();
669

    
670
            if (zoomAndPanCanvas2.Width.IsNaN())
671
            {
672
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
673
            }
674

    
675
            Logger.sendCheckLog("-- pageNavigator_PageChanging_ControlData Setting --", 1);
676
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
677
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
678

    
679
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
680
            foreach (var info in gridSelectionItem)
681
            {
682
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
683
            }
684
            /// fire selection event
685
            this.gridViewMarkup.UnselectAll();
686
            this.gridViewMarkup.Select(gridSelectionItem);
687

    
688
            if (!testPanel2.IsHidden)
689
            {
690
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
691
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
692
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
693

    
694
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
695
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
696

    
697

    
698
                foreach (var item in gridSelectionRevItem)
699
                {
700
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
701
                    {
702
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
703
                    });
704
                }
705
            }
706

    
707
            var instanceMain = this.ParentOfType<MainWindow>();
708
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
709
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
710

    
711
            instanceMain.dzTopMenu.rotateOffSet = 0;
712
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
713
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
714

    
715
            //}
716
            SetCommentPages(true);
717
        }
718

    
719

    
720
        
721

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

    
748
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
749
        {
750
            if (e.MiddleButton == MouseButtonState.Pressed)
751
            {
752

    
753
            }
754
            e.Handled = true;
755
            if (e.Delta > 0)
756
            {
757
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
758
                ZoomIn(currentContentMousePoint);
759
            }
760
            else
761
            {
762
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
763
                ZoomOut(currentContentMousePoint);
764
            }
765
        }
766

    
767
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
768
        {
769
            e.Handled = true;
770
            if (e.Delta > 0)
771
            {
772
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
773
                ZoomIn_Sync(currentContentMousePoint);
774
            }
775
            else
776
            {
777
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
778
                ZoomOut_Sync(currentContentMousePoint);
779
            }
780
        }
781

    
782
        #region ZoomIn & ZoomOut
783

    
784
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
785
        {
786
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
787
                zoomAndPanControl.ContentZoomFocusY));
788
        }
789

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

    
796

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

    
810
            if (zoomAndPanControl2 != null && Sync.IsChecked)
811
            {
812
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
813
            }
814
        }
815

    
816
        private void ZoomIn(Point contentZoomCenter)
817
        {
818
            if (zoomAndPanControl.ContentScale > 0.19)
819
            {
820
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
821
            }
822
            else
823
            {
824
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
825
            }
826

    
827
            if (zoomAndPanControl2 != null && Sync.IsChecked)
828
            {
829
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
830
            }
831

    
832
        }
833

    
834
        private void ZoomOut_Sync(Point contentZoomCenter)
835
        {
836
            if (zoomAndPanControl2.ContentScale > 0.39)
837
            {
838
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
839
            }
840
            else
841
            {
842
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
843
            }
844

    
845
            if (Sync.IsChecked)
846
            {
847
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
848
            }
849
        }
850

    
851
        private void ZoomIn_Sync(Point contentZoomCenter)
852
        {
853
            if (zoomAndPanControl2.ContentScale > 0.19)
854
            {
855
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
856
            }
857
            else
858
            {
859
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
860
            }
861

    
862
            if (Sync.IsChecked)
863
            {
864
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
865
            }
866
        }
867

    
868
        private void ZoomOut()
869
        {
870
            zoomAndPanControl.ContentScale -= 0.1;
871
            //if (zoomAndPanControl2 != null)
872
            //{
873
            //    zoomAndPanControl2.ContentScale -= 0.1;
874
            //}
875
        }
876

    
877
        private void ZoomIn()
878
        {
879
            zoomAndPanControl.ContentScale += 0.1;
880
            //if (zoomAndPanControl2 != null)
881
            //{
882
            //    zoomAndPanControl2.ContentScale += 0.1;
883
            //}
884
        }
885

    
886
        #endregion
887

    
888
        private void init()
889
        {
890
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
891
            {
892

    
893
                ControlList.Clear();
894
                listBox.Items.Clear();
895
                selected_item.Clear();
896

    
897
                (item as IMarkupCommonData).IsSelected = false;
898
            }
899

    
900
        }
901

    
902
        private HitTestResultBehavior MyCallback(HitTestResult result)
903
        {
904
            //this.cursor = Cursors.UpArrow;
905
            var element = result.VisualHit;
906
            while (element != null && !(element is CommentUserInfo))
907
                element = VisualTreeHelper.GetParent(element);
908

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

    
947
        public void ReleaseSelectPath()
948
        {
949
            if (SelectionPath == null)
950
            {
951
                SelectionPath = new Path();
952
                SelectionPath.Name = "";
953
            }
954
            if (SelectionPath.Name != "")
955
            {
956
                SelectionPath.Name = "None";
957
            }
958
            SelectionPath.Opacity = 0.01;
959
            SelectionPath.RenderTransform = null;
960
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
961
        }
962

    
963
        #region 컨트롤 초기화 
964
        public void Control_Init(object control)
965
        {
966
            if (L_Size != 0 && (control as IPath) != null)
967
            {
968
                (control as IPath).LineSize = L_Size;
969
                L_Size = 0;
970
            }
971

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

    
1058
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1059
        {
1060
            //Control_Init(e.Source);
1061
        }
1062
        private Window _dragdropWindow = null;
1063

    
1064
        [DllImport("user32.dll")]
1065
        [return: MarshalAs(UnmanagedType.Bool)]
1066
        internal static extern bool GetCursorPos(ref Win32Point pt);
1067

    
1068
        [StructLayout(LayoutKind.Sequential)]
1069
        internal struct Win32Point
1070
        {
1071
            public Int32 X;
1072
            public Int32 Y;
1073
        };
1074
        public string symbol_id = null;
1075
        public long symbol_group_id;
1076
        public int symbol_SelectedIndex;
1077
        public ImageSource symbol_img;
1078
        public string symbol_Data = null;
1079
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1080
        {
1081
            if (this._dragdropWindow != null)
1082
            {
1083
                this._dragdropWindow.Close();
1084
                this._dragdropWindow = null;
1085
            }
1086

    
1087
            symbol_id = id;
1088
            symbol_group_id = group_id;
1089
            symbol_SelectedIndex = SelectedIndex;
1090
            symbol_Data = Data_;
1091
            symbol_img = img;
1092

    
1093
      
1094
            CreateDragDropWindow2(img);
1095
        }
1096

    
1097
        private void CreateDragDropWindow2(ImageSource image)
1098
        {
1099
            this._dragdropWindow = new Window();
1100
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1101
            _dragdropWindow.WindowStyle = WindowStyle.None;
1102
            _dragdropWindow.AllowsTransparency = true;           
1103
            _dragdropWindow.AllowDrop = false;
1104
            _dragdropWindow.Background = null;
1105
            _dragdropWindow.IsHitTestVisible = false;
1106
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1107
            _dragdropWindow.Topmost = true;
1108
            _dragdropWindow.ShowInTaskbar = false;
1109
            
1110
            Rectangle r = new Rectangle();
1111
            r.Width = image.Width;
1112
            r.Height = image.Height;
1113
            r.Opacity = 0.5;            
1114
            r.Fill = new ImageBrush(image);
1115
            this._dragdropWindow.Content = r;
1116

    
1117
            Win32Point w32Mouse = new Win32Point();
1118
            GetCursorPos(ref w32Mouse);
1119

    
1120
            //w32Mouse.X = getCurrentPoint.X;
1121
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1122
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1123
            this._dragdropWindow.Show();
1124
        }
1125

    
1126
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1127
        {
1128
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1129
            {
1130
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1131

    
1132
                Point currentPos = e.GetPosition(rect);
1133

    
1134
                floatingTip.HorizontalOffset = currentPos.X + 20;
1135
                floatingTip.VerticalOffset = currentPos.Y;
1136

    
1137

    
1138
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1139
                //tool.Content = "ToolTip";
1140
                //panel.ToolTip = tool;
1141
            }
1142

    
1143
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1144
            {
1145
                #region 마우스 오버 시 색상 변경
1146
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1147
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1148

    
1149
                //if (firstCondition != null)
1150
                //{
1151
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1152

    
1153
                //    if (firstCondition.GetType().Name == "TextControl")
1154
                //    {
1155
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1156
                //        return;
1157
                //    }
1158
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1159
                //    {
1160
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1161
                //        return;
1162
                //    }
1163

    
1164
                //    if (L_Size == 0)
1165
                //    {
1166
                //        L_Size = (firstCondition as IPath).LineSize;
1167
                //        (firstCondition as IPath).LineSize *= 4;
1168
                //    }
1169
                //    switch (firstCondition.GetType().Name)
1170
                //    {
1171
                //        case "RectangleControl":
1172
                //            {
1173
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1174
                //            }
1175
                //            break;
1176
                //        case "CircleControl":
1177
                //            {
1178
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1179
                //            }
1180
                //            break;
1181
                //        case "TriControl":
1182
                //            {
1183
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1184
                //            }
1185
                //            break;
1186
                //        case "RectCloudControl":
1187
                //            {
1188
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1189
                //            }
1190
                //            break;
1191
                //        case "CloudControl":
1192
                //            {
1193
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1194
                //            }
1195
                //            break;
1196
                //        case "PolygonControl":
1197
                //            {
1198
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1199
                //            }
1200
                //            break;
1201
                //        case "ArcControl":
1202
                //            {
1203
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1204
                //            }
1205
                //            break;
1206
                //        case "LineControl":
1207
                //            {
1208
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1209
                //            }
1210
                //            break;
1211
                //        case "ArrowControl_Multi":
1212
                //            {
1213
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1214
                //            }
1215
                //            break;
1216

    
1217
                //        default:
1218
                //            {
1219

    
1220
                //            }
1221
                //            break;
1222
                //    }
1223
                //} 
1224
                #endregion
1225
            }
1226

    
1227
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1228
            #region 주석
1229
            //if (mouseButtonDown == MouseButton.Middle)
1230
            //{
1231
            //    SetCursor();
1232
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1233
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1234

    
1235
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1236
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1237
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1238

    
1239
            //    //SetCursor();
1240
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1241
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1242

    
1243
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1244

    
1245
            //    //zoomAndPanControl.ContentOffsetX += 1;
1246
            //    //zoomAndPanControl.ContentOffsetY += 1;
1247

    
1248
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1249
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1250
            //}
1251
            #endregion
1252

    
1253
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1254
            {
1255
                SetCursor();
1256
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1257
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1258

    
1259
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1260
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1261
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1262

    
1263
                if (Sync.IsChecked)
1264
                {
1265
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1266
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1267
                }
1268
            }
1269

    
1270
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1271
            {
1272
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1273
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1274
                SetCursor();
1275

    
1276
                if (IsDrawing)
1277
                {
1278
                    if (currentControl == null)
1279
                    {
1280
                        switch (controlType)
1281
                        {
1282
                            case ControlType.PenControl:
1283
                                {
1284
                                    if (inkBoard.Tag.ToString() == "Ink")
1285
                                    {
1286
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1287
                                    }
1288
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1289
                                    {
1290
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1291
                                    }
1292
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1293
                                    {
1294
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1295
                                    }
1296

    
1297
                                    //inkBoard.Strokes.Add(stroke);
1298
                                }
1299
                                break;
1300
                        }
1301
                        return;
1302
                    }
1303
                }
1304

    
1305
                if (currentControl != null)
1306
                {
1307
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1308
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1309
                    //강인구 추가
1310
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1311

    
1312
                    if ((currentControl as IPath) != null)
1313
                    {
1314
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1315
                    }
1316
                    if ((currentControl as LineControl) != null)
1317
                    {
1318
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1319
                    }
1320

    
1321
                    if ((currentControl as IShapeControl) != null)
1322
                    {
1323
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1324
                    }
1325
                    if ((currentControl as TextControl) != null)
1326
                    {
1327
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1328
                        {
1329
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1330
                        }
1331
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1332
                        {
1333
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1334
                        }
1335
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1336
                        {
1337
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1338
                        }
1339
                    }
1340
                    else if ((currentControl as ArrowTextControl) != null)
1341
                    {
1342
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1343
                        {
1344
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1345
                        }
1346
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1347
                        {
1348
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1349
                        }
1350
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1351
                        {
1352
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1353
                        }
1354
                    }
1355
                    else if ((currentControl as RectCloudControl) != null)
1356
                    {
1357
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1358
                    }
1359
                    else if ((currentControl as CloudControl) != null)
1360
                    {
1361
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1362
                    }
1363

    
1364
                    switch (controlType)
1365
                    {
1366
                        case (ControlType.Coordinate):
1367
                            {
1368
                                var control = currentControl as CoordinateControl;
1369

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

    
1383

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

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

    
1402
                                    //강인구 추가
1403
                                    control.ControlType = controlType;
1404
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1405
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1406
                                    //  control.Paint = PaintSet.Fill;
1407
                                }
1408
                            }
1409
                            break;
1410
                        case (ControlType.InsideWhite):
1411
                            {
1412
                                var control = currentControl as InsideWhiteControl;
1413

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

    
1427

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

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

    
1446
                                    //강인구 추가
1447
                                    control.ControlType = controlType;
1448
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1449
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1450
                                    control.Paint = PaintSet.Fill;
1451
                                }
1452
                            }
1453
                            break;
1454
                        case (ControlType.OverlapWhite):
1455
                            {
1456
                                var control = currentControl as OverlapWhiteControl;
1457

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

    
1471

    
1472
                                        if (ViewerDataModel.Instance.IsPressShift)
1473
                                        {
1474
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1475
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1476
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1477
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1478
                                        }
1479

    
1480
                                        control.PointSet = new List<Point>
1481
                                        {
1482
                                            control.StartPoint,
1483
                                            control.LeftBottomPoint,
1484
                                            control.EndPoint,
1485
                                            control.TopRightPoint,
1486
                                        };
1487
                                        control.updateControl();
1488
                                    }
1489

    
1490
                                    //강인구 추가
1491
                                    control.ControlType = controlType;
1492
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1493
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1494
                                    control.Paint = PaintSet.Fill;
1495
                                }
1496
                            }
1497
                            break;
1498
                        case (ControlType.ClipWhite):
1499
                            {
1500
                                var control = currentControl as ClipWhiteControl;
1501

    
1502
                                if (control != null)
1503
                                {
1504
                                    if (move.mousemode == MouseMode.Drawing)
1505
                                    {
1506
                                        //move.control_Move(ControlList, true, moveX, moveY);
1507
                                    }
1508
                                    else
1509
                                    {
1510
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1511
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1512
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1513
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1514

    
1515

    
1516
                                        if (ViewerDataModel.Instance.IsPressShift)
1517
                                        {
1518
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1519
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1520
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1521
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1522
                                        }
1523

    
1524
                                        control.PointSet = new List<Point>
1525
                                        {
1526
                                            control.StartPoint,
1527
                                            control.LeftBottomPoint,
1528
                                            control.EndPoint,
1529
                                            control.TopRightPoint,
1530
                                        };
1531
                                        control.updateControl();
1532
                                    }
1533

    
1534
                                    //강인구 추가
1535
                                    control.ControlType = controlType;
1536
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1537
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1538
                                    control.Paint = PaintSet.Fill;
1539
                                }
1540
                            }
1541
                            break;
1542
                        case ControlType.Rectangle:
1543
                            {
1544
                                var control = currentControl as RectangleControl;
1545

    
1546
                                if (control != null)
1547
                                {
1548
                                    if (move.mousemode == MouseMode.Drawing)
1549
                                    {
1550
                                        //move.control_Move(ControlList, true, moveX, moveY);
1551
                                    }
1552
                                    else
1553
                                    {
1554
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1555
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1556
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1557
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1558

    
1559

    
1560
                                        if (ViewerDataModel.Instance.IsPressShift)
1561
                                        {
1562
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1563
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1564
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1565
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1566
                                        }
1567

    
1568
                                        control.PointSet = new List<Point>
1569
                                        {
1570
                                            control.StartPoint,
1571
                                            control.LeftBottomPoint,
1572
                                            control.EndPoint,
1573
                                            control.TopRightPoint,
1574
                                        };
1575
                                        control.updateControl();
1576
                                    }
1577

    
1578
                                    //강인구 추가
1579
                                    control.ControlType = controlType;
1580
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1581
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1582
                                }
1583
                            }
1584
                            break;
1585

    
1586
                        case ControlType.RectCloud:
1587
                            {
1588
                                var control = currentControl as RectCloudControl;
1589

    
1590
                                if (control != null)
1591
                                {
1592
                                    if (move.mousemode == MouseMode.Drawing)
1593
                                    {
1594
                                        //move.control_Move(ControlList, true, moveX, moveY);
1595
                                    }
1596
                                    else
1597
                                    {
1598
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1599
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1600
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1601
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1602

    
1603
                                        if (ViewerDataModel.Instance.IsPressShift)
1604
                                        {
1605
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1606
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1607
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1608
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1609
                                        }
1610

    
1611
                                        control.PointSet = new List<Point>
1612
                                        {
1613
                                            control.StartPoint,
1614
                                            control.LeftBottomPoint,
1615
                                            control.EndPoint,
1616
                                            control.TopRightPoint,
1617
                                        };
1618
                                    }
1619

    
1620
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1621
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1622
                                }
1623
                            }
1624
                            break;
1625

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

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

    
1648
                                    control.PointSet = new List<Point>
1649
                                        {
1650
                                            control.StartPoint,
1651
                                            control.EndPoint,
1652
                                        };
1653

    
1654
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1655
                                }
1656

    
1657
                            }
1658
                            break;
1659

    
1660
                        case ControlType.CancelLine:
1661
                            {
1662
                                var control = currentControl as LineControl;
1663
                                if (control != null)
1664
                                {
1665
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1666
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1667
                                    control.ControlType = controlType;
1668
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1669
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1670
                                    Point tempPoint = control.EndPoint;
1671

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

    
1683

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

    
1692

    
1693
                            }
1694
                            break;
1695

    
1696
                        case ControlType.ArrowLine:
1697
                            {
1698
                                var control = currentControl as LineControl;
1699
                                if (control != null)
1700
                                {
1701
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1702
                                    control.ControlType = controlType;
1703
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1704
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1705
                                    Point tempPoint = control.EndPoint;
1706

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

    
1718

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

    
1729
                        case ControlType.TwinLine:
1730
                            {
1731
                                var control = currentControl as LineControl;
1732
                                if (control != null)
1733
                                {
1734
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1735
                                    control.ControlType = controlType;
1736
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1737
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1738
                                    Point tempPoint = control.EndPoint;
1739

    
1740
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1741
                                    {
1742
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1743
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1744
                                        control.EndPoint = tempPoint;
1745
                                    }
1746
                                    else
1747
                                    {
1748
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1749
                                    }
1750

    
1751

    
1752
                                    control.PointSet = new List<Point>
1753
                                            {
1754
                                                control.StartPoint,
1755
                                                control.EndPoint,
1756
                                            };
1757
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1758
                                }
1759
                            }
1760
                            break;
1761

    
1762
                        case ControlType.DimLine:
1763
                            {
1764
                                var control = currentControl as LineControl;
1765
                                if (control != null)
1766
                                {
1767
                                    control.LineStyleSet = LineStyleSet.DimLine;
1768
                                    control.ControlType = controlType;
1769
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1770
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1771
                                    Point tempPoint = control.EndPoint;
1772

    
1773
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1774
                                    {
1775
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1776
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1777
                                        control.EndPoint = tempPoint;
1778
                                    }
1779
                                    else
1780
                                    {
1781
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1782
                                    }
1783

    
1784
                                    control.PointSet = new List<Point>
1785
                                            {
1786
                                                control.StartPoint,
1787
                                                control.EndPoint,
1788
                                            };
1789
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1790
                                }
1791
                            }
1792
                            break;
1793

    
1794
                        case ControlType.ChainLine:
1795
                            {
1796
                                var control = currentControl as PolygonControl;
1797

    
1798
                                if (control != null)
1799
                                {
1800

    
1801
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1802
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1803

    
1804
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1805

    
1806
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1807
                                    {
1808
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1809
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1810
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1811
                                        //control.EndPoint = tempPoint;
1812
                                    }
1813
                                    else
1814
                                    {
1815
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1816
                                    }
1817

    
1818
                                    ///control.SetPolyPath();
1819

    
1820
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1821
                                }
1822
                            }
1823
                            break;
1824

    
1825
                        case ControlType.ArcLine:
1826
                            {
1827
                                var control = currentControl as ArcControl;
1828
                                if (control != null)
1829
                                {
1830
                                    control.isTransOn = false;
1831
                                    control.ControlType = controlType;
1832
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1833
                                    control.MidPoint = new Point(0, 0);
1834
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1835
                                    Point tempPoint = control.EndPoint;
1836

    
1837
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1838
                                    {
1839
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1840
                                        control.EndPoint = tempPoint;
1841
                                    }
1842
                                    else
1843
                                    {
1844
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1845
                                    }
1846

    
1847

    
1848
                                    control.PointSet = new List<Point>
1849
                                            {
1850
                                                control.StartPoint,
1851
                                                control.MidPoint,
1852
                                                control.EndPoint,
1853
                                            };
1854
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1855
                                }
1856
                            }
1857
                            break;
1858

    
1859
                        case ControlType.ArcArrow:
1860
                            {
1861
                                var control = currentControl as ArrowArcControl;
1862
                                if (control != null)
1863
                                {
1864
                                    control.isTransOn = false;
1865
                                    control.ControlType = controlType;
1866
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1867
                                    control.MidPoint = new Point(0, 0);
1868
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1869
                                    Point tempPoint = control.EndPoint;
1870

    
1871
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1872
                                    {
1873
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1874
                                        control.EndPoint = tempPoint;
1875
                                    }
1876
                                    else
1877
                                    {
1878
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1879
                                    }
1880

    
1881

    
1882
                                    control.PointSet = new List<Point>
1883
                                            {
1884
                                                control.StartPoint,
1885
                                                control.MidPoint,
1886
                                                control.EndPoint,
1887
                                            };
1888
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1889
                                }
1890
                            }
1891
                            break;
1892

    
1893
                        case ControlType.ArrowMultiLine:
1894
                            {
1895
                                var control = currentControl as ArrowControl_Multi;
1896
                                if (control != null)
1897
                                {
1898
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1899
                                    Point tempPoint = control.EndPoint;
1900
                                    if (control.MiddlePoint == new Point(0, 0))
1901
                                    {
1902
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1903
                                        {
1904
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1905
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1906
                                            control.EndPoint = tempPoint;
1907
                                        }
1908
                                        else
1909
                                        {
1910
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1911
                                        }
1912
                                    }
1913
                                    else
1914
                                    {
1915
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1916
                                        {
1917
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1918
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1919
                                            control.EndPoint = tempPoint;
1920
                                        }
1921
                                        else
1922
                                        {
1923
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1924
                                        }
1925

    
1926
                                    }
1927

    
1928
                                    control.PointSet = new List<Point>
1929
                                            {
1930
                                                control.StartPoint,
1931
                                                control.MiddlePoint,
1932
                                                control.EndPoint,
1933
                                            };
1934
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1935
                                }
1936
                            }
1937
                            break;
1938

    
1939
                        case ControlType.Circle:
1940
                            {
1941
                                var control = currentControl as CircleControl;
1942

    
1943
                                if (control != null)
1944
                                {
1945
                                    if (move.mousemode == MouseMode.Drawing)
1946
                                    {
1947
                                        //move.control_Move(ControlList, true, moveX, moveY);
1948
                                    }
1949
                                    else
1950
                                    {
1951
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1952
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1953
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1954
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1955

    
1956
                                        if (ViewerDataModel.Instance.IsPressShift)
1957
                                        {
1958
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1959
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1960
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1961
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1962
                                        }
1963

    
1964
                                        control.PointSet = new List<Point>
1965
                                        {
1966
                                            control.StartPoint,
1967
                                            control.LeftBottomPoint,
1968
                                            control.EndPoint,
1969
                                            control.TopRightPoint,
1970
                                        };
1971
                                    }
1972

    
1973
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1974
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1975

    
1976
                                }
1977
                            }
1978
                            break;
1979

    
1980
                        case ControlType.PolygonCloud:
1981
                            {
1982
                                var control = currentControl as CloudControl;
1983

    
1984
                                if (control != null)
1985
                                {
1986
                                    control.isTransOn = true;
1987
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1988

    
1989
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1990

    
1991
                                    control.SetCloud();
1992
                                    //강인구 추가
1993
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1994
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1995
                                }
1996
                            }
1997
                            break;
1998

    
1999
                        case ControlType.Triangle:
2000
                            {
2001
                                var control = currentControl as TriControl;
2002

    
2003
                                if (control != null)
2004
                                {
2005
                                    if (move.mousemode == MouseMode.Drawing)
2006
                                    {
2007
                                        //move.control_Move(ControlList, true, moveX, moveY);
2008
                                    }
2009
                                    else
2010
                                    {
2011
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2012
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2013

    
2014
                                        if (ViewerDataModel.Instance.checkAxis)
2015
                                        {
2016
                                            Point tempPoint = control.EndPoint;
2017
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2018
                                            control.EndPoint = tempPoint;
2019
                                        }
2020

    
2021

    
2022
                                        if (ViewerDataModel.Instance.IsPressShift)
2023
                                        {
2024
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2025
                                            if (2 == Points.Count())
2026
                                            {
2027
                                                control.MidPoint = Points[0];
2028
                                                control.EndPoint = Points[1];
2029
                                            }
2030
                                        }
2031

    
2032
                                        control.PointSet = new List<Point>
2033
                                            {
2034
                                                control.StartPoint,
2035
                                                control.MidPoint,
2036
                                                control.EndPoint,
2037
                                            };
2038
                                    }
2039

    
2040
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2041
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2042
                                }
2043
                            }
2044
                            break;
2045

    
2046
                        case ControlType.ImgControl:
2047
                            {
2048
                                var control = currentControl as ImgControl;
2049

    
2050
                                if (control != null)
2051
                                {
2052
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2053
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2054
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2055
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2056

    
2057
                                    control.PointSet = new List<Point>
2058
                                        {
2059
                                            control.StartPoint,
2060
                                            control.LeftBottomPoint,
2061
                                            control.EndPoint,
2062
                                            control.TopRightPoint,
2063
                                        };
2064
                                }
2065
                            }
2066
                            break;
2067

    
2068
                        case ControlType.Date:
2069
                            {
2070
                                var control = currentControl as DateControl;
2071

    
2072
                                if (control != null)
2073
                                {
2074
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2075
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2076
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2077
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2078
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2079

    
2080
                                    control.PointSet = new List<Point>
2081
                                        {
2082
                                            control.StartPoint,
2083
                                            control.LeftBottomPoint,
2084
                                            control.EndPoint,
2085
                                            control.TopRightPoint,
2086
                                        };
2087
                                }
2088
                            }
2089
                            break;
2090

    
2091
                        case ControlType.ArrowTextControl:
2092
                            {
2093
                                var control = currentControl as ArrowTextControl;
2094

    
2095
                                if (control != null)
2096
                                {
2097
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2098
                                    Point tempPoint = control.EndPoint;
2099

    
2100
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2101

    
2102
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2103
                                    {
2104
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2105
                                        control.EndPoint = tempPoint;
2106
                                    }
2107
                                    else
2108
                                    {
2109
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2110
                                    }
2111
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2112

    
2113
                                    control.PointSet = new List<Point>
2114
                                            {
2115
                                                control.StartPoint,
2116
                                                control.MidPoint,
2117
                                                control.EndPoint,
2118
                                            };
2119
                                }
2120
                            }
2121
                            break;
2122

    
2123
                        case ControlType.ArrowTransTextControl:
2124
                            {
2125
                                var control = currentControl as ArrowTextControl;
2126

    
2127
                                if (control != null)
2128
                                {
2129
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2130
                                    Point tempPoint = control.EndPoint;
2131
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2132

    
2133
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2134
                                    {
2135
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2136
                                        control.EndPoint = tempPoint;
2137
                                    }
2138
                                    else
2139
                                    {
2140
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2141
                                    }
2142
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2143
                                    control.isFixed = true;
2144

    
2145
                                    control.PointSet = new List<Point>
2146
                                            {
2147
                                                control.StartPoint,
2148
                                                control.MidPoint,
2149
                                                control.EndPoint,
2150
                                            };
2151
                                }
2152
                            }
2153
                            break;
2154

    
2155
                        case ControlType.ArrowTextBorderControl:
2156
                            {
2157
                                var control = currentControl as ArrowTextControl;
2158

    
2159
                                if (control != null)
2160
                                {
2161
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2162
                                    Point tempPoint = control.EndPoint;
2163
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2164
                                    {
2165
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2166
                                        control.EndPoint = tempPoint;
2167
                                    }
2168
                                    else
2169
                                    {
2170
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2171
                                    }
2172
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2173
                                    control.PointSet = new List<Point>
2174
                                            {
2175
                                                control.StartPoint,
2176
                                                control.MidPoint,
2177
                                                control.EndPoint,
2178
                                            };
2179
                                }
2180

    
2181
                            }
2182
                            break;
2183
                        case ControlType.ArrowTransTextBorderControl:
2184
                            {
2185
                                var control = currentControl as ArrowTextControl;
2186

    
2187
                                if (control != null)
2188
                                {
2189
                                    control.isFixed = true;
2190
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2191
                                    Point tempPoint = control.EndPoint;
2192
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2193
                                    {
2194
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2195
                                        control.EndPoint = tempPoint;
2196
                                    }
2197
                                    else
2198
                                    {
2199
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2200
                                    }
2201

    
2202
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2203
                                    control.PointSet = new List<Point>
2204
                                            {
2205
                                                control.StartPoint,
2206
                                                control.MidPoint,
2207
                                                control.EndPoint,
2208
                                            };
2209
                                }
2210

    
2211
                            }
2212
                            break;
2213
                        case ControlType.ArrowTextCloudControl:
2214
                            {
2215
                                var control = currentControl as ArrowTextControl;
2216

    
2217
                                if (control != null)
2218
                                {
2219
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2220
                                    Point tempPoint = control.EndPoint;
2221
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2222
                                    {
2223
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2224
                                        control.EndPoint = tempPoint;
2225
                                    }
2226
                                    else
2227
                                    {
2228
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2229
                                    }
2230
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2231
                                    control.PointSet = new List<Point>
2232
                                            {
2233
                                                control.StartPoint,
2234
                                                control.MidPoint,
2235
                                                control.EndPoint,
2236
                                            };
2237
                                }
2238

    
2239
                            }
2240
                            break;
2241
                        case ControlType.ArrowTransTextCloudControl:
2242
                            {
2243
                                var control = currentControl as ArrowTextControl;
2244

    
2245
                                if (control != null)
2246
                                {
2247
                                    control.isFixed = true;
2248
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2249
                                    Point tempPoint = control.EndPoint;
2250
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2251
                                    {
2252
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2253
                                        control.EndPoint = tempPoint;
2254
                                    }
2255
                                    else
2256
                                    {
2257
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2258
                                    }
2259
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2260
                                    control.PointSet = new List<Point>
2261
                                            {
2262
                                                control.StartPoint,
2263
                                                control.MidPoint,
2264
                                                control.EndPoint,
2265
                                            };
2266
                                }
2267

    
2268
                            }
2269
                            break;
2270
                        case ControlType.PolygonControl:
2271
                            {
2272
                                var control = currentControl as PolygonControl;
2273

    
2274
                                if (control != null)
2275
                                {
2276
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2277
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2278
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2279
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2280
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2281
                                    control.updateControl();
2282
                                }
2283
                            }
2284
                            break;
2285
                        //강인구 추가
2286
                        case ControlType.Sign:
2287
                            {
2288
                                var control = currentControl as SignControl;
2289

    
2290
                                if (control != null)
2291
                                {
2292
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2293
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2294
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2295
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2296

    
2297
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2298
                                    {
2299
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2300
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2301
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2302
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2303
                                        stream.Position = 0;
2304
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2305
                                        BitmapImage returnImage = new BitmapImage();
2306
                                        returnImage.BeginInit();
2307
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2308
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2309
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2310
                                        returnImage.StreamSource = ms;
2311
                                        returnImage.EndInit();
2312
                                        stream.Close();
2313

    
2314
                                        control.SignImage = returnImage;
2315
                                    }
2316
                                    control.PointSet = new List<Point>
2317
                                        {
2318
                                            control.StartPoint,
2319
                                            control.LeftBottomPoint,
2320
                                            control.EndPoint,
2321
                                            control.TopRightPoint,
2322
                                        };
2323
                                }
2324
                            }
2325
                            break;
2326
                        //TODO: 강인구 추가
2327
                        case ControlType.Symbol:
2328
                            {
2329
                                var control = currentControl as SymControl;
2330

    
2331
                                if (control != null)
2332
                                {
2333
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2334
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2335
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2336
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2337
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2338
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2339

    
2340
                                    if (control.StartPoint != control.EndPoint)
2341
                                    {
2342
                                        if (control.PathData == null)
2343
                                        {
2344
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2345
                                            {
2346
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2347
                                            }
2348
                                        }
2349
                                    }
2350

    
2351
                                    control.PointSet = new List<Point>
2352
                                        {
2353
                                            control.StartPoint,
2354
                                            control.LeftBottomPoint,
2355
                                            control.EndPoint,
2356
                                            control.TopRightPoint,
2357
                                        };
2358
                                }
2359
                            }
2360
                            break;
2361
                        ///TODO: 
2362
                        case ControlType.Stamp:
2363
                            {
2364
                                var control = currentControl as SymControlN;
2365

    
2366
                                if (control != null)
2367
                                {
2368

    
2369
                                    if (control.StartPoint == control.EndPoint)
2370
                                    {
2371
                                        //string appovalData = "";
2372

    
2373
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2374
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2375

    
2376

    
2377
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2378

    
2379
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2380
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2381
                                        writer.Write(xamlData);
2382
                                        writer.Flush();
2383
                                        stream.Position = 0;
2384

    
2385
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2386
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2387
                                        UIElement ob = obj as UIElement;
2388

    
2389
                                        //control.ApplyTemplate();
2390

    
2391
                                        control.SetViewBox();
2392
                                        control.PathXathData = App.SystemInfo.STAMP;
2393
                                        control.Base_ViewBox.Child = ob;
2394
                                    }
2395

    
2396
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2397
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2398
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2399
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2400
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2401

    
2402

    
2403
                                    control.PointSet = new List<Point>
2404
                                    {
2405
                                        control.StartPoint,
2406
                                        control.LeftBottomPoint,
2407
                                        control.EndPoint,
2408
                                        control.TopRightPoint,
2409
                                    };
2410
                                }
2411
                            }
2412
                            break;
2413
                        case ControlType.Mark:
2414
                            {
2415
                                var control = currentControl as RectangleControl;
2416

    
2417
                                if (control != null)
2418
                                {
2419
                                    if (move.mousemode == MouseMode.Drawing)
2420
                                    {
2421
                                        //move.control_Move(ControlList, true, moveX, moveY);
2422
                                    }
2423
                                    else
2424
                                    {
2425
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2426
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2427
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2428
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2429

    
2430

    
2431
                                        control.PointSet = new List<Point>
2432
                                    {
2433
                                        control.StartPoint,
2434
                                        control.LeftBottomPoint,
2435
                                        control.EndPoint,
2436
                                        control.TopRightPoint,
2437
                                    };
2438
                                    }
2439

    
2440
                                    //강인구 추가
2441
                                    control.Paint = PaintSet.Fill;
2442
                                }
2443
                            }
2444
                            break;
2445
                        case ControlType.PenControl:
2446
                            {
2447
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2448
                                //inkBoard.Strokes.Add(stroke);
2449
                            }
2450
                            break;
2451
                        default:
2452
                            break;
2453
                    }
2454
                }
2455
            }
2456
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2457
            {
2458
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2459

    
2460
                if (isDraggingSelectionRect)
2461
                {
2462
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2463

    
2464
                    e.Handled = true;
2465
                }
2466
                else if (isLeftMouseButtonDownOnWindow)
2467
                {
2468
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2469
                    double dragDistance = Math.Abs(dragDelta.Length);
2470

    
2471
                    if (dragDistance > DragThreshold)
2472
                    {
2473
                        isDraggingSelectionRect = true;
2474

    
2475
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2476
                    }
2477

    
2478
                    e.Handled = true;
2479
                }
2480

    
2481

    
2482
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2483
                {
2484
                    //SelectionPath = new Path();
2485
                    //PathFigure pathFigure = new PathFigure();
2486
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2487
                    //SelectionPath.Opacity = 0.5;
2488
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2489
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2490
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2491
                }
2492
                else
2493
                {
2494
                    //List<Stroke> removingStroke = new List<Stroke>();
2495
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2496
                    //StrokeCollection stC = new StrokeCollection();
2497
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2498
                    //{
2499
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2500
                    //    p1.Intersect(p2);
2501
                    //    if (p1.IsEmpty)
2502
                    //    {
2503

    
2504

    
2505
                    //        p1 = SelectionPath.Data.Bounds;
2506
                    //        bool intersectCheck = false;
2507
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2508
                    //        {
2509
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2510
                    //            p1.Intersect(p3);
2511
                    //            if (!p1.IsEmpty)
2512
                    //            {
2513
                    //                intersectCheck = true;
2514
                    //            }
2515
                    //        }
2516
                    //        if (intersectCheck)
2517
                    //        {
2518
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2519
                    //        }
2520

    
2521
                    //    }
2522
                    //    else
2523
                    //    {
2524
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2525
                    //    }
2526
                    //}
2527

    
2528
                    e.Handled = true;
2529
                }
2530
            }
2531
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2532
            { //symbol      
2533
                if(_dragdropWindow != null)
2534
                {
2535
                    Win32Point w32Mouse = new Win32Point();
2536
                    GetCursorPos(ref w32Mouse);
2537

    
2538
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2539
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2540
                }                
2541
            }
2542
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2543
            {
2544
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2545
                if (control != null)
2546
                {
2547
                    this.cursor = Cursors.Hand;
2548
                    SetCursor();
2549
                }
2550
                else
2551
                {
2552
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2553

    
2554
                    SetCursor();
2555
                }
2556
            }
2557
            else
2558
            {
2559
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2560

    
2561
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2562
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2563

    
2564
                //if (hitList.Count > 0)
2565
                //{
2566

    
2567
                //}
2568

    
2569
                #region 조건 설정 : firstCondition
2570
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2571
                //pnts = generalTransform.Transform(pnts);
2572
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2573
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2574
                //                               this.DeepLayer._BaseLayer).ToObservable()
2575
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2576
                //                      select kkk).FirstOrDefault();
2577

    
2578
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2579
                //if (canvas !=null)
2580
                //{
2581
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2582
                //    {
2583
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2584
                //        if (uiElement!=null)
2585
                //        {
2586
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2587
                //        }
2588
                //    }
2589
                //}
2590

    
2591
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2592
                //hitResultsList.Clear();
2593

    
2594
                #endregion
2595
            }
2596
        }
2597

    
2598
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2599
        {
2600
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2601
            {
2602
                SetCursor();
2603
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2604
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2605

    
2606
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2607

    
2608
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2609
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2610

    
2611
                if (Sync.IsChecked)
2612
                {
2613
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2614
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2615
                }
2616
            }
2617
        }
2618

    
2619
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2620

    
2621
        private EllipseGeometry hitArea = new EllipseGeometry();
2622

    
2623
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2624
        {
2625
            IsDrawing = false;
2626

    
2627
            if (mouseHandlingMode != MouseHandlingMode.None)
2628
            {
2629
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2630
                {
2631
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2632

    
2633
                    SetCursor();
2634

    
2635
                    switch (controlType)
2636
                    {
2637
                        case ControlType.None:
2638
                            break;
2639
                        case ControlType.Rectangle:
2640
                            {
2641

    
2642
                            }
2643
                            break;
2644
                        case ControlType.PenControl:
2645
                            {
2646

    
2647
                            }
2648
                            break;
2649
                        default:
2650
                            break;
2651
                    }
2652
                }
2653
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2654
                {
2655
                    if (isLeftMouseButtonDownOnWindow)
2656
                    {
2657
                        bool wasDragSelectionApplied = false;
2658

    
2659
                        if (isDraggingSelectionRect)
2660
                        {
2661
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2662
                            {
2663
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2664
                                mouseHandlingMode = MouseHandlingMode.None;
2665
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2666
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2667
                                Set_Symbol_Capture(endPoint);
2668
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2669
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2670
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2671
                            }
2672
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2673
                            {
2674
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2675
                                mouseHandlingMode = MouseHandlingMode.None;
2676
                                Set_Capture();
2677

    
2678
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2679
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2680
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2681
                            }
2682
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2683
                            {
2684
                                ApplyDragSelectionRect();
2685
                            }
2686
                            else
2687
                            {
2688
                                double x = Canvas.GetLeft(dragZoomBorder);
2689
                                double y = Canvas.GetTop(dragZoomBorder);
2690
                                double width = dragZoomBorder.Width;
2691
                                double height = dragZoomBorder.Height;
2692
                                Rect dragRect = new Rect(x, y, width, height);
2693

    
2694
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2695

    
2696
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2697
                            }
2698

    
2699
                            isDraggingSelectionRect = false;
2700
                            e.Handled = true;
2701
                            wasDragSelectionApplied = true;
2702
                        }
2703

    
2704
                        if (isLeftMouseButtonDownOnWindow)
2705
                        {
2706
                            isLeftMouseButtonDownOnWindow = false;
2707
                            this.ReleaseMouseCapture();
2708
                            e.Handled = true;
2709
                        }
2710

    
2711
                        if (!wasDragSelectionApplied)
2712
                        {
2713
                            init();
2714
                        }
2715
                    }
2716
                }
2717
                else if (mouseButtonDown == MouseButton.Right)
2718
                {
2719
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2720
                    SetCursor();
2721
                }
2722

    
2723
                zoomAndPanControl.ReleaseMouseCapture();
2724

    
2725

    
2726
                e.Handled = true;
2727
            }
2728
            else
2729
            {
2730
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2731
                SetCursor();
2732
            }
2733
            mouseButtonDown = MouseButton.Left;
2734

    
2735
            //controlType = ControlType.SingleLine;
2736
        }
2737

    
2738
        public void Set_Symbol_Capture(Point endPoint)
2739
        {       
2740
            double x = canvasDrawingMouseDownPoint.X;
2741
            double y = canvasDrawingMouseDownPoint.Y;
2742
            if(x > endPoint.X)
2743
            {
2744
                x = endPoint.X;
2745
                y = endPoint.Y;
2746
            }
2747

    
2748
            double width = dragCaptureBorder.Width;
2749
            double height = dragCaptureBorder.Height;
2750

    
2751
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2752

    
2753
            if (x < 0)
2754
            {
2755
                width += x;
2756
                x = 0;
2757
            }
2758
            if (y < 0)
2759
            {
2760
                height += y;
2761
                y = 0;
2762

    
2763
                width = (int)canvasImage.PixelWidth - x;
2764
            }
2765
            if (x + width > canvasImage.PixelWidth)
2766
            {
2767
                width = (int)canvasImage.PixelWidth - x;
2768
            }
2769
            if (y + height > canvasImage.PixelHeight)
2770
            {
2771
                height = (int)canvasImage.PixelHeight - y;
2772
            }
2773
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2774

    
2775
            string uri = "";
2776
            if (userData.COMPANY != "EXT")
2777
            {
2778
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO,
2779
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2780
            }
2781
            else
2782
            {
2783
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2784
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2785
            }
2786

    
2787
            var defaultBitmapImage = new BitmapImage();
2788
            defaultBitmapImage.BeginInit();
2789
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2790
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2791
            defaultBitmapImage.UriSource = new Uri(uri);
2792
            defaultBitmapImage.EndInit();
2793

    
2794
            //GC.Collect();
2795

    
2796
            if (defaultBitmapImage.IsDownloading)
2797
            {
2798
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2799
                {
2800
                    defaultBitmapImage.Freeze();
2801
                    //GC.Collect();
2802
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2803
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2804
                };
2805
            }
2806
        }
2807

    
2808
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2809
        {
2810
            mouseButtonDown = MouseButton.Left;
2811
        }
2812

    
2813
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2814
        {
2815
            mouseButtonDown = MouseButton.Left;
2816
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2817
        }
2818

    
2819
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2820
        {
2821

    
2822
        }
2823

    
2824
        /// <summary>
2825
        /// select items by dragging
2826
        /// </summary>
2827
        private void ApplyDragSelectionRect()
2828
        {
2829
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2830

    
2831
            double x = Canvas.GetLeft(dragSelectionBorder);
2832
            double y = Canvas.GetTop(dragSelectionBorder);
2833
            double width = dragSelectionBorder.Width;
2834
            double height = dragSelectionBorder.Height;
2835
            Rect dragRect = new Rect(x, y, width, height);
2836
            Boolean Flag = false;
2837
            dragRect.Inflate(width / 10, height / 10);
2838
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2839
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2840

    
2841
            dragRect = new Rect(x, y, width, height);
2842
            dragRect.Inflate(width / 10, height / 10);
2843

    
2844
            foreach (var item in Items)
2845
            {
2846
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2847

    
2848
                if (Flag)
2849
                {
2850
                    adornerSet.Add(item);
2851
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2852

    
2853
                    Control_Style(item);
2854
                }
2855
            }
2856
            if (adornerSet.Count > 0)
2857
            {
2858
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2859
                SelectLayer.Children.Add(final);
2860
            }
2861
        }
2862

    
2863
        private void InitDragSelectionRect(Point pt1, Point pt2)
2864
        {
2865
            //캡쳐 중
2866
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2867
            {
2868
                dragCaptureBorder.Visibility = Visibility.Visible;
2869
            }
2870
            //선택 중
2871
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2872
            {
2873

    
2874
                dragSelectionBorder.Visibility = Visibility.Visible;
2875
            }
2876
            else
2877
            {
2878
                dragZoomBorder.Visibility = Visibility.Visible;
2879
            }
2880
            UpdateDragSelectionRect(pt1, pt2);
2881
        }
2882

    
2883
        /// <summary>
2884
        /// Update the position and size of the rectangle used for drag selection.
2885
        /// </summary>
2886
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2887
        {
2888
            double x, y, width, height;
2889

    
2890
            //
2891
            // Determine x,y,width and height of the rect inverting the points if necessary.
2892
            // 
2893

    
2894
            if (pt2.X < pt1.X)
2895
            {
2896
                x = pt2.X;
2897
                width = pt1.X - pt2.X;
2898
            }
2899
            else
2900
            {
2901
                x = pt1.X;
2902
                width = pt2.X - pt1.X;
2903
            }
2904

    
2905
            if (pt2.Y < pt1.Y)
2906
            {
2907
                y = pt2.Y;
2908
                height = pt1.Y - pt2.Y;
2909
            }
2910
            else
2911
            {
2912
                y = pt1.Y;
2913
                height = pt2.Y - pt1.Y;
2914
            }
2915

    
2916
            //
2917
            // Update the coordinates of the rectangle used for drag selection.
2918
            //
2919
            //캡쳐 중
2920
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2921
            {
2922
                Canvas.SetLeft(dragCaptureBorder, x);
2923
                Canvas.SetTop(dragCaptureBorder, y);
2924
                dragCaptureBorder.Width = width;
2925
                dragCaptureBorder.Height = height;
2926
            }
2927
            //선택 중
2928
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2929
            {
2930
                Canvas.SetLeft(dragSelectionBorder, x);
2931
                Canvas.SetTop(dragSelectionBorder, y);
2932
                dragSelectionBorder.Width = width;
2933
                dragSelectionBorder.Height = height;
2934
            }
2935
            else
2936
            {
2937
                Canvas.SetLeft(dragZoomBorder, x);
2938
                Canvas.SetTop(dragZoomBorder, y);
2939
                dragZoomBorder.Width = width;
2940
                dragZoomBorder.Height = height;
2941
            }
2942
        }
2943

    
2944
        private void drawingPannelRotate(double angle)
2945
        {
2946
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2947
            rotate.Angle = angle;
2948
            var rotationNum = Math.Abs((rotate.Angle / 90));
2949

    
2950
            if (angle == 90 || angle == 270)
2951
            {
2952
                double emptySize = zoomAndPanCanvas.Width;
2953
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2954
                zoomAndPanCanvas.Height = emptySize;
2955
            }
2956
            if (angle == 0)
2957
            {
2958
                translate.X = 0;
2959
                translate.Y = 0;
2960
            }
2961
            else if (angle == 90)
2962
            {
2963
                translate.X = zoomAndPanCanvas.Width;
2964
                translate.Y = 0;
2965
            }
2966
            else if (angle == 180)
2967
            {
2968
                translate.X = zoomAndPanCanvas.Width;
2969
                translate.Y = zoomAndPanCanvas.Height;
2970
            }
2971
            else
2972
            {
2973
                translate.X = 0;
2974
                translate.Y = zoomAndPanCanvas.Height;
2975
            }
2976

    
2977
            zoomAndPanControl.RotationAngle = rotate.Angle;
2978

    
2979

    
2980
            if (!testPanel2.IsHidden)
2981
            {
2982
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2983
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2984
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2985
            }
2986

    
2987
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2988
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2989
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2990
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2991
            ViewerDataModel.Instance.Angle = rotate.Angle;
2992
        }
2993

    
2994
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2995
        {
2996
            string Data_ = "";
2997

    
2998
            try
2999
            {
3000
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3001
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3002
                if (Data_ != null || Data_ != "")
3003
                {
3004
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3005
                }
3006
                else
3007
                {
3008
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3009
                }
3010

    
3011
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
3012
                {
3013
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
3014
                    STATE = 0,
3015
                };
3016
                if (Data_ != null)
3017
                {
3018
                    Image img = new Image();
3019
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
3020
                    if (Data_.Contains(".svg"))
3021
                    {
3022
                        byte[] imageData = null;
3023
                        DrawingImage image = null;
3024
                        using (System.Net.WebClient web = new System.Net.WebClient())
3025
                        {
3026
                            imageData = web.DownloadData(new Uri(Data_));
3027
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3028
                            image = SvgReader.Load(stream);
3029
                        }
3030
                        img.Source = image;
3031
                    }
3032
                    else
3033
                    {
3034
                        img.Source = new BitmapImage(new Uri(Data_));
3035
                    }
3036

    
3037
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3038
                    {
3039
                        PointSet = new List<Point>(),
3040
                        FilePath = Data_,
3041
                        ImageData = img.Source,
3042
                        StartPoint = canvasZoomPanningMouseDownPoint,
3043
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3044
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3045
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3046
                        canvasZoomPanningMouseDownPoint.Y),
3047
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3048
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3049
                    };
3050

    
3051
                    currentControl.PointSet = new List<Point>
3052
                                        {
3053
                                            currentControl.StartPoint,
3054
                                            currentControl.LeftBottomPoint,
3055
                                            currentControl.EndPoint,
3056
                                            currentControl.TopRightPoint,
3057
                                        };
3058
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3059
                    UndoData = new Undo_data()
3060
                    {
3061
                        IsUndo = false,
3062
                        Event = Event_Type.Create,
3063
                        EventTime = DateTime.Now,
3064
                        Markup_List = new List<Multi_Undo_data>()
3065
                    };
3066
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3067
                    {
3068
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3069
                    });
3070

    
3071
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3072
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3073
                    UndoData.Markup_List.Add(multi_Undo_Data);
3074
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3075

    
3076
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3077
                    currentControl.CommentID = Commons.shortGuid();
3078
                    currentControl.SymbolID = id;
3079
                    currentControl.GroupID = group_id;
3080
                    currentControl.ApplyTemplate();
3081
                    currentControl.SetImage();
3082

    
3083
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3084
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3085
                    SelectLayer.Children.Add(final);
3086
                }
3087
            }
3088
            catch (Exception ex)
3089
            {
3090
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3091
            }
3092
        }
3093

    
3094
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3095
        {            
3096
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3097
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3098
            {
3099
                set_option.Value = double.Parse(set_option.ContentText);
3100
            }
3101

    
3102
            InkControl_Convert();
3103

    
3104
            ///TODO:
3105
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
3106
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
3107

    
3108
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3109
            {
3110
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3111
            }
3112
            /// up to here
3113

    
3114
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3115
            {
3116
                if (arrow_text as ArrowTextControl != null)
3117
                {
3118
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3119
                }
3120
            }
3121

    
3122
            mouseButtonDown = e.ChangedButton;
3123
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3124

    
3125
            //if (currentControl != null)
3126
            {
3127
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3128
                if (text_item_ != null)
3129
                {
3130
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3131
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3132
                    (text_item_ as TextControl).IsEditing = false;
3133
                    (text_item_ as TextControl).EnableEditing = false;
3134
                    currentControl = null;
3135
                }
3136

    
3137
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3138
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3139
                {
3140
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3141
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3142
                    currentControl = null;
3143
                }
3144
            }
3145

    
3146
            double Ang = 0;                                          
3147
            if (rotate.Angle != 0)
3148
            {
3149
                Ang = 360 - rotate.Angle;
3150
            }
3151
            move = new Move();
3152

    
3153
            if (e.OriginalSource is System.Windows.Controls.Image)
3154
            {
3155
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3156
            }
3157

    
3158
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3159
            {                
3160
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3161
                //SetCursor();
3162

    
3163
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3164
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3165
                if(symbol_id != null)
3166
                {
3167
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3168
                }                
3169
            }
3170

    
3171
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3172
            {
3173
                if (this._dragdropWindow != null)
3174
                {
3175
                    this._dragdropWindow.Close();
3176
                    this._dragdropWindow = null;
3177
                    symbol_id = null;
3178
                }
3179
            }
3180

    
3181
            if (mouseButtonDown == MouseButton.Left)
3182
            {
3183
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3184
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3185

    
3186
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3187
                SetCursor();
3188

    
3189
                if (!ViewerDataModel.Instance.IsPressCtrl)
3190
                {
3191
                    SelectionSet.Instance.UnSelect(this);
3192
                }
3193
            }
3194
            if (mouseButtonDown == MouseButton.Middle)
3195
            {
3196
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3197
                cursor = Cursors.SizeAll;
3198
                SetCursor();
3199
            }
3200
            if (mouseButtonDown == MouseButton.Right)
3201
            {
3202
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3203
                cursor = Cursors.SizeAll;
3204
                SetCursor();
3205
            }
3206
            else if (mouseButtonDown == MouseButton.XButton1)
3207
            {
3208
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3209
                {
3210
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3211
                }
3212

    
3213
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3214

    
3215
            }
3216
            else if (mouseButtonDown == MouseButton.XButton2)
3217
            {
3218
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3219
                {
3220
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3221
                }
3222
            }
3223

    
3224
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3225
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3226
            {
3227
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3228
                {
3229
                    if (SelectLayer.Children.Count == 0)
3230
                    {
3231
                        isLeftMouseButtonDownOnWindow = true;
3232
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3233
                    }
3234

    
3235
                    if (controlType == ControlType.None)
3236
                    {
3237
                        isLeftMouseButtonDownOnWindow = true;
3238
                    }
3239
                }
3240

    
3241
                //캡쳐 모드 설정
3242
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3243
                {
3244
                    dragCaptureBorder.Visibility = Visibility.Visible;
3245
                    isLeftMouseButtonDownOnWindow = true;
3246
                }
3247

    
3248
                //줌 모드 설정
3249
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3250
                {
3251
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3252
                    isLeftMouseButtonDownOnWindow = true;
3253
                }               
3254

    
3255
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3256
                if (control != null)
3257
                {
3258
                    AdornerFinal final = null;
3259

    
3260
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3261
                    {
3262
                        /// 기존 selection 해제
3263
                        SelectionSet.Instance.UnSelect(this);
3264

    
3265
                        final = new AdornerFinal(control);
3266

    
3267
                        Control_Style(control);
3268

    
3269
                        if ((control as IPath) != null)
3270
                        {
3271
                            if ((control as IPath).LineSize != 0)
3272
                            {
3273
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3274
                            }
3275
                        }
3276
                        if ((control as IShapeControl) != null)
3277
                        {
3278
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3279
                            {
3280
                                ViewerDataModel.Instance.checkHatchShape = true;
3281
                            }
3282
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3283
                            {
3284
                                ViewerDataModel.Instance.checkFillShape = true;
3285
                            }
3286
                            else
3287
                            {
3288
                                ViewerDataModel.Instance.checkHatchShape = false;
3289
                                ViewerDataModel.Instance.checkFillShape = false;
3290
                            }
3291
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3292
                        }
3293

    
3294
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3295

    
3296
                        if ((control as TextControl) != null)
3297
                        {
3298
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3299
                            {
3300
                                ViewerDataModel.Instance.checkTextStyle = true;
3301
                            }
3302
                            else
3303
                            {
3304
                                ViewerDataModel.Instance.checkTextStyle = false;
3305
                            }
3306

    
3307
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3308
                            {
3309
                                ViewerDataModel.Instance.checkTextStyle = true;
3310
                            }
3311
                            else
3312
                            {
3313
                                ViewerDataModel.Instance.checkTextStyle = false;
3314
                            }
3315
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3316
                            {
3317
                                ViewerDataModel.Instance.checkTextWeight = true;
3318
                            }
3319
                            else
3320
                            {
3321
                                ViewerDataModel.Instance.checkTextWeight = false;
3322
                            }
3323
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3324
                            {
3325
                                ViewerDataModel.Instance.checkUnderLine = true;
3326
                            }
3327
                            else
3328
                            {
3329
                                ViewerDataModel.Instance.checkUnderLine = false;
3330
                            }
3331
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3332
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3333

    
3334
                        }
3335
                        else if ((control as ArrowTextControl) != null)
3336
                        {
3337
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3338
                            {
3339
                                ViewerDataModel.Instance.checkTextStyle = true;
3340
                            }
3341
                            else
3342
                            {
3343
                                ViewerDataModel.Instance.checkTextStyle = false;
3344
                            }
3345

    
3346
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3347
                            {
3348
                                ViewerDataModel.Instance.checkTextStyle = true;
3349
                            }
3350
                            else
3351
                            {
3352
                                ViewerDataModel.Instance.checkTextStyle = false;
3353
                            }
3354
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3355
                            {
3356
                                ViewerDataModel.Instance.checkTextWeight = true;
3357
                            }
3358
                            else
3359
                            {
3360
                                ViewerDataModel.Instance.checkTextWeight = false;
3361
                            }
3362
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3363
                            {
3364
                                ViewerDataModel.Instance.checkUnderLine = true;
3365
                            }
3366
                            else
3367
                            {
3368
                                ViewerDataModel.Instance.checkUnderLine = false;
3369
                            }
3370
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3371
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3372
                        }
3373
                        else if ((control as RectCloudControl) != null)
3374
                        {
3375
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3376
                        }
3377
                        else if ((control as CloudControl) != null)
3378
                        {
3379
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3380
                        }
3381
                    }
3382
                    else
3383
                    {
3384
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3385
                        SelectionSet.Instance.UnSelect(this);
3386
                        comment.Add(control);
3387

    
3388
                        Control_Style(control);
3389

    
3390
                        final = new AdornerFinal(comment);
3391
                    }
3392

    
3393
                    if(final != null) this.SelectLayer.Children.Add(final);
3394
                }              
3395
            }
3396
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3397
            {               
3398
                init();
3399
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3400
                if (cursor != Cursors.SizeAll)
3401
                {
3402
                    cursor = Cursors.Cross;
3403
                    SetCursor();
3404
                }
3405
                bool init_user = false;
3406
                foreach (var user in gridViewMarkup.Items)
3407
                {
3408
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3409
                    {
3410
                        init_user = true;
3411
                    }
3412
                }
3413
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3414
                {
3415
                    RadWindow.Alert(new DialogParameters
3416
                    {
3417
                        Owner = Application.Current.MainWindow,
3418
                        Theme = new VisualStudio2013Theme(),
3419
                        Header = "안내",
3420
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3421
                    });
3422
                    return;
3423
                }
3424
                else
3425
                {
3426
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3427
                    if (item != null)
3428
                    {
3429
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3430
                    }
3431
                }
3432

    
3433
                multi_Undo_Data = new Multi_Undo_data();
3434
                //강인구 Undo/Redo 보류
3435
                UndoData = new Undo_data()
3436
                {
3437
                    IsUndo = false,
3438
                    Event = Event_Type.Create,
3439
                    EventTime = DateTime.Now,
3440
                    Markup_List = new List<Multi_Undo_data>()
3441
                };
3442

    
3443
                switch (controlType)
3444
                {
3445
                    case ControlType.Coordinate:
3446
                        {
3447
                            if (mouseButtonDown == MouseButton.Left)
3448
                            {
3449
                                if (currentControl is CoordinateControl)
3450
                                {
3451
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3452
                                    {
3453
                                        return;
3454
                                    }
3455

    
3456
                                    CreateControl();
3457

    
3458
                                    (currentControl as CoordinateControl).ApplyOverViewData();
3459
                                    currentControl = null;
3460
                                    this.cursor = Cursors.Arrow;
3461
                                }
3462
                                else
3463
                                {
3464
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3465
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3466
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3467
                                    {
3468
                                        currentControl = null;
3469
                                        this.cursor = Cursors.Arrow;
3470
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3471
                                        return;
3472
                                    }
3473
                                    else
3474
                                    {
3475
                                        currentControl = new CoordinateControl
3476
                                        {
3477
                                            Background = new SolidColorBrush(Colors.Black),
3478
                                            ControlType = ControlType.Coordinate
3479
                                        };
3480

    
3481
                                        currentControl.CommentID = Commons.shortGuid();
3482
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3483
                                        currentControl.IsNew = true;
3484

    
3485
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3486

    
3487
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3488
                                    }
3489
                                }
3490
                            }
3491
                        }
3492
                        break;
3493
                    case ControlType.InsideWhite:
3494
                        {
3495
                            if (mouseButtonDown == MouseButton.Left)
3496
                            {
3497
                                if (currentControl is InsideWhiteControl)
3498
                                {
3499
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3500
                                    {
3501
                                        return;
3502
                                    }
3503

    
3504
                                    CreateControl();
3505

    
3506
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3507
                                    currentControl = null;
3508
                                    this.cursor = Cursors.Arrow;
3509
                                }
3510
                                else
3511
                                {
3512
                                    currentControl = new InsideWhiteControl
3513
                                    {
3514
                                        Background = new SolidColorBrush(Colors.Black),
3515
                                        ControlType = ControlType.InsideWhite
3516
                                    };
3517

    
3518
                                    currentControl.CommentID = Commons.shortGuid();
3519
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3520
                                    currentControl.IsNew = true;
3521
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3522

    
3523
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3524
                                }
3525
                            }
3526
                        }
3527
                        break;
3528
                    case ControlType.OverlapWhite:
3529
                        {
3530
                            if (mouseButtonDown == MouseButton.Left)
3531
                            {
3532
                                if (currentControl is OverlapWhiteControl)
3533
                                {
3534
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3535
                                    {
3536
                                        return;
3537
                                    }
3538

    
3539
                                    CreateControl();
3540

    
3541
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3542
                                    currentControl = null;
3543
                                    this.cursor = Cursors.Arrow;
3544
                                }
3545
                                else
3546
                                {
3547
                                    currentControl = new OverlapWhiteControl
3548
                                    {
3549
                                        Background = new SolidColorBrush(Colors.Black),
3550
                                        ControlType = ControlType.OverlapWhite
3551
                                    };
3552

    
3553
                                    currentControl.CommentID = Commons.shortGuid();
3554
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3555
                                    currentControl.IsNew = true;
3556
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3557

    
3558
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3559
                                }
3560
                            }
3561
                        }
3562
                        break;
3563
                    case ControlType.ClipWhite:
3564
                        {
3565
                            if (mouseButtonDown == MouseButton.Left)
3566
                            {
3567
                                if (currentControl is ClipWhiteControl)
3568
                                {
3569
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3570
                                    {
3571
                                        return;
3572
                                    }
3573

    
3574
                                    CreateControl();
3575

    
3576
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
3577
                                    currentControl = null;
3578
                                    this.cursor = Cursors.Arrow;
3579
                                }
3580
                                else
3581
                                {
3582
                                    currentControl = new ClipWhiteControl
3583
                                    {
3584
                                        Background = new SolidColorBrush(Colors.Black),
3585
                                        ControlType = ControlType.ClipWhite
3586
                                    };
3587

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

    
3593
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3594
                                }
3595
                            }
3596
                        }
3597
                        break;
3598
                    case ControlType.Rectangle:
3599
                        {
3600
                            if (mouseButtonDown == MouseButton.Left)
3601
                            {
3602
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3603
                                //{
3604
                                    if (currentControl is RectangleControl)
3605
                                    {
3606
                                        //20180906 LJY TEST IsRotationDrawingEnable
3607
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3608
                                        {
3609
                                            return;
3610
                                        }
3611

    
3612
                                        CreateControl();
3613

    
3614
                                        (currentControl as RectangleControl).ApplyOverViewData();
3615
                                        currentControl = null;
3616
                                    
3617
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3618
                                    }
3619
                                    else
3620
                                    {
3621
                                        currentControl = new RectangleControl
3622
                                        {
3623
                                            Background = new SolidColorBrush(Colors.Black),
3624
                                            ControlType = ControlType.Rectangle
3625
                                        };
3626

    
3627
                                        currentControl.CommentID = Commons.shortGuid();
3628
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3629
                                        currentControl.IsNew = true;
3630
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3631

    
3632
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3633
                                    }
3634
                                //}
3635
                            }
3636
                        }
3637
                        break;
3638
                    case ControlType.RectCloud:
3639
                        {
3640
                            if (mouseButtonDown == MouseButton.Left)
3641
                            {
3642
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3643
                                //{
3644
                                    if (currentControl is RectCloudControl)
3645
                                    {
3646
                                        //20180906 LJY TEST IsRotationDrawingEnable
3647
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3648
                                        {
3649
                                            return;
3650
                                        }
3651

    
3652
                                        CreateControl();
3653

    
3654
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3655
                                        currentControl = null;
3656
                                    
3657
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3658
                                    }
3659
                                    else
3660
                                    {
3661
                                        currentControl = new RectCloudControl
3662
                                        {
3663
                                            Background = new SolidColorBrush(Colors.Black)
3664
                                        };
3665

    
3666
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3667
                                        currentControl.CommentID = Commons.shortGuid();
3668
                                        currentControl.IsNew = true;
3669
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3670
                                    }
3671
                                //}
3672
                            }
3673
                        }
3674
                        break;
3675
                    case ControlType.Circle:
3676
                        {
3677
                            if (mouseButtonDown == MouseButton.Left)
3678
                            {
3679
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3680
                                //{
3681
                                    if (currentControl is CircleControl)
3682
                                    {
3683
                                        //20180906 LJY TEST IsRotationDrawingEnable
3684
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3685
                                        {
3686
                                            return;
3687
                                        }
3688

    
3689
                                        CreateControl();
3690

    
3691
                                        (currentControl as CircleControl).ApplyOverViewData();
3692
                                        currentControl = null;
3693
                                    }
3694
                                    else
3695
                                    {
3696
                                        currentControl = new CircleControl
3697
                                        {
3698
                                            Background = new SolidColorBrush(Colors.Black)
3699
                                        };
3700

    
3701
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3702
                                        currentControl.CommentID = Commons.shortGuid();
3703
                                        currentControl.IsNew = true;
3704
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3705
                                    }
3706
                                //}
3707
                            }
3708
                        }
3709
                        break;
3710
                    case ControlType.Triangle:
3711
                        {
3712
                            if (mouseButtonDown == MouseButton.Left)
3713
                            {
3714
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3715
                                //{
3716
                                    if (currentControl is TriControl)
3717
                                    {
3718
                                        var content = currentControl as TriControl;
3719
                                        if (content.MidPoint == new Point(0, 0))
3720
                                        {
3721
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3722
                                        }
3723
                                        else
3724
                                        {
3725
                                            //20180906 LJY TEST IsRotationDrawingEnable
3726
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3727
                                            {
3728
                                                return;
3729
                                            }
3730

    
3731
                                            CreateControl();
3732

    
3733
                                            (currentControl as TriControl).ApplyOverViewData();
3734
                                            currentControl = null;
3735
                                        }
3736
                                    }
3737
                                    else
3738
                                    {
3739
                                        currentControl = new TriControl
3740
                                        {
3741
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3742
                                            Background = new SolidColorBrush(Colors.Black),
3743
                                        };
3744

    
3745
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3746
                                        currentControl.CommentID = Commons.shortGuid();
3747
                                        currentControl.IsNew = true;
3748
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3749
                                    }
3750
                                //}
3751
                            }
3752
                        }
3753
                        break;
3754
                    case ControlType.SingleLine:
3755
                        {
3756
                            if (mouseButtonDown == MouseButton.Left)
3757
                            {
3758
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3759
                                //{
3760
                                    if (currentControl is LineControl)
3761
                                    {
3762
                                        //20180906 LJY TEST IsRotationDrawingEnable
3763
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3764
                                        {
3765
                                            return;
3766
                                        }
3767

    
3768
                                        CreateControl();
3769

    
3770
                                        (currentControl as LineControl).ApplyOverViewData();
3771
                                        currentControl = null;
3772
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3773
                                    }
3774
                                    else
3775
                                    {
3776
                                        currentControl = new LineControl
3777
                                        {
3778
                                            Background = new SolidColorBrush(Colors.Black)
3779
                                        };
3780

    
3781
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3782
                                        currentControl.CommentID = Commons.shortGuid();
3783
                                        currentControl.IsNew = true;
3784
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3785
                                        this.MainAngle.Visibility = Visibility.Visible;
3786
                                    }
3787
                                //}
3788
                            }
3789
                        }
3790
                        break;
3791
                    case ControlType.CancelLine:
3792
                        {
3793
                            if (mouseButtonDown == MouseButton.Left)
3794
                            {
3795
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3796
                                //{
3797
                                    if (currentControl is LineControl)
3798
                                    {
3799
                                        //20180906 LJY TEST IsRotationDrawingEnable
3800
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3801
                                        {
3802
                                            return;
3803
                                        }
3804

    
3805
                                        CreateControl();
3806

    
3807
                                        (currentControl as LineControl).ApplyOverViewData();
3808
                                        currentControl = null;
3809
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3810
                                    }
3811
                                    else
3812
                                    {
3813
                                        currentControl = new LineControl
3814
                                        {
3815
                                            Background = new SolidColorBrush(Colors.Black)
3816
                                        };
3817

    
3818
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3819
                                        currentControl.CommentID = Commons.shortGuid();
3820
                                        currentControl.IsNew = true;
3821
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3822
                                        this.MainAngle.Visibility = Visibility.Visible;
3823
                                    }
3824
                                //}
3825
                            }
3826
                        }
3827
                        break;
3828
                    case ControlType.ArrowLine:
3829
                        {
3830
                            if (mouseButtonDown == MouseButton.Left)
3831
                            {
3832
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3833
                                //{
3834
                                    if (currentControl is LineControl)
3835
                                    {
3836
                                        //20180906 LJY TEST IsRotationDrawingEnable
3837
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3838
                                        {
3839
                                            return;
3840
                                        }
3841

    
3842
                                        CreateControl();
3843

    
3844
                                        (currentControl as LineControl).ApplyOverViewData();
3845
                                        currentControl = null;
3846
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3847
                                    }
3848
                                    else
3849
                                    {
3850
                                        currentControl = new LineControl
3851
                                        {
3852
                                            Background = new SolidColorBrush(Colors.Black)
3853
                                        };
3854

    
3855
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3856
                                        currentControl.CommentID = Commons.shortGuid();
3857
                                        currentControl.IsNew = true;
3858
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3859
                                        this.MainAngle.Visibility = Visibility.Visible;
3860
                                    }
3861
                                //}
3862
                            }
3863
                        }
3864
                        break;
3865
                    case ControlType.TwinLine:
3866
                        {
3867
                            if (mouseButtonDown == MouseButton.Left)
3868
                            {
3869
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3870
                                //{
3871
                                    if (currentControl is LineControl)
3872
                                    {
3873
                                        //20180906 LJY TEST IsRotationDrawingEnable
3874
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3875
                                        {
3876
                                            return;
3877
                                        }
3878

    
3879
                                        CreateControl();
3880

    
3881
                                        (currentControl as LineControl).ApplyOverViewData();
3882
                                        currentControl = null;
3883
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3884
                                    }
3885
                                    else
3886
                                    {
3887
                                        currentControl = new LineControl
3888
                                        {
3889
                                            Background = new SolidColorBrush(Colors.Black)
3890
                                        };
3891
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3892
                                        currentControl.CommentID = Commons.shortGuid();
3893
                                        currentControl.IsNew = true;
3894
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3895
                                        this.MainAngle.Visibility = Visibility.Visible;
3896
                                    }
3897
                                //}
3898
                            }
3899
                        }
3900
                        break;
3901
                    case ControlType.DimLine:
3902
                        {
3903
                            if (mouseButtonDown == MouseButton.Left)
3904
                            {
3905
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3906
                                //{
3907
                                    if (currentControl is LineControl)
3908
                                    {
3909
                                        //20180906 LJY TEST IsRotationDrawingEnable
3910
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3911
                                        {
3912
                                            return;
3913
                                        }
3914
                                        CreateControl();
3915

    
3916
                                        (currentControl as LineControl).ApplyOverViewData();
3917
                                        currentControl = null;
3918
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3919
                                    }
3920
                                    else
3921
                                    {
3922
                                        currentControl = new LineControl
3923
                                        {
3924
                                            Background = new SolidColorBrush(Colors.Black)
3925
                                        };
3926
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3927
                                        currentControl.CommentID = Commons.shortGuid();
3928
                                        currentControl.IsNew = true;
3929
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3930
                                        this.MainAngle.Visibility = Visibility.Visible;
3931
                                    }
3932
                                //}
3933
                            }
3934
                        }
3935
                        break;
3936
                    case ControlType.ChainLine:
3937
                        {
3938
                            if (currentControl is PolygonControl)
3939
                            {
3940
                                var control = currentControl as PolygonControl;
3941

    
3942
                                if (mouseButtonDown == MouseButton.Right)
3943
                                {
3944
                                    //20180906 LJY TEST IsRotationDrawingEnable
3945
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3946
                                    {
3947
                                        return;
3948
                                    }
3949

    
3950
                                    CreateControl();
3951

    
3952
                                    (currentControl as PolygonControl).ApplyOverViewData();
3953
                                    currentControl = null;
3954
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3955
                                    return;
3956
                                }
3957

    
3958
                                if (!control.IsCompleted)
3959
                                {
3960
                                    control.PointSet.Add(control.EndPoint);
3961
                                    this.MainAngle.Visibility = Visibility.Visible;
3962
                                }
3963
                            }
3964
                            else
3965
                            {
3966
                                if (mouseButtonDown == MouseButton.Left)
3967
                                {
3968
                                    MainAngle.Visibility = Visibility.Visible;
3969
                                    currentControl = new PolygonControl
3970
                                    {
3971
                                        PointSet = new List<Point>(),
3972
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3973
                                        ControlType = ControlType.ChainLine,
3974
                                        DashSize = ViewerDataModel.Instance.DashSize,
3975
                                        LineSize = ViewerDataModel.Instance.LineSize,
3976
                                        //PointC = new StylusPointSet()
3977
                                    };
3978

    
3979
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3980
                                    //{
3981
                                        var polygonControl = (currentControl as PolygonControl);
3982
                                        currentControl.CommentID = Commons.shortGuid();
3983
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3984
                                        currentControl.IsNew = true;
3985
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3986
                                        //currentControl.OnApplyTemplate();
3987
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3988
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3989
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3990
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3991
                                    //}
3992
                                }
3993
                            }
3994
                        }
3995
                        break;
3996
                    case ControlType.ArcLine:
3997
                        {
3998
                            if (mouseButtonDown == MouseButton.Left)
3999
                            {
4000
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4001
                                //{
4002
                                    if (currentControl is ArcControl)
4003
                                    {
4004
                                        //20180906 LJY TEST IsRotationDrawingEnable
4005
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4006
                                        {
4007
                                            return;
4008
                                        }
4009

    
4010
                                        CreateControl();
4011

    
4012
                                        (currentControl as ArcControl).ApplyOverViewData();
4013
                                        currentControl = null;
4014
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4015
                                    }
4016
                                    else
4017
                                    {
4018
                                        currentControl = new ArcControl
4019
                                        {
4020
                                            Background = new SolidColorBrush(Colors.Black)
4021
                                        };
4022
                                        currentControl.CommentID = Commons.shortGuid();
4023
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4024
                                        currentControl.IsNew = true;
4025
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4026
                                        this.MainAngle.Visibility = Visibility.Visible;
4027
                                    }
4028
                                //}
4029
                            }
4030
                            else if (mouseButtonDown == MouseButton.Right)
4031
                            {
4032
                                if (currentControl != null)
4033
                                {
4034
                                    (currentControl as ArcControl).setClock();
4035
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
4036
                                    //(currentControl as ArcControl).ApplyTemplate();
4037
                                }
4038
                            }
4039
                        }
4040
                        break;
4041
                    case ControlType.ArcArrow:
4042
                        {
4043
                            if (mouseButtonDown == MouseButton.Left)
4044
                            {
4045
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4046
                                //{
4047
                                if (currentControl is ArrowArcControl)
4048
                                {
4049
                                    //20180906 LJY TEST IsRotationDrawingEnable
4050
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4051
                                    {
4052
                                        return;
4053
                                    }
4054

    
4055
                                    CreateControl();
4056

    
4057
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
4058
                                    currentControl = null;
4059
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4060
                                }
4061
                                else
4062
                                {
4063
                                    currentControl = new ArrowArcControl
4064
                                    {
4065
                                        Background = new SolidColorBrush(Colors.Black)
4066
                                    };
4067
                                    currentControl.CommentID = Commons.shortGuid();
4068
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4069
                                    currentControl.IsNew = true;
4070
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4071
                                    this.MainAngle.Visibility = Visibility.Visible;
4072
                                }
4073
                                //}
4074
                            }
4075
                            else if (mouseButtonDown == MouseButton.Right)
4076
                            {
4077
                                if (currentControl != null)
4078
                                {
4079
                                    (currentControl as ArrowArcControl).setClock();
4080
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
4081
                                    //(currentControl as ArcControl).ApplyTemplate();
4082
                                }
4083
                            }
4084
                        }
4085
                        break;
4086
                    case ControlType.ArrowMultiLine:
4087
                        {
4088
                            if (mouseButtonDown == MouseButton.Left)
4089
                            {
4090
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4091
                                //{
4092

    
4093
                                    if (currentControl is ArrowControl_Multi)
4094
                                    {
4095
                                        var content = currentControl as ArrowControl_Multi;
4096
                                        if (content.MiddlePoint == new Point(0, 0))
4097
                                        {
4098
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
4099
                                            {
4100
                                                content.MiddlePoint = content.EndPoint;
4101
                                            }
4102
                                            else
4103
                                            {
4104
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4105
                                            }
4106
                                        }
4107
                                        else
4108
                                        {
4109
                                            //20180906 LJY TEST IsRotationDrawingEnable
4110
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4111
                                            {
4112
                                                return;
4113
                                            }
4114

    
4115
                                            CreateControl();
4116

    
4117
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
4118
                                            currentControl = null;
4119
                                            this.MainAngle.Visibility = Visibility.Collapsed;
4120
                                        }
4121
                                    }
4122
                                    else
4123
                                    {
4124
                                        currentControl = new ArrowControl_Multi
4125
                                        {
4126
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4127
                                            Background = new SolidColorBrush(Colors.Black)
4128
                                        };
4129
                                        currentControl.CommentID = Commons.shortGuid();
4130
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4131
                                        currentControl.IsNew = true;
4132
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4133
                                        this.MainAngle.Visibility = Visibility.Visible;
4134
                                    }
4135
                                //}
4136
                            }
4137
                        }
4138
                        break;
4139
                    case ControlType.PolygonCloud:
4140
                        {
4141
                            if (currentControl is CloudControl)
4142
                            {
4143
                                var control = currentControl as CloudControl;
4144
                                if (mouseButtonDown == MouseButton.Right)
4145
                                {
4146
                                    control.IsCompleted = true;
4147
                                }
4148

    
4149
                                if (!control.IsCompleted)
4150
                                {
4151
                                    control.PointSet.Add(control.EndPoint);
4152
                                }
4153
                                else
4154
                                {
4155
                                    //20180906 LJY TEST IsRotationDrawingEnable
4156
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4157
                                    {
4158
                                        return;
4159
                                    }
4160

    
4161
                                    CreateControl();
4162

    
4163
                                    control.isTransOn = true;
4164
                                    var firstPoint = control.PointSet.First();
4165

    
4166
                                    control.PointSet.Add(firstPoint);
4167
                                    control.DrawingCloud();
4168
                                    control.ApplyOverViewData();
4169

    
4170
                                    currentControl = null;
4171
                                }
4172
                            }
4173
                            else
4174
                            {
4175
                                if (mouseButtonDown == MouseButton.Left)
4176
                                {
4177
                                    currentControl = new CloudControl
4178
                                    {
4179
                                        PointSet = new List<Point>(),
4180
                                        PointC = new StylusPointSet()
4181
                                    };
4182

    
4183
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4184
                                    //{
4185
                                        var polygonControl = (currentControl as CloudControl);
4186
                                        currentControl.CommentID = Commons.shortGuid();
4187
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4188
                                        currentControl.IsNew = true;
4189
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4190

    
4191
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4192
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4193
                                    
4194
                                    //}
4195
                                }
4196
                            }
4197
                        }
4198
                        break;
4199
                    case ControlType.ImgControl:
4200
                        {
4201
                            if (mouseButtonDown == MouseButton.Left)
4202
                            {
4203
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4204
                                //{
4205
                                    if (currentControl is ImgControl)
4206
                                    {
4207
                                        //20180906 LJY TEST IsRotationDrawingEnable
4208
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4209
                                        {
4210
                                            return;
4211
                                        }
4212

    
4213
                                        CreateControl();
4214
                                        (currentControl as ImgControl).ApplyOverViewData();
4215
                                        controlType = ControlType.ImgControl;
4216
                                        currentControl = null;
4217
                                    }
4218
                                    else
4219
                                    {
4220
                                        
4221
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4222
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4223
                                        {
4224
                                            Image img = new Image();
4225
                                            //img.Source = new BitmapImage(new Uri(filename));
4226
                                            if (filename.Contains(".svg"))
4227
                                            {
4228
                                                byte[] imageData = null;
4229
                                                DrawingImage image = null;
4230
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4231
                                                {
4232
                                                    imageData = web.DownloadData(new Uri(filename));
4233
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4234
                                                    image = SvgReader.Load(stream);
4235
                                                }
4236
                                                img.Source = image;
4237
                                            }
4238
                                            else
4239
                                            {
4240
                                                img.Source = new BitmapImage(new Uri(filename));
4241
                                            }
4242

    
4243
                                            currentControl = new ImgControl
4244
                                            {
4245
                                                    Background = new SolidColorBrush(Colors.Black),
4246
                                                    PointSet = new List<Point>(),
4247
                                                    FilePath = filename,
4248
                                                    ImageData = img.Source,
4249
                                                    StartPoint = canvasDrawingMouseDownPoint,
4250
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4251
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4252
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4253
                                                    ControlType = ControlType.ImgControl
4254
                                                };
4255

    
4256
                                        
4257
                                                currentControl.CommentID = Commons.shortGuid();                                            
4258
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4259
                                                currentControl.IsNew = true;
4260
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4261

    
4262
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4263
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4264
                                        }
4265
                                    }
4266
                                //}
4267
                            }
4268
                        }
4269
                        break;
4270
                    case ControlType.Date:
4271
                        {
4272
                            if (mouseButtonDown == MouseButton.Left)
4273
                            {
4274
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4275
                                //{
4276
                                    if (currentControl is DateControl)
4277
                                    {
4278
                                        //20180906 LJY TEST IsRotationDrawingEnable
4279
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4280
                                        {
4281
                                            return;
4282
                                        }
4283

    
4284
                                        CreateControl();
4285
                                        (currentControl as DateControl).ApplyOverViewData();
4286
                                        currentControl = null;
4287

    
4288
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4289
                                        {
4290
                                            controlType = ControlType.None;
4291
                                            IsSwingMode = false;
4292
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4293
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4294
                                            mouseHandlingMode = MouseHandlingMode.None;
4295
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4296
                                            txtBatch.Visibility = Visibility.Collapsed;
4297

    
4298
                                        }
4299
                                    }
4300
                                    else
4301
                                    {
4302
                                        currentControl = new DateControl
4303
                                        {
4304
                                            Background = new SolidColorBrush(Colors.Black)
4305
                                        };
4306
                                        currentControl.CommentID = Commons.shortGuid();
4307
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4308
                                        currentControl.IsNew = true;
4309
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4310

    
4311
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4312
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4313
                                }
4314
                                //}
4315
                            }
4316
                        }
4317
                        break;
4318
                    case ControlType.TextControl:
4319
                        {
4320
                            if (mouseButtonDown == MouseButton.Left)
4321
                            {
4322
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4323
                                {
4324
                                    currentControl = new TextControl
4325
                                    {
4326
                                        ControlType = controlType
4327
                                    };
4328
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4329
                                    currentControl.CommentID = Commons.shortGuid();
4330
                                    currentControl.IsNew = true;
4331
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4332
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4333
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4334
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4335
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4336
                                    
4337
                                    (currentControl as TextControl).ControlType_No = 0;
4338
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4339
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4340
                                    (currentControl as TextControl).ApplyTemplate();
4341
                                    (currentControl as TextControl).Base_TextBox.Focus();
4342

    
4343
                                    CreateControl();
4344

    
4345
                                }
4346
                            }
4347
                        }
4348
                        break;
4349
                    case ControlType.TextBorder:
4350
                        {
4351
                            if (mouseButtonDown == MouseButton.Left)
4352
                            {
4353
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4354
                                {
4355
                                    currentControl = new TextControl
4356
                                    {
4357
                                        ControlType = controlType
4358
                                    };
4359

    
4360
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4361
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4362
                                    currentControl.CommentID = Commons.shortGuid();
4363
                                    currentControl.IsNew = true;
4364
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4365
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4366
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4367
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4368
                                    
4369
                                    (currentControl as TextControl).ControlType_No = 1;
4370
                                    (currentControl as TextControl).Angle = Ang;
4371
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4372
                                    (currentControl as TextControl).ApplyTemplate();
4373
                                    (currentControl as TextControl).Base_TextBox.Focus();
4374
                                    CreateControl();
4375

    
4376
                                    //currentControl = null;
4377
                                }
4378
                            }
4379
                        }
4380
                        break;
4381
                    case ControlType.TextCloud:
4382
                        {
4383
                            if (mouseButtonDown == MouseButton.Left)
4384
                            {
4385
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4386
                                {
4387
                                    currentControl = new TextControl
4388
                                    {
4389
                                        ControlType = controlType
4390
                                    };
4391

    
4392
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4393
                                    currentControl.CommentID = Commons.shortGuid();
4394
                                    currentControl.IsNew = true;
4395
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4396
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4397

    
4398
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4399
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4400
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4401

    
4402
                                    (currentControl as TextControl).Angle = Ang;
4403
                                    (currentControl as TextControl).ControlType_No = 2;
4404
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4405
                                    (currentControl as TextControl).ApplyTemplate();
4406
                                    (currentControl as TextControl).Base_TextBox.Focus();
4407
                                    CreateControl();
4408
                                    //currentControl = null;
4409
                                }
4410
                            }
4411
                        }
4412
                        break;
4413
                    case ControlType.ArrowTextControl:
4414
                         {
4415
                            if (mouseButtonDown == MouseButton.Left)
4416
                            {
4417
                                if (currentControl is ArrowTextControl)
4418
                                {
4419
                                    //20180906 LJY TEST IsRotationDrawingEnable
4420
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4421
                                    {
4422
                                        return;
4423
                                    }                                    
4424

    
4425
                                    CreateControl();
4426

    
4427
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4428
                                    (currentControl as ArrowTextControl).IsEditing = false;
4429
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4430
                                    (currentControl as ArrowTextControl).IsNew = false;
4431
                                    currentControl = null;
4432
                                }
4433
                                else
4434
                                {
4435
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4436
                                    //{
4437
                                        currentControl = new ArrowTextControl();
4438
                                        currentControl.CommentID = Commons.shortGuid();
4439
                                        currentControl.IsNew = true;
4440
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4441
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4442

    
4443
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4444
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4445
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4446
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4447
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4448

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

    
4452
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4453
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4454
                                        this.MainAngle.Visibility = Visibility.Visible;
4455

    
4456
                                    
4457
                                    //}
4458
                                }
4459
                            }
4460
                        }
4461
                        break;
4462
                    case ControlType.ArrowTransTextControl:
4463
                        {
4464
                            if (mouseButtonDown == MouseButton.Left)
4465
                            {
4466
                                if (currentControl is ArrowTextControl)
4467
                                {
4468
                                    //20180906 LJY TEST IsRotationDrawingEnable
4469
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4470
                                    {
4471
                                        return;
4472
                                    }                                    
4473

    
4474
                                    CreateControl();
4475
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4476
                                    currentControl.IsNew = false;
4477
                                    currentControl = null;
4478
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4479
                                }
4480
                                else
4481
                                {
4482
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4483
                                    //{
4484
                                         currentControl = new ArrowTextControl();
4485
                                        currentControl.CommentID = Commons.shortGuid();
4486
                                        currentControl.IsNew = true;
4487
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4488
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4489
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4490
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4491
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4492
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4493
                                        (currentControl as ArrowTextControl).isFixed = true;
4494
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4495

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

    
4499
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4500
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4501
                                        (currentControl as ArrowTextControl).isTrans = true;
4502
                                }
4503
                            }
4504
                        }
4505
                        break;
4506
                    case ControlType.ArrowTextBorderControl:
4507
                         {
4508
                            if (mouseButtonDown == MouseButton.Left)
4509
                            {
4510
                                if (currentControl is ArrowTextControl)
4511
                                {
4512
                                    //20180906 LJY TEST IsRotationDrawingEnable
4513
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4514
                                    {
4515
                                        return;
4516
                                    }
4517

    
4518
                                    CreateControl();
4519
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4520
                                    currentControl.IsNew = false;
4521
                                    currentControl = null;
4522
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4523
                                }
4524
                                else
4525
                                {
4526
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4527
                                    //{
4528
                                        currentControl = new ArrowTextControl()
4529
                                        {
4530
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4531
                                        };
4532
                                        currentControl.CommentID = Commons.shortGuid();
4533
                                        currentControl.IsNew = true;
4534
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4535
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4536

    
4537
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4538

    
4539
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4540

    
4541
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4542
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4543
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4544

    
4545
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4546
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4547
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4548
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4549
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4550
                                    //}
4551
                                }
4552
                            }
4553
                        }
4554
                        break;
4555
                    case ControlType.ArrowTransTextBorderControl:
4556
                        {
4557
                            if (mouseButtonDown == MouseButton.Left)
4558
                            {
4559
                                if (currentControl is ArrowTextControl)
4560
                                {
4561
                                    //20180906 LJY TEST IsRotationDrawingEnable
4562
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4563
                                    {
4564
                                        return;
4565
                                    }
4566
                                    CreateControl();
4567
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4568
                                    currentControl.IsNew = false;
4569
                                    currentControl = null;
4570
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4571
                                }
4572
                                else
4573
                                {
4574
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4575
                                    //{
4576
                                    
4577

    
4578
                                    currentControl = new ArrowTextControl()
4579
                                        {
4580
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4581
                                        };
4582
                                        currentControl.CommentID = Commons.shortGuid();
4583
                                        currentControl.IsNew = true;
4584
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4585
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4586

    
4587
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4588

    
4589
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4590
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4591
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4592
                                        (currentControl as ArrowTextControl).isFixed = true;
4593
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4594
                                     
4595
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4596
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4597
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4598

    
4599
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4600
                                        this.MainAngle.Visibility = Visibility.Visible;
4601
                                    
4602
                                    //20180911 LJY
4603
                                        (currentControl as ArrowTextControl).isTrans = true;
4604
                                    
4605

    
4606
                                    //}
4607
                                }
4608
                            }
4609
                        }
4610
                        break;
4611
                    case ControlType.ArrowTextCloudControl:
4612
                        {
4613
                            if (mouseButtonDown == MouseButton.Left)
4614
                            {
4615
                                if (currentControl is ArrowTextControl)
4616
                                {
4617
                                    //20180906 LJY TEST IsRotationDrawingEnable
4618
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4619
                                    {
4620
                                        return;
4621
                                    }
4622
                                    CreateControl();
4623
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4624
                                    currentControl.IsNew = false;
4625
                                    currentControl = null;
4626
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4627
                                }
4628
                                else
4629
                                {
4630
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4631
                                    //{
4632
                                        currentControl = new ArrowTextControl()
4633
                                        {
4634
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4635
                                        };
4636
                                        currentControl.CommentID = Commons.shortGuid();
4637
                                        currentControl.IsNew = true;
4638
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4639
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4640

    
4641
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4642
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4643
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4644
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4645
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4646

    
4647
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4648
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4649
                                    
4650
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4651
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4652
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4653
                                    //}
4654
                                }
4655
                            }
4656
                        }
4657
                        break;
4658
                    case ControlType.ArrowTransTextCloudControl:
4659
                        {
4660
                            if (mouseButtonDown == MouseButton.Left)
4661
                            {
4662
                                if (currentControl is ArrowTextControl)
4663
                                {
4664
                                    //20180906 LJY TEST IsRotationDrawingEnable
4665
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4666
                                    {
4667
                                        return;
4668
                                    }
4669
                                    CreateControl();
4670
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4671
                                    currentControl.IsNew = false;
4672
                                    currentControl = null;
4673
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4674
                                }
4675
                                else
4676
                                {
4677
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4678
                                    //{
4679
                                        currentControl = new ArrowTextControl()
4680
                                        {
4681
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4682
                                        };
4683
                                        currentControl.CommentID = Commons.shortGuid();
4684
                                        currentControl.IsNew = true; 
4685
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4686
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4687
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4688

    
4689
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4690
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4691
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4692
                                        (currentControl as ArrowTextControl).isFixed = true;
4693
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4694

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

    
4698
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4699
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4700
                                        this.MainAngle.Visibility = Visibility.Visible;  
4701
                                    
4702
                                    //20180911 LJY
4703
                                        (currentControl as ArrowTextControl).isTrans = true;
4704
                                    //}
4705
                                }
4706
                            }
4707
                        }
4708
                        break;
4709
                    case ControlType.PolygonControl:
4710
                        {
4711
                            if (currentControl is PolygonControl)
4712
                            {
4713
                                var control = currentControl as PolygonControl;
4714

    
4715
                                if (mouseButtonDown == MouseButton.Right)
4716
                                {
4717
                                    control.IsCompleted = true;
4718
                                }
4719

    
4720
                                if (!control.IsCompleted)
4721
                                {
4722
                                    control.PointSet.Add(control.EndPoint);
4723
                                }
4724
                                else
4725
                                {
4726
                                    //20180906 LJY TEST IsRotationDrawingEnable
4727
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4728
                                    {
4729
                                        return;
4730
                                    }
4731

    
4732
                                    var firstPoint = control.PointSet.First();
4733
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4734
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4735
                                    control.PointSet.Add(firstPoint);
4736

    
4737
                                    control.ApplyOverViewData();
4738

    
4739
                                    CreateControl();
4740
                                    control.updateControl();
4741
                                    currentControl = null;
4742
                                }
4743
                            }
4744
                            else
4745
                            {
4746
                                if (mouseButtonDown == MouseButton.Left)
4747
                                {
4748
                                    currentControl = new PolygonControl
4749
                                    {
4750
                                        PointSet = new List<Point>(),
4751
                                    };
4752

    
4753
                                    var polygonControl = (currentControl as PolygonControl);
4754
                                    currentControl.CommentID = Commons.shortGuid();
4755
                                    currentControl.IsNew = true;
4756
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4757
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
4758
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
4759
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4760
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4761
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4762
                                    polygonControl.ApplyTemplate();
4763
                                    polygonControl.Visibility = Visibility.Visible;
4764
                                }
4765
                            }
4766
                        }
4767
                        break;
4768
                    //강인구 추가
4769
                    case ControlType.Sign:
4770
                        {
4771
                            if (mouseButtonDown == MouseButton.Left)
4772
                            {
4773
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4774
                                //{
4775
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4776

    
4777
                                    if (_sign == null)
4778
                                    {
4779
                                        txtBatch.Visibility = Visibility.Collapsed;
4780
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4781
                                        controlType = ControlType.None;
4782

    
4783
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4784
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4785
                                        return;
4786
                                    }
4787

    
4788
                                    if (currentControl is SignControl)
4789
                                    {
4790
                                        //20180906 LJY TEST IsRotationDrawingEnable
4791
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4792
                                        {
4793
                                            return;
4794
                                        }
4795

    
4796
                                        CreateControl();
4797
                                        currentControl = null;
4798
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4799
                                        {
4800
                                            txtBatch.Text = "Place Date";
4801
                                            controlType = ControlType.Date;
4802
                                        }
4803
                                    }
4804
                                    else
4805
                                    {
4806
                                        currentControl = new SignControl
4807
                                        {
4808
                                            Background = new SolidColorBrush(Colors.Black),
4809
                                            UserNumber = App.ViewInfo.UserID,
4810
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4811
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4812
                                            ControlType = ControlType.Sign
4813
                                        };
4814

    
4815
                                        currentControl.CommentID = Commons.shortGuid();
4816
                                        currentControl.IsNew = true;
4817
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4818
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4819

    
4820
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4821
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4822
                                }
4823
                                //}
4824
                            }
4825
                        }
4826
                        break;
4827
                    case ControlType.Mark:
4828
                        {
4829
                            if (mouseButtonDown == MouseButton.Left)
4830
                            {
4831
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4832
                                //{
4833
                                    if (currentControl is RectangleControl)
4834
                                    {
4835
                                        //20180906 LJY TEST IsRotationDrawingEnable
4836
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4837
                                        {
4838
                                            return;
4839
                                        }
4840

    
4841
                                        CreateControl();
4842
                                        (currentControl as RectangleControl).ApplyOverViewData();
4843
                                        currentControl = null;
4844
                                    
4845
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4846

    
4847
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4848
                                        {
4849
                                            txtBatch.Text = "Place Signature";
4850
                                            controlType = ControlType.Sign;
4851
                                        }
4852
                                    }
4853
                                    else
4854
                                    {
4855
                                        currentControl = new RectangleControl
4856
                                        {
4857
                                            Background = new SolidColorBrush(Colors.Black),
4858
                                            Paint = PaintSet.Fill
4859
                                        };
4860

    
4861
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4862
                                        currentControl.CommentID = Commons.shortGuid();
4863
                                        currentControl.IsNew = true;
4864
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4865
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4866
                                    }
4867
                                //}
4868
                            }
4869
                        }
4870
                        break;
4871
                    case ControlType.Symbol:
4872
                        {
4873
                            if (mouseButtonDown == MouseButton.Left)
4874
                            {
4875
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4876
                                //{
4877
                                    if (currentControl is SymControl)
4878
                                    {
4879
                                        //20180906 LJY TEST IsRotationDrawingEnable
4880
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4881
                                        {
4882
                                            return;
4883
                                        }
4884
                                        CreateControl();
4885
                                        currentControl = null;
4886
                                    
4887
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4888
                                    }
4889
                                    else
4890
                                    {
4891
                                        currentControl = new SymControl
4892
                                        {
4893
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4894
                                            Background = new SolidColorBrush(Colors.Black),
4895
                                            ControlType = ControlType.Symbol
4896
                                        };
4897

    
4898
                                        currentControl.IsNew = true;
4899
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4900
                                        currentControl.CommentID = Commons.shortGuid();
4901
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4902

    
4903
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4904
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4905
                                }
4906
                                //}
4907
                            }
4908
                        }
4909
                        break;
4910
                    case ControlType.Stamp:
4911
                        {
4912
                            if (mouseButtonDown == MouseButton.Left)
4913
                            {
4914
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4915
                                //{
4916
                                    if (currentControl is SymControlN)
4917
                                    {
4918
                                        //20180906 LJY TEST IsRotationDrawingEnable
4919
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4920
                                        {
4921
                                            return;
4922
                                        }
4923

    
4924
                                        CreateControl();
4925
                                        currentControl = null;
4926
                                   
4927

    
4928
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4929
                                    }
4930
                                    else
4931
                                    {
4932
                                        currentControl = new SymControlN
4933
                                        {
4934
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4935
                                            Background = new SolidColorBrush(Colors.Black),
4936
                                            ControlType = ControlType.Stamp
4937
                                        };
4938

    
4939
                                        currentControl.IsNew = true;
4940
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4941
                                        currentControl.CommentID = Commons.shortGuid();
4942
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4943
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4944
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4945
                                }                                    
4946
                                //}
4947
                            }
4948
                        }
4949
                        break;
4950
                    case ControlType.PenControl:
4951
                        {
4952
                            if (inkBoard.Tag.ToString() == "Ink")
4953
                            {
4954
                                inkBoard.IsEnabled = true;
4955
                                StartNewStroke(canvasDrawingMouseDownPoint);
4956
                            }
4957
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4958
                            {
4959
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4960
                            }
4961
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4962
                            {
4963
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4964
                            }
4965
                            IsDrawing = true;
4966
                            return;
4967
                        }
4968
                    default:
4969
                        if (currentControl != null)
4970
                        {
4971
                            currentControl.CommentID = null;
4972
                            currentControl.IsNew = false;
4973
                        }
4974
                        break;
4975
                }
4976
            }
4977
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4978
            {
4979
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4980
                {
4981
                    bool mouseOff = false;
4982
                    foreach (var item in SelectLayer.Children)
4983
                    {
4984
                        if (item is AdornerFinal)
4985
                        {
4986

    
4987
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4988
                            if (over != null)
4989
                            {
4990
                                mouseOff = true;
4991
                            }
4992
                        }
4993
                    }
4994

    
4995
                    if (!mouseOff)
4996
                    {
4997
                        SelectionSet.Instance.UnSelect(this);
4998
                    }
4999
                }
5000
                zoomAndPanControl.CaptureMouse();
5001
                e.Handled = true;
5002
            }
5003
        }
5004

    
5005
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5006
        {
5007
            mouseButtonDown = e.ChangedButton;
5008
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5009
        }
5010

    
5011
        private void RemoveLineStroke(Point P)
5012
        {
5013
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
5014
            if (control != null)
5015
            {
5016
                UndoData = new Undo_data()
5017
                {
5018
                    IsUndo = false,
5019
                    Event = Event_Type.Delete,
5020
                    EventTime = DateTime.Now,
5021
                    Markup_List = new List<Multi_Undo_data>()
5022
                };
5023

    
5024

    
5025
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5026
                UndoData.Markup_List.Add(multi_Undo_Data);
5027
                multi_Undo_Data = new Multi_Undo_data();
5028

    
5029
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
5030
                var Item_ = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
5031
                ViewerDataModel.Instance.MyMarkupList.Remove(Item_);
5032
                
5033
                //임시파일에서도 삭제한다.
5034
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
5035
                
5036
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5037
                {
5038
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5039
                });
5040
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5041

    
5042
            }
5043
        }
5044

    
5045
        private void RemovePointStroke(Point P)
5046
        {
5047
            foreach (Stroke hits in inkBoard.Strokes)
5048
            {
5049
                foreach (StylusPoint sty in hits.StylusPoints)
5050
                {
5051

    
5052
                }
5053
                if (hits.HitTest(P))
5054
                {
5055
                    inkBoard.Strokes.Remove(hits);
5056
                    return;
5057
                }
5058
            }
5059
        }
5060

    
5061
        private void StartNewStroke(Point P)
5062
        {
5063
            strokePoints = new StylusPointCollection();
5064
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5065
            strokePoints.Add(segment1Start);
5066
            stroke = new Stroke(strokePoints);
5067

    
5068
            stroke.DrawingAttributes.Color = Colors.Red;
5069
            stroke.DrawingAttributes.Width = 4;
5070
            stroke.DrawingAttributes.Height = 4;
5071

    
5072
            inkBoard.Strokes.Add(stroke);
5073

    
5074
        }
5075

    
5076
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5077
        {
5078
            ConsolidationMethod();
5079
        }
5080

    
5081
        public void TeamConsolidationMethod()
5082
        {
5083
            UpdateMyMarkupList();
5084
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5085
            {
5086
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5087
            }
5088
            else
5089
            {
5090
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5091
                {
5092
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
5093
                    {
5094
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
5095
                        return;
5096
                    }                    
5097
                }
5098
                ViewerDataModel.Instance.IsConsolidate = true;
5099
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5100
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5101

    
5102
                string project_no = App.ViewInfo.ProjectNO;
5103
                string doc_id = _DocInfo.ID;
5104
                string user_id = App.ViewInfo.UserID;
5105
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5106
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5107
                {
5108
                    markupInfoItems.Add(item);
5109
                }
5110
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5111
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5112
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
5113

    
5114
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5115
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5116
            }
5117
        }
5118
        public void ConsolidationMethod()
5119
        {
5120
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5121
            {
5122
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5123
            }
5124
            else
5125
            {
5126
                /*
5127
                ViewerDataModel.Instance.IsConsolidate = true;
5128
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5129

    
5130
                string project_no = App.ViewInfo.ProjectNO;
5131
                string doc_id = _DocInfo.ID;
5132
                string user_id = App.ViewInfo.UserID;
5133
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5134
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5135
                {
5136
                    markupInfoItems.Add(item);
5137
                }
5138
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5139
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5140

    
5141
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5142
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5143
                */
5144
                
5145
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
5146
                foreach (var item in this.gridViewMarkup.SelectedItems)
5147
                {
5148
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
5149
                }
5150
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
5151

    
5152
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
5153
            }
5154
        }
5155

    
5156
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5157
        {
5158
            if (App.ViewInfo != null)
5159
            {
5160
                btnConsolidate = (sender as RadRibbonButton);
5161
                if (!App.ViewInfo.NewCommentPermission)
5162
                {
5163
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5164
                }
5165
            }
5166
        }
5167

    
5168
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5169
        {
5170
            TeamConsolidationMethod();
5171
        }
5172

    
5173
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5174
        {
5175
            btnTeamConsolidate = sender as RadRibbonButton;
5176
            if (App.ViewInfo != null)
5177
            {
5178
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5179
                {
5180
                    if (btnConsolidate != null)
5181
                    {
5182
                        btnConsolidate.Visibility = Visibility.Collapsed;
5183
                    }
5184

    
5185
                    if (!App.ViewInfo.NewCommentPermission)
5186
                    {
5187
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5188
                    }
5189
                }
5190
                else
5191
                {
5192
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5193
                }
5194
            }
5195
        }
5196

    
5197
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5198
        {
5199
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5200
            if (item != null)
5201
            {
5202
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5203

    
5204
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5205
            }
5206
            else
5207
            {
5208
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5209
            }
5210
        }
5211

    
5212
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5213
        {
5214
            btnFinalPDF = sender as RadRibbonButton;
5215
            if (App.ViewInfo != null)
5216
            {
5217
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5218
                {
5219
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5220
                    if (btnConsolidate != null)
5221
                    {
5222
                        btnConsolidate.Visibility = Visibility.Collapsed;
5223
                    }
5224
                }
5225
            }
5226
        }
5227

    
5228
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5229
        {
5230
            UpdateMyMarkupList();
5231

    
5232
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5233
            {
5234
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5235
            }
5236
            else
5237
            {
5238
                ViewerDataModel.Instance.IsConsolidate = true;
5239
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5240
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5241

    
5242
                string project_no = App.ViewInfo.ProjectNO;
5243
                string doc_id = _DocInfo.ID;
5244
                string user_id = App.ViewInfo.UserID;
5245
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5246
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5247
                {
5248
                    markupInfoItems.Add(item);
5249
                }
5250
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5251
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5252
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5253
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5254

    
5255
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5256
                if (item2 != null)
5257
                {
5258
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5259

    
5260
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5261
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5262
                }
5263
                else
5264
                {
5265
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5266
                }
5267
            }
5268
        }
5269

    
5270
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5271
        {
5272
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5273

    
5274
            if (App.ViewInfo != null)
5275
            {
5276
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5277
                {
5278
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5279
                }
5280
            }
5281
        }
5282

    
5283
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5284
        {
5285
            if (CompareMode.IsChecked)
5286
            {
5287
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5288
                {
5289
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5290
                }
5291
                if (ViewerDataModel.Instance.PageNumber == 0)
5292
                {
5293
                    ViewerDataModel.Instance.PageNumber = 1;
5294
                }
5295

    
5296
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5297
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5298
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5299

    
5300
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5301
            }
5302
            else
5303
            {
5304
                da.From = 1;
5305
                da.To = 1;
5306
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5307
                da.AutoReverse = false;
5308
                canvas_compareBorder.Children.Clear();
5309
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5310
            }
5311
        }
5312

    
5313
        private void Sync_Click(object sender, RoutedEventArgs e)
5314
        {
5315
            if (Sync.IsChecked)
5316
            {
5317
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5318
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5319
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5320
            }
5321
        }
5322

    
5323
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5324
        {
5325
            if (UserList.IsChecked)
5326
            {
5327
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5328
            }
5329
            else
5330
            {
5331
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5332
            }
5333
        }
5334

    
5335
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5336
        {
5337

    
5338
            if (BalanceMode.IsChecked)
5339
            {
5340
                ViewerDataModel.Instance.PageBalanceMode = true;
5341
            }
5342
            else
5343
            {
5344
                ViewerDataModel.Instance.PageBalanceMode = false;
5345
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5346
            }
5347
        }
5348

    
5349
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5350
        {
5351
            //초기화
5352
            testPanel2.IsHidden = true;
5353
            ViewerDataModel.Instance.PageBalanceMode = false;
5354
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5355
            ViewerDataModel.Instance.PageNumber = 0;
5356
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5357
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5358
            UserList.IsChecked = false;
5359
            BalanceMode.IsChecked = false;
5360
        }
5361

    
5362
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5363
        {
5364
            if ((sender as System.Windows.Controls.Control).Tag != null)
5365
            {
5366
                //Compare 초기화
5367
                CompareMode.IsChecked = false;
5368
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5369

    
5370
                if (ViewerDataModel.Instance.PageNumber == 0)
5371
                {
5372
                    ViewerDataModel.Instance.PageNumber = 1;
5373
                }
5374

    
5375
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5376
                {
5377
                }
5378
                else
5379
                {
5380
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5381
                }
5382

    
5383
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5384
                {
5385

    
5386
                }
5387
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5388
                {
5389
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5390
                }
5391

    
5392
                if (!testPanel2.IsHidden)
5393
                {
5394
                    if (IsSyncPDFMode)
5395
                    {
5396
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5397
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5398

    
5399
                        if (pdfpath.IsDownloading)
5400
                        {
5401
                            pdfpath.DownloadCompleted += (ex, arg) =>
5402
                            {
5403
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5404
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5405
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5406
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5407
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5408
                            };
5409
                        }
5410
                        else
5411
                        {
5412
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5413
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5414
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5415

    
5416
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5417
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5418
                        }
5419

    
5420
                    }
5421
                    else
5422
                    {
5423
                        string uri = "";
5424

    
5425
                        if (userData.COMPANY != "EXT")
5426
                        {
5427
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5428
                        }
5429
                        else
5430
                        {
5431
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5432
                        }
5433

    
5434
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5435

    
5436
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5437
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5438
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5439

    
5440
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5441
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5442

    
5443
                        if (defaultBitmapImage_Compare.IsDownloading)
5444
                        {
5445
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5446
                            {
5447
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5448
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5449
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5450

    
5451
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5452
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5453
                            };
5454
                        }
5455
                    }
5456

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

    
5461
                    foreach (var item in gridSelectionRevItem)
5462
                    {
5463
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5464
                        {
5465
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5466
                        });
5467
                    }
5468

    
5469
                    //강인구 추가
5470
                    zoomAndPanControl2.ZoomTo(new Rect
5471
                    {
5472
                        X = 0,
5473
                        Y = 0,
5474
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5475
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5476
                    });
5477

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

    
5480
                }
5481
            }
5482
        }
5483

    
5484
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5485
        {
5486
            if (MarkupMode.IsChecked)
5487
            {
5488
                IsSyncPDFMode = true;
5489

    
5490
                var uri = CurrentRev.TO_VENDOR;
5491

    
5492
                if (ViewerDataModel.Instance.PageNumber == 0)
5493
                {
5494
                    ViewerDataModel.Instance.PageNumber = 1;
5495
                }
5496

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

    
5501
                if (pdfpath.IsDownloading)
5502
                {
5503
                    pdfpath.DownloadCompleted += (ex, arg) =>
5504
                    {
5505
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5506
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5507
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5508
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5509
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5510
                    };
5511
                }
5512
                else
5513
                {
5514
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5515
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5516
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5517

    
5518
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5519
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5520
                }
5521
            }
5522
            else
5523
            {
5524
                IsSyncPDFMode = false;
5525
                string uri = "";
5526
                if (userData.COMPANY != "EXT")
5527
                {
5528
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5529
                }
5530
                else
5531
                {
5532
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5533
                }
5534

    
5535
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5536

    
5537
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5538
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5539
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5540

    
5541
                if (defaultBitmapImage_Compare.IsDownloading)
5542
                {
5543
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5544
                    {
5545
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5546
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5547
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5548
                    };
5549
                }
5550
                zoomAndPanControl2.ApplyTemplate();
5551
                zoomAndPanControl2.UpdateLayout();
5552
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5553
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5554
            }
5555
        }
5556

    
5557
        private void RadButton_Click(object sender, RoutedEventArgs e)
5558
        {
5559
            gridViewHistory_Busy.IsBusy = true;
5560

    
5561
            RadButton instance = sender as RadButton;
5562
            if (instance.CommandParameter != null)
5563
            {
5564
                CurrentRev = instance.CommandParameter as VPRevision;
5565
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5566
                {
5567
                    if (ea.Error == null && ea.Result != null)
5568
                    {
5569
                        testPanel2.IsHidden = false;
5570

    
5571
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5572
                        foreach(var info in ea.Result)
5573
                        {
5574
                            if(info.UserID == App.ViewInfo.UserID)
5575
                            {
5576
                                info.userDelete = true;
5577
                                info.DisplayColor = "FFFF0000";
5578
                            }
5579
                            else
5580
                            {
5581
                                info.userDelete = false;
5582
                            }
5583
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5584
                        }
5585
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5586

    
5587
                        string uri = "";
5588
                        if (userData.COMPANY != "EXT")
5589
                        {
5590
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5591
                        }
5592
                        else
5593
                        {
5594
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5595
                        }
5596

    
5597
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5598

    
5599
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5600

    
5601
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5602
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5603
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5604

    
5605
                        if (defaultBitmapImage_Compare.IsDownloading)
5606
                        {
5607
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5608
                            {
5609
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5610
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5611
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5612
                            };
5613
                        }
5614

    
5615
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5616
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5617
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5618
                        zoomAndPanControl2.ApplyTemplate();
5619
                        zoomAndPanControl2.UpdateLayout();
5620

    
5621
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5622
                        {
5623
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5624
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5625
                        }
5626

    
5627
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5628
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5629
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5630

    
5631
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5632
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5633
                        gridViewHistory_Busy.IsBusy = false;
5634
                    }
5635

    
5636
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5637
                };
5638
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5639
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5640
            }
5641
        }
5642

    
5643
        public void Sync_Event(VPRevision Currnet_Rev)
5644
        {
5645
            CurrentRev = Currnet_Rev;
5646

    
5647
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5648
            {
5649
                if (ea.Error == null && ea.Result != null)
5650
                {
5651
                    testPanel2.IsHidden = false;
5652

    
5653
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5654
                    foreach(var info in ea.Result)
5655
                    {
5656
                        if(info.UserID == App.ViewInfo.UserID)
5657
                        {
5658
                            info.userDelete = true;
5659
                            info.DisplayColor = "FFFF0000";
5660
                        }
5661
                        else
5662
                        {
5663
                            info.userDelete = false;
5664
                        }
5665
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5666
                    }
5667
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5668

    
5669
                    string uri = "";
5670
                    if (userData.COMPANY != "EXT")
5671
                    {
5672
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5673
                    }
5674
                    else
5675
                    {
5676
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5677
                    }
5678

    
5679
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5680

    
5681
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5682

    
5683
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5684
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5685
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5686

    
5687
                    if (defaultBitmapImage_Compare.IsDownloading)
5688
                    {
5689
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5690
                        {
5691
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5692
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5693
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5694
                        };
5695
                    }
5696

    
5697

    
5698
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5699
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5700
                    zoomAndPanControl2.ApplyTemplate();
5701
                    zoomAndPanControl2.UpdateLayout();
5702

    
5703
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5704
                    {
5705
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5706
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5707
                    }
5708
                    //}
5709

    
5710
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5711
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5712
                    gridViewHistory_Busy.IsBusy = false;
5713
                }
5714
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5715

    
5716
            };
5717
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5718
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5719
        }
5720

    
5721
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5722
        {
5723
            if (sender is Image)
5724
            {
5725
                if ((sender as Image).Tag != null)
5726
                {
5727
                    var pdfUrl = (sender as Image).Tag.ToString();
5728
                    System.Diagnostics.Process.Start(pdfUrl);
5729
                }
5730
                else
5731
                {
5732
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5733
                }
5734
            }
5735
        }
5736

    
5737
        private void Create_Symbol(object sender, RoutedEventArgs e)
5738
        {
5739
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5740

    
5741
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5742
            {
5743
                DialogMessage_Alert("Please Select Controls", "Alert");
5744
            }
5745
            else //선택된 것이 있으면
5746
            {
5747
                string MarkupData = "";
5748
                adorner_ = new AdornerFinal();
5749

    
5750
                foreach (var item in SelectLayer.Children)
5751
                {
5752
                    if (item.GetType().Name == "AdornerFinal")
5753
                    {
5754
                        adorner_ = (item as Controls.AdornerFinal);
5755
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5756
                        {
5757
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5758
                            {
5759
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5760
                                MarkupData += markupReturn.ConvertData;
5761
                            }
5762
                        }
5763
                    }
5764
                }
5765
                DialogParameters parameters = new DialogParameters()
5766
                {
5767
                    Owner = Application.Current.MainWindow,
5768
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5769
                    DefaultPromptResultValue = "Custom State",
5770
                    Content = "Name :",
5771
                    Header = "Insert Custom Symbol Name",
5772
                    Theme = new VisualStudio2013Theme(),
5773
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5774
                };
5775
                RadWindow.Prompt(parameters);
5776
            }
5777

    
5778
        }
5779
        public int symbolselectindex = 0;
5780
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5781
        {
5782
            //Save save = new Save();
5783
            try
5784
            {
5785
                string svgfilename = null;
5786
                if (symbolname != null)
5787
                {
5788
                    if (symbolpng == true || symbolsvg == true)
5789
                    {
5790
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5791
                        string guid = Commons.shortGuid();
5792

    
5793
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5794
                        //Check_Uri.UriCheck();
5795
                        fileUploader.RunCompleted += (ex, arg) =>
5796
                        {
5797
                            filename = arg.Result;
5798
                            if (symbolpng == true)
5799
                            {
5800
                                if (filename != null)
5801
                                { 
5802
                                    if (symbolselectindex == 0)
5803
                                    {
5804
                                        SymbolSave(symbolname, filename, data);
5805
                                    }
5806
                                    else
5807
                                    {
5808
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5809
                                    }
5810
                                    DataBind();
5811
                                }                                
5812
                            }
5813

    
5814
                            if (symbolsvg == true)
5815
                            {
5816
                                try
5817
                                {
5818
                                    var defaultBitmapImage = new BitmapImage();
5819
                                    defaultBitmapImage.BeginInit();
5820
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5821
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5822
                                    Check_Uri.UriCheck(filename);
5823
                                    defaultBitmapImage.UriSource = new Uri(filename);
5824
                                    defaultBitmapImage.EndInit();
5825

    
5826
                                    System.Drawing.Bitmap image;
5827

    
5828
                                    if (defaultBitmapImage.IsDownloading)
5829
                                    {
5830
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5831
                                        {
5832
                                            defaultBitmapImage.Freeze();
5833
                                            image = GetBitmap(defaultBitmapImage);
5834
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5835
                                            Process potrace = new Process
5836
                                            {
5837
                                                StartInfo = new ProcessStartInfo
5838
                                                {
5839
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5840
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5841
                                                    RedirectStandardInput = true,
5842
                                                    RedirectStandardOutput = true,
5843
                                                    RedirectStandardError = true,
5844
                                                    UseShellExecute = false,
5845
                                                    CreateNoWindow = true,
5846
                                                    WindowStyle = ProcessWindowStyle.Hidden
5847
                                                },
5848
                                            };
5849

    
5850
                                            StringBuilder svgBuilder = new StringBuilder();
5851
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5852
                                            {
5853
                                                svgBuilder.AppendLine(e2.Data);
5854
                                            };
5855

    
5856
                                            potrace.EnableRaisingEvents = true;
5857
                                            potrace.Start();
5858
                                            potrace.Exited += (sender, e) =>
5859
                                            {
5860
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5861
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5862
                                                Check_Uri.UriCheck(svgfilename);
5863
                                                if (symbolselectindex == 0)
5864
                                                {
5865
                                                    SymbolSave(symbolname, svgfilename, data);
5866
                                                }
5867
                                                else
5868
                                                {
5869
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5870
                                                }
5871

    
5872
                                                DataBind();
5873
                                            };
5874
                                            potrace.WaitForExit();
5875
                                        };
5876
                                    }
5877
                                    else
5878
                                    {
5879
                                        //GC.Collect();
5880
                                    }
5881
                                }
5882
                                catch(Exception ee)
5883
                                {
5884
                                    DialogMessage_Alert("" + ee, "Alert");
5885
                                }
5886
                            }
5887
                        };                                             
5888
                    }
5889
                }
5890
            }
5891
            catch (Exception e)
5892
            {
5893
                //DialogMessage_Alert(e + "", "Alert");
5894
            }            
5895
        }
5896

    
5897
        public void SymbolSave(string Name, string Url, string Data)
5898
        {
5899
            try
5900
            {
5901
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5902
                {
5903
                    ID = Commons.shortGuid(),
5904
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5905
                    NAME = Name,
5906
                    IMAGE_URL = Url,
5907
                    DATA = Data
5908
                };
5909

    
5910
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5911
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5912
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5913
            }
5914
            catch (Exception)
5915
            {
5916
                throw;
5917
            }
5918
        }
5919

    
5920
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5921
        {
5922
            try
5923
            {
5924
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5925
                {
5926
                    ID = Commons.shortGuid(),
5927
                    DEPARTMENT = Department,
5928
                    NAME = Name,
5929
                    IMAGE_URL = Url,
5930
                    DATA = Data
5931
                };
5932
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5933
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5934
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5935
            }
5936
            catch (Exception)
5937
            {
5938
                throw;
5939
            }
5940
        }
5941

    
5942
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5943
        {           
5944
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5945
            DataBind();
5946
        }
5947

    
5948
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5949
        {
5950
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5951
            DataBind();
5952
        }
5953
        private void DataBind()
5954
        {
5955
            try
5956
            {
5957
                Symbol_Custom Custom = new Symbol_Custom();
5958
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5959
                //ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
5960
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5961
                foreach (var item in symbol_Private)
5962
                {
5963
                    Custom.Name = item.NAME;
5964
                    Custom.ImageUri = item.IMAGE_URL;
5965
                    Custom.ID = item.ID;
5966
                    Custom_List.Add(Custom);
5967
                    Custom = new Symbol_Custom();
5968
                }
5969
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5970
                
5971
                Custom = new Symbol_Custom();
5972
                Custom_List = new List<Symbol_Custom>();
5973

    
5974
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5975

    
5976
                List<SYMBOL_PUBLIC> symbol_Public;
5977

    
5978
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5979
                {
5980
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5981
                }
5982
                else
5983
                {
5984
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5985
                }
5986
                foreach (var item in symbol_Public)
5987
                {
5988
                    Custom.Name = item.NAME;
5989
                    Custom.ImageUri = item.IMAGE_URL;
5990
                    Custom.ID = item.ID;
5991
                    Custom_List.Add(Custom);
5992
                    Custom = new Symbol_Custom();
5993
                }
5994
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5995
                BaseClient.Close();                
5996
            }
5997
            catch(Exception e)
5998
            {
5999
                //DialogMessage_Alert("DataBind", "Alert");
6000
            }
6001
            
6002
        }
6003
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
6004
        {
6005
            try
6006
            {
6007
                if (args.PromptResult != null)
6008
                {
6009
                    if (args.DialogResult.Value)
6010
                    {
6011
                        PngBitmapEncoder _Encoder = symImage(data);
6012

    
6013
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6014
                        _Encoder.Save(fs);
6015
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6016

    
6017
                        byte[] Img_byte = fs.ToArray();
6018

    
6019
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6020
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
6021
                        Check_Uri.UriCheck(filename);
6022
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6023
                        {
6024
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
6025
                        }
6026
                        else
6027
                        {
6028
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6029
                        }
6030
                        DataBind();
6031
                    }
6032
                }
6033
            }
6034
            catch(Exception ex)
6035
            {
6036
                DialogMessage_Alert("" + ex, "Alert");
6037
            }
6038
        }
6039

    
6040
        public PngBitmapEncoder symImage(string data)
6041
        {
6042

    
6043
            Canvas _canvas = new Canvas();
6044
            _canvas.Background = Brushes.White;
6045
            _canvas.Width = adorner_.BorderSize.Width;
6046
            _canvas.Height = adorner_.BorderSize.Height;
6047
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
6048

    
6049
            BitmapEncoder encoder = new PngBitmapEncoder();
6050

    
6051

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

    
6054
            DrawingVisual dv = new DrawingVisual();
6055

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

    
6059
            using (DrawingContext ctx = dv.RenderOpen())
6060
            {
6061
                VisualBrush vb = new VisualBrush(_canvas);
6062
                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)));
6063
            }
6064

    
6065
            try
6066
            {
6067
                renderBitmap.Render(dv);
6068

    
6069
                //GC.Collect();
6070
                GC.WaitForPendingFinalizers();
6071
                //GC.Collect();
6072
                // encode png data
6073
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6074
                // puch rendered bitmap into it
6075
                pngEncoder.Interlace = PngInterlaceOption.Off;
6076
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6077
                return pngEncoder;
6078

    
6079
            }
6080
            catch //(Exception ex)
6081
            {
6082
                return null;
6083
            }
6084

    
6085
        }
6086

    
6087
        public void DialogMessage_Alert(string content, string header)
6088
        {
6089
            var box = new TextBlock();
6090
            box.MinWidth = 400;
6091
            box.FontSize = 11;
6092
            //box.FontSize = 12;
6093
            box.Text = content;
6094
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6095

    
6096
            DialogParameters parameters = new DialogParameters()
6097
            {
6098
                Owner = Application.Current.MainWindow,
6099
                Content = box,
6100
                Header = header,
6101
                Theme = new VisualStudio2013Theme(),
6102
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6103
            };            
6104
            RadWindow.Alert(parameters);
6105
        }
6106

    
6107
        #region 캡쳐 기능
6108

    
6109
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6110
        {
6111
            if (x < 0)
6112
            {
6113
                width += x;
6114
                x = 0;
6115
            }
6116
            if (y < 0)
6117
            {
6118
                height += y;
6119
                y = 0;
6120

    
6121
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6122
            }
6123
            if (x + width > zoomAndPanCanvas.ActualWidth)
6124
            {
6125
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6126
            }
6127
            if (y + height > zoomAndPanCanvas.ActualHeight)
6128
            {
6129
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6130
            }
6131

    
6132
            byte[] pixels = CopyPixels(x, y, width, height);
6133

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

    
6136
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6137
        }
6138

    
6139
        public byte[] CopyPixels(int x, int y, int width, int height)
6140
        {
6141
            byte[] pixels = new byte[width * height * 4];
6142
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6143

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

    
6147
            return pixels;
6148
        }
6149

    
6150
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6151
        {
6152
            DrawingVisual drawingVisual = new DrawingVisual();
6153
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6154

    
6155
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6156
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6157
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6158
            drawingContext.Close();
6159

    
6160
            // 비트맵으로 변환합니다.
6161
            RenderTargetBitmap target =
6162
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6163
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6164

    
6165
            target.Render(drawingVisual);
6166
            return target;
6167
        }
6168

    
6169
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6170
        {
6171
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6172
            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);
6173
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6174
            bmp.UnlockBits(data);
6175
            return bmp;
6176
        }
6177
        public string symbolname = null;
6178
        public bool symbolsvg = true;
6179
        public bool symbolpng = true;
6180

    
6181
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6182
        {
6183
            System.Drawing.Bitmap image = GetBitmap(source);
6184
            //흰색 제거
6185
            //image.MakeTransparent(System.Drawing.Color.White);
6186

    
6187
            var imageStream = new System.IO.MemoryStream();
6188
            byte[] imageBytes = null;
6189
            using (imageStream)
6190
            {
6191
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6192
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6193
                imageStream.Position = 0;
6194
                imageBytes = imageStream.ToArray();
6195
            }
6196

    
6197
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6198

    
6199
            RadWindow CheckPop = new RadWindow();
6200
            //Alert check = new Alert(Msg);
6201

    
6202
            CheckPop = new RadWindow
6203
            {
6204
                MinWidth = 400,
6205
                MinHeight = 100,
6206
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6207
                Header = "Alert",
6208
                Content = symbolPrompt,
6209
                //DialogResult = 
6210
                ResizeMode = System.Windows.ResizeMode.NoResize,
6211
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6212
                IsTopmost = true,
6213
            };
6214
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6215
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6216
            CheckPop.ShowDialog();
6217

    
6218
            /*
6219
            DialogParameters parameters = new DialogParameters()
6220
            {
6221
                Owner = Application.Current.MainWindow,
6222
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6223
                DefaultPromptResultValue = "Custom State",
6224
                Content = "Name :",
6225
                Header = "Insert Custom Symbol Name",
6226
                Theme = new VisualStudio2013Theme(),
6227
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6228
            };            
6229
            RadWindow.Prompt(parameters);
6230
            */
6231
        }
6232

    
6233
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6234
        {
6235
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6236
            KCOMDataModel.DataModel.CHECK_LIST check_;
6237
            string Result = streamToBase64.ImageToBase64(source);
6238
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6239
            string projectno = App.ViewInfo.ProjectNO;
6240
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6241

    
6242
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6243
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6244
            if (Item != null)
6245
            {
6246
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6247
            }
6248
            else
6249
            {
6250
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6251
            }
6252

    
6253
            if (Item == null)
6254
            {
6255
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6256
                {
6257
                    ID = Commons.shortGuid(),
6258
                    USER_ID = App.ViewInfo.UserID,
6259
                    IMAGE_URL = Result,
6260
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6261
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6262
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6263
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6264
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6265
                    STATUS = "False",
6266
                    CREATE_TIME = DateTime.Now,
6267
                    UPDATE_TIME = DateTime.Now,
6268
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6269
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6270
                };
6271
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6272
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6273
                //this.BaseClient.AddCheckList(projectno, check_);
6274
            }
6275
            else
6276
            {
6277
                Item.IMAGE_URL = Result;
6278
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6279
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6280
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6281
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6282
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6283
            }
6284

    
6285
        }
6286

    
6287
        public void Set_Capture()
6288
        {
6289
            double x = canvasDrawingMouseDownPoint.X;
6290
            double y = canvasDrawingMouseDownPoint.Y;
6291
            double width = dragCaptureBorder.Width;
6292
            double height = dragCaptureBorder.Height;
6293

    
6294
            if (width > 5 || height > 5)
6295
            {
6296
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6297
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6298
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6299
            }
6300
        }
6301
        #endregion
6302

    
6303
        //MarkupInfoItem
6304
        public void CreateControl()
6305
        {
6306

    
6307
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6308
            {
6309
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6310
            });
6311
            multi_Undo_Data.Markup = currentControl;
6312
            UndoData.Markup_List.Add(multi_Undo_Data);
6313

    
6314
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6315

    
6316
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6317
        }
6318

    
6319
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6320
        {
6321
            multi_Undo_Data = new Multi_Undo_data();
6322

    
6323
            multi_Undo_Data.Markup = control;
6324

    
6325
            if ((control as IShapeControl) != null)
6326
            {
6327
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6328
            }
6329
            if ((control as IDashControl) != null)
6330
            {
6331
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6332
            }
6333
            if ((control as IPath) != null)
6334
            {
6335
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6336
            }
6337
            if ((control as UIElement) != null)
6338
            {
6339
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6340
            }
6341

    
6342
            return multi_Undo_Data;
6343
        }
6344

    
6345
        public void Undo()
6346
        {
6347
            // if (ViewerDataModel.Instance.IsPressCtrl)
6348
            //   {
6349
            //      ViewerDataModel.Instance.IsPressCtrl = false;
6350
            //   }
6351
            Undo_data undo = new Undo_data();
6352
            AdornerFinal final;
6353
            SelectionSet.Instance.UnSelect(this);
6354

    
6355
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6356
            if (undo == null)
6357
                return;
6358

    
6359

    
6360

    
6361
            switch (undo.Event)
6362
            {
6363
                case (Event_Type.Create):
6364
                    {
6365
                        foreach (var item in undo.Markup_List)
6366
                        {
6367
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6368
                        }
6369
                    }
6370
                    break;
6371
                case (Event_Type.Delete):
6372
                    {
6373
                        foreach (var item in undo.Markup_List)
6374
                        {
6375
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6376
                        }
6377
                    }
6378
                    break;
6379
                case (Event_Type.Thumb):
6380
                    {
6381
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6382

    
6383
                        foreach (var item in undo.Markup_List)
6384
                        {
6385
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6386

    
6387
                            if ((item.Markup as IViewBox) != null)
6388
                            {
6389
                                (item.Markup as IViewBox).Angle = item.Angle;
6390
                            }
6391
                            if ((item.Markup as TextControl) != null)
6392
                            {
6393
                                (item.Markup as TextControl).Angle = item.Angle;
6394
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6395
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6396
                            }
6397
                            else
6398
                            {
6399
                                (item.Markup as IPath).PointSet = item.PointSet;
6400
                                (item.Markup as IPath).updateControl();
6401
                            }
6402

    
6403
                            comment.Add(item.Markup);
6404
                        }
6405
                        final = new AdornerFinal(comment);
6406
                        SelectLayer.Children.Add(final);
6407
                        SelectionSet.Instance.UnSelect(this);
6408
                    }
6409
                    break;
6410
                case (Event_Type.Select):
6411
                    {
6412
                        SelectionSet.Instance.UnSelect(this);
6413
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6414

    
6415
                        foreach (var item in undo.Markup_List)
6416
                        {
6417
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6418

    
6419
                            if ((item.Markup as IPath) != null)
6420
                            {
6421
                                (item.Markup as IPath).LineSize = item.LineSize;
6422
                            }
6423
                            if ((item.Markup as UIElement) != null)
6424
                            {
6425
                                (item.Markup as UIElement).Opacity = item.Opacity;
6426
                            }
6427
                            if ((item.Markup as IDashControl) != null)
6428
                            {
6429
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6430
                            }
6431
                            if ((item.Markup as IShapeControl) != null)
6432
                            {
6433
                                (item.Markup as IShapeControl).Paint = item.paint;
6434
                            }
6435

    
6436
                            comment.Add(item.Markup);
6437
                        }
6438

    
6439
                        final = new AdornerFinal(comment);
6440
                        SelectLayer.Children.Add(final);
6441
                    }
6442
                    break;
6443
                case (Event_Type.Option):
6444
                    {
6445
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6446

    
6447
                        foreach (var item in undo.Markup_List)
6448
                        {
6449
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6450

    
6451
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
6452
                            {
6453
                                (item.Markup as IPath).LineSize = undo.LineSize;
6454
                            }
6455
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
6456
                            {
6457
                                (item.Markup as UIElement).Opacity = undo.Opacity;
6458
                            }
6459
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
6460
                            {
6461
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
6462
                            }
6463
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
6464
                            {
6465
                                (item.Markup as LineControl).Interval = undo.Interval;
6466
                            }
6467
                            else if (item.Markup as IShapeControl != null)
6468
                            {
6469
                                (item.Markup as IShapeControl).Paint = undo.paint;
6470
                            }
6471
                            comment.Add(item.Markup);
6472
                        }
6473
                        final = new AdornerFinal(comment);
6474
                        SelectLayer.Children.Add(final);
6475
                    }
6476
                    break;
6477
            }
6478
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6479
            {
6480
                i.IsUndo = true;
6481
            });
6482
        }
6483

    
6484

    
6485

    
6486
        public void Redo()
6487
        {
6488
            //if (ViewerDataModel.Instance.IsPressCtrl)
6489
            //{
6490
            //    ViewerDataModel.Instance.IsPressCtrl = false;
6491
            //}
6492
            AdornerFinal final;
6493
            Undo_data redo = new Undo_data();
6494
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6495
            SelectionSet.Instance.UnSelect(this);
6496
            if (redo == null)
6497
                return;
6498

    
6499
            switch (redo.Event)
6500
            {
6501
                case (Event_Type.Create):
6502
                    {
6503
                        foreach (var item in redo.Markup_List)
6504
                        {
6505
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6506
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
6507
                        }
6508
                    }
6509
                    break;
6510
                case (Event_Type.Delete):
6511
                    {
6512
                        foreach (var item in redo.Markup_List)
6513
                        {
6514
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6515
                        }
6516
                    }
6517
                    break;
6518
                case (Event_Type.Thumb):
6519
                    {
6520
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6521

    
6522
                        foreach (var item in redo.Markup_List)
6523
                        {
6524
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6525

    
6526
                            if ((item.Markup as IViewBox) != null)
6527
                            {
6528
                                (item.Markup as IViewBox).Angle = item.Angle;
6529
                            }
6530
                            if ((item.Markup as TextControl) != null)
6531
                            {
6532
                                (item.Markup as TextControl).Angle = item.Angle;
6533

    
6534
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6535
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6536
                            }
6537
                            else
6538
                            {
6539
                                (item.Markup as IPath).PointSet = item.PointSet;
6540
                                (item.Markup as IPath).updateControl();
6541
                            }
6542
                            comment.Add(item.Markup);
6543
                        }
6544
                        final = new AdornerFinal(comment);
6545
                        SelectLayer.Children.Add(final);
6546
                        SelectionSet.Instance.UnSelect(this);
6547
                    }
6548
                    break;
6549
                case (Event_Type.Select):
6550
                    {
6551
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6552

    
6553
                        foreach (var item in redo.Markup_List)
6554
                        {
6555
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6556

    
6557
                            if ((item.Markup as IPath) != null)
6558
                            {
6559
                                (item.Markup as IPath).LineSize = item.LineSize;
6560
                            }
6561
                            if ((item.Markup as UIElement) != null)
6562
                            {
6563
                                (item.Markup as UIElement).Opacity = item.Opacity;
6564
                            }
6565
                            if ((item.Markup as IDashControl) != null)
6566
                            {
6567
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6568
                            }
6569
                            if ((item.Markup as IShapeControl) != null)
6570
                            {
6571
                                (item.Markup as IShapeControl).Paint = item.paint;
6572
                            }
6573

    
6574
                            comment.Add(item.Markup);
6575
                        }
6576
                        final = new AdornerFinal(comment);
6577
                        SelectLayer.Children.Add(final);
6578
                    }
6579
                    break;
6580
                case (Event_Type.Option):
6581
                    {
6582
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6583

    
6584
                        foreach (var item in redo.Markup_List)
6585
                        {
6586
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6587
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6588
                            {
6589
                                (item.Markup as IPath).LineSize = redo.LineSize;
6590
                            }
6591
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6592
                            {
6593
                                (item.Markup as UIElement).Opacity = redo.Opacity;
6594
                            }
6595
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
6596
                            {
6597
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
6598
                            }
6599
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
6600
                            {
6601
                                (item.Markup as LineControl).Interval = redo.Interval;
6602
                            }
6603
                            else if (item.Markup as IShapeControl != null)
6604
                            {
6605
                                (item.Markup as IShapeControl).Paint = redo.paint;
6606
                            }
6607
                            comment.Add(item.Markup);
6608
                        }
6609
                        final = new AdornerFinal(comment);
6610
                        SelectLayer.Children.Add(final);
6611
                    }
6612
                    break;
6613
            }
6614

    
6615
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6616
            {
6617
                i.IsUndo = false;
6618
            });
6619
        }
6620

    
6621
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6622
        {
6623
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6624
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6625
            {
6626
                if (items.UserID == Select_ID)
6627
                {
6628
                    foreach (var item in items.MarkupList)
6629
                    {
6630
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6631
                        {
6632
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6633
                                items.MarkupInfoID, Commons.shortGuid());
6634
                        }
6635
                    }
6636
                }
6637
            }
6638
        }
6639

    
6640
        public void InkControl_Convert()
6641
        {
6642
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6643
            if (inkBoard.Strokes.Count > 0)
6644
            {
6645
                inkBoard.Strokes.ToList().ForEach(stroke =>
6646
                {
6647
                    List<Stroke> removingStroke = new List<Stroke>();
6648
                    StrokeCollection stC = new StrokeCollection();
6649

    
6650
                    removingStroke.Add(stroke);
6651

    
6652
                    InkToPath ip = new InkToPath();
6653
                    List<Point> inkPointSet = new List<Point>();
6654
                    PolygonControl pc = null;
6655
                    pc = new PolygonControl()
6656
                    {
6657
                        Angle = 0,
6658
                        PointSet = new List<Point>(),
6659
                        ControlType = ControlType.Ink
6660
                    };
6661
                    foreach (var item in removingStroke)
6662
                    {
6663
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6664
                        inkBoard.Strokes.Remove(item);
6665
                    }
6666
                    if (inkPointSet.Count != 0)
6667
                    {
6668
                        //강인구 추가(PenControl Undo Redo 추가)
6669
                        UndoData = new Undo_data()
6670
                        {
6671
                            IsUndo = false,
6672
                            Event = Event_Type.Create,
6673
                            EventTime = DateTime.Now,
6674
                            Markup_List = new List<Multi_Undo_data>()
6675
                        };
6676

    
6677
                        pc.StartPoint = inkPointSet[0];
6678
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6679
                        pc.PointSet = inkPointSet;
6680
                        pc.LineSize = 3;
6681
                        pc.CommentID = Commons.shortGuid();
6682
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6683
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6684
                        ///pc.SetPolyPath();
6685

    
6686
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6687
                        {
6688
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6689
                        });
6690
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6691
                        UndoData.Markup_List.Add(multi_Undo_Data);
6692
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6693
                    }
6694
                });
6695
            }
6696
        }
6697

    
6698
        /// <summary>
6699
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6700
        /// </summary>
6701
        /// <param name="StartP">StartPoint</param>
6702
        /// <param name="EndP">EndPoint</param>
6703
        /// <returns>Return_EndPoint</returns>
6704
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6705
        {
6706
            Point Return_Point = new Point();
6707

    
6708
            double dx = EndP.X - StartP.X;
6709
            double dy = EndP.Y - StartP.Y;
6710
            double length;
6711

    
6712
            switch (controlType)
6713
            {
6714
                case ControlType.Triangle:
6715
                    {
6716
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6717
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6718
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6719
                    }
6720
                    break;
6721
                default:
6722
                    {
6723
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6724
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6725
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6726
                    }
6727
                    break;
6728
            }
6729

    
6730
            return Return_Point;
6731
        }
6732

    
6733
        /// <summary>
6734
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6735
        /// </summary>
6736
        /// <author>humkyung</author>
6737
        /// <date>2018.04.26</date>
6738
        /// <param name="StartP"></param>
6739
        /// <param name="EndP"></param>
6740
        /// <returns></returns>
6741
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6742
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6743
        {
6744
            List<Point> res = new List<Point>();
6745

    
6746
            double dx = EndP.X - StartP.X;
6747
            double dy = EndP.Y - StartP.Y;
6748
            double length = Math.Sqrt(dx * dx + dy * dy);
6749
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6750
            dx /= length;
6751
            dy /= length;
6752
            double tmp = dx;
6753
            dx = -dy; dy = tmp; /// rotate by 90 degree
6754

    
6755
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6756
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6757

    
6758
            return res;
6759
        }
6760

    
6761
        /// <summary>
6762
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6763
        /// </summary>
6764
        /// <author>ingu</author>
6765
        /// <date>2018.06.05</date>
6766
        /// <param name="getPoint"></param>
6767
        /// <returns></returns>
6768
        private bool IsGetoutpoint(Point getPoint)
6769
        {
6770
            if (getPoint == new Point())
6771
            {
6772
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6773
                currentControl = null;
6774
                return true;
6775
            }
6776

    
6777
            return false;
6778
        }
6779

    
6780
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6781
        {
6782
            e.Effects = DragDropEffects.Copy;
6783
        }
6784

    
6785
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6786
        {
6787
            e.Effects = DragDropEffects.Copy;
6788
        }
6789

    
6790
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6791
        {
6792
            e.Effects = DragDropEffects.None;
6793
        }
6794

    
6795
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6796
        {
6797
            try
6798
            {
6799
                if (e.Data.GetDataPresent(typeof(string)))
6800
                {
6801
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6802
                    string dragData = e.Data.GetData(typeof(string)) as string;
6803
                    Move_Symbol(sender, dragData);
6804
                }
6805
            }
6806
            catch (Exception ex)
6807
            {
6808
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6809
            }            
6810
        }
6811

    
6812
        private void Move_Symbol(object sender, string dragData)
6813
        {
6814
            try
6815
            {
6816
                if (dragData.Contains("|DZ|"))
6817
                {
6818
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6819

    
6820
                    string[] delimiterChars = { "|DZ|" };
6821
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6822

    
6823
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6824

    
6825
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6826

    
6827
                    //강인구 Undo/Redo 보류
6828
                    UndoData = new Undo_data()
6829
                    {
6830
                        IsUndo = false,
6831
                        Event = Event_Type.Create,
6832
                        EventTime = DateTime.Now,
6833
                        Markup_List = new List<Multi_Undo_data>()
6834
                    };
6835

    
6836
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6837
                    {
6838
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6839
                    });
6840

    
6841
                    foreach (string parse in data)
6842
                    {
6843
                        if (parse != "")
6844
                        {
6845
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
6846
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
6847

    
6848
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6849
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6850

    
6851
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6852

    
6853
                            multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
6854

    
6855
                            UndoData.Markup_List.Add(multi_Undo_Data);
6856
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6857
                        }
6858
                    }
6859
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6860

    
6861
                    /// move symbol to current mouse point
6862
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6863
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6864
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6865

    
6866
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6867
                    {
6868
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6869
                    }
6870
                    /// up to here
6871

    
6872
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6873
                }
6874
            }
6875
            catch (Exception ex)
6876
            {
6877
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
6878
            }            
6879
        }        
6880
    }
6881
}
클립보드 이미지 추가 (최대 크기: 500 MB)