프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3264
                        final = new AdornerFinal(control);
3265

    
3266
                        Control_Style(control);
3267

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

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

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

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

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

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

    
3387
                        Control_Style(control);
3388

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

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

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

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

    
3455
                                    CreateControl();
3456

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

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

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

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

    
3503
                                    CreateControl();
3504

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

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

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

    
3538
                                    CreateControl();
3539

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

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

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

    
3573
                                    CreateControl();
3574

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

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

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

    
3611
                                        CreateControl();
3612

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

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

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

    
3651
                                        CreateControl();
3652

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

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

    
3688
                                        CreateControl();
3689

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

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

    
3730
                                            CreateControl();
3731

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

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

    
3767
                                        CreateControl();
3768

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

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

    
3804
                                        CreateControl();
3805

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

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

    
3841
                                        CreateControl();
3842

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

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

    
3878
                                        CreateControl();
3879

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

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

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

    
3949
                                    CreateControl();
3950

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

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

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

    
4009
                                        CreateControl();
4010

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

    
4054
                                    CreateControl();
4055

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

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

    
4114
                                            CreateControl();
4115

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

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

    
4160
                                    CreateControl();
4161

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4342
                                    CreateControl();
4343

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

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

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

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

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

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

    
4424
                                    CreateControl();
4425

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4736
                                    control.ApplyOverViewData();
4737

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5023

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

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

    
5041
            }
5042
        }
5043

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

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

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

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

    
5071
            inkBoard.Strokes.Add(stroke);
5072

    
5073
        }
5074

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5479
                }
5480
            }
5481
        }
5482

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

    
5489
                var uri = CurrentRev.TO_VENDOR;
5490

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5696

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

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

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

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

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

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

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

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

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

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

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

    
5825
                                    System.Drawing.Bitmap image;
5826

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

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

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

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

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

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

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

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

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

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

    
5975
                List<SYMBOL_PUBLIC> symbol_Public;
5976

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

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

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

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

    
6039
        public PngBitmapEncoder symImage(string data)
6040
        {
6041

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

    
6048
            BitmapEncoder encoder = new PngBitmapEncoder();
6049

    
6050

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

    
6053
            DrawingVisual dv = new DrawingVisual();
6054

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

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

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

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

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

    
6084
        }
6085

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

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

    
6106
        #region 캡쳐 기능
6107

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

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

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

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

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

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

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

    
6146
            return pixels;
6147
        }
6148

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

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

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

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

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

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

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

    
6196
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6197

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

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

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

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

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

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

    
6284
        }
6285

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

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

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

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

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

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

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

    
6322
            multi_Undo_Data.Markup = control;
6323

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

    
6341
            return multi_Undo_Data;
6342
        }
6343

    
6344
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6345
        {
6346
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6347
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6348
            {
6349
                if (items.UserID == Select_ID)
6350
                {
6351
                    foreach (var item in items.MarkupList)
6352
                    {
6353
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6354
                        {
6355
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6356
                                items.MarkupInfoID, Commons.shortGuid());
6357
                        }
6358
                    }
6359
                }
6360
            }
6361
        }
6362

    
6363
        public void InkControl_Convert()
6364
        {
6365
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6366
            if (inkBoard.Strokes.Count > 0)
6367
            {
6368
                inkBoard.Strokes.ToList().ForEach(stroke =>
6369
                {
6370
                    List<Stroke> removingStroke = new List<Stroke>();
6371
                    StrokeCollection stC = new StrokeCollection();
6372

    
6373
                    removingStroke.Add(stroke);
6374

    
6375
                    InkToPath ip = new InkToPath();
6376
                    List<Point> inkPointSet = new List<Point>();
6377
                    PolygonControl pc = null;
6378
                    pc = new PolygonControl()
6379
                    {
6380
                        Angle = 0,
6381
                        PointSet = new List<Point>(),
6382
                        ControlType = ControlType.Ink
6383
                    };
6384
                    foreach (var item in removingStroke)
6385
                    {
6386
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6387
                        inkBoard.Strokes.Remove(item);
6388
                    }
6389
                    if (inkPointSet.Count != 0)
6390
                    {
6391
                        //강인구 추가(PenControl Undo Redo 추가)
6392
                        UndoData = new Undo_data()
6393
                        {
6394
                            IsUndo = false,
6395
                            Event = Event_Type.Create,
6396
                            EventTime = DateTime.Now,
6397
                            Markup_List = new List<Multi_Undo_data>()
6398
                        };
6399

    
6400
                        pc.StartPoint = inkPointSet[0];
6401
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6402
                        pc.PointSet = inkPointSet;
6403
                        pc.LineSize = 3;
6404
                        pc.CommentID = Commons.shortGuid();
6405
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6406
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6407
                        ///pc.SetPolyPath();
6408

    
6409
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6410
                        {
6411
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6412
                        });
6413
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6414
                        UndoData.Markup_List.Add(multi_Undo_Data);
6415
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6416
                    }
6417
                });
6418
            }
6419
        }
6420

    
6421
        /// <summary>
6422
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6423
        /// </summary>
6424
        /// <param name="StartP">StartPoint</param>
6425
        /// <param name="EndP">EndPoint</param>
6426
        /// <returns>Return_EndPoint</returns>
6427
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6428
        {
6429
            Point Return_Point = new Point();
6430

    
6431
            double dx = EndP.X - StartP.X;
6432
            double dy = EndP.Y - StartP.Y;
6433
            double length;
6434

    
6435
            switch (controlType)
6436
            {
6437
                case ControlType.Triangle:
6438
                    {
6439
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6440
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6441
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6442
                    }
6443
                    break;
6444
                default:
6445
                    {
6446
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6447
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6448
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6449
                    }
6450
                    break;
6451
            }
6452

    
6453
            return Return_Point;
6454
        }
6455

    
6456
        /// <summary>
6457
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6458
        /// </summary>
6459
        /// <author>humkyung</author>
6460
        /// <date>2018.04.26</date>
6461
        /// <param name="StartP"></param>
6462
        /// <param name="EndP"></param>
6463
        /// <returns></returns>
6464
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6465
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6466
        {
6467
            List<Point> res = new List<Point>();
6468

    
6469
            double dx = EndP.X - StartP.X;
6470
            double dy = EndP.Y - StartP.Y;
6471
            double length = Math.Sqrt(dx * dx + dy * dy);
6472
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6473
            dx /= length;
6474
            dy /= length;
6475
            double tmp = dx;
6476
            dx = -dy; dy = tmp; /// rotate by 90 degree
6477

    
6478
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6479
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6480

    
6481
            return res;
6482
        }
6483

    
6484
        /// <summary>
6485
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6486
        /// </summary>
6487
        /// <author>ingu</author>
6488
        /// <date>2018.06.05</date>
6489
        /// <param name="getPoint"></param>
6490
        /// <returns></returns>
6491
        private bool IsGetoutpoint(Point getPoint)
6492
        {
6493
            if (getPoint == new Point())
6494
            {
6495
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6496
                currentControl = null;
6497
                return true;
6498
            }
6499

    
6500
            return false;
6501
        }
6502

    
6503
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6504
        {
6505
            e.Effects = DragDropEffects.Copy;
6506
        }
6507

    
6508
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6509
        {
6510
            e.Effects = DragDropEffects.Copy;
6511
        }
6512

    
6513
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6514
        {
6515
            e.Effects = DragDropEffects.None;
6516
        }
6517

    
6518
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6519
        {
6520
            try
6521
            {
6522
                if (e.Data.GetDataPresent(typeof(string)))
6523
                {
6524
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6525
                    string dragData = e.Data.GetData(typeof(string)) as string;
6526
                    Move_Symbol(sender, dragData);
6527
                }
6528
            }
6529
            catch (Exception ex)
6530
            {
6531
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6532
            }            
6533
        }
6534

    
6535
        private void Move_Symbol(object sender, string dragData)
6536
        {
6537
            try
6538
            {
6539
                if (dragData.Contains("|DZ|"))
6540
                {
6541
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6542

    
6543
                    string[] delimiterChars = { "|DZ|" };
6544
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6545

    
6546
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6547

    
6548
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6549

    
6550
                    //강인구 Undo/Redo 보류
6551
                    UndoData = new Undo_data()
6552
                    {
6553
                        IsUndo = false,
6554
                        Event = Event_Type.Create,
6555
                        EventTime = DateTime.Now,
6556
                        Markup_List = new List<Multi_Undo_data>()
6557
                    };
6558

    
6559
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6560
                    {
6561
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6562
                    });
6563

    
6564
                    foreach (string parse in data)
6565
                    {
6566
                        if (parse != "")
6567
                        {
6568
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
6569
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
6570

    
6571
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6572
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6573

    
6574
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6575

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

    
6578
                            UndoData.Markup_List.Add(multi_Undo_Data);
6579
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6580
                        }
6581
                    }
6582
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6583

    
6584
                    /// move symbol to current mouse point
6585
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6586
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6587
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6588

    
6589
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6590
                    {
6591
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6592
                    }
6593
                    /// up to here
6594

    
6595
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6596
                }
6597
            }
6598
            catch (Exception ex)
6599
            {
6600
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
6601
            }            
6602
        }        
6603
    }
6604
}
클립보드 이미지 추가 (최대 크기: 500 MB)