프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 52827a4c

이력 | 보기 | 이력해설 | 다운로드 (254 KB)

1

2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Line;
4
using MarkupToPDF.Controls.Polygon;
5
using MarkupToPDF.Controls.Shape;
6
using MarkupToPDF.Controls.Text;
7
using MarkupToPDF.Controls.Etc;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Data;
15
using System.Windows.Documents;
16
using System.Windows.Input;
17
using System.Windows.Media;
18
using System.Windows.Media.Imaging;
19
using System.Windows.Navigation;
20
using System.Windows.Shapes;
21
using KCOM.Common;
22
using IKCOM;
23
using System.Windows.Ink;
24
using System.Collections.ObjectModel;
25
using Telerik.Windows.Controls;
26
using KCOM.Events;
27
using System.Reflection;
28
using MarkupToPDF.Common;
29
using KCOM.Controls;
30
using KCOMDataModel.DataModel;
31
using System.Xml;
32
using static KCOM.TempFile;
33
using System.Windows.Threading;
34
using System.Diagnostics;
35
using System.Threading;
36
using System.Windows.Resources;
37
using Svg2Xaml;
38
using System.Runtime.InteropServices;
39
using System.Windows.Media.Effects;
40
using MarkupToPDF.Controls.Cad;
41
using MarkupToPDF.Controls.Parsing;
42
using Telerik.Windows.Data;
43
using System.ComponentModel;
44
using static KCOM.Controls.Sample;
45
using System.Web;
46

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

    
56
            T instance = Activator.CreateInstance<T>();
57

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

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

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

    
94
        public TextBox Gui { get; private set; }
95

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

    
109
        public void WriteLine(string line)
110
        {
111
            if (!Gui.Dispatcher.CheckAccess())
112
            {
113
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
114
                return;
115
            }
116

    
117
            Gui.Text += line + Environment.NewLine;
118
        }
119
    }
120

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

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

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

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

    
183
                }
184
            }
185
        }
186

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

    
211
        public bool IsSyncPDFMode { get; set; }
212

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

    
237
        #endregion
238

    
239
        public MainMenu()
240
        {
241
            App.splashString(ISplashMessage.MAINMENU_0);            
242
            //InitializeComponent();    
243
            this.Loaded += MainMenu_Loaded;
244
        }
245

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

    
256
        List<TempDt> tempDtList = new List<TempDt>();
257

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

    
263
        /// <summary>
264
        /// get image url
265
        /// </summary>
266
        /// <author>humkyung</author>
267
        /// <param name="sDocumentID"></param>
268
        /// <returns></returns>
269
        public string GetImageURL(string sDocumentID, int iPageNo)
270
        {
271
            string uri = string.Empty;
272

    
273
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
274
            if (userData.COMPANY != "EXT")
275
            {
276
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
277
            }
278
            else
279
            {
280
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
281
            }
282

    
283
            return uri;
284
        }
285

    
286
        /// <summary>
287
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
288
        /// </summary>
289
        /// <returns></returns>
290
        public string GetOriginalPDFURL()
291
        {
292
            string uri = string.Empty;
293
            string sDocumentID = this._DocItem.DOCUMENT_ID;
294
            string filename = string.Empty;
295
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
296
            {
297
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
298
            }
299
            else
300
            {
301
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
302
            }
303
            
304
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
305
            if (userData.COMPANY != "EXT")
306
            {
307
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
308
            }
309
            else
310
            {
311
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
312
            }
313
            uri = uri.Replace(".png", "");
314
            return uri;
315
        }
316
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
317
        {
318
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
319
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
320
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
321
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
322
            {
323
                return true;
324
            }
325

    
326
            return false;
327
        }
328

    
329
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
330
        {
331
            if (rotate.Angle == 90 || rotate.Angle == 270)
332
            {
333
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
334
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
335
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
336
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
337
                {
338
                    return true;
339
                }
340
            }
341
            else
342
            {
343
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
344
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
345
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
346
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
347
                {
348
                    return true;
349
                }
350
            }
351

    
352
            return false;
353
        }
354

    
355
        public void DeleteItem(MarkupInfoItem item)
356
        {
357
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
358
            {
359
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
360

    
361
            
362
            ViewerDataModel.Instance._markupInfoList.Remove(item);
363

    
364
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
365
            {
366
                ViewerDataModel.Instance.MarkupControls.Remove(a);
367
            });
368

    
369
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
370
            {
371
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
372
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
373
                null, Event_Type.Delete, a.CommentID, null);
374
            });
375

    
376
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
377
            {
378
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
379
                //임시파일에서도 삭제
380
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
381
            });
382

    
383
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
384

    
385
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
386
            {
387
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
388
                {
389
                    var infoId = Commons.shortGuid();
390
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
391
                    {
392
                        CreateTime = DateTime.Now,
393
                        Depatment = userData.DEPARTMENT,
394
                        UpdateTime = DateTime.Now,
395
                        DisplayColor = "#FFFF0000",
396
                        UserID = userData.ID,
397
                        UserName = userData.NAME,
398
                        PageCount = 1,
399
                        Description = "",
400
                        MarkupInfoID = infoId,
401
                        MarkupList = null,
402
                        MarkupVersionID = Commons.shortGuid(),
403
                        Consolidate = 0,
404
                        PartConsolidate = 0,
405
                        userDelete = true,
406
                        AvoidConsolidate = 0,
407
                        IsPreviewUser = true
408
                    };
409
                    App.Custom_ViewInfoId = infoId;
410
                }
411
            }
412
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
413
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
414
        }
415

    
416
        /// <summary>
417
        /// delete selected comments
418
        /// </summary>
419
        /// <param name="sender"></param>
420
        /// <param name="e"></param>
421
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
422
        {
423
            DialogParameters parameters = new DialogParameters()
424
            {
425
                Owner = Application.Current.MainWindow,
426
                Content = new TextBlock()
427
                { 
428
                    MinWidth = 400,
429
                    FontSize = 11,
430
                    Text = "정말 삭제 하시겠습니까?",
431
                    TextWrapping = System.Windows.TextWrapping.Wrap
432
                },
433
                Header = "Confirm",
434
                Theme = new VisualStudio2013Theme(),
435
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
436
                OkButtonContent = "Yes",
437
                CancelButtonContent = "No",
438
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
439
                {
440
                    if(wc.DialogResult == true)
441
                    {
442
                        //선택된 어도너가 있을시 삭제가 되지 않음
443
                        SelectionSet.Instance.UnSelect(this);
444

    
445
                        Button content = (sender as Button);
446
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
447

    
448
                        DeleteItem(item);
449
                    }
450
                }
451
            };
452
            RadWindow.Confirm(parameters);
453
        }
454

    
455
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
456

    
457
        private static Timer timer;
458
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
459
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
460
        {
461
            InitializeComponent();            
462
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
463

    
464
            if (App.ParameterMode)
465
            {
466
                App.splashString(ISplashMessage.MAINMENU_1);
467
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
468
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
469
                imageViewer_Compare = new Image();
470
                ViewerDataModel.Instance.Capture_Opacity = 0;
471
                da.From = 0.8;
472
                da.To = 0;
473
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
474
                da.AutoReverse = true;
475
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
476

    
477
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
478
                {
479
                    this.SymbolPane.Visibility = Visibility.Collapsed;
480
                    this.FavoritePane.Visibility = Visibility.Collapsed;
481
                    this.drawingRotateCanvas.IsHitTestVisible = false;
482
                }
483
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
484
            }
485
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
486
        }
487

    
488
        
489

    
490
        private void timercallback(Object o)
491
        {
492
            Stopwatch sw = new Stopwatch();
493
            sw.Start();
494
            TempFile.TempFileAdd();
495
            sw.Stop();
496

    
497
            Dispatcher.InvokeAsync(new Action(delegate
498
            {
499
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
500
                {
501
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
502
                }
503
            }));
504

    
505
            ////GC.Collect();
506
        }
507
        
508
        /// <summary>
509
        /// update my markuplist
510
        ///  - update existing markup data if already exist
511
        ///  - add new markup data if control is new
512
        /// </summary>
513
        public void UpdateMyMarkupList()
514
        {
515
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
516

    
517
            /// add or update markup list
518
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
519
            {
520
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
521

    
522
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
523
                if (exist != null) //신규 추가 된 코멘트
524
                {
525
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
526
                    {
527
                        exist.Data = root.ConvertData;
528
                        exist.IsUpdate = true;
529
                    }
530
                }
531
                else if (root.CommentID != null)
532
                {
533
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
534
                    {
535
                        ID = control.CommentID,
536
                        Data = root.ConvertData,
537
                        Data_Type = root.DATA_TYPE,
538
                        MarkupInfoID = App.Custom_ViewInfoId,
539
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
540
                        Symbol_ID = control.SymbolID,
541
                        //Group_ID = control.GroupID,
542
                    });
543
                }
544
            }
545

    
546
            /// delete markup list
547
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
548
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
549
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
550
                          select markup).ToList();
551
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
552
            /// up to here
553

    
554
            //if (modified)
555
            //{
556
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
557
            //    {
558
            //        ComingNewBieEnd = true;
559
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
560
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
561
            //        gridViewMarkup.ItemsSource = null;
562
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
563
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
564

    
565
            //        GroupDescriptor descriptor = new GroupDescriptor();
566
            //        descriptor.Member = "Depatment";
567
            //        descriptor.DisplayContent = "DEPT";
568
            //        descriptor.SortDirection = ListSortDirection.Ascending;
569
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
570
            //    }
571
            //}
572
        }
573

    
574
        DispatcherTimer renderTesttimer;
575

    
576
        /// <summary>
577
        /// start page changing
578
        ///  - save controls if page is modified
579
        ///  - starting download page image
580
        /// </summary>
581
        /// <param name="sender"></param>
582
        /// <param name="e"></param>
583
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
584
        {
585
            CompareMode.IsChecked = false;
586
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
587

    
588
            #region 페이지가 벗어난 경우
589

    
590
            if (BalancePoint < 1)
591
            {
592
                BalancePoint = 1;
593
                ViewerDataModel.Instance.PageBalanceNumber = 0;
594
            }
595

    
596
            if (pageNavigator.PageCount < BalancePoint)
597
            {
598
                BalancePoint = pageNavigator.PageCount;
599
                ViewerDataModel.Instance.PageBalanceNumber = 0;
600
            }
601

    
602
            #endregion
603

    
604
            ViewerDataModel.Instance.PageNumber = BalancePoint;
605

    
606
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
607
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
608
            var pageUri = pageNavigator.CurrentPage.PageUri;
609
            var contentScale = zoomAndPanControl.ContentScale;
610

    
611
            #region 페이지 이미지 로딩 수정
612

    
613
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
614
            try
615
            {
616
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
617
                
618
            }
619
            catch (Exception ex)
620
            {
621
                ViewerDataModel.Instance.ImageViewPath = null;
622
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
623
                DialogMessage_Alert(imgfailedmsg, "Warning");
624
                App.FileLogger.Fatal(ex);
625
            }
626
            ScaleImage(pageWidth, pageHeight);
627

    
628
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
629
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
630

    
631
            zoomAndPanCanvas.Width = pageWidth;
632
            zoomAndPanCanvas.Height = pageHeight;
633

    
634
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
635
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
636

    
637
            inkBoard.Width = pageWidth;
638
            inkBoard.Height = pageHeight;
639

    
640
            #endregion
641

    
642
            if (!testPanel2.IsHidden)
643
            {
644
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
645
                //PDF모드일때 잠시 대기(강인구)
646
                if (IsSyncPDFMode)
647
                {
648
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
649
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
650

    
651
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
652
                    if (pdfpath.IsDownloading)
653
                    {
654
                        pdfpath.DownloadCompleted += (ex, arg) =>
655
                        {
656
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
657
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
658
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
659
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
660
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
661
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
662
                        };
663
                    }
664
                    else
665
                    {
666
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
667
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
668
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
669
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
670

    
671
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
672
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
673
                    }
674
                }
675
                else
676
                {
677
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
678
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
679

    
680
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
681
                    var defaultBitmapImage_Compare = new BitmapImage();
682
                    defaultBitmapImage_Compare.BeginInit();
683
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
684
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
685
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
686
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
687
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
688
                    defaultBitmapImage_Compare.EndInit();
689

    
690
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
691

    
692
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
693
                    zoomAndPanControl.ZoomTo(new Rect
694
                    {
695
                        X = 0,
696
                        Y = 0,
697
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
698
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
699
                    });
700

    
701
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
702
                    if (defaultBitmapImage_Compare.IsDownloading)
703
                    {
704
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
705
                        {
706
                            defaultBitmapImage_Compare.Freeze();
707
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
708
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
709
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
710
                            ComparePanel.UpdateLayout();
711
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
712
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
713

    
714
                            zoomAndPanControl.ZoomTo(new Rect
715
                            {
716
                                X = 0,
717
                                Y = 0,
718
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
719
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
720
                            });
721

    
722
                            //defaultBitmapImage_Compare dispose
723
                            defaultBitmapImage_Compare = null;
724
                            GC.Collect();
725
                        };
726
                    }
727
                }
728
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
729
            }
730

    
731
            this.pageNavigator.ChangePage(e.PageNumber);
732
        }
733

    
734
        /// <summary>
735
        /// called after page is changed
736
        /// </summary>
737
        /// <param name="sender"></param>
738
        /// <param name="e"></param>
739
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
740
        {
741
            if (zoomAndPanCanvas2.Width.IsNaN())
742
            {
743
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
744
            }
745

    
746
            /// 컨트롤을 새로 생성한다.
747
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
748
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
749
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
750
            { 
751
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
752
                if (info != null)
753
                {
754
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
755
                    if (info.UserID == App.ViewInfo.UserID)
756
                    {
757
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
758
                                        markup.MarkupInfoID, markup.ID);
759
                        control.Visibility = Visibility.Hidden;
760
                    }
761
                    else
762
                    {
763
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
764
                                                                markup.MarkupInfoID, markup.ID);
765
                        control.Visibility = Visibility.Hidden;
766
                    }
767
                }
768
            };
769
            /// up to here
770

    
771
            /// fire selection event
772
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
773
            this.gridViewMarkup.UnselectAll();
774
            this.gridViewMarkup.Select(gridSelectionItem);
775

    
776
            if (!testPanel2.IsHidden)
777
            {
778
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
779
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
780
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
781

    
782
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
783
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
784

    
785

    
786
                foreach (var item in gridSelectionRevItem)
787
                {
788
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
789
                    {
790
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
791
                    });
792
                }
793
            }
794

    
795
            var instanceMain = this.ParentOfType<MainWindow>();
796
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
797
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
798

    
799
            instanceMain.dzTopMenu.rotateOffSet = 0;
800
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
801
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
802
            
803
            SetCommentPages(true);
804
        }
805

    
806
        public void SetCommentPages(bool onlyMe = false)
807
        {
808
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
809
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
810
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
811
            {
812
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
813
                if(item.MarkupList != null)
814
                {
815
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
816
                    instance.UserName = item.UserName;
817
                    instance.Depart = item.Depatment;
818
                    instance.MarkupInfoID = item.MarkupInfoID;
819
                    instance.IsSelected = true;
820
                    instance.isConSolidation = item.Consolidate;
821
                    instance.SetColor = item.DisplayColor;
822
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
823
                    {
824
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
825
                    }
826
                    else
827
                    {
828
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
829
                    }
830
                    _pages.Add(instance);
831
                }                   
832
            }
833
            
834
            this.pageNavigator.SetCommentList(_pages.ToList());
835
        }
836

    
837
        public void MarkupitemViewUpdate(string markupinfo_id)
838
        {
839
            //db에 업데이트 한 list 를 view 에 업데이트
840
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
841
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
842
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
843
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
844
            if (dbinfo.MarkupList.Count > 0)
845
            {
846
                if (viewinfo.MarkupList != null)
847
                {
848
                    viewinfo.MarkupList.Clear();
849
                    viewinfo.MarkupList = null;
850
                }
851
                viewinfo.MarkupList = new List<MarkupItem>();
852
                foreach (var item in dbinfo.MarkupList)
853
                {
854
                    viewinfo.MarkupList.Add(item);
855
                }
856
            }
857
        }
858

    
859
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
860
        {
861
            if (e.MiddleButton == MouseButtonState.Pressed)
862
            {
863

    
864
            }
865
            e.Handled = true;
866
            if (e.Delta > 0)
867
            {
868
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
869
                ZoomIn(currentContentMousePoint);
870
            }
871
            else
872
            {
873
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
874
                ZoomOut(currentContentMousePoint);
875
            }
876
        }
877

    
878
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
879
        {
880
            e.Handled = true;
881
            if (e.Delta > 0)
882
            {
883
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
884
                ZoomIn_Sync(currentContentMousePoint);
885
            }
886
            else
887
            {
888
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
889
                ZoomOut_Sync(currentContentMousePoint);
890
            }
891
        }
892

    
893
        #region ZoomIn & ZoomOut
894

    
895
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
896
        {
897
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
898
                zoomAndPanControl.ContentZoomFocusY));
899
        }
900

    
901
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
902
        {
903
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
904
                zoomAndPanControl.ContentZoomFocusY));
905
        }
906

    
907

    
908
        //강인구 추가 (줌 인아웃 수치 변경)
909
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
910
        private void ZoomOut(Point contentZoomCenter)
911
        {
912
            if (zoomAndPanControl.ContentScale > 0.39)
913
            {
914
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
915
            }
916
            else
917
            {
918
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
919
            }
920

    
921
            if (zoomAndPanControl2 != null && Sync.IsChecked)
922
            {
923
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
924
            }
925
        }
926

    
927
        private void ZoomIn(Point contentZoomCenter)
928
        {
929
            if (zoomAndPanControl.ContentScale > 0.19)
930
            {
931
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
932
            }
933
            else
934
            {
935
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
936
            }
937

    
938
            if (zoomAndPanControl2 != null && Sync.IsChecked)
939
            {
940
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
941
            }
942

    
943
        }
944

    
945
        private void ZoomOut_Sync(Point contentZoomCenter)
946
        {
947
            if (zoomAndPanControl2.ContentScale > 0.39)
948
            {
949
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
950
            }
951
            else
952
            {
953
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
954
            }
955

    
956
            if (Sync.IsChecked)
957
            {
958
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
959
            }
960
        }
961

    
962
        private void ZoomIn_Sync(Point contentZoomCenter)
963
        {
964
            if (zoomAndPanControl2.ContentScale > 0.19)
965
            {
966
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
967
            }
968
            else
969
            {
970
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
971
            }
972

    
973
            if (Sync.IsChecked)
974
            {
975
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
976
            }
977
        }
978

    
979
        private void ZoomOut()
980
        {
981
            zoomAndPanControl.ContentScale -= 0.1;
982
            //if (zoomAndPanControl2 != null)
983
            //{
984
            //    zoomAndPanControl2.ContentScale -= 0.1;
985
            //}
986
        }
987

    
988
        private void ZoomIn()
989
        {
990
            zoomAndPanControl.ContentScale += 0.1;
991
            //if (zoomAndPanControl2 != null)
992
            //{
993
            //    zoomAndPanControl2.ContentScale += 0.1;
994
            //}
995
        }
996

    
997
        #endregion
998

    
999
        private void init()
1000
        {
1001
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1002
            {
1003

    
1004
                ControlList.Clear();
1005
                listBox.Items.Clear();
1006
                selected_item.Clear();
1007

    
1008
                (item as IMarkupCommonData).IsSelected = false;
1009
            }
1010

    
1011
        }
1012

    
1013
        private HitTestResultBehavior MyCallback(HitTestResult result)
1014
        {
1015
            //this.cursor = Cursors.UpArrow;
1016
            var element = result.VisualHit;
1017
            while (element != null && !(element is CommentUserInfo))
1018
                element = VisualTreeHelper.GetParent(element);
1019

    
1020
            if (element == null)
1021
            {
1022
                return HitTestResultBehavior.Stop;
1023
            }
1024
            else
1025
            {
1026
                if (element is CommentUserInfo)
1027
                {
1028
                    if (!hitList.Contains(element))
1029
                    {
1030
                        hitList.Add((CommentUserInfo)element);
1031
                    }
1032
                    else
1033
                    {
1034
                        return HitTestResultBehavior.Stop;
1035
                    }
1036
                }
1037
            }
1038
            return HitTestResultBehavior.Continue;
1039
        }
1040

    
1041
        public void ReleaseSelectPath()
1042
        {
1043
            if (SelectionPath == null)
1044
            {
1045
                SelectionPath = new Path();
1046
                SelectionPath.Name = "";
1047
            }
1048
            if (SelectionPath.Name != "")
1049
            {
1050
                SelectionPath.Name = "None";
1051
            }
1052
            SelectionPath.Opacity = 0.01;
1053
            SelectionPath.RenderTransform = null;
1054
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1055
        }
1056

    
1057
        #region 컨트롤 초기화 
1058
        public void Control_Init(object control)
1059
        {
1060
            if (L_Size != 0 && (control as IPath) != null)
1061
            {
1062
                (control as IPath).LineSize = L_Size;
1063
                L_Size = 0;
1064
            }
1065

    
1066
            switch (control.GetType().Name)
1067
            {
1068
                case "RectangleControl":
1069
                    {
1070
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1071
                    }
1072
                    break;
1073
                case "CircleControl":
1074
                    {
1075
                        (control as CircleControl).StrokeColor = Brushes.Red;
1076
                    }
1077
                    break;
1078
                case "TriControl":
1079
                    {
1080
                        (control as TriControl).StrokeColor = Brushes.Red;
1081
                    }
1082
                    break;
1083
                case "RectCloudControl":
1084
                    {
1085
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1086
                    }
1087
                    break;
1088
                case "CloudControl":
1089
                    {
1090
                        (control as CloudControl).StrokeColor = Brushes.Red;
1091
                    }
1092
                    break;
1093
                case "PolygonControl":
1094
                    {
1095
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1096
                    }
1097
                    break;
1098
                case "ArcControl":
1099
                    {
1100
                        (control as ArcControl).StrokeColor = Brushes.Red;
1101
                    }
1102
                    break;
1103
                case "ArrowArcControl":
1104
                    {
1105
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1106
                    }
1107
                    break;
1108
                case "LineControl":
1109
                    {
1110
                        (control as LineControl).StrokeColor = Brushes.Red;
1111
                    }
1112
                    break;
1113
                case "ArrowControl_Multi":
1114
                    {
1115
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1116
                    }
1117
                    break;
1118
                case "TextControl":
1119
                    {
1120
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1121
                    }
1122
                    break;
1123
                case "ArrowTextControl":
1124
                    {
1125
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1126
                    }
1127
                    break;
1128
                case "InsideWhiteControl":
1129
                    {
1130
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1131
                    }
1132
                    break;
1133
                case "OverlapWhiteControl":
1134
                    {
1135
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1136
                    }
1137
                    break;
1138
                case "ClipWhiteControl":
1139
                    {
1140
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1141
                    }
1142
                    break;
1143
                case "CoordinateControl":
1144
                    {
1145
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1146
                    }
1147
                    break;
1148
            }
1149
        }
1150
        #endregion
1151

    
1152
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1153
        {
1154
            //Control_Init(e.Source);
1155
        }
1156
        //private Window _dragdropWindow = null;
1157

    
1158
        [DllImport("user32.dll")]
1159
        [return: MarshalAs(UnmanagedType.Bool)]
1160
        internal static extern bool GetCursorPos(ref Win32Point pt);
1161

    
1162
        [StructLayout(LayoutKind.Sequential)]
1163
        internal struct Win32Point
1164
        {
1165
            public Int32 X;
1166
            public Int32 Y;
1167
        };
1168
        /*
1169
       public string symbol_id = null;
1170
       public long symbol_group_id;
1171
       public int symbol_SelectedIndex;
1172
       public ImageSource symbol_img;
1173
       public string symbol_Data = null;
1174
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1175
       {
1176
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1177
               zoomAndPanCanvas.ActualHeight / 2));
1178

    
1179

    
1180
               if (this._dragdropWindow != null)
1181
               {
1182
                   this._dragdropWindow.Close();
1183
                   this._dragdropWindow = null;
1184
               }
1185

    
1186
               symbol_id = id;
1187
               symbol_group_id = group_id;
1188
               symbol_SelectedIndex = SelectedIndex;
1189
               symbol_Data = Data_;
1190
               symbol_img = img;
1191

    
1192

    
1193
               CreateDragDropWindow2(img);
1194
              
1195
    }
1196

    
1197
    private void CreateDragDropWindow2(ImageSource image)
1198
        {
1199
            this._dragdropWindow = new Window();
1200
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1201
            _dragdropWindow.WindowStyle = WindowStyle.None;
1202
            _dragdropWindow.AllowsTransparency = true;           
1203
            _dragdropWindow.AllowDrop = false;
1204
            _dragdropWindow.Background = null;
1205
            _dragdropWindow.IsHitTestVisible = false;
1206
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1207
            _dragdropWindow.Topmost = true;
1208
            _dragdropWindow.ShowInTaskbar = false;
1209
            
1210
            Rectangle r = new Rectangle();
1211
            r.Width = image.Width;
1212
            r.Height = image.Height;
1213
            r.Opacity = 0.5;            
1214
            r.Fill = new ImageBrush(image);
1215
            this._dragdropWindow.Content = r;
1216

    
1217
            Win32Point w32Mouse = new Win32Point();
1218
            GetCursorPos(ref w32Mouse);
1219

    
1220
            //w32Mouse.X = getCurrentPoint.X;
1221
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1222
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1223
            this._dragdropWindow.Show();
1224
        }
1225
         */
1226
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1227
        {
1228
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1229
            {
1230
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1231

    
1232
                Point currentPos = e.GetPosition(rect);
1233

    
1234
                floatingTip.HorizontalOffset = currentPos.X + 20;
1235
                floatingTip.VerticalOffset = currentPos.Y;
1236
            }
1237

    
1238
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1239
            
1240
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1241
            {
1242
                SetCursor();
1243
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1244
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1245

    
1246
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1247
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1248
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1249

    
1250
                if (Sync.IsChecked)
1251
                {
1252
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1253
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1254
                }
1255
            }
1256

    
1257
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1258
            {
1259
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1260
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1261
                SetCursor();
1262

    
1263
                if (currentControl != null)
1264
                {
1265
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1266
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1267
                    //강인구 추가
1268
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1269

    
1270
                    if ((currentControl as IPath) != null)
1271
                    {
1272
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1273
                    }
1274
                    if ((currentControl as LineControl) != null)
1275
                    {
1276
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1277
                    }
1278

    
1279
                    if ((currentControl as IShapeControl) != null)
1280
                    {
1281
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1282
                    }
1283
                    if ((currentControl as TextControl) != null)
1284
                    {
1285
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1286
                        {
1287
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1288
                        }
1289
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1290
                        {
1291
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1292
                        }
1293
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1294
                        {
1295
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1296
                        }
1297
                    }
1298
                    else if ((currentControl as ArrowTextControl) != null)
1299
                    {
1300
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1301
                        {
1302
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1303
                        }
1304
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1305
                        {
1306
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1307
                        }
1308
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1309
                        {
1310
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1311
                        }
1312
                    }
1313
                    else if ((currentControl as RectCloudControl) != null)
1314
                    {
1315
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1316
                    }
1317
                    else if ((currentControl as CloudControl) != null)
1318
                    {
1319
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1320
                    }
1321

    
1322

    
1323
                    #region // 모든 컨트롤의 공통기능 제어
1324
                    if (controlType != ControlType.PenControl)
1325
                    {
1326
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1327
                    }
1328

    
1329

    
1330
                    #endregion
1331

    
1332
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1333

    
1334
                    switch (controlType)
1335
                    {
1336
                        case (ControlType.Coordinate):
1337
                            {
1338
                                var control = currentControl as CoordinateControl;
1339
                                if (control != null)
1340
                                {
1341
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1342
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1343
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1344
                                }
1345
                            }
1346
                            break;
1347
                        case (ControlType.InsideWhite):
1348
                            {
1349
                                var control = currentControl as InsideWhiteControl;
1350
                                if (control != null)
1351
                                {
1352
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1353
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1354
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1355
                                    control.Paint = PaintSet.Fill;
1356
                                }
1357
                            }
1358
                            break;
1359
                        case ControlType.OverlapWhite:
1360
                            {
1361
                                var control = currentControl as OverlapWhiteControl;
1362
                                if (control != null)
1363
                                {
1364
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1365
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1366
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1367
                                    control.Paint = PaintSet.Fill;
1368
                                }
1369
                            }
1370
                            break;
1371
                        case ControlType.ClipWhite:
1372
                            {
1373
                                var control = currentControl as ClipWhiteControl;
1374
                                if (control != null)
1375
                                {
1376
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1377
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1378
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1379
                                    control.Paint = PaintSet.Fill;
1380
                                }
1381
                            }
1382
                            break;
1383
                        case ControlType.RectCloud:
1384
                            {
1385
                                var control = currentControl as RectCloudControl;
1386
                                if (control != null)
1387
                                {
1388
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1389
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1390
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1391
                                }
1392
                            }
1393
                            break;
1394
                        case ControlType.SingleLine:
1395
                        case ControlType.CancelLine:
1396
                        case ControlType.ArrowLine:
1397
                        case ControlType.TwinLine:
1398
                        case ControlType.DimLine:
1399
                            {
1400
                                var control = currentControl as LineControl;
1401
                                if (control != null)
1402
                                {
1403
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1404
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1405
                                }
1406

    
1407
                            }
1408
                            break;
1409

    
1410
                        case ControlType.ArcLine:
1411
                            {
1412
                                var control = currentControl as ArcControl;
1413
                                if (control != null)
1414
                                {
1415
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1416
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1417
                                }
1418
                            }
1419
                            break;
1420

    
1421
                        case ControlType.ArcArrow:
1422
                            {
1423
                                var control = currentControl as ArrowArcControl;
1424
                                if (control != null)
1425
                                {
1426
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1427
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1428
                                }
1429
                            }
1430
                            break;
1431

    
1432
                        case ControlType.ArrowMultiLine:
1433
                            {
1434
                                var control = currentControl as ArrowControl_Multi;
1435
                                if (control != null)
1436
                                {
1437
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1438
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1439
                                }
1440
                            }
1441
                            break;
1442

    
1443
                        case ControlType.Circle:
1444
                            {
1445
                                var control = currentControl as CircleControl;
1446

    
1447
                                if (control != null)
1448
                                {
1449
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1450
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1451
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1452
                                }
1453
                            }
1454
                            break;
1455

    
1456
                        case ControlType.PolygonCloud:
1457
                            {
1458
                                var control = currentControl as CloudControl;
1459
                                if (control != null)
1460
                                {
1461
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1462
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1463
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1464
                                }
1465
                            }
1466
                            break;
1467

    
1468
                        case ControlType.Triangle:
1469
                            {
1470
                                var control = currentControl as TriControl;
1471
                                if (control != null)
1472
                                {
1473
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1474
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1475
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1476
                                }
1477
                            }
1478
                            break;
1479

    
1480
                        case ControlType.ImgControl:
1481
                            {
1482
                                var control = currentControl as ImgControl;
1483
                                if (control != null)
1484
                                {
1485
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1486
                                }
1487
                            }
1488
                            break;
1489

    
1490
                        case ControlType.Date:
1491
                            {
1492
                                var control = currentControl as DateControl;
1493
                                if (control != null)
1494
                                {
1495
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1496
                                }
1497
                            }
1498
                            break;
1499

    
1500
                        case ControlType.ArrowTextControl:
1501
                        case ControlType.ArrowTransTextControl:
1502
                        case ControlType.ArrowTextBorderControl:
1503
                        case ControlType.ArrowTransTextBorderControl:
1504
                        case ControlType.ArrowTextCloudControl:
1505
                        case ControlType.ArrowTransTextCloudControl:
1506
                            {
1507
                                var control = currentControl as ArrowTextControl;
1508
                                if (control != null)
1509
                                {
1510
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1511
                                }
1512
                            }
1513
                            break;
1514
                        case ControlType.PolygonControl:
1515
                        case ControlType.ChainLine:
1516
                            {
1517
                                var control = currentControl as PolygonControl;
1518
                                if (control != null)
1519
                                {
1520
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1521
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1522
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1523
                                }
1524
                            }
1525
                            break;
1526
                        case ControlType.Sign:
1527
                            {
1528
                                var control = currentControl as SignControl;
1529
                                if (control != null)
1530
                                {
1531
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1532
                                }
1533
                            }
1534
                            break;
1535
                        case ControlType.Symbol:
1536
                            {
1537
                                var control = currentControl as SymControl;
1538
                                if (control != null)
1539
                                {
1540
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1541
                                }
1542
                            }
1543
                            break;
1544
                        case ControlType.Stamp:
1545
                            {
1546
                                var control = currentControl as SymControlN;
1547
                                if (control != null)
1548
                                {
1549
                                    if (control.STAMP != null)
1550
                                    {
1551
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1552
                                    }
1553
                                    else
1554
                                    {
1555
                                        currentControl = null;
1556
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1557
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1558
                                    }
1559
                                }
1560
                            }
1561
                            break;
1562
                        case ControlType.Rectangle:
1563
                        case ControlType.Mark:
1564
                            {
1565
                                var control = currentControl as RectangleControl;
1566
                                if (control != null)
1567
                                {
1568
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1569
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1570
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1571
                                }
1572
                            }
1573
                            break;
1574
                        case ControlType.PenControl:
1575
                            {
1576
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1577
                                //inkBoard.Strokes.Add(stroke);
1578
                            }
1579
                            break;
1580
                        default:
1581
                            break;
1582
                    }
1583

    
1584
                    #endregion
1585
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1586
                    {
1587
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1588
                    }
1589
                }
1590
            }
1591
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1592
            {
1593
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1594
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1595
                SetCursor();
1596
                if (currentControl == null)
1597
                {
1598
                    switch (controlType)
1599
                    {
1600
                        case ControlType.PenControl:
1601
                            {
1602
                                if (inkBoard.Tag.ToString() == "Ink")
1603
                                {
1604
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1605
                                }
1606
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1607
                                {
1608
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1609
                                }
1610
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1611
                                {
1612
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1613
                                }
1614

    
1615
                                //inkBoard.Strokes.Add(stroke);
1616
                            }
1617
                            break;
1618
                    }
1619
                    return;
1620
                }
1621
            }
1622
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1623
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1624
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1625
            {
1626
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1627

    
1628
                if (isDraggingSelectionRect)
1629
                {
1630
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1631
                    e.Handled = true;
1632
                }
1633
                else if (isLeftMouseButtonDownOnWindow)
1634
                {
1635
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1636
                    double dragDistance = Math.Abs(dragDelta.Length);
1637

    
1638
                    if (dragDistance > DragThreshold)
1639
                    {
1640
                        isDraggingSelectionRect = true;
1641
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1642
                    }
1643

    
1644
                    e.Handled = true;
1645
                }
1646

    
1647
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1648
                {
1649
                }
1650
                else
1651
                {
1652
                    e.Handled = true;
1653
                }
1654
            }
1655
            /*
1656
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1657
            { //symbol      
1658
                if(_dragdropWindow != null)
1659
                {
1660
                    Win32Point w32Mouse = new Win32Point();
1661
                    GetCursorPos(ref w32Mouse);
1662

    
1663
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1664
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1665
                }                
1666
            }
1667
            */
1668
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1669
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1670
            {
1671
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1672
                if(control != null)
1673
                {
1674
                    this.cursor = Cursors.Hand;
1675
                    SetCursor();
1676
                }
1677
                else
1678
                {
1679
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1680
                    SetCursor();
1681
                }
1682
            }
1683
            else
1684
            {
1685
            }
1686
        }
1687

    
1688
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1689
        {
1690
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1691
            {
1692
                SetCursor();
1693
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1694
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1695

    
1696
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1697

    
1698
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1699
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1700

    
1701
                if (Sync.IsChecked)
1702
                {
1703
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1704
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1705
                }
1706
            }
1707
        }
1708

    
1709
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1710

    
1711
        private EllipseGeometry hitArea = new EllipseGeometry();
1712

    
1713
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1714
        {
1715
            IsDrawing = false;
1716
    
1717
            if (mouseHandlingMode != MouseHandlingMode.None)
1718
            {
1719
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1720
                {
1721
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1722

    
1723
                    SetCursor();
1724

    
1725
                    switch (controlType)
1726
                    {
1727
                        case ControlType.None:
1728
                            break;
1729
                        case ControlType.Rectangle:
1730
                            {
1731

    
1732
                            }
1733
                            break;
1734
                        case ControlType.PenControl:
1735
                            {
1736

    
1737
                            }
1738
                            break;
1739
                        default:
1740
                            break;
1741
                    }                    
1742
                }
1743
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1744
                {
1745
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1746

    
1747
                    if (isLeftMouseButtonDownOnWindow)
1748
                    {
1749
                        bool wasDragSelectionApplied = false;
1750

    
1751
                        if (isDraggingSelectionRect)
1752
                        {
1753
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1754
                            {
1755
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1756
                                mouseHandlingMode = MouseHandlingMode.None;
1757
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1758
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1759
                                Set_Symbol_Capture(endPoint);
1760
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1761
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1762
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1763
                            }
1764
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1765
                            {
1766
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1767
                                mouseHandlingMode = MouseHandlingMode.None;
1768
                                Set_Capture();
1769

    
1770
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1771
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1772
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1773
                            }
1774
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1775
                            {
1776
                                ApplyDragSelectionRect();
1777
                            }
1778
                            else
1779
                            {
1780
                                double x = Canvas.GetLeft(dragZoomBorder);
1781
                                double y = Canvas.GetTop(dragZoomBorder);
1782
                                double width = dragZoomBorder.Width;
1783
                                double height = dragZoomBorder.Height;
1784
                                Rect dragRect = new Rect(x, y, width, height);
1785

    
1786
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1787

    
1788
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1789
                            }
1790

    
1791
                            isDraggingSelectionRect = false;
1792
                            e.Handled = true;
1793
                            wasDragSelectionApplied = true;
1794
                        }
1795

    
1796
                        if (isLeftMouseButtonDownOnWindow)
1797
                        {
1798
                            isLeftMouseButtonDownOnWindow = false;
1799
                            this.ReleaseMouseCapture();
1800
                            e.Handled = true;
1801
                        }
1802

    
1803
                        if (!wasDragSelectionApplied)
1804
                        {
1805
                            init();
1806
                        }
1807
                    }
1808
                }
1809
                else if (e.RightButton == MouseButtonState.Pressed)
1810
                {
1811
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1812
                    SetCursor();
1813
                }
1814

    
1815
                zoomAndPanControl.ReleaseMouseCapture();
1816

    
1817

    
1818
                e.Handled = true;
1819
            }
1820
            else
1821
            {
1822
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1823
                SetCursor();
1824
            }
1825

    
1826
            ///mouseButtonDown = MouseButton.Left;
1827
            //controlType = ControlType.SingleLine;
1828
        }
1829

    
1830
        public void Set_Symbol_Capture(Point endPoint)
1831
        {       
1832
            double x = canvasDrawingMouseDownPoint.X;
1833
            double y = canvasDrawingMouseDownPoint.Y;
1834
            if(x > endPoint.X)
1835
            {
1836
                x = endPoint.X;
1837
                y = endPoint.Y;
1838
            }
1839

    
1840
            double width = dragCaptureBorder.Width;
1841
            double height = dragCaptureBorder.Height;
1842

    
1843
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1844

    
1845
            if (x < 0)
1846
            {
1847
                width += x;
1848
                x = 0;
1849
            }
1850
            if (y < 0)
1851
            {
1852
                height += y;
1853
                y = 0;
1854

    
1855
                width = (int)canvasImage.PixelWidth - x;
1856
            }
1857
            if (x + width > canvasImage.PixelWidth)
1858
            {
1859
                width = (int)canvasImage.PixelWidth - x;
1860
            }
1861
            if (y + height > canvasImage.PixelHeight)
1862
            {
1863
                height = (int)canvasImage.PixelHeight - y;
1864
            }
1865
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1866

    
1867
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1868
            var defaultBitmapImage = new BitmapImage();
1869
            defaultBitmapImage.BeginInit();
1870
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1871
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1872
            defaultBitmapImage.UriSource = new Uri(uri);
1873
            defaultBitmapImage.EndInit();
1874

    
1875
            //GC.Collect();
1876

    
1877
            if (defaultBitmapImage.IsDownloading)
1878
            {
1879
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1880
                {
1881
                    defaultBitmapImage.Freeze();
1882
                    //GC.Collect();
1883
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1884
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1885
                };
1886
            }
1887
        }
1888

    
1889
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1890
        {
1891
            ///mouseButtonDown = MouseButton.Left;
1892
        }
1893

    
1894
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1895
        {
1896
            ///mouseButtonDown = MouseButton.Left;
1897
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1898
        }
1899

    
1900
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1901
        {
1902

    
1903
        }
1904

    
1905
        /// <summary>
1906
        /// select items by dragging
1907
        /// </summary>
1908
        private void ApplyDragSelectionRect()
1909
        {
1910
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1911

    
1912
            double x = Canvas.GetLeft(dragSelectionBorder);
1913
            double y = Canvas.GetTop(dragSelectionBorder);
1914
            double width = dragSelectionBorder.Width;
1915
            double height = dragSelectionBorder.Height;
1916
            Boolean Flag = false;
1917
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1918
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1919

    
1920
            Rect dragRect = new Rect(x, y, width, height);
1921
            ///dragRect.Inflate(width / 10, height / 10);
1922

    
1923
            foreach (var item in Items)
1924
            {
1925
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1926

    
1927
                if (Flag)
1928
                {
1929
                    adornerSet.Add(item);
1930
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1931
                    Control_Style(item);
1932
                }
1933
            }
1934
            if (adornerSet.Count > 0)
1935
            {
1936
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1937
                SelectLayer.Children.Add(final);
1938
            }
1939
        }
1940

    
1941
        private void InitDragSelectionRect(Point pt1, Point pt2)
1942
        {
1943
            //캡쳐 중
1944
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1945
            {
1946
                dragCaptureBorder.Visibility = Visibility.Visible;
1947
            }
1948
            //선택 중
1949
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1950
            {
1951

    
1952
                dragSelectionBorder.Visibility = Visibility.Visible;
1953
            }
1954
            else
1955
            {
1956
                dragZoomBorder.Visibility = Visibility.Visible;
1957
            }
1958
            UpdateDragSelectionRect(pt1, pt2);
1959
        }
1960

    
1961
        /// <summary>
1962
        /// Update the position and size of the rectangle used for drag selection.
1963
        /// </summary>
1964
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1965
        {
1966
            double x, y, width, height;
1967

    
1968
            //
1969
            // Determine x,y,width and height of the rect inverting the points if necessary.
1970
            // 
1971

    
1972
            if (pt2.X < pt1.X)
1973
            {
1974
                x = pt2.X;
1975
                width = pt1.X - pt2.X;
1976
            }
1977
            else
1978
            {
1979
                x = pt1.X;
1980
                width = pt2.X - pt1.X;
1981
            }
1982

    
1983
            if (pt2.Y < pt1.Y)
1984
            {
1985
                y = pt2.Y;
1986
                height = pt1.Y - pt2.Y;
1987
            }
1988
            else
1989
            {
1990
                y = pt1.Y;
1991
                height = pt2.Y - pt1.Y;
1992
            }
1993

    
1994
            //
1995
            // Update the coordinates of the rectangle used for drag selection.
1996
            //
1997
            //캡쳐 중
1998
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1999
            {
2000
                Canvas.SetLeft(dragCaptureBorder, x);
2001
                Canvas.SetTop(dragCaptureBorder, y);
2002
                dragCaptureBorder.Width = width;
2003
                dragCaptureBorder.Height = height;
2004
            }
2005
            //선택 중
2006
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2007
            {
2008
                Canvas.SetLeft(dragSelectionBorder, x);
2009
                Canvas.SetTop(dragSelectionBorder, y);
2010
                dragSelectionBorder.Width = width;
2011
                dragSelectionBorder.Height = height;
2012
            }
2013
            else
2014
            {
2015
                Canvas.SetLeft(dragZoomBorder, x);
2016
                Canvas.SetTop(dragZoomBorder, y);
2017
                dragZoomBorder.Width = width;
2018
                dragZoomBorder.Height = height;
2019
            }
2020
        }
2021

    
2022
        private void drawingPannelRotate(double angle)
2023
        {
2024
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2025
            rotate.Angle = angle;
2026
            var rotationNum = Math.Abs((rotate.Angle / 90));
2027

    
2028
            if (angle == 90 || angle == 270)
2029
            {
2030
                double emptySize = zoomAndPanCanvas.Width;
2031
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2032
                zoomAndPanCanvas.Height = emptySize;
2033
            }
2034
            if (angle == 0)
2035
            {
2036
                translate.X = 0;
2037
                translate.Y = 0;
2038
            }
2039
            else if (angle == 90)
2040
            {
2041
                translate.X = zoomAndPanCanvas.Width;
2042
                translate.Y = 0;
2043
            }
2044
            else if (angle == 180)
2045
            {
2046
                translate.X = zoomAndPanCanvas.Width;
2047
                translate.Y = zoomAndPanCanvas.Height;
2048
            }
2049
            else
2050
            {
2051
                translate.X = 0;
2052
                translate.Y = zoomAndPanCanvas.Height;
2053
            }
2054

    
2055
            zoomAndPanControl.RotationAngle = rotate.Angle;
2056

    
2057

    
2058
            if (!testPanel2.IsHidden)
2059
            {
2060
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2061
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2062
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2063
            }
2064

    
2065
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2066
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2067
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2068
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2069
            ViewerDataModel.Instance.Angle = rotate.Angle;
2070
        }
2071

    
2072
        private void syncPannelRotate(double angle)
2073
        {
2074
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2075
            rotate.Angle = angle;
2076
            var rotationNum = Math.Abs((rotate.Angle / 90));
2077

    
2078
            if (angle == 90 || angle == 270)
2079
            {
2080
                double emptySize = zoomAndPanCanvas2.Width;
2081
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2082
                zoomAndPanCanvas2.Height = emptySize;
2083
            }
2084
            if (angle == 0)
2085
            {
2086
                translate2.X = 0;
2087
                translate2.Y = 0;
2088
            }
2089
            else if (angle == 90)
2090
            {
2091
                translate2.X = zoomAndPanCanvas2.Width;
2092
                translate2.Y = 0;
2093
            }
2094
            else if (angle == 180)
2095
            {
2096
                translate2.X = zoomAndPanCanvas2.Width;
2097
                translate2.Y = zoomAndPanCanvas2.Height;
2098
            }
2099
            else
2100
            {
2101
                translate2.X = 0;
2102
                translate2.Y = zoomAndPanCanvas2.Height;
2103
            }
2104

    
2105
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2106
        }
2107

    
2108
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2109
        {
2110
            string Data_ = "";
2111

    
2112
            try
2113
            {
2114
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2115
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2116
                if (Data_ != null || Data_ != "")
2117
                {
2118
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2119
                }
2120
                else
2121
                {
2122
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2123
                }
2124

    
2125
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2126
                //{
2127
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2128
                //    STATE = 0,
2129
                //};
2130
                if (Data_ != null)
2131
                {
2132
                    Image img = new Image();
2133
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2134
                    if (Data_.Contains(".svg"))
2135
                    {
2136
                        byte[] imageData = null;
2137
                        DrawingImage image = null;
2138
                        using (System.Net.WebClient web = new System.Net.WebClient())
2139
                        {
2140
                            imageData = web.DownloadData(new Uri(Data_));
2141
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2142
                            image = SvgReader.Load(stream);
2143
                        }
2144
                        img.Source = image;
2145
                    }
2146
                    else
2147
                    {
2148
                        img.Source = new BitmapImage(new Uri(Data_));
2149
                    }
2150

    
2151
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2152
                    {
2153
                        PointSet = new List<Point>(),
2154
                        FilePath = Data_,
2155
                        ImageData = img.Source,
2156
                        StartPoint = canvasZoomPanningMouseDownPoint,
2157
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2158
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2159
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2160
                        canvasZoomPanningMouseDownPoint.Y),
2161
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2162
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2163
                    };
2164

    
2165
                    currentControl.PointSet = new List<Point>
2166
                                        {
2167
                                            currentControl.StartPoint,
2168
                                            currentControl.LeftBottomPoint,
2169
                                            currentControl.EndPoint,
2170
                                            currentControl.TopRightPoint,
2171
                                        };
2172
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2173
                    UndoData = new Undo_data()
2174
                    {
2175
                        IsUndo = false,
2176
                        Event = Event_Type.Create,
2177
                        EventTime = DateTime.Now,
2178
                        Markup_List = new List<Multi_Undo_data>()
2179
                    };
2180
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2181
                    {
2182
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2183
                    });
2184

    
2185
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2186
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2187
                    UndoData.Markup_List.Add(multi_Undo_Data);
2188
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2189

    
2190
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2191
                    currentControl.CommentID = Commons.shortGuid();
2192
                    currentControl.SymbolID = id;
2193
                    currentControl.GroupID = group_id;
2194
                    currentControl.ApplyTemplate();
2195
                    currentControl.SetImage();
2196

    
2197
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2198
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2199
                    SelectLayer.Children.Add(final);
2200
                }
2201
            }
2202
            catch (Exception ex)
2203
            {
2204
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2205
            }
2206
        }
2207

    
2208
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2209
        {            
2210
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2211
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2212
            {
2213
                set_option.Value = double.Parse(set_option.ContentText);
2214
                //set_option.Focusable = false;
2215
                zoomAndPanControl.Focus();
2216
            }
2217

    
2218
            ConvertInkControlToPolygon();
2219

    
2220
            ///TODO:
2221
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2222
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2223

    
2224
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2225
            {
2226
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2227
            }
2228
            /// up to here
2229

    
2230
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2231
            {
2232
                if (item as ArrowTextControl != null)
2233
                {
2234
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2235
                }
2236
                else if (item as TextControl != null)
2237
                {
2238
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2239
                }
2240
            }
2241

    
2242
            //if (currentControl != null)
2243
            {
2244
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2245
                if (text_item_ != null)
2246
                {
2247
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2248
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2249
                    (text_item_ as TextControl).IsEditingMode = false;                    
2250
                    currentControl = null;
2251
                }
2252

    
2253
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2254
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2255
                {
2256
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2257
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2258
                    currentControl = null;
2259
                }
2260
            }
2261

    
2262
            double Ang = 0;                                          
2263
            if (rotate.Angle != 0)
2264
            {
2265
                Ang = 360 - rotate.Angle;
2266
            }
2267

    
2268
            if (e.OriginalSource is System.Windows.Controls.Image)
2269
            {
2270
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2271
            }
2272
            /*
2273
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2274
            {                
2275
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2276
                if(symbol_id != null)
2277
                {
2278
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2279
                }                
2280
            }
2281

    
2282
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2283
            {
2284
                if (this._dragdropWindow != null)
2285
                {
2286
                    this._dragdropWindow.Close();
2287
                    this._dragdropWindow = null;
2288
                    symbol_id = null;
2289
                }
2290
            }
2291
            */
2292

    
2293
            if (e.LeftButton == MouseButtonState.Pressed)
2294
            {
2295
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2296
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2297

    
2298
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2299
                SetCursor();
2300

    
2301
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2302
            }
2303

    
2304
            if (e.MiddleButton == MouseButtonState.Pressed)
2305
            {
2306
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2307
                cursor = Cursors.SizeAll;
2308
                SetCursor();
2309
            }
2310
            if (e.RightButton == MouseButtonState.Pressed)
2311
            {
2312
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2313
                cursor = Cursors.SizeAll;
2314
                SetCursor();
2315
            }
2316
            else if (e.XButton1 == MouseButtonState.Pressed)
2317
            {
2318
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2319
                {
2320
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2321
                }
2322

    
2323
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2324

    
2325
            }
2326
            else if (e.XButton2 == MouseButtonState.Pressed)
2327
            {
2328
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2329
                {
2330
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2331
                }
2332
            }
2333

    
2334
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2335
            {
2336
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2337
                {
2338
                    if (SelectLayer.Children.Count == 0)
2339
                    {
2340
                        isLeftMouseButtonDownOnWindow = true;
2341
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2342
                    }
2343

    
2344
                    if (controlType == ControlType.None)
2345
                    {
2346
                        isLeftMouseButtonDownOnWindow = true;
2347
                    }
2348
                }
2349

    
2350
                /// 캡쳐 모드 설정
2351
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2352
                {
2353
                    dragCaptureBorder.Visibility = Visibility.Visible;
2354
                    isLeftMouseButtonDownOnWindow = true;
2355
                }
2356

    
2357
                /// 줌 모드 설정
2358
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2359
                {
2360
                    isLeftMouseButtonDownOnWindow = true;
2361
                }
2362

    
2363
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2364
                if (control != null)
2365
                {
2366
                    AdornerFinal final = null;
2367

    
2368
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2369
                    {
2370
                        /// 기존 selection 해제
2371
                        SelectionSet.Instance.UnSelect(this);
2372

    
2373
                        final = new AdornerFinal(control);
2374

    
2375
                        this.Control_Style(control);
2376

    
2377
                        if ((control as IPath) != null)
2378
                        {
2379
                            if ((control as IPath).LineSize != 0)
2380
                            {
2381
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2382
                            }
2383
                        }
2384
                        if ((control as IShapeControl) != null)
2385
                        {
2386
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2387
                            {
2388
                                ViewerDataModel.Instance.checkHatchShape = true;
2389
                            }
2390
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2391
                            {
2392
                                ViewerDataModel.Instance.checkFillShape = true;
2393
                            }
2394
                            else
2395
                            {
2396
                                ViewerDataModel.Instance.checkHatchShape = false;
2397
                                ViewerDataModel.Instance.checkFillShape = false;
2398
                            }
2399
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2400
                        }
2401

    
2402
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2403

    
2404
                        if ((control as TextControl) != null)
2405
                        {
2406
                            if(!((control as TextControl).EnableEditing)) {
2407
                                (control as TextControl).EnableEditing = true;
2408
                            }
2409
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2410
                            {
2411
                                ViewerDataModel.Instance.checkTextStyle = true;
2412
                            }
2413
                            else
2414
                            {
2415
                                ViewerDataModel.Instance.checkTextStyle = false;
2416
                            }
2417
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2418
                            {
2419
                                ViewerDataModel.Instance.checkTextWeight = true;
2420
                            }
2421
                            else
2422
                            {
2423
                                ViewerDataModel.Instance.checkTextWeight = false;
2424
                            }
2425
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2426
                            {
2427
                                ViewerDataModel.Instance.checkUnderLine = true;
2428
                            }
2429
                            else
2430
                            {
2431
                                ViewerDataModel.Instance.checkUnderLine = false;
2432
                            }
2433
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2434
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2435

    
2436
                        }
2437
                        else if ((control as ArrowTextControl) != null)
2438
                        {
2439
                            if (!((control as ArrowTextControl).EnableEditing))
2440
                            {
2441
                                (control as ArrowTextControl).EnableEditing = true;
2442
                            }
2443
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2444
                            {
2445
                                ViewerDataModel.Instance.checkTextStyle = true;
2446
                            }
2447
                            else
2448
                            {
2449
                                ViewerDataModel.Instance.checkTextStyle = false;
2450
                            }
2451
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2452
                            {
2453
                                ViewerDataModel.Instance.checkTextWeight = true;
2454
                            }
2455
                            else
2456
                            {
2457
                                ViewerDataModel.Instance.checkTextWeight = false;
2458
                            }
2459
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2460
                            {
2461
                                ViewerDataModel.Instance.checkUnderLine = true;
2462
                            }
2463
                            else
2464
                            {
2465
                                ViewerDataModel.Instance.checkUnderLine = false;
2466
                            }
2467
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2468
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2469
                        }
2470
                        else if ((control as RectCloudControl) != null)
2471
                        {
2472
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2473
                        }
2474
                        else if ((control as CloudControl) != null)
2475
                        {
2476
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2477
                        }
2478
                    }
2479
                    else
2480
                    {
2481
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2482
                        SelectionSet.Instance.UnSelect(this);
2483
                        comment.Add(control);
2484

    
2485
                        Control_Style(control);
2486

    
2487
                        final = new AdornerFinal(comment);
2488
                    }
2489

    
2490
                    if (final != null)
2491
                    {
2492
                        this.SelectLayer.Children.Add(final);
2493
                    }
2494
                }              
2495
            }
2496
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2497
            {               
2498
                init();
2499
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2500
                if (cursor != Cursors.SizeAll)
2501
                {
2502
                    cursor = Cursors.Cross;
2503
                    SetCursor();
2504
                }
2505
                bool init_user = false;
2506
                foreach (var user in gridViewMarkup.Items)
2507
                {
2508
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2509
                    {
2510
                        init_user = true;
2511
                    }
2512
                }
2513
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2514
                {
2515
                    RadWindow.Alert(new DialogParameters
2516
                    {
2517
                        Owner = Application.Current.MainWindow,
2518
                        Theme = new VisualStudio2013Theme(),
2519
                        Header = "안내",
2520
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2521
                    });
2522
                    return;
2523
                }
2524
                else
2525
                {
2526
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2527
                    if (item != null)
2528
                    {
2529
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2530
                    }
2531
                }
2532

    
2533
                switch (controlType)
2534
                {
2535
                    case ControlType.Coordinate:
2536
                        {
2537
                            if (e.LeftButton == MouseButtonState.Pressed)
2538
                            {
2539
                                if (currentControl is CoordinateControl)
2540
                                {
2541
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2542
                                    {
2543
                                        return;
2544
                                    }
2545

    
2546
                                    CreateCommand.Instance.Execute(currentControl);
2547

    
2548
                                    currentControl = null;
2549
                                    this.cursor = Cursors.Arrow;
2550
                                }
2551
                                else
2552
                                {
2553
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2554
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2555
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2556
                                    {
2557
                                        currentControl = null;
2558
                                        this.cursor = Cursors.Arrow;
2559
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2560
                                        return;
2561
                                    }
2562
                                    else
2563
                                    {
2564
                                        currentControl = new CoordinateControl
2565
                                        {
2566
                                            Background = new SolidColorBrush(Colors.Black),
2567
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2568
                                            ControlType = ControlType.Coordinate
2569
                                        };
2570

    
2571
                                        currentControl.CommentID = Commons.shortGuid();
2572
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2573
                                        currentControl.IsNew = true;
2574

    
2575
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2576

    
2577
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2578
                                    }
2579
                                }
2580
                            }
2581
                        }
2582
                        break;
2583
                    case ControlType.InsideWhite:
2584
                        {
2585
                            if (e.LeftButton == MouseButtonState.Pressed)
2586
                            {
2587
                                if (currentControl is InsideWhiteControl)
2588
                                {
2589
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2590
                                    {
2591
                                        return;
2592
                                    }
2593

    
2594
                                    CreateCommand.Instance.Execute(currentControl);
2595

    
2596
                                    currentControl = null;
2597
                                    this.cursor = Cursors.Arrow;
2598
                                }
2599
                                else
2600
                                {
2601
                                    currentControl = new InsideWhiteControl
2602
                                    {
2603
                                        Background = new SolidColorBrush(Colors.Black),
2604
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2605
                                        ControlType = ControlType.InsideWhite
2606
                                    };
2607

    
2608
                                    currentControl.CommentID = Commons.shortGuid();
2609
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2610
                                    currentControl.IsNew = true;
2611
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2612

    
2613
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2614
                                }
2615
                            }
2616
                        }
2617
                        break;
2618
                    case ControlType.OverlapWhite:
2619
                        {
2620
                            if (e.LeftButton == MouseButtonState.Pressed)
2621
                            {
2622
                                if (currentControl is OverlapWhiteControl)
2623
                                {
2624
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2625
                                    {
2626
                                        return;
2627
                                    }
2628

    
2629
                                    CreateCommand.Instance.Execute(currentControl);
2630

    
2631
                                    currentControl = null;
2632
                                    this.cursor = Cursors.Arrow;
2633
                                }
2634
                                else
2635
                                {
2636
                                    currentControl = new OverlapWhiteControl
2637
                                    {
2638
                                        Background = new SolidColorBrush(Colors.Black),
2639
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2640
                                        ControlType = ControlType.OverlapWhite
2641
                                    };
2642

    
2643
                                    currentControl.CommentID = Commons.shortGuid();
2644
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2645
                                    currentControl.IsNew = true;
2646
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2647

    
2648
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2649
                                }
2650
                            }
2651
                        }
2652
                        break;
2653
                    case ControlType.ClipWhite:
2654
                        {
2655
                            if (e.LeftButton == MouseButtonState.Pressed)
2656
                            {
2657
                                if (currentControl is ClipWhiteControl)
2658
                                {
2659
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2660
                                    {
2661
                                        return;
2662
                                    }
2663

    
2664
                                    CreateCommand.Instance.Execute(currentControl);
2665

    
2666
                                    currentControl = null;
2667
                                    this.cursor = Cursors.Arrow;
2668
                                }
2669
                                else
2670
                                {
2671
                                    currentControl = new ClipWhiteControl
2672
                                    {
2673
                                        Background = new SolidColorBrush(Colors.Black),
2674
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2675
                                        ControlType = ControlType.ClipWhite
2676
                                    };
2677

    
2678
                                    currentControl.CommentID = Commons.shortGuid();
2679
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2680
                                    currentControl.IsNew = true;
2681
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2682

    
2683
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2684
                                }
2685
                            }
2686
                        }
2687
                        break;
2688
                    case ControlType.Rectangle:
2689
                        {
2690
                            if (e.LeftButton == MouseButtonState.Pressed)
2691
                            {
2692
                                if (currentControl is RectangleControl)
2693
                                {
2694
                                    //20180906 LJY TEST IsRotationDrawingEnable
2695
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2696
                                    {
2697
                                        return;
2698
                                    }
2699

    
2700
                                    CreateCommand.Instance.Execute(currentControl);
2701
                                    currentControl = null;
2702
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2703
                                }
2704
                                else
2705
                                {
2706
                                    currentControl = new RectangleControl
2707
                                    {
2708
                                        Background = new SolidColorBrush(Colors.Black),
2709
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2710
                                        ControlType = ControlType.Rectangle
2711
                                    };
2712

    
2713
                                    currentControl.CommentID = Commons.shortGuid();
2714
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2715
                                    currentControl.IsNew = true;
2716
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2717

    
2718
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2719
                                }
2720
                            }
2721
                        }
2722
                        break;
2723
                    case ControlType.RectCloud:
2724
                        {
2725
                            if (e.LeftButton == MouseButtonState.Pressed)
2726
                            {
2727
                                if (currentControl is RectCloudControl)
2728
                                {
2729
                                    //20180906 LJY TEST IsRotationDrawingEnable
2730
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2731
                                    {
2732
                                        return;
2733
                                    }
2734

    
2735
                                    CreateCommand.Instance.Execute(currentControl);
2736

    
2737
                                    currentControl = null;
2738
                                
2739
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2740
                                }
2741
                                else
2742
                                {
2743
                                    currentControl = new RectCloudControl
2744
                                    {
2745
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2746
                                        ControlType = ControlType.RectCloud,
2747
                                        Background = new SolidColorBrush(Colors.Black)
2748
                                    };
2749

    
2750
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2751
                                    currentControl.CommentID = Commons.shortGuid();
2752
                                    currentControl.IsNew = true;
2753
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2754
                                }
2755
                            }
2756
                        }
2757
                        break;
2758
                    case ControlType.Circle:
2759
                        {
2760
                            if (e.LeftButton == MouseButtonState.Pressed)
2761
                            {
2762
                                if (currentControl is CircleControl)
2763
                                {
2764
                                    //20180906 LJY TEST IsRotationDrawingEnable
2765
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2766
                                    {
2767
                                        return;
2768
                                    }
2769

    
2770
                                    CreateCommand.Instance.Execute(currentControl);
2771

    
2772
                                    currentControl = null;
2773
                                }
2774
                                else
2775
                                {
2776
                                    currentControl = new CircleControl
2777
                                    {
2778
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2779
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2780
                                        Background = new SolidColorBrush(Colors.Black)
2781
                                    };
2782

    
2783
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2784
                                    currentControl.CommentID = Commons.shortGuid();
2785
                                    currentControl.IsNew = true;
2786
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2787
                                }
2788
                            }
2789
                        }
2790
                        break;
2791
                    case ControlType.Triangle:
2792
                        {
2793
                            if (e.LeftButton == MouseButtonState.Pressed)
2794
                            {
2795
                                if (currentControl is TriControl)
2796
                                {
2797
                                    var content = currentControl as TriControl;
2798
                                    if (content.MidPoint == new Point(0, 0))
2799
                                    {
2800
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2801
                                    }
2802
                                    else
2803
                                    {
2804
                                        //20180906 LJY TEST IsRotationDrawingEnable
2805
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2806
                                        {
2807
                                            return;
2808
                                        }
2809

    
2810
                                        CreateCommand.Instance.Execute(currentControl);
2811

    
2812
                                        currentControl = null;
2813
                                    }
2814
                                }
2815
                                else
2816
                                {
2817
                                    currentControl = new TriControl
2818
                                    {
2819
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2820
                                        Background = new SolidColorBrush(Colors.Black),
2821
                                    };
2822

    
2823
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2824
                                    currentControl.CommentID = Commons.shortGuid();
2825
                                    currentControl.IsNew = true;
2826
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2827
                                }
2828
                            }
2829
                        }
2830
                        break;
2831
                    case ControlType.CancelLine:
2832
                    case ControlType.SingleLine:
2833
                    case ControlType.ArrowLine:
2834
                    case ControlType.TwinLine:
2835
                    case ControlType.DimLine:
2836
                        {
2837
                            if (e.LeftButton == MouseButtonState.Pressed)
2838
                            {
2839
                                if (currentControl is LineControl)
2840
                                {
2841
                                    //20180906 LJY TEST IsRotationDrawingEnable
2842
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2843
                                    {
2844
                                        return;
2845
                                    }
2846

    
2847
                                    CreateCommand.Instance.Execute(currentControl);
2848
                                    currentControl = null;
2849
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2850
                                }
2851
                                else
2852
                                {
2853
                                    currentControl = new LineControl
2854
                                    {
2855
                                        ControlType = this.controlType,
2856
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2857
                                        Background = new SolidColorBrush(Colors.Black)
2858
                                    };
2859

    
2860
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2861
                                    currentControl.CommentID = Commons.shortGuid();
2862
                                    currentControl.IsNew = true;
2863
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2864
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
2865
                                }
2866
                            }
2867
                        }
2868
                        break;
2869
                    case ControlType.PolygonControl:
2870
                        {
2871
                            if (currentControl is PolygonControl)
2872
                            {
2873
                                var control = currentControl as PolygonControl;
2874

    
2875
                                if (e.RightButton == MouseButtonState.Pressed)
2876
                                {
2877
                                    control.IsCompleted = true;
2878
                                }
2879

    
2880
                                if (!control.IsCompleted)
2881
                                {
2882
                                    control.PointSet.Add(control.EndPoint);
2883
                                }
2884
                                else
2885
                                {
2886
                                    //20180906 LJY TEST IsRotationDrawingEnable
2887
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2888
                                    {
2889
                                        return;
2890
                                    }
2891

    
2892
                                    var firstPoint = control.PointSet.First();
2893
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2894
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2895
                                    control.PointSet.Add(firstPoint);
2896

    
2897
                                    control.ApplyOverViewData();
2898

    
2899
                                    CreateCommand.Instance.Execute(currentControl);
2900
                                    control.UpdateControl();
2901
                                    currentControl = null;
2902
                                }
2903
                            }
2904
                            else
2905
                            {
2906
                                if (e.LeftButton == MouseButtonState.Pressed)
2907
                                {
2908
                                    currentControl = new PolygonControl
2909
                                    {
2910
                                        PointSet = new List<Point>(),
2911
                                    };
2912

    
2913
                                    var polygonControl = (currentControl as PolygonControl);
2914
                                    currentControl.CommentID = Commons.shortGuid();
2915
                                    currentControl.IsNew = true;
2916
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2917
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2918
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2919
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2920
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2921
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2922
                                    polygonControl.ApplyTemplate();
2923
                                    polygonControl.Visibility = Visibility.Visible;
2924
                                }
2925
                            }
2926
                        }
2927
                        break;
2928
                    case ControlType.ChainLine:
2929
                        {
2930
                            if (currentControl is PolygonControl)
2931
                            {
2932
                                var control = currentControl as PolygonControl;
2933

    
2934
                                if (e.RightButton == MouseButtonState.Pressed)
2935
                                {
2936
                                    //20180906 LJY TEST IsRotationDrawingEnable
2937
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2938
                                    {
2939
                                        return;
2940
                                    }
2941

    
2942
                                    CreateCommand.Instance.Execute(currentControl);
2943

    
2944
                                    currentControl = null;
2945
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2946
                                    return;
2947
                                }
2948

    
2949
                                if (!control.IsCompleted)
2950
                                {
2951
                                    control.PointSet.Add(control.EndPoint);
2952
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
2953
                                }
2954
                            }
2955
                            else
2956
                            {
2957
                                if (e.LeftButton == MouseButtonState.Pressed)
2958
                                {
2959
                                    MainAngle.Visibility = Visibility.Visible;
2960
                                    currentControl = new PolygonControl
2961
                                    {
2962
                                        PointSet = new List<Point>(),
2963
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2964
                                        ControlType = ControlType.ChainLine,
2965
                                        DashSize = ViewerDataModel.Instance.DashSize,
2966
                                        LineSize = ViewerDataModel.Instance.LineSize,
2967
                                        //PointC = new StylusPointSet()
2968
                                    };
2969

    
2970
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2971
                                    //{
2972
                                        var polygonControl = (currentControl as PolygonControl);
2973
                                        currentControl.CommentID = Commons.shortGuid();
2974
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2975
                                        currentControl.IsNew = true;
2976
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2977
                                        //currentControl.OnApplyTemplate();
2978
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2979
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2980
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2981
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2982
                                    //}
2983
                                }
2984
                            }
2985
                        }
2986
                        break;
2987
                    case ControlType.ArcLine:
2988
                        {
2989
                            if (e.LeftButton == MouseButtonState.Pressed)
2990
                            {
2991
                                if (currentControl is ArcControl)
2992
                                {
2993
                                    //20180906 LJY TEST IsRotationDrawingEnable
2994
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2995
                                    {
2996
                                        return;
2997
                                    }
2998

    
2999
                                    CreateCommand.Instance.Execute(currentControl);
3000

    
3001
                                    currentControl = null;
3002
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3003
                                }
3004
                                else
3005
                                {
3006
                                    currentControl = new ArcControl
3007
                                    {
3008
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3009
                                        Background = new SolidColorBrush(Colors.Black)
3010
                                    };
3011
                                    currentControl.CommentID = Commons.shortGuid();
3012
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3013
                                    currentControl.IsNew = true;
3014
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3015
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3016
                                }
3017
                            }
3018
                            else if (e.RightButton == MouseButtonState.Pressed)
3019
                            {
3020
                                if (currentControl != null)
3021
                                {
3022
                                    (currentControl as ArcControl).setClock();
3023
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3024
                                }
3025
                            }
3026
                        }
3027
                        break;
3028
                    case ControlType.ArcArrow:
3029
                        {
3030
                            if (e.LeftButton == MouseButtonState.Pressed)
3031
                            {
3032
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3033
                                //{
3034
                                if (currentControl is ArrowArcControl)
3035
                                {
3036
                                    //20180906 LJY TEST IsRotationDrawingEnable
3037
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3038
                                    {
3039
                                        return;
3040
                                    }
3041

    
3042
                                    CreateCommand.Instance.Execute(currentControl);
3043

    
3044
                                    currentControl = null;
3045
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3046
                                }
3047
                                else
3048
                                {
3049
                                    currentControl = new ArrowArcControl
3050
                                    {
3051
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3052
                                        Background = new SolidColorBrush(Colors.Black)
3053
                                    };
3054
                                    currentControl.CommentID = Commons.shortGuid();
3055
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3056
                                    currentControl.IsNew = true;
3057
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3058
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3059
                                }
3060
                                //}
3061
                            }
3062
                            else if (e.RightButton == MouseButtonState.Pressed)
3063
                            {
3064
                                if (currentControl != null)
3065
                                {
3066
                                    (currentControl as ArrowArcControl).setClock();
3067
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3068
                                    //(currentControl as ArcControl).ApplyTemplate();
3069
                                }
3070
                            }
3071
                        }
3072
                        break;
3073
                    case ControlType.ArrowMultiLine:
3074
                        {
3075
                            if (e.LeftButton == MouseButtonState.Pressed)
3076
                            {
3077
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3078
                                //{
3079

    
3080
                                    if (currentControl is ArrowControl_Multi)
3081
                                    {
3082
                                        var content = currentControl as ArrowControl_Multi;
3083
                                        if (content.MiddlePoint == new Point(0, 0))
3084
                                        {
3085
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3086
                                            {
3087
                                                content.MiddlePoint = content.EndPoint;
3088
                                            }
3089
                                            else
3090
                                            {
3091
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3092
                                            }
3093
                                        }
3094
                                        else
3095
                                        {
3096
                                            //20180906 LJY TEST IsRotationDrawingEnable
3097
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3098
                                            {
3099
                                                return;
3100
                                            }
3101

    
3102
                                            CreateCommand.Instance.Execute(currentControl);
3103

    
3104
                                            currentControl = null;
3105
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3106
                                        }
3107
                                    }
3108
                                    else
3109
                                    {
3110
                                        currentControl = new ArrowControl_Multi
3111
                                        {
3112
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3113
                                            Background = new SolidColorBrush(Colors.Black)
3114
                                        };
3115
                                        currentControl.CommentID = Commons.shortGuid();
3116
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3117
                                        currentControl.IsNew = true;
3118
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3119
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3120
                                    }
3121
                                //}
3122
                            }
3123
                        }
3124
                        break;
3125
                    case ControlType.PolygonCloud:
3126
                        {
3127
                            if (currentControl is CloudControl)
3128
                            {
3129
                                var control = currentControl as CloudControl;
3130
                                if (e.RightButton == MouseButtonState.Pressed)
3131
                                {
3132
                                    control.IsCompleted = true;
3133
                                }
3134

    
3135
                                if (!control.IsCompleted)
3136
                                {
3137
                                    control.PointSet.Add(control.EndPoint);
3138
                                }
3139
                                else
3140
                                {
3141
                                    //20180906 LJY TEST IsRotationDrawingEnable
3142
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3143
                                    {
3144
                                        return;
3145
                                    }
3146

    
3147
                                    CreateCommand.Instance.Execute(currentControl);
3148

    
3149
                                    control.isTransOn = true;
3150
                                    var firstPoint = control.PointSet.First();
3151

    
3152
                                    control.PointSet.Add(firstPoint);
3153
                                    control.DrawingCloud();
3154
                                    control.ApplyOverViewData();
3155

    
3156
                                    currentControl = null;
3157
                                }
3158
                            }
3159
                            else
3160
                            {
3161
                                if (e.LeftButton == MouseButtonState.Pressed)
3162
                                {
3163
                                    currentControl = new CloudControl
3164
                                    {
3165
                                        PointSet = new List<Point>(),
3166
                                        PointC = new StylusPointSet()
3167
                                    };
3168

    
3169
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3170
                                    //{
3171
                                        var polygonControl = (currentControl as CloudControl);
3172
                                        currentControl.CommentID = Commons.shortGuid();
3173
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3174
                                        currentControl.IsNew = true;
3175
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3176

    
3177
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3178
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3179
                                    
3180
                                    //}
3181
                                }
3182
                            }
3183
                        }
3184
                        break;
3185
                    case ControlType.ImgControl:
3186
                        {
3187
                            if (e.LeftButton == MouseButtonState.Pressed)
3188
                            {
3189
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3190
                                //{
3191
                                    if (currentControl is ImgControl)
3192
                                    {
3193
                                        //20180906 LJY TEST IsRotationDrawingEnable
3194
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3195
                                        {
3196
                                            return;
3197
                                        }
3198

    
3199
                                        CreateCommand.Instance.Execute(currentControl);
3200
                                        controlType = ControlType.ImgControl;
3201
                                        currentControl = null;
3202
                                    }
3203
                                    else
3204
                                    {
3205
                                        
3206
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3207
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3208
                                        {
3209
                                            Image img = new Image();
3210
                                            if (filename.Contains(".svg"))
3211
                                            {
3212
                                                byte[] imageData = null;
3213
                                                DrawingImage image = null;
3214
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3215
                                                {
3216
                                                    imageData = web.DownloadData(new Uri(filename));
3217
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3218
                                                    image = SvgReader.Load(stream);
3219
                                                }
3220
                                                img.Source = image;
3221
                                            }
3222
                                            else
3223
                                            {
3224
                                                img.Source = new BitmapImage(new Uri(filename));
3225
                                            }
3226

    
3227
                                            currentControl = new ImgControl
3228
                                            {
3229
                                                    Background = new SolidColorBrush(Colors.Black),
3230
                                                    PointSet = new List<Point>(),
3231
                                                    FilePath = filename,
3232
                                                    ImageData = img.Source,
3233
                                                    StartPoint = canvasDrawingMouseDownPoint,
3234
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3235
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3236
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3237
                                                    ControlType = ControlType.ImgControl
3238
                                                };
3239

    
3240
                                        
3241
                                                currentControl.CommentID = Commons.shortGuid();                                            
3242
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3243
                                                currentControl.IsNew = true;
3244
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3245

    
3246
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3247
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3248
                                    }
3249
                                    }
3250
                                //}
3251
                            }
3252
                        }
3253
                        break;
3254
                    case ControlType.Date:
3255
                        {
3256
                            if (e.LeftButton == MouseButtonState.Pressed)
3257
                            {
3258
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3259
                                //{
3260
                                    if (currentControl is DateControl)
3261
                                    {
3262
                                        //20180906 LJY TEST IsRotationDrawingEnable
3263
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3264
                                        {
3265
                                            return;
3266
                                        }
3267

    
3268
                                        CreateCommand.Instance.Execute(currentControl);
3269
                                        currentControl = null;
3270

    
3271
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3272
                                        {
3273
                                            controlType = ControlType.None;
3274
                                            IsSwingMode = false;
3275
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3276
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3277
                                            mouseHandlingMode = MouseHandlingMode.None;
3278
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3279
                                            txtBatch.Visibility = Visibility.Collapsed;
3280

    
3281
                                        }
3282
                                    }
3283
                                    else
3284
                                    {
3285
                                        currentControl = new DateControl
3286
                                        {
3287
                                            StartPoint = canvasDrawingMouseDownPoint,
3288
                                            Background = new SolidColorBrush(Colors.Black)
3289
                                        };
3290
                                        currentControl.CommentID = Commons.shortGuid();
3291
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3292
                                        currentControl.IsNew = true;
3293
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3294

    
3295
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3296
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3297
                                }
3298
                                //}
3299
                            }
3300
                        }
3301
                        break;
3302
                    case ControlType.TextControl:
3303
                        {
3304
                            if (e.LeftButton == MouseButtonState.Pressed)
3305
                            {
3306
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3307
                                {
3308
                                    currentControl = new TextControl
3309
                                    {
3310
                                        ControlType = controlType
3311
                                    };
3312
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3313
                                    currentControl.CommentID = Commons.shortGuid();
3314
                                    currentControl.IsNew = true;
3315
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3316
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3317
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3318

    
3319
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3320
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3321
                                    
3322
                                    (currentControl as TextControl).ControlType_No = 0;
3323
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3324
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3325
                                    (currentControl as TextControl).ApplyTemplate();
3326
                                    (currentControl as TextControl).Base_TextBox.Focus();
3327
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3328
                                    CreateCommand.Instance.Execute(currentControl);
3329
                                }
3330
                            }
3331
                        }
3332
                        break;
3333
                    case ControlType.TextBorder:
3334
                        {
3335
                            if (e.LeftButton == MouseButtonState.Pressed)
3336
                            {
3337
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3338
                                {
3339
                                    currentControl = new TextControl
3340
                                    {
3341
                                        ControlType = controlType
3342
                                    };
3343

    
3344
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3345
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3346
                                    currentControl.CommentID = Commons.shortGuid();
3347
                                    currentControl.IsNew = true;
3348
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3349
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3350
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3351
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3352
                                    
3353
                                    (currentControl as TextControl).ControlType_No = 1;
3354
                                    (currentControl as TextControl).CommentAngle = Ang;
3355
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3356
                                    (currentControl as TextControl).ApplyTemplate();
3357
                                    (currentControl as TextControl).Base_TextBox.Focus();
3358
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3359
                                    CreateCommand.Instance.Execute(currentControl);
3360
                                }
3361
                            }
3362
                        }
3363
                        break;
3364
                    case ControlType.TextCloud:
3365
                        {
3366
                            if (e.LeftButton == MouseButtonState.Pressed)
3367
                            {
3368
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3369
                                {
3370
                                    currentControl = new TextControl
3371
                                    {
3372
                                        ControlType = controlType
3373
                                    };
3374

    
3375
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3376
                                    currentControl.CommentID = Commons.shortGuid();
3377
                                    currentControl.IsNew = true;
3378
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3379
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3380

    
3381
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3382
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3383
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3384

    
3385
                                    (currentControl as TextControl).CommentAngle = Ang;
3386
                                    (currentControl as TextControl).ControlType_No = 2;
3387
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3388
                                    (currentControl as TextControl).ApplyTemplate();
3389
                                    (currentControl as TextControl).Base_TextBox.Focus();
3390
                                    CreateCommand.Instance.Execute(currentControl);
3391
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3392
                                    //currentControl = null;
3393
                                }
3394
                            }
3395
                        }
3396
                        break;
3397
                    case ControlType.ArrowTextControl:
3398
                         {
3399
                            if (e.LeftButton == MouseButtonState.Pressed)
3400
                            {
3401
                                if (currentControl is ArrowTextControl)
3402
                                {
3403
                                    //20180906 LJY TEST IsRotationDrawingEnable
3404
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3405
                                    {
3406
                                        return;
3407
                                    }
3408

    
3409
                                    CreateCommand.Instance.Execute(currentControl);
3410

    
3411
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3412
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3413
                                    (currentControl as ArrowTextControl).IsNew = false;
3414
                                    currentControl = null;
3415
                                }
3416
                                else
3417
                                {
3418
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3419
                                    //{
3420
                                        currentControl = new ArrowTextControl();
3421
                                        currentControl.CommentID = Commons.shortGuid();
3422
                                        currentControl.IsNew = true;
3423
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3424
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3425

    
3426
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3427
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3428
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3429
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3430
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3431

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

    
3435
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3436
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3437
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3438
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3439

    
3440
                                    
3441
                                    //}
3442
                                }
3443
                            }
3444
                        }
3445
                        break;
3446
                    case ControlType.ArrowTransTextControl:
3447
                        {
3448
                            if (e.LeftButton == MouseButtonState.Pressed)
3449
                            {
3450
                                if (currentControl is ArrowTextControl)
3451
                                {
3452
                                    //20180906 LJY TEST IsRotationDrawingEnable
3453
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3454
                                    {
3455
                                        return;
3456
                                    }
3457

    
3458
                                    CreateCommand.Instance.Execute(currentControl);
3459

    
3460
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3461
                                    
3462
                                    currentControl.IsNew = false;
3463
                                    currentControl = null;
3464
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3465
                                }
3466
                                else
3467
                                {
3468
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3469
                                    //{
3470
                                    currentControl = new ArrowTextControl()
3471
                                    {
3472
                                        ControlType = ControlType.ArrowTransTextControl
3473
                                    };
3474
                                    currentControl.CommentID = Commons.shortGuid();
3475
                                    currentControl.IsNew = true;
3476
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3477
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3478
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3479
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3480
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3481
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3482
                                    (currentControl as ArrowTextControl).isFixed = true;
3483
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3484

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

    
3488
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3489
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3490
                                    (currentControl as ArrowTextControl).isTrans = true;
3491
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3492
                                }
3493
                            }
3494
                        }
3495
                        break;
3496
                    case ControlType.ArrowTextBorderControl:
3497
                         {
3498
                            if (e.LeftButton == MouseButtonState.Pressed)
3499
                            {
3500
                                if (currentControl is ArrowTextControl)
3501
                                {
3502
                                    //20180906 LJY TEST IsRotationDrawingEnable
3503
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3504
                                    {
3505
                                        return;
3506
                                    }
3507

    
3508
                                    CreateCommand.Instance.Execute(currentControl);
3509
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3510
                                    currentControl.IsNew = false;
3511
                                    currentControl = null;
3512
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3513
                                }
3514
                                else
3515
                                {
3516
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3517
                                    //{
3518
                                        currentControl = new ArrowTextControl()
3519
                                        {
3520
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3521
                                        };
3522
                                        currentControl.CommentID = Commons.shortGuid();
3523
                                        currentControl.IsNew = true;
3524
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3525
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3526

    
3527
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3528

    
3529
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3530

    
3531
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3532
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3533
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3534
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3535
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3536
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3537
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3538
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3539
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                    
3540
                                    //}
3541
                                }
3542
                            }
3543
                        }
3544
                        break;
3545
                    case ControlType.ArrowTransTextBorderControl:
3546
                        {
3547
                            if (e.LeftButton == MouseButtonState.Pressed)
3548
                            {
3549
                                if (currentControl is ArrowTextControl)
3550
                                {
3551
                                    //20180906 LJY TEST IsRotationDrawingEnable
3552
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3553
                                    {
3554
                                        return;
3555
                                    }
3556
                                    CreateCommand.Instance.Execute(currentControl);
3557
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3558
                                    currentControl.IsNew = false;
3559
                                    currentControl = null;
3560

    
3561
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3562
                                }
3563
                                else
3564
                                {
3565
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3566
                                    //{
3567
                                    
3568

    
3569
                                    currentControl = new ArrowTextControl()
3570
                                    {
3571
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3572
                                        ControlType = ControlType.ArrowTransTextBorderControl
3573

    
3574
                                    };
3575
                                        currentControl.CommentID = Commons.shortGuid();
3576
                                        currentControl.IsNew = true;
3577
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3578
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3579

    
3580
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3581

    
3582
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3583
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3584
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3585
                                        (currentControl as ArrowTextControl).isFixed = true;
3586
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3587
                                     
3588
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3589
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3590
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3591
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3592
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3593
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3594
                                    
3595
                                    //20180911 LJY
3596
                                        (currentControl as ArrowTextControl).isTrans = true;
3597
                                    
3598

    
3599
                                    //}
3600
                                }
3601
                            }
3602
                        }
3603
                        break;
3604
                    case ControlType.ArrowTextCloudControl:
3605
                        {
3606
                            if (e.LeftButton == MouseButtonState.Pressed)
3607
                            {
3608
                                if (currentControl is ArrowTextControl)
3609
                                {
3610
                                    //20180906 LJY TEST IsRotationDrawingEnable
3611
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3612
                                    {
3613
                                        return;
3614
                                    }
3615
                                    CreateCommand.Instance.Execute(currentControl);
3616
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3617
                                    currentControl.IsNew = false;
3618
                                    currentControl = null;
3619
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3620
                                }
3621
                                else
3622
                                {
3623
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3624
                                    //{
3625
                                        currentControl = new ArrowTextControl()
3626
                                        {
3627
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3628
                                        };
3629
                                        currentControl.CommentID = Commons.shortGuid();
3630
                                        currentControl.IsNew = true;
3631
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3632
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3633

    
3634
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3635
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3636
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3637
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3638
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3639
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3640
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3641
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3642
                                    
3643
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3644
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3645
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                        
3646
                                    //}
3647
                                }
3648
                            }
3649
                        }
3650
                        break;
3651
                    case ControlType.ArrowTransTextCloudControl:
3652
                        {
3653
                            if (e.LeftButton == MouseButtonState.Pressed)
3654
                            {
3655
                                if (currentControl is ArrowTextControl)
3656
                                {
3657
                                    //20180906 LJY TEST IsRotationDrawingEnable
3658
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3659
                                    {
3660
                                        return;
3661
                                    }
3662
                                    CreateCommand.Instance.Execute(currentControl);
3663
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3664
                                    currentControl.IsNew = false;
3665
                                    currentControl = null;
3666
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3667
                                }
3668
                                else
3669
                                {
3670
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3671
                                    //{
3672
                                        currentControl = new ArrowTextControl()
3673
                                        {
3674
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3675
                                            ControlType = ControlType.ArrowTransTextCloudControl
3676

    
3677
                                        };
3678
                                        currentControl.CommentID = Commons.shortGuid();
3679
                                        currentControl.IsNew = true; 
3680
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3681
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3682
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3683

    
3684
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3685
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3686
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3687
                                        (currentControl as ArrowTextControl).isFixed = true;
3688
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3689

    
3690
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3691
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3692
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3693
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3694
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3695
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;  
3696
                                    
3697
                                    //20180911 LJY
3698
                                        (currentControl as ArrowTextControl).isTrans = true;
3699
                                    //}
3700
                                }
3701
                            }
3702
                        }
3703
                        break;
3704
                    //강인구 추가
3705
                    case ControlType.Sign:
3706
                        {
3707
                            if (e.LeftButton == MouseButtonState.Pressed)
3708
                            {
3709
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3710
                                //{
3711
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3712

    
3713
                                    if (_sign == null)
3714
                                    {
3715
                                        txtBatch.Visibility = Visibility.Collapsed;
3716
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3717
                                        controlType = ControlType.None;
3718

    
3719
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3720
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3721
                                        return;
3722
                                    }
3723

    
3724
                                    if (currentControl is SignControl)
3725
                                    {
3726
                                        //20180906 LJY TEST IsRotationDrawingEnable
3727
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3728
                                        {
3729
                                            return;
3730
                                        }
3731

    
3732
                                        CreateCommand.Instance.Execute(currentControl);
3733
                                        currentControl = null;
3734
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3735
                                        {
3736
                                            txtBatch.Text = "Place Date";
3737
                                            controlType = ControlType.Date;
3738
                                        }
3739
                                    }
3740
                                    else
3741
                                    {
3742
                                        currentControl = new SignControl
3743
                                        {
3744
                                            Background = new SolidColorBrush(Colors.Black),
3745
                                            UserNumber = App.ViewInfo.UserID,
3746
                                            ProjectNO = App.ViewInfo.ProjectNO,
3747
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3748
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3749
                                            ControlType = ControlType.Sign
3750
                                        };
3751

    
3752
                                        currentControl.CommentID = Commons.shortGuid();
3753
                                        currentControl.IsNew = true;
3754
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3755
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3756

    
3757
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3758
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3759
                                }
3760
                                //}
3761
                            }
3762
                        }
3763
                        break;
3764
                    case ControlType.Mark:
3765
                        {
3766
                            if (e.LeftButton == MouseButtonState.Pressed)
3767
                            {
3768
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3769
                                //{
3770
                                    if (currentControl is RectangleControl)
3771
                                    {
3772
                                        //20180906 LJY TEST IsRotationDrawingEnable
3773
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3774
                                        {
3775
                                            return;
3776
                                        }
3777

    
3778
                                        CreateCommand.Instance.Execute(currentControl);
3779
                                        (currentControl as RectangleControl).ApplyOverViewData();
3780
                                        currentControl = null;
3781
                                    
3782
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3783

    
3784
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3785
                                        {
3786
                                            txtBatch.Text = "Place Signature";
3787
                                            controlType = ControlType.Sign;
3788
                                        }
3789
                                    }
3790
                                    else
3791
                                    {
3792
                                        currentControl = new RectangleControl
3793
                                        {
3794
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3795
                                            Background = new SolidColorBrush(Colors.Black),
3796
                                            ControlType = ControlType.Mark ,
3797
                                            Paint = PaintSet.Fill
3798
                                        };
3799

    
3800
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3801
                                        currentControl.CommentID = Commons.shortGuid();
3802
                                        currentControl.IsNew = true;
3803
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3804
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3805
                                    }
3806
                                //}
3807
                            }
3808
                        }
3809
                        break;
3810
                    case ControlType.Symbol:
3811
                        {
3812
                            if (e.LeftButton == MouseButtonState.Pressed)
3813
                            {
3814
                                if (currentControl is SymControl)
3815
                                {
3816
                                    //20180906 LJY TEST IsRotationDrawingEnable
3817
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3818
                                    {
3819
                                        return;
3820
                                    }
3821
                                    CreateCommand.Instance.Execute(currentControl);
3822
                                    currentControl = null;
3823
                                
3824
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3825
                                }
3826
                                else
3827
                                {
3828
                                    currentControl = new SymControl
3829
                                    {
3830
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3831
                                        Background = new SolidColorBrush(Colors.Black),
3832
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3833
                                        ControlType = ControlType.Symbol
3834
                                    };
3835

    
3836
                                    currentControl.IsNew = true;
3837
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3838
                                    currentControl.CommentID = Commons.shortGuid();
3839
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3840

    
3841
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3842
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3843
                                }
3844
                                //}
3845
                            }
3846
                        }
3847
                        break;
3848
                    case ControlType.Stamp:
3849
                        {
3850
                            if (e.LeftButton == MouseButtonState.Pressed)
3851
                            {
3852
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3853
                                //{
3854
                                    if (currentControl is SymControlN)
3855
                                    {
3856
                                        //20180906 LJY TEST IsRotationDrawingEnable
3857
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3858
                                        {
3859
                                            return;
3860
                                        }
3861

    
3862
                                        CreateCommand.Instance.Execute(currentControl);
3863
                                        currentControl = null;
3864
                                   
3865

    
3866
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3867
                                    }
3868
                                    else
3869
                                    {
3870
                                        currentControl = new SymControlN
3871
                                        {
3872
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3873
                                            Background = new SolidColorBrush(Colors.Black),
3874
                                            STAMP = App.SystemInfo.STAMP,                                            
3875
                                            ControlType = ControlType.Stamp
3876
                                        };
3877

    
3878
                                        currentControl.IsNew = true;
3879
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3880
                                        currentControl.CommentID = Commons.shortGuid();
3881
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3882
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3883
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
3884
                                }                                    
3885
                                //}
3886
                            }
3887
                        }
3888
                        break;
3889
                    case ControlType.PenControl:
3890
                        {
3891
                            if (inkBoard.Tag.ToString() == "Ink")
3892
                            {
3893
                                inkBoard.IsEnabled = true;
3894
                                StartNewStroke(canvasDrawingMouseDownPoint);
3895
                            }
3896
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3897
                            {
3898
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3899
                            }
3900
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3901
                            {
3902
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3903
                            }
3904
                            IsDrawing = true;
3905
                            return;
3906
                        }
3907
                    default:
3908
                        if (currentControl != null)
3909
                        {
3910
                            currentControl.CommentID = null;
3911
                            currentControl.IsNew = false;
3912
                        }
3913
                        break;
3914
                }
3915

    
3916
                if (currentControl != null)
3917
                {
3918
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
3919
                }
3920
            }
3921
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3922
            {
3923
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3924
                {
3925
                    bool mouseOff = false;
3926
                    foreach (var item in SelectLayer.Children)
3927
                    {
3928
                        if (item is AdornerFinal)
3929
                        {
3930

    
3931
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3932
                            if (over != null)
3933
                            {
3934
                                mouseOff = true;
3935
                            }
3936
                        }
3937
                    }
3938

    
3939
                    if (!mouseOff)
3940
                    {
3941
                        SelectionSet.Instance.UnSelect(this);
3942
                    }
3943
                }
3944
                zoomAndPanControl.CaptureMouse();
3945
                e.Handled = true;
3946
            }
3947
          
3948
        }
3949

    
3950
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3951
        {
3952
            ///mouseButtonDown = e.ChangedButton;
3953
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3954
        }
3955

    
3956
        private void RemoveLineStroke(Point P)
3957
        {
3958
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3959
            if (control != null)
3960
            {
3961
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3962
            }
3963
        }
3964

    
3965
        private void RemovePointStroke(Point P)
3966
        {
3967
            foreach (Stroke hits in inkBoard.Strokes)
3968
            {
3969
                foreach (StylusPoint sty in hits.StylusPoints)
3970
                {
3971

    
3972
                }
3973
                if (hits.HitTest(P))
3974
                {
3975
                    inkBoard.Strokes.Remove(hits);
3976
                    return;
3977
                }
3978
            }
3979
        }
3980

    
3981
        private void StartNewStroke(Point P)
3982
        {
3983
            strokePoints = new StylusPointCollection();
3984
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3985
            strokePoints.Add(segment1Start);
3986
            stroke = new Stroke(strokePoints);
3987

    
3988
            stroke.DrawingAttributes.Color = Colors.Red;
3989
            stroke.DrawingAttributes.Width = 4;
3990
            stroke.DrawingAttributes.Height = 4;
3991

    
3992
            inkBoard.Strokes.Add(stroke);
3993
        }
3994

    
3995
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3996
        {
3997
            ConsolidationMethod();
3998
        }
3999

    
4000
        /// <summary>
4001
        /// execute TeamConsolidationCommand
4002
        /// </summary>
4003
        public void TeamConsolidationMethod()
4004
        {
4005
            this.UpdateMyMarkupList();
4006
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4007
            {
4008
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4009
            }
4010
            else
4011
            {
4012

    
4013
                ViewerDataModel.Instance.IsConsolidate = true;
4014
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4015

    
4016
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4017
                {
4018
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4019
                    {
4020
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4021
                        return;
4022
                    }                    
4023
                }
4024
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4025
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4026
                {
4027
                    MarkupInfoList.Add(item);
4028
                }
4029
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4030
            }
4031
        }
4032

    
4033
        public void ConsolidationMethod()
4034
        {
4035
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4036
            {
4037
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4038
            }
4039
            else
4040
            {
4041
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4042
                foreach (var item in this.gridViewMarkup.SelectedItems)
4043
                {
4044
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4045
                }
4046
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4047
                
4048
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4049
            }
4050
        }
4051

    
4052
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4053
        {
4054
            if (App.ViewInfo != null)
4055
            {
4056
                btnConsolidate = (sender as RadRibbonButton);
4057
                if (!App.ViewInfo.NewCommentPermission)
4058
                {
4059
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4060
                }
4061
            }
4062
        }
4063

    
4064
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4065
        {
4066
            TeamConsolidationMethod();
4067
        }
4068

    
4069
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4070
        {
4071
            btnTeamConsolidate = sender as RadRibbonButton;
4072
            if (App.ViewInfo != null)
4073
            {
4074
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4075
                {
4076
                    if (btnConsolidate != null)
4077
                    {
4078
                        btnConsolidate.Visibility = Visibility.Collapsed;
4079
                    }
4080

    
4081
                    if (!App.ViewInfo.NewCommentPermission)
4082
                    {
4083
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4084
                    }
4085
                }
4086
                else
4087
                {
4088
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4089
                }
4090
            }
4091
        }
4092

    
4093
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4094
        {
4095
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4096
            if(item != null)
4097
            {
4098
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4099
                {
4100
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4101
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4102
                }
4103
                else
4104
                {
4105
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4106
                }
4107
            }else{
4108
                //Consolidate 가 없는 경우
4109
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4110
            }
4111
            
4112
        }
4113

    
4114
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4115
        {
4116
            btnFinalPDF = sender as RadRibbonButton;
4117
            if (App.ViewInfo != null)
4118
            {
4119
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4120
                {
4121
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4122
                    if (btnConsolidate != null)
4123
                    {
4124
                        btnConsolidate.Visibility = Visibility.Collapsed;
4125
                    }
4126
                }
4127
            }
4128
        }
4129

    
4130
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4131
        {
4132
            UpdateMyMarkupList();
4133

    
4134
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4135
            {
4136
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4137
            }
4138
            else
4139
            {
4140
                ViewerDataModel.Instance.IsConsolidate = true;
4141
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4142
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4143

    
4144
                string project_no = App.ViewInfo.ProjectNO;
4145
                string doc_id = _DocInfo.ID;
4146
                string user_id = App.ViewInfo.UserID;
4147
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4148
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4149
                {
4150
                    markupInfoItems.Add(item);
4151
                }
4152
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4153
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4154
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4155
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4156

    
4157
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4158
                if (item2 != null)
4159
                {
4160
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4161

    
4162
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4163
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4164
                }
4165
                else
4166
                {
4167
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4168
                }
4169
            }
4170
        }
4171

    
4172
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4173
        {
4174
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4175

    
4176
            if (App.ViewInfo != null)
4177
            {
4178
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4179
                {
4180
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4181
                }
4182
            }
4183
        }
4184

    
4185
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4186
        {
4187
            SetCompareRect();
4188
        }
4189

    
4190
        private void Sync_Click(object sender, RoutedEventArgs e)
4191
        {
4192
            if (Sync.IsChecked)
4193
            {
4194
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4195
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4196
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4197
            }
4198
        }
4199

    
4200
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4201
        {
4202
            if (UserList.IsChecked)
4203
            {
4204
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4205
            }
4206
            else
4207
            {
4208
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4209
            }
4210
        }
4211

    
4212
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4213
        {
4214

    
4215
            if (BalanceMode.IsChecked)
4216
            {
4217
                ViewerDataModel.Instance.PageBalanceMode = true;
4218
            }
4219
            else
4220
            {
4221
                ViewerDataModel.Instance.PageBalanceMode = false;
4222
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4223
            }
4224
        }
4225

    
4226
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4227
        {
4228
            //초기화
4229
            testPanel2.IsHidden = true;
4230
            ViewerDataModel.Instance.PageBalanceMode = false;
4231
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4232
            ViewerDataModel.Instance.PageNumber = 0;
4233
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4234
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4235
            UserList.IsChecked = false;
4236
            BalanceMode.IsChecked = false;
4237
        }
4238

    
4239
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4240
        {
4241
            if ((sender as System.Windows.Controls.Control).Tag != null)
4242
            {
4243
                //Compare 초기화
4244
                CompareMode.IsChecked = false;
4245
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4246

    
4247
                if (ViewerDataModel.Instance.PageNumber == 0)
4248
                {
4249
                    ViewerDataModel.Instance.PageNumber = 1;
4250
                }
4251

    
4252
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4253
                {
4254
                }
4255
                else
4256
                {
4257
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4258
                }
4259

    
4260
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4261
                {
4262

    
4263
                }
4264
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4265
                {
4266
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4267
                }
4268

    
4269
                if (!testPanel2.IsHidden)
4270
                {
4271
                    if (IsSyncPDFMode)
4272
                    {
4273
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4274
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4275

    
4276
                        if (pdfpath.IsDownloading)
4277
                        {
4278
                            pdfpath.DownloadCompleted += (ex, arg) =>
4279
                            {
4280
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4281
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4282
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4283
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4284
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4285
                            };
4286
                        }
4287
                        else
4288
                        {
4289
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4290
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4291
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4292

    
4293
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4294
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4295
                        }
4296

    
4297
                    }
4298
                    else
4299
                    {
4300
                        string uri = this.GetImageURL(_ViewInfo.ProjectNO, ViewerDataModel.Instance.PageNumber);
4301

    
4302
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4303

    
4304
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4305
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4306
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4307

    
4308
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4309
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4310

    
4311
                        if (defaultBitmapImage_Compare.IsDownloading)
4312
                        {
4313
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4314
                            {
4315
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4316
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4317
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4318

    
4319
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4320
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4321
                            };
4322
                        }
4323
                    }
4324

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

    
4329
                    foreach (var item in gridSelectionRevItem)
4330
                    {
4331
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4332
                        {
4333
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4334
                        });
4335
                    }
4336

    
4337
                    //강인구 추가
4338
                    zoomAndPanControl2.ZoomTo(new Rect
4339
                    {
4340
                        X = 0,
4341
                        Y = 0,
4342
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4343
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4344
                    });
4345

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

    
4348
                }
4349
            }
4350
        }
4351

    
4352
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4353
        {
4354
            if (MarkupMode.IsChecked)
4355
            {
4356
                IsSyncPDFMode = true;
4357

    
4358
                var uri = CurrentRev.TO_VENDOR;
4359

    
4360
                if (ViewerDataModel.Instance.PageNumber == 0)
4361
                {
4362
                    ViewerDataModel.Instance.PageNumber = 1;
4363
                }
4364

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

    
4369
                if (pdfpath.IsDownloading)
4370
                {
4371
                    pdfpath.DownloadCompleted += (ex, arg) =>
4372
                    {
4373
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4374
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4375
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4376
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4377
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4378
                    };
4379
                }
4380
                else
4381
                {
4382
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4383
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4384
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4385

    
4386
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4387
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4388
                }
4389
            }
4390
            else
4391
            {
4392
                IsSyncPDFMode = false;
4393
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4394

    
4395
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4396

    
4397
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4398
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4399
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4400

    
4401
                if (defaultBitmapImage_Compare.IsDownloading)
4402
                {
4403
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4404
                    {
4405
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4406
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4407
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4408
                    };
4409
                }
4410
                zoomAndPanControl2.ApplyTemplate();
4411
                zoomAndPanControl2.UpdateLayout();
4412
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4413
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4414
            }
4415
        }
4416

    
4417
        /// <summary>
4418
        /// Compare된 영역을 초기화
4419
        /// </summary>
4420
        private void ClearCompareRect()
4421
        {
4422
            da.From = 1;
4423
            da.To = 1;
4424
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4425
            da.AutoReverse = false;
4426
            canvas_compareBorder.Children.Clear();
4427
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4428
        }
4429

    
4430
        /// <summary>
4431
        /// 문서 Comprare 
4432
        /// </summary>
4433
        private void SetCompareRect()
4434
        {
4435
            if (CompareMode.IsChecked)
4436
            {
4437
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4438
                {
4439
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4440
                }
4441
                if (ViewerDataModel.Instance.PageNumber == 0)
4442
                {
4443
                    ViewerDataModel.Instance.PageNumber = 1;
4444
                }
4445

    
4446
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4447
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4448
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4449

    
4450
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4451
            }
4452
            else
4453
            {
4454
                ClearCompareRect();
4455
            }
4456
        }
4457

    
4458
        private void RadButton_Click(object sender, RoutedEventArgs e)
4459
        {
4460
            gridViewHistory_Busy.IsBusy = true;
4461

    
4462
            RadButton instance = sender as RadButton;
4463
            if (instance.CommandParameter != null)
4464
            {
4465
                CurrentRev = instance.CommandParameter as VPRevision;
4466
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4467

    
4468
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4469
                {
4470
                    if (ea.Error == null && ea.Result != null)
4471
                    {
4472
                        testPanel2.IsHidden = false;
4473

    
4474
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4475
                        foreach(var info in ea.Result)
4476
                        {
4477
                            if(info.UserID == App.ViewInfo.UserID)
4478
                            {
4479
                                info.userDelete = true;
4480
                                info.DisplayColor = "FFFF0000";
4481
                            }
4482
                            else
4483
                            {
4484
                                info.userDelete = false;
4485
                            }
4486
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4487
                        }
4488
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4489

    
4490
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4491

    
4492
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4493

    
4494
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4495
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4496
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4497
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4498
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4499
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4500

    
4501
                        zoomAndPanControl2.ApplyTemplate();
4502
                        zoomAndPanControl2.UpdateLayout();
4503
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4504
                        {
4505
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4506
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4507
                        }
4508

    
4509
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4510
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4511
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4512

    
4513
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4514
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4515
                        gridViewHistory_Busy.IsBusy = false;
4516
                    }
4517

    
4518
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4519

    
4520
                    if (GetSyncMarkupInfoItemshandler != null)
4521
                    {
4522
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4523
                    }
4524

    
4525
                    ClearCompareRect();
4526
                    SetCompareRect();
4527
                };
4528

    
4529
                /// 중복 실행이 발생하여 수정함.
4530
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4531
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4532

    
4533
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4534
            }
4535
        }
4536

    
4537
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4538
        {
4539
            try
4540
            {
4541
                if (sender is RadButton)
4542
                {
4543
                    if ((sender as RadButton).Tag != null)
4544
                    {
4545
                        var url = (sender as RadButton).Tag.ToString();
4546
                        System.Diagnostics.Process.Start(url);
4547
                    }
4548
                    else
4549
                    {
4550
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4551
                    }
4552
                }
4553
            }
4554
            catch (Exception ex)
4555
            {
4556
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4557
            }
4558
        }
4559

    
4560
        public void Sync_Event(VPRevision Currnet_Rev)
4561
        {
4562
            CurrentRev = Currnet_Rev;
4563

    
4564
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4565
            {
4566
                if (ea.Error == null && ea.Result != null)
4567
                {
4568
                    testPanel2.IsHidden = false;
4569

    
4570
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4571
                    foreach(var info in ea.Result)
4572
                    {
4573
                        if(info.UserID == App.ViewInfo.UserID)
4574
                        {
4575
                            info.userDelete = true;
4576
                            info.DisplayColor = "FFFF0000";
4577
                        }
4578
                        else
4579
                        {
4580
                            info.userDelete = false;
4581
                        }
4582
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4583
                    }
4584
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4585

    
4586
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4587

    
4588
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4589

    
4590
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4591

    
4592
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4593
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4594
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4595

    
4596
                    if (defaultBitmapImage_Compare.IsDownloading)
4597
                    {
4598
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4599
                        {
4600
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4601
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4602
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4603
                        };
4604
                    }
4605

    
4606

    
4607
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4608
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4609
                    zoomAndPanControl2.ApplyTemplate();
4610
                    zoomAndPanControl2.UpdateLayout();
4611

    
4612
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4613
                    {
4614
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4615
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4616
                    }
4617
                    //}
4618

    
4619
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4620
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4621
                    gridViewHistory_Busy.IsBusy = false;
4622
                }
4623
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4624

    
4625
            };
4626
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4627
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4628
        }
4629

    
4630
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4631
        {
4632
            if (sender is Image)
4633
            {
4634
                if ((sender as Image).Tag != null)
4635
                {
4636
                    var pdfUrl = (sender as Image).Tag.ToString();
4637
                    System.Diagnostics.Process.Start(pdfUrl);
4638
                }
4639
                else
4640
                {
4641
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4642
                }
4643
            }
4644
        }
4645

    
4646
        private void Create_Symbol(object sender, RoutedEventArgs e)
4647
        {
4648
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4649

    
4650
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4651
            {
4652
                DialogMessage_Alert("Please Select Controls", "Alert");
4653
            }
4654
            else //선택된 것이 있으면
4655
            {
4656
                string MarkupData = "";
4657
                adorner_ = new AdornerFinal();
4658

    
4659
                foreach (var item in SelectLayer.Children)
4660
                {
4661
                    if (item.GetType().Name == "AdornerFinal")
4662
                    {
4663
                        adorner_ = (item as Controls.AdornerFinal);
4664
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4665
                        {
4666
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4667
                            {
4668
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4669
                                MarkupData += markupReturn.ConvertData;
4670
                            }
4671
                        }
4672
                    }
4673
                }
4674
                DialogParameters parameters = new DialogParameters()
4675
                {
4676
                    Owner = Application.Current.MainWindow,
4677
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4678
                    DefaultPromptResultValue = "Custom State",
4679
                    Content = "Name :",
4680
                    Header = "Insert Custom Symbol Name",
4681
                    Theme = new VisualStudio2013Theme(),
4682
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4683
                };
4684
                RadWindow.Prompt(parameters);
4685
            }
4686

    
4687
        }
4688
        public int symbolselectindex = 0;
4689
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4690
        {
4691
            //Save save = new Save();
4692
            try
4693
            {
4694
                string svgfilename = null;
4695
                if (symbolname != null)
4696
                {
4697
                    if (symbolpng == true || symbolsvg == true)
4698
                    {
4699
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4700
                        string guid = Commons.shortGuid();
4701

    
4702
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4703
                        //Check_Uri.UriCheck();
4704
                        fileUploader.RunCompleted += (ex, arg) =>
4705
                        {
4706
                            filename = arg.Result;
4707
                            if (symbolpng == true)
4708
                            {
4709
                                if (filename != null)
4710
                                { 
4711
                                    if (symbolselectindex == 0)
4712
                                    {
4713
                                        SymbolSave(symbolname, filename, data);
4714
                                    }
4715
                                    else
4716
                                    {
4717
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4718
                                    }
4719
                                    DataBind();
4720
                                }                                
4721
                            }
4722

    
4723
                            if (symbolsvg == true)
4724
                            {
4725
                                try
4726
                                {
4727
                                    var defaultBitmapImage = new BitmapImage();
4728
                                    defaultBitmapImage.BeginInit();
4729
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4730
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4731
                                    Check_Uri.UriCheck(filename);
4732
                                    defaultBitmapImage.UriSource = new Uri(filename);
4733
                                    defaultBitmapImage.EndInit();
4734

    
4735
                                    System.Drawing.Bitmap image;
4736

    
4737
                                    if (defaultBitmapImage.IsDownloading)
4738
                                    {
4739
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4740
                                        {
4741
                                            defaultBitmapImage.Freeze();
4742
                                            image = GetBitmap(defaultBitmapImage);
4743
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4744
                                            Process potrace = new Process
4745
                                            {
4746
                                                StartInfo = new ProcessStartInfo
4747
                                                {
4748
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4749
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4750
                                                    RedirectStandardInput = true,
4751
                                                    RedirectStandardOutput = true,
4752
                                                    RedirectStandardError = true,
4753
                                                    UseShellExecute = false,
4754
                                                    CreateNoWindow = true,
4755
                                                    WindowStyle = ProcessWindowStyle.Hidden
4756
                                                },
4757
                                            };
4758

    
4759
                                            StringBuilder svgBuilder = new StringBuilder();
4760
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4761
                                            {
4762
                                                svgBuilder.AppendLine(e2.Data);
4763
                                            };
4764

    
4765
                                            potrace.EnableRaisingEvents = true;
4766
                                            potrace.Start();
4767
                                            potrace.Exited += (sender, e) =>
4768
                                            {
4769
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4770
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4771
                                                Check_Uri.UriCheck(svgfilename);
4772
                                                if (symbolselectindex == 0)
4773
                                                {
4774
                                                    SymbolSave(symbolname, svgfilename, data);
4775
                                                }
4776
                                                else
4777
                                                {
4778
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4779
                                                }
4780

    
4781
                                                DataBind();
4782
                                            };
4783
                                            potrace.WaitForExit();
4784
                                        };
4785
                                    }
4786
                                    else
4787
                                    {
4788
                                        //GC.Collect();
4789
                                    }
4790
                                }
4791
                                catch(Exception ee)
4792
                                {
4793
                                    DialogMessage_Alert("" + ee, "Alert");
4794
                                }
4795
                            }
4796
                        };                                             
4797
                    }
4798
                }
4799
            }
4800
            catch (Exception e)
4801
            {
4802
                //DialogMessage_Alert(e + "", "Alert");
4803
            }            
4804
        }
4805

    
4806
        public void SymbolSave(string Name, string Url, string Data)
4807
        {
4808
            try
4809
            {
4810
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4811
                {
4812
                    ID = Commons.shortGuid(),
4813
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4814
                    NAME = Name,
4815
                    IMAGE_URL = Url,
4816
                    DATA = Data
4817
                };
4818

    
4819
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4820
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4821
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4822
            }
4823
            catch (Exception)
4824
            {
4825
                throw;
4826
            }
4827
        }
4828

    
4829
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4830
        {
4831
            try
4832
            {
4833
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4834
                {
4835
                    ID = Commons.shortGuid(),
4836
                    DEPARTMENT = Department,
4837
                    NAME = Name,
4838
                    IMAGE_URL = Url,
4839
                    DATA = Data
4840
                };
4841
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4842
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4843
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4844
            }
4845
            catch (Exception)
4846
            {
4847
                throw;
4848
            }
4849
        }
4850

    
4851
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4852
        {           
4853
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4854
            DataBind();
4855
        }
4856

    
4857
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4858
        {
4859
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4860
            DataBind();
4861
        }
4862
        private void DataBind()
4863
        {
4864
            try
4865
            {
4866
                Symbol_Custom Custom = new Symbol_Custom();
4867
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4868
                
4869
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4870
                foreach (var item in symbol_Private)
4871
                {
4872
                    Custom.Name = item.NAME;
4873
                    Custom.ImageUri = item.IMAGE_URL;
4874
                    Custom.ID = item.ID;
4875
                    Custom_List.Add(Custom);
4876
                    Custom = new Symbol_Custom();
4877
                }
4878
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4879
                
4880
                Custom = new Symbol_Custom();
4881
                Custom_List = new List<Symbol_Custom>();
4882

    
4883
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4884

    
4885
                List<SYMBOL_PUBLIC> symbol_Public;
4886

    
4887
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4888
                {
4889
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4890
                }
4891
                else
4892
                {
4893
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4894
                }
4895
                foreach (var item in symbol_Public)
4896
                {
4897
                    Custom.Name = item.NAME;
4898
                    Custom.ImageUri = item.IMAGE_URL;
4899
                    Custom.ID = item.ID;
4900
                    Custom_List.Add(Custom);
4901
                    Custom = new Symbol_Custom();
4902
                }
4903
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4904
                BaseClient.Close();                
4905
            }
4906
            catch(Exception e)
4907
            {
4908
                //DialogMessage_Alert("DataBind", "Alert");
4909
            }
4910
            
4911
        }
4912
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4913
        {
4914
            try
4915
            {
4916
                if (args.PromptResult != null)
4917
                {
4918
                    if (args.DialogResult.Value)
4919
                    {
4920
                        PngBitmapEncoder _Encoder = symImage(data);
4921

    
4922
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4923
                        _Encoder.Save(fs);
4924
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4925

    
4926
                        byte[] Img_byte = fs.ToArray();
4927

    
4928
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4929
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4930
                        Check_Uri.UriCheck(filename);
4931
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4932
                        {
4933
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4934
                        }
4935
                        else
4936
                        {
4937
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4938
                        }
4939
                        DataBind();
4940
                    }
4941
                }
4942
            }
4943
            catch(Exception ex)
4944
            {
4945
                DialogMessage_Alert("" + ex, "Alert");
4946
            }
4947
        }
4948

    
4949
        public PngBitmapEncoder symImage(string data)
4950
        {
4951

    
4952
            Canvas _canvas = new Canvas();
4953
            _canvas.Background = Brushes.White;
4954
            _canvas.Width = adorner_.BorderSize.Width;
4955
            _canvas.Height = adorner_.BorderSize.Height;
4956
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4957

    
4958
            BitmapEncoder encoder = new PngBitmapEncoder();
4959

    
4960

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

    
4963
            DrawingVisual dv = new DrawingVisual();
4964

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

    
4968
            using (DrawingContext ctx = dv.RenderOpen())
4969
            {
4970
                VisualBrush vb = new VisualBrush(_canvas);
4971
                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)));
4972
            }
4973

    
4974
            try
4975
            {
4976
                renderBitmap.Render(dv);
4977

    
4978
                //GC.Collect();
4979
                GC.WaitForPendingFinalizers();
4980
                //GC.Collect();
4981
                // encode png data
4982
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4983
                // puch rendered bitmap into it
4984
                pngEncoder.Interlace = PngInterlaceOption.Off;
4985
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4986
                return pngEncoder;
4987

    
4988
            }
4989
            catch //(Exception ex)
4990
            {
4991
                return null;
4992
            }
4993

    
4994
        }
4995

    
4996
        public void DialogMessage_Alert(string content, string header)
4997
        {
4998
            DialogParameters parameters = new DialogParameters()
4999
            {
5000
                Owner = this.ParentOfType<MainWindow>(),
5001
                Content = new TextBlock()
5002
                { 
5003
                    MinWidth = 400,
5004
                    FontSize = 11,
5005
                    Text = content,
5006
                    TextWrapping = System.Windows.TextWrapping.Wrap
5007
                },
5008
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5009
                Header = header,
5010
                Theme = new VisualStudio2013Theme(),
5011
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5012
            };            
5013
            RadWindow.Alert(parameters);
5014
        }
5015

    
5016
        #region 캡쳐 기능
5017

    
5018
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5019
        {
5020
            if (x < 0)
5021
            {
5022
                width += x;
5023
                x = 0;
5024
            }
5025
            if (y < 0)
5026
            {
5027
                height += y;
5028
                y = 0;
5029

    
5030
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5031
            }
5032
            if (x + width > zoomAndPanCanvas.ActualWidth)
5033
            {
5034
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5035
            }
5036
            if (y + height > zoomAndPanCanvas.ActualHeight)
5037
            {
5038
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5039
            }
5040

    
5041
            byte[] pixels = CopyPixels(x, y, width, height);
5042

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

    
5045
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5046
        }
5047

    
5048
        public byte[] CopyPixels(int x, int y, int width, int height)
5049
        {
5050
            byte[] pixels = new byte[width * height * 4];
5051
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5052

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

    
5056
            return pixels;
5057
        }
5058

    
5059
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5060
        {
5061
            DrawingVisual drawingVisual = new DrawingVisual();
5062
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5063

    
5064
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5065
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5066
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5067
            drawingContext.Close();
5068

    
5069
            // 비트맵으로 변환합니다.
5070
            RenderTargetBitmap target =
5071
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5072
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5073

    
5074
            target.Render(drawingVisual);
5075
            return target;
5076
        }
5077

    
5078
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5079
        {
5080
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5081
            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);
5082
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5083
            bmp.UnlockBits(data);
5084
            return bmp;
5085
        }
5086
        public string symbolname = null;
5087
        public bool symbolsvg = true;
5088
        public bool symbolpng = true;
5089

    
5090
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5091
        {
5092
            System.Drawing.Bitmap image = GetBitmap(source);
5093
            //흰색 제거
5094
            //image.MakeTransparent(System.Drawing.Color.White);
5095

    
5096
            var imageStream = new System.IO.MemoryStream();
5097
            byte[] imageBytes = null;
5098
            using (imageStream)
5099
            {
5100
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5101
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5102
                imageStream.Position = 0;
5103
                imageBytes = imageStream.ToArray();
5104
            }
5105

    
5106
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5107

    
5108
            RadWindow CheckPop = new RadWindow();
5109
            //Alert check = new Alert(Msg);
5110

    
5111
            CheckPop = new RadWindow
5112
            {
5113
                MinWidth = 400,
5114
                MinHeight = 100,
5115
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5116
                Header = "Alert",
5117
                Content = symbolPrompt,
5118
                //DialogResult = 
5119
                ResizeMode = System.Windows.ResizeMode.NoResize,
5120
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5121
                IsTopmost = true,
5122
            };
5123
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5124
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5125
            CheckPop.ShowDialog();
5126

    
5127
            /*
5128
            DialogParameters parameters = new DialogParameters()
5129
            {
5130
                Owner = Application.Current.MainWindow,
5131
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5132
                DefaultPromptResultValue = "Custom State",
5133
                Content = "Name :",
5134
                Header = "Insert Custom Symbol Name",
5135
                Theme = new VisualStudio2013Theme(),
5136
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5137
            };            
5138
            RadWindow.Prompt(parameters);
5139
            */
5140
        }
5141

    
5142
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5143
        {
5144
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5145
            KCOMDataModel.DataModel.CHECK_LIST check_;
5146
            string Result = streamToBase64.ImageToBase64(source);
5147
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5148
            string projectno = App.ViewInfo.ProjectNO;
5149
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5150

    
5151
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5152
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5153
            if (Item != null)
5154
            {
5155
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5156
            }
5157
            else
5158
            {
5159
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5160
            }
5161

    
5162
            if (Item == null)
5163
            {
5164
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5165
                {
5166
                    ID = Commons.shortGuid(),
5167
                    USER_ID = App.ViewInfo.UserID,
5168
                    IMAGE_URL = Result,
5169
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5170
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5171
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5172
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5173
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5174
                    STATUS = "False",
5175
                    CREATE_TIME = DateTime.Now,
5176
                    UPDATE_TIME = DateTime.Now,
5177
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5178
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5179
                };
5180
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5181
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5182
                //this.BaseClient.AddCheckList(projectno, check_);
5183
            }
5184
            else
5185
            {
5186
                Item.IMAGE_URL = Result;
5187
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5188
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5189
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5190
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5191
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5192
            }
5193

    
5194
        }
5195

    
5196
        public void Set_Capture()
5197
        {
5198
            double x = canvasDrawingMouseDownPoint.X;
5199
            double y = canvasDrawingMouseDownPoint.Y;
5200
            double width = dragCaptureBorder.Width;
5201
            double height = dragCaptureBorder.Height;
5202

    
5203
            if (width > 5 || height > 5)
5204
            {
5205
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5206
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5207
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5208
            }
5209
        }
5210
        #endregion
5211

    
5212
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5213
        {
5214
            multi_Undo_Data = new Multi_Undo_data();
5215

    
5216
            multi_Undo_Data.Markup = control;
5217

    
5218
            if ((control as IShapeControl) != null)
5219
            {
5220
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5221
            }
5222
            if ((control as IDashControl) != null)
5223
            {
5224
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5225
            }
5226
            if ((control as IPath) != null)
5227
            {
5228
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5229
            }
5230
            if ((control as UIElement) != null)
5231
            {
5232
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5233
            }
5234

    
5235
            return multi_Undo_Data;
5236
        }
5237

    
5238
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5239
        {
5240
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5241
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5242
            {
5243
                if (items.UserID == Select_ID)
5244
                {
5245
                    foreach (var item in items.MarkupList)
5246
                    {
5247
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5248
                        {
5249
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5250
                                items.MarkupInfoID, Commons.shortGuid());
5251
                        }
5252
                    }
5253
                }
5254
            }
5255
        }
5256

    
5257
        /// <summary>
5258
        /// convert inkcontrol to polygoncontrol
5259
        /// </summary>
5260
        public void ConvertInkControlToPolygon()
5261
        {
5262
            if (inkBoard.Strokes.Count > 0)
5263
            {
5264
                inkBoard.Strokes.ToList().ForEach(stroke =>
5265
                {
5266
                    InkToPath ip = new InkToPath();
5267

    
5268
                    List<Point> inkPointSet = new List<Point>();
5269
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5270

    
5271
                    PolygonControl pc = new PolygonControl()
5272
                    {
5273
                        CommentAngle = 0,
5274
                        PointSet = inkPointSet,
5275
                        ControlType = ControlType.Ink
5276
                    };
5277
                    pc.StartPoint = inkPointSet[0];
5278
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5279
                    pc.LineSize = 3;
5280
                    pc.CommentID = Commons.shortGuid();
5281
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5282

    
5283
                    if (pc.PointSet.Count > 0)
5284
                    {
5285
                        CreateCommand.Instance.Execute(pc);
5286
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5287
                    }
5288
                });
5289
                inkBoard.Strokes.Clear();
5290
            }
5291
        }
5292

    
5293
        /// <summary>
5294
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5295
        /// </summary>
5296
        /// <author>ingu</author>
5297
        /// <date>2018.06.05</date>
5298
        /// <param name="getPoint"></param>
5299
        /// <returns></returns>
5300
        private bool IsGetoutpoint(Point getPoint)
5301
        {
5302
            if (getPoint == new Point())
5303
            {
5304
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5305
                currentControl = null;
5306
                return true;
5307
            }
5308

    
5309
            return false;
5310
        }
5311

    
5312
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5313
        {
5314
            e.Effects = DragDropEffects.Copy;
5315
        }
5316

    
5317
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5318
        {
5319
            e.Effects = DragDropEffects.Copy;
5320
        }
5321

    
5322
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5323
        {
5324
            e.Effects = DragDropEffects.None;
5325
        }
5326

    
5327
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5328
        {
5329
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5330
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5331

    
5332
            ScaleImage(pageWidth, pageHeight);
5333
        }
5334

    
5335
        /// <summary>
5336
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5337
        /// </summary>
5338
        /// <param name="pageWidth">원본 사이즈</param>
5339
        /// <param name="pageHeight">원본 사이즈</param>
5340
        /// <returns></returns>
5341
        private void ScaleImage(double pageWidth,double pageHeight)
5342
        {
5343
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5344
        }
5345

    
5346
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5347
        {
5348
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5349
        }
5350

    
5351

    
5352
        /*
5353
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5354
        {
5355
            try
5356
            {
5357
                if (e.Data.GetDataPresent(typeof(string)))
5358
                {
5359
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5360
                    string dragData = e.Data.GetData(typeof(string)) as string;
5361
                    Move_Symbol(sender, dragData);
5362
                }
5363
            }
5364
            catch (Exception ex)
5365
            {
5366
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5367
            }            
5368
        }
5369
        */
5370
    }
5371
}
클립보드 이미지 추가 (최대 크기: 500 MB)