프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 0f26a9aa

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

    
317
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
318
        {
319
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
320
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
321
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
322
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
323
            {
324
                return true;
325
            }
326

    
327
            return false;
328
        }
329

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

    
353
            return false;
354
        }
355

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
489
        
490

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

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

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

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

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

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

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

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

    
575
        DispatcherTimer renderTesttimer;
576

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

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

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

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

    
603
            #endregion
604

    
605
            ViewerDataModel.Instance.PageNumber = BalancePoint;
606

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

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

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

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

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

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

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

    
641
            #endregion
642

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

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

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

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

    
691
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
692

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

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

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

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

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

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

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

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

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

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

    
786

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

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

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

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

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

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

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

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

    
894
        #region ZoomIn & ZoomOut
895

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

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

    
908

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

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

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

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

    
944
        }
945

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

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

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

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

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

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

    
998
        #endregion
999

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

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

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

    
1012
        }
1013

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

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

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

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

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

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

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

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

    
1180

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

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

    
1193

    
1194
               CreateDragDropWindow2(img);
1195
              
1196
    }
1197

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

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

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

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

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

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

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

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

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

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

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

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

    
1323
                    switch (controlType)
1324
                    {
1325
                        case (ControlType.Coordinate):
1326
                            {
1327
                                var control = currentControl as CoordinateControl;
1328
                                if (control != null)
1329
                                {
1330
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1331
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1332
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1333
                                }
1334
                            }
1335
                            break;
1336
                        case (ControlType.InsideWhite):
1337
                            {
1338
                                var control = currentControl as InsideWhiteControl;
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
                                    control.Paint = PaintSet.Fill;
1345
                                }
1346
                            }
1347
                            break;
1348
                        case ControlType.OverlapWhite:
1349
                            {
1350
                                var control = currentControl as OverlapWhiteControl;
1351
                                if (control != null)
1352
                                {
1353
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1354
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1355
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1356
                                    control.Paint = PaintSet.Fill;
1357
                                }
1358
                            }
1359
                            break;
1360
                        case ControlType.ClipWhite:
1361
                            {
1362
                                var control = currentControl as ClipWhiteControl;
1363
                                if (control != null)
1364
                                {
1365
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1366
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1367
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1368
                                    control.Paint = PaintSet.Fill;
1369
                                }
1370
                            }
1371
                            break;
1372
                        case ControlType.RectCloud:
1373
                            {
1374
                                var control = currentControl as RectCloudControl;
1375
                                if (control != null)
1376
                                {
1377
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1378
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1379
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1380
                                }
1381
                            }
1382
                            break;
1383
                        case ControlType.SingleLine:
1384
                        case ControlType.CancelLine:
1385
                        case ControlType.ArrowLine:
1386
                        case ControlType.TwinLine:
1387
                        case ControlType.DimLine:
1388
                            {
1389
                                var control = currentControl as LineControl;
1390
                                if (control != null)
1391
                                {
1392
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1393
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1394
                                }
1395
                            }
1396
                            break;
1397

    
1398
                        case ControlType.ArcLine:
1399
                            {
1400
                                var control = currentControl as ArcControl;
1401
                                if (control != null)
1402
                                {
1403
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1404
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1405
                                }
1406
                            }
1407
                            break;
1408

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

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

    
1431
                        case ControlType.Circle:
1432
                            {
1433
                                if (currentControl != null)
1434
                                {
1435
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1436
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1437
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1438
                                }
1439
                            }
1440
                            break;
1441

    
1442
                        case ControlType.PolygonCloud:
1443
                            {
1444
                                var control = currentControl as CloudControl;
1445
                                if (control != null)
1446
                                {
1447
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1448
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1449
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1450
                                }
1451
                            }
1452
                            break;
1453

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

    
1466
                        case ControlType.ImgControl:
1467
                            {
1468
                                var control = currentControl as ImgControl;
1469
                                if (control != null)
1470
                                {
1471
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1472
                                }
1473
                            }
1474
                            break;
1475

    
1476
                        case ControlType.Date:
1477
                            {
1478
                                var control = currentControl as DateControl;
1479
                                if (control != null)
1480
                                {
1481
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1482
                                }
1483
                            }
1484
                            break;
1485

    
1486
                        case ControlType.ArrowTextControl:
1487
                        case ControlType.ArrowTransTextControl:
1488
                        case ControlType.ArrowTextBorderControl:
1489
                        case ControlType.ArrowTransTextBorderControl:
1490
                        case ControlType.ArrowTextCloudControl:
1491
                        case ControlType.ArrowTransTextCloudControl:
1492
                            {
1493
                                var control = currentControl as ArrowTextControl;
1494
                                if (control != null)
1495
                                {
1496
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1497
                                }
1498
                            }
1499
                            break;
1500
                        case ControlType.PolygonControl:
1501
                        case ControlType.ChainLine:
1502
                            {
1503
                                var control = currentControl as PolygonControl;
1504
                                if (control != null)
1505
                                {
1506
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1507
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1508
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1509
                                }
1510
                            }
1511
                            break;
1512
                        case ControlType.Sign:
1513
                            {
1514
                                var control = currentControl as SignControl;
1515
                                if (control != null)
1516
                                {
1517
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1518
                                }
1519
                            }
1520
                            break;
1521
                        case ControlType.Symbol:
1522
                            {
1523
                                var control = currentControl as SymControl;
1524
                                if (control != null)
1525
                                {
1526
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1527
                                }
1528
                            }
1529
                            break;
1530
                        case ControlType.Stamp:
1531
                            {
1532
                                var control = currentControl as SymControlN;
1533
                                if (control != null)
1534
                                {
1535
                                    if (control.STAMP != null)
1536
                                    {
1537
                                        control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1538
                                    }
1539
                                    else
1540
                                    {
1541
                                        currentControl = null;
1542
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1543
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1544
                                    }
1545
                                }                                    
1546
                            }
1547
                            break;
1548
                        case ControlType.Rectangle:
1549
                        case ControlType.Mark:
1550
                            {
1551
                                var control = currentControl as RectangleControl;
1552
                                if (control != null)
1553
                                {
1554
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1555
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1556
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1557
                                }
1558
                            }
1559
                            break;
1560
                        case ControlType.PenControl:
1561
                            {
1562
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1563
                                //inkBoard.Strokes.Add(stroke);
1564
                            }
1565
                            break;
1566
                        default:
1567
                            break;
1568
                    }
1569
                }
1570
            }
1571
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1572
            {
1573
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1574
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1575
                SetCursor();
1576
                if (currentControl == null)
1577
                {
1578
                    switch (controlType)
1579
                    {
1580
                        case ControlType.PenControl:
1581
                            {
1582
                                if (inkBoard.Tag.ToString() == "Ink")
1583
                                {
1584
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1585
                                }
1586
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1587
                                {
1588
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1589
                                }
1590
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1591
                                {
1592
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1593
                                }
1594

    
1595
                                //inkBoard.Strokes.Add(stroke);
1596
                            }
1597
                            break;
1598
                    }
1599
                    return;
1600
                }
1601
            }
1602
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1603
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1604
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1605
            {
1606
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1607

    
1608
                if (isDraggingSelectionRect)
1609
                {
1610
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1611
                    e.Handled = true;
1612
                }
1613
                else if (isLeftMouseButtonDownOnWindow)
1614
                {
1615
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1616
                    double dragDistance = Math.Abs(dragDelta.Length);
1617

    
1618
                    if (dragDistance > DragThreshold)
1619
                    {
1620
                        isDraggingSelectionRect = true;
1621
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1622
                    }
1623

    
1624
                    e.Handled = true;
1625
                }
1626

    
1627
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1628
                {
1629
                }
1630
                else
1631
                {
1632
                    e.Handled = true;
1633
                }
1634
            }
1635
            /*
1636
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1637
            { //symbol      
1638
                if(_dragdropWindow != null)
1639
                {
1640
                    Win32Point w32Mouse = new Win32Point();
1641
                    GetCursorPos(ref w32Mouse);
1642

    
1643
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1644
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1645
                }                
1646
            }
1647
            */
1648
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1649
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1650
            {
1651
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1652
                if(control != null)
1653
                {
1654
                    this.cursor = Cursors.Hand;
1655
                    SetCursor();
1656
                }
1657
                else
1658
                {
1659
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1660
                    SetCursor();
1661
                }
1662
            }
1663
            else
1664
            {
1665
            }
1666
        }
1667

    
1668
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1669
        {
1670
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1671
            {
1672
                SetCursor();
1673
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1674
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1675

    
1676
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1677

    
1678
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1679
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1680

    
1681
                if (Sync.IsChecked)
1682
                {
1683
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1684
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1685
                }
1686
            }
1687
        }
1688

    
1689
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1690

    
1691
        private EllipseGeometry hitArea = new EllipseGeometry();
1692

    
1693
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1694
        {
1695
            IsDrawing = false;
1696

    
1697
            if (mouseHandlingMode != MouseHandlingMode.None)
1698
            {
1699
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1700
                {
1701
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1702

    
1703
                    SetCursor();
1704

    
1705
                    switch (controlType)
1706
                    {
1707
                        case ControlType.None:
1708
                            break;
1709
                        case ControlType.Rectangle:
1710
                            {
1711

    
1712
                            }
1713
                            break;
1714
                        case ControlType.PenControl:
1715
                            {
1716

    
1717
                            }
1718
                            break;
1719
                        default:
1720
                            break;
1721
                    }                    
1722
                }
1723
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1724
                {
1725
                    if (isLeftMouseButtonDownOnWindow)
1726
                    {
1727
                        bool wasDragSelectionApplied = false;
1728

    
1729
                        if (isDraggingSelectionRect)
1730
                        {
1731
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1732
                            {
1733
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1734
                                mouseHandlingMode = MouseHandlingMode.None;
1735
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1736
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1737
                                Set_Symbol_Capture(endPoint);
1738
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1739
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1740
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1741
                            }
1742
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1743
                            {
1744
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1745
                                mouseHandlingMode = MouseHandlingMode.None;
1746
                                Set_Capture();
1747

    
1748
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1749
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1750
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1751
                            }
1752
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1753
                            {
1754
                                ApplyDragSelectionRect();
1755
                            }
1756
                            else
1757
                            {
1758
                                double x = Canvas.GetLeft(dragZoomBorder);
1759
                                double y = Canvas.GetTop(dragZoomBorder);
1760
                                double width = dragZoomBorder.Width;
1761
                                double height = dragZoomBorder.Height;
1762
                                Rect dragRect = new Rect(x, y, width, height);
1763

    
1764
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1765

    
1766
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1767
                            }
1768

    
1769
                            isDraggingSelectionRect = false;
1770
                            e.Handled = true;
1771
                            wasDragSelectionApplied = true;
1772
                        }
1773

    
1774
                        if (isLeftMouseButtonDownOnWindow)
1775
                        {
1776
                            isLeftMouseButtonDownOnWindow = false;
1777
                            this.ReleaseMouseCapture();
1778
                            e.Handled = true;
1779
                        }
1780

    
1781
                        if (!wasDragSelectionApplied)
1782
                        {
1783
                            init();
1784
                        }
1785
                    }
1786
                }
1787
                else if (e.RightButton == MouseButtonState.Pressed)
1788
                {
1789
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1790
                    SetCursor();
1791
                }
1792

    
1793
                zoomAndPanControl.ReleaseMouseCapture();
1794

    
1795

    
1796
                e.Handled = true;
1797
            }
1798
            else
1799
            {
1800
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1801
                SetCursor();
1802
            }
1803

    
1804
            ///mouseButtonDown = MouseButton.Left;
1805
            //controlType = ControlType.SingleLine;
1806
        }
1807

    
1808
        public void Set_Symbol_Capture(Point endPoint)
1809
        {       
1810
            double x = canvasDrawingMouseDownPoint.X;
1811
            double y = canvasDrawingMouseDownPoint.Y;
1812
            if(x > endPoint.X)
1813
            {
1814
                x = endPoint.X;
1815
                y = endPoint.Y;
1816
            }
1817

    
1818
            double width = dragCaptureBorder.Width;
1819
            double height = dragCaptureBorder.Height;
1820

    
1821
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1822

    
1823
            if (x < 0)
1824
            {
1825
                width += x;
1826
                x = 0;
1827
            }
1828
            if (y < 0)
1829
            {
1830
                height += y;
1831
                y = 0;
1832

    
1833
                width = (int)canvasImage.PixelWidth - x;
1834
            }
1835
            if (x + width > canvasImage.PixelWidth)
1836
            {
1837
                width = (int)canvasImage.PixelWidth - x;
1838
            }
1839
            if (y + height > canvasImage.PixelHeight)
1840
            {
1841
                height = (int)canvasImage.PixelHeight - y;
1842
            }
1843
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1844

    
1845
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1846
            var defaultBitmapImage = new BitmapImage();
1847
            defaultBitmapImage.BeginInit();
1848
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1849
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1850
            defaultBitmapImage.UriSource = new Uri(uri);
1851
            defaultBitmapImage.EndInit();
1852

    
1853
            //GC.Collect();
1854

    
1855
            if (defaultBitmapImage.IsDownloading)
1856
            {
1857
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1858
                {
1859
                    defaultBitmapImage.Freeze();
1860
                    //GC.Collect();
1861
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1862
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1863
                };
1864
            }
1865
        }
1866

    
1867
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1868
        {
1869
            ///mouseButtonDown = MouseButton.Left;
1870
        }
1871

    
1872
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1873
        {
1874
            ///mouseButtonDown = MouseButton.Left;
1875
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1876
        }
1877

    
1878
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1879
        {
1880

    
1881
        }
1882

    
1883
        /// <summary>
1884
        /// select items by dragging
1885
        /// </summary>
1886
        private void ApplyDragSelectionRect()
1887
        {
1888
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1889

    
1890
            double x = Canvas.GetLeft(dragSelectionBorder);
1891
            double y = Canvas.GetTop(dragSelectionBorder);
1892
            double width = dragSelectionBorder.Width;
1893
            double height = dragSelectionBorder.Height;
1894
            Boolean Flag = false;
1895
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1896
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1897

    
1898
            Rect dragRect = new Rect(x, y, width, height);
1899
            ///dragRect.Inflate(width / 10, height / 10);
1900

    
1901
            foreach (var item in Items)
1902
            {
1903
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1904

    
1905
                if (Flag)
1906
                {
1907
                    adornerSet.Add(item);
1908
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1909
                    Control_Style(item);
1910
                }
1911
            }
1912
            if (adornerSet.Count > 0)
1913
            {
1914
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1915
                SelectLayer.Children.Add(final);
1916
            }
1917
        }
1918

    
1919
        private void InitDragSelectionRect(Point pt1, Point pt2)
1920
        {
1921
            //캡쳐 중
1922
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1923
            {
1924
                dragCaptureBorder.Visibility = Visibility.Visible;
1925
            }
1926
            //선택 중
1927
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1928
            {
1929

    
1930
                dragSelectionBorder.Visibility = Visibility.Visible;
1931
            }
1932
            else
1933
            {
1934
                dragZoomBorder.Visibility = Visibility.Visible;
1935
            }
1936
            UpdateDragSelectionRect(pt1, pt2);
1937
        }
1938

    
1939
        /// <summary>
1940
        /// Update the position and size of the rectangle used for drag selection.
1941
        /// </summary>
1942
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1943
        {
1944
            double x, y, width, height;
1945

    
1946
            //
1947
            // Determine x,y,width and height of the rect inverting the points if necessary.
1948
            // 
1949

    
1950
            if (pt2.X < pt1.X)
1951
            {
1952
                x = pt2.X;
1953
                width = pt1.X - pt2.X;
1954
            }
1955
            else
1956
            {
1957
                x = pt1.X;
1958
                width = pt2.X - pt1.X;
1959
            }
1960

    
1961
            if (pt2.Y < pt1.Y)
1962
            {
1963
                y = pt2.Y;
1964
                height = pt1.Y - pt2.Y;
1965
            }
1966
            else
1967
            {
1968
                y = pt1.Y;
1969
                height = pt2.Y - pt1.Y;
1970
            }
1971

    
1972
            //
1973
            // Update the coordinates of the rectangle used for drag selection.
1974
            //
1975
            //캡쳐 중
1976
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1977
            {
1978
                Canvas.SetLeft(dragCaptureBorder, x);
1979
                Canvas.SetTop(dragCaptureBorder, y);
1980
                dragCaptureBorder.Width = width;
1981
                dragCaptureBorder.Height = height;
1982
            }
1983
            //선택 중
1984
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1985
            {
1986
                Canvas.SetLeft(dragSelectionBorder, x);
1987
                Canvas.SetTop(dragSelectionBorder, y);
1988
                dragSelectionBorder.Width = width;
1989
                dragSelectionBorder.Height = height;
1990
            }
1991
            else
1992
            {
1993
                Canvas.SetLeft(dragZoomBorder, x);
1994
                Canvas.SetTop(dragZoomBorder, y);
1995
                dragZoomBorder.Width = width;
1996
                dragZoomBorder.Height = height;
1997
            }
1998
        }
1999

    
2000
        private void drawingPannelRotate(double angle)
2001
        {
2002
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2003
            rotate.Angle = angle;
2004
            var rotationNum = Math.Abs((rotate.Angle / 90));
2005

    
2006
            if (angle == 90 || angle == 270)
2007
            {
2008
                double emptySize = zoomAndPanCanvas.Width;
2009
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2010
                zoomAndPanCanvas.Height = emptySize;
2011
            }
2012
            if (angle == 0)
2013
            {
2014
                translate.X = 0;
2015
                translate.Y = 0;
2016
            }
2017
            else if (angle == 90)
2018
            {
2019
                translate.X = zoomAndPanCanvas.Width;
2020
                translate.Y = 0;
2021
            }
2022
            else if (angle == 180)
2023
            {
2024
                translate.X = zoomAndPanCanvas.Width;
2025
                translate.Y = zoomAndPanCanvas.Height;
2026
            }
2027
            else
2028
            {
2029
                translate.X = 0;
2030
                translate.Y = zoomAndPanCanvas.Height;
2031
            }
2032

    
2033
            zoomAndPanControl.RotationAngle = rotate.Angle;
2034

    
2035

    
2036
            if (!testPanel2.IsHidden)
2037
            {
2038
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2039
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2040
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2041
            }
2042

    
2043
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2044
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2045
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2046
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2047
            ViewerDataModel.Instance.Angle = rotate.Angle;
2048
        }
2049

    
2050
        private void syncPannelRotate(double angle)
2051
        {
2052
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2053
            rotate.Angle = angle;
2054
            var rotationNum = Math.Abs((rotate.Angle / 90));
2055

    
2056
            if (angle == 90 || angle == 270)
2057
            {
2058
                double emptySize = zoomAndPanCanvas2.Width;
2059
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2060
                zoomAndPanCanvas2.Height = emptySize;
2061
            }
2062
            if (angle == 0)
2063
            {
2064
                translate2.X = 0;
2065
                translate2.Y = 0;
2066
            }
2067
            else if (angle == 90)
2068
            {
2069
                translate2.X = zoomAndPanCanvas2.Width;
2070
                translate2.Y = 0;
2071
            }
2072
            else if (angle == 180)
2073
            {
2074
                translate2.X = zoomAndPanCanvas2.Width;
2075
                translate2.Y = zoomAndPanCanvas2.Height;
2076
            }
2077
            else
2078
            {
2079
                translate2.X = 0;
2080
                translate2.Y = zoomAndPanCanvas2.Height;
2081
            }
2082

    
2083
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2084
        }
2085

    
2086
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2087
        {
2088
            string Data_ = "";
2089

    
2090
            try
2091
            {
2092
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2093
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2094
                if (Data_ != null || Data_ != "")
2095
                {
2096
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2097
                }
2098
                else
2099
                {
2100
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2101
                }
2102

    
2103
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2104
                //{
2105
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2106
                //    STATE = 0,
2107
                //};
2108
                if (Data_ != null)
2109
                {
2110
                    Image img = new Image();
2111
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2112
                    if (Data_.Contains(".svg"))
2113
                    {
2114
                        byte[] imageData = null;
2115
                        DrawingImage image = null;
2116
                        using (System.Net.WebClient web = new System.Net.WebClient())
2117
                        {
2118
                            imageData = web.DownloadData(new Uri(Data_));
2119
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2120
                            image = SvgReader.Load(stream);
2121
                        }
2122
                        img.Source = image;
2123
                    }
2124
                    else
2125
                    {
2126
                        img.Source = new BitmapImage(new Uri(Data_));
2127
                    }
2128

    
2129
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2130
                    {
2131
                        PointSet = new List<Point>(),
2132
                        FilePath = Data_,
2133
                        ImageData = img.Source,
2134
                        StartPoint = canvasZoomPanningMouseDownPoint,
2135
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2136
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2137
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2138
                        canvasZoomPanningMouseDownPoint.Y),
2139
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2140
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2141
                    };
2142

    
2143
                    currentControl.PointSet = new List<Point>
2144
                                        {
2145
                                            currentControl.StartPoint,
2146
                                            currentControl.LeftBottomPoint,
2147
                                            currentControl.EndPoint,
2148
                                            currentControl.TopRightPoint,
2149
                                        };
2150
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2151
                    UndoData = new Undo_data()
2152
                    {
2153
                        IsUndo = false,
2154
                        Event = Event_Type.Create,
2155
                        EventTime = DateTime.Now,
2156
                        Markup_List = new List<Multi_Undo_data>()
2157
                    };
2158
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2159
                    {
2160
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2161
                    });
2162

    
2163
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2164
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2165
                    UndoData.Markup_List.Add(multi_Undo_Data);
2166
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2167

    
2168
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2169
                    currentControl.CommentID = Commons.shortGuid();
2170
                    currentControl.SymbolID = id;
2171
                    currentControl.GroupID = group_id;
2172
                    currentControl.ApplyTemplate();
2173
                    currentControl.SetImage();
2174

    
2175
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2176
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2177
                    SelectLayer.Children.Add(final);
2178
                }
2179
            }
2180
            catch (Exception ex)
2181
            {
2182
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2183
            }
2184
        }
2185

    
2186
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2187
        {            
2188
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2189
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2190
            {
2191
                set_option.Value = double.Parse(set_option.ContentText);
2192
                //set_option.Focusable = false;
2193
                zoomAndPanControl.Focus();
2194
            }
2195

    
2196
            ConvertInkControlToPolygon();
2197

    
2198
            ///TODO:
2199
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2200
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2201

    
2202
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2203
            {
2204
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2205
            }
2206
            /// up to here
2207

    
2208
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2209
            {
2210
                if (item as ArrowTextControl != null)
2211
                {
2212
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2213
                }
2214
                else if (item as TextControl != null)
2215
                {
2216
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2217
                }
2218
            }
2219

    
2220
            //if (currentControl != null)
2221
            {
2222
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2223
                if (text_item_ != null)
2224
                {
2225
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2226
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2227
                    (text_item_ as TextControl).IsEditingMode = false;                    
2228
                    currentControl = null;
2229
                }
2230

    
2231
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2232
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2233
                {
2234
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2235
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2236
                    currentControl = null;
2237
                }
2238
            }
2239

    
2240
            double Ang = 0;                                          
2241
            if (rotate.Angle != 0)
2242
            {
2243
                Ang = 360 - rotate.Angle;
2244
            }
2245

    
2246
            if (e.OriginalSource is System.Windows.Controls.Image)
2247
            {
2248
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2249
            }
2250
            /*
2251
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2252
            {                
2253
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2254
                if(symbol_id != null)
2255
                {
2256
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2257
                }                
2258
            }
2259

    
2260
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2261
            {
2262
                if (this._dragdropWindow != null)
2263
                {
2264
                    this._dragdropWindow.Close();
2265
                    this._dragdropWindow = null;
2266
                    symbol_id = null;
2267
                }
2268
            }
2269
            */
2270

    
2271
            if (e.LeftButton == MouseButtonState.Pressed)
2272
            {
2273
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2274
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2275

    
2276
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2277
                SetCursor();
2278

    
2279
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2280
            }
2281

    
2282
            if (e.MiddleButton == MouseButtonState.Pressed)
2283
            {
2284
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2285
                cursor = Cursors.SizeAll;
2286
                SetCursor();
2287
            }
2288
            if (e.RightButton == MouseButtonState.Pressed)
2289
            {
2290
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2291
                cursor = Cursors.SizeAll;
2292
                SetCursor();
2293
            }
2294
            else if (e.XButton1 == MouseButtonState.Pressed)
2295
            {
2296
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2297
                {
2298
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2299
                }
2300

    
2301
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2302

    
2303
            }
2304
            else if (e.XButton2 == MouseButtonState.Pressed)
2305
            {
2306
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2307
                {
2308
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2309
                }
2310
            }
2311

    
2312
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2313
            {
2314
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2315
                {
2316
                    if (SelectLayer.Children.Count == 0)
2317
                    {
2318
                        isLeftMouseButtonDownOnWindow = true;
2319
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2320
                    }
2321

    
2322
                    if (controlType == ControlType.None)
2323
                    {
2324
                        isLeftMouseButtonDownOnWindow = true;
2325
                    }
2326
                }
2327

    
2328
                /// 캡쳐 모드 설정
2329
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2330
                {
2331
                    dragCaptureBorder.Visibility = Visibility.Visible;
2332
                    isLeftMouseButtonDownOnWindow = true;
2333
                }
2334

    
2335
                /// 줌 모드 설정
2336
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2337
                {
2338
                    isLeftMouseButtonDownOnWindow = true;
2339
                }
2340

    
2341
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2342
                if (control != null)
2343
                {
2344
                    AdornerFinal final = null;
2345

    
2346
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2347
                    {
2348
                        /// 기존 selection 해제
2349
                        SelectionSet.Instance.UnSelect(this);
2350

    
2351
                        final = new AdornerFinal(control);
2352

    
2353
                        this.Control_Style(control);
2354

    
2355
                        if ((control as IPath) != null)
2356
                        {
2357
                            if ((control as IPath).LineSize != 0)
2358
                            {
2359
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2360
                            }
2361
                        }
2362
                        if ((control as IShapeControl) != null)
2363
                        {
2364
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2365
                            {
2366
                                ViewerDataModel.Instance.checkHatchShape = true;
2367
                            }
2368
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2369
                            {
2370
                                ViewerDataModel.Instance.checkFillShape = true;
2371
                            }
2372
                            else
2373
                            {
2374
                                ViewerDataModel.Instance.checkHatchShape = false;
2375
                                ViewerDataModel.Instance.checkFillShape = false;
2376
                            }
2377
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2378
                        }
2379

    
2380
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2381

    
2382
                        if ((control as TextControl) != null)
2383
                        {
2384
                            if(!((control as TextControl).EnableEditing)) {
2385
                                (control as TextControl).EnableEditing = true;
2386
                            }
2387
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2388
                            {
2389
                                ViewerDataModel.Instance.checkTextStyle = true;
2390
                            }
2391
                            else
2392
                            {
2393
                                ViewerDataModel.Instance.checkTextStyle = false;
2394
                            }
2395
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2396
                            {
2397
                                ViewerDataModel.Instance.checkTextWeight = true;
2398
                            }
2399
                            else
2400
                            {
2401
                                ViewerDataModel.Instance.checkTextWeight = false;
2402
                            }
2403
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2404
                            {
2405
                                ViewerDataModel.Instance.checkUnderLine = true;
2406
                            }
2407
                            else
2408
                            {
2409
                                ViewerDataModel.Instance.checkUnderLine = false;
2410
                            }
2411
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2412
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2413

    
2414
                        }
2415
                        else if ((control as ArrowTextControl) != null)
2416
                        {
2417
                            if (!((control as ArrowTextControl).EnableEditing))
2418
                            {
2419
                                (control as ArrowTextControl).EnableEditing = true;
2420
                            }
2421
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2422
                            {
2423
                                ViewerDataModel.Instance.checkTextStyle = true;
2424
                            }
2425
                            else
2426
                            {
2427
                                ViewerDataModel.Instance.checkTextStyle = false;
2428
                            }
2429
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2430
                            {
2431
                                ViewerDataModel.Instance.checkTextWeight = true;
2432
                            }
2433
                            else
2434
                            {
2435
                                ViewerDataModel.Instance.checkTextWeight = false;
2436
                            }
2437
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2438
                            {
2439
                                ViewerDataModel.Instance.checkUnderLine = true;
2440
                            }
2441
                            else
2442
                            {
2443
                                ViewerDataModel.Instance.checkUnderLine = false;
2444
                            }
2445
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2446
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2447
                        }
2448
                        else if ((control as RectCloudControl) != null)
2449
                        {
2450
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2451
                        }
2452
                        else if ((control as CloudControl) != null)
2453
                        {
2454
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2455
                        }
2456
                    }
2457
                    else
2458
                    {
2459
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2460
                        SelectionSet.Instance.UnSelect(this);
2461
                        comment.Add(control);
2462

    
2463
                        Control_Style(control);
2464

    
2465
                        final = new AdornerFinal(comment);
2466
                    }
2467

    
2468
                    if (final != null)
2469
                    {
2470
                        this.SelectLayer.Children.Add(final);
2471
                    }
2472
                }              
2473
            }
2474
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2475
            {               
2476
                init();
2477
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2478
                if (cursor != Cursors.SizeAll)
2479
                {
2480
                    cursor = Cursors.Cross;
2481
                    SetCursor();
2482
                }
2483
                bool init_user = false;
2484
                foreach (var user in gridViewMarkup.Items)
2485
                {
2486
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2487
                    {
2488
                        init_user = true;
2489
                    }
2490
                }
2491
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2492
                {
2493
                    RadWindow.Alert(new DialogParameters
2494
                    {
2495
                        Owner = Application.Current.MainWindow,
2496
                        Theme = new VisualStudio2013Theme(),
2497
                        Header = "안내",
2498
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2499
                    });
2500
                    return;
2501
                }
2502
                else
2503
                {
2504
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2505
                    if (item != null)
2506
                    {
2507
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2508
                    }
2509
                }
2510

    
2511
                switch (controlType)
2512
                {
2513
                    case ControlType.Coordinate:
2514
                        {
2515
                            if (e.LeftButton == MouseButtonState.Pressed)
2516
                            {
2517
                                if (currentControl is CoordinateControl)
2518
                                {
2519
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2520
                                    {
2521
                                        return;
2522
                                    }
2523

    
2524
                                    CreateCommand.Instance.Execute(currentControl);
2525

    
2526
                                    currentControl = null;
2527
                                    this.cursor = Cursors.Arrow;
2528
                                }
2529
                                else
2530
                                {
2531
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2532
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2533
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2534
                                    {
2535
                                        currentControl = null;
2536
                                        this.cursor = Cursors.Arrow;
2537
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2538
                                        return;
2539
                                    }
2540
                                    else
2541
                                    {
2542
                                        currentControl = new CoordinateControl
2543
                                        {
2544
                                            Background = new SolidColorBrush(Colors.Black),
2545
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2546
                                            ControlType = ControlType.Coordinate
2547
                                        };
2548

    
2549
                                        currentControl.CommentID = Commons.shortGuid();
2550
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2551
                                        currentControl.IsNew = true;
2552

    
2553
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2554

    
2555
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2556
                                    }
2557
                                }
2558
                            }
2559
                        }
2560
                        break;
2561
                    case ControlType.InsideWhite:
2562
                        {
2563
                            if (e.LeftButton == MouseButtonState.Pressed)
2564
                            {
2565
                                if (currentControl is InsideWhiteControl)
2566
                                {
2567
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2568
                                    {
2569
                                        return;
2570
                                    }
2571

    
2572
                                    CreateCommand.Instance.Execute(currentControl);
2573

    
2574
                                    currentControl = null;
2575
                                    this.cursor = Cursors.Arrow;
2576
                                }
2577
                                else
2578
                                {
2579
                                    currentControl = new InsideWhiteControl
2580
                                    {
2581
                                        Background = new SolidColorBrush(Colors.Black),
2582
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2583
                                        ControlType = ControlType.InsideWhite
2584
                                    };
2585

    
2586
                                    currentControl.CommentID = Commons.shortGuid();
2587
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2588
                                    currentControl.IsNew = true;
2589
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2590

    
2591
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2592
                                }
2593
                            }
2594
                        }
2595
                        break;
2596
                    case ControlType.OverlapWhite:
2597
                        {
2598
                            if (e.LeftButton == MouseButtonState.Pressed)
2599
                            {
2600
                                if (currentControl is OverlapWhiteControl)
2601
                                {
2602
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2603
                                    {
2604
                                        return;
2605
                                    }
2606

    
2607
                                    CreateCommand.Instance.Execute(currentControl);
2608

    
2609
                                    currentControl = null;
2610
                                    this.cursor = Cursors.Arrow;
2611
                                }
2612
                                else
2613
                                {
2614
                                    currentControl = new OverlapWhiteControl
2615
                                    {
2616
                                        Background = new SolidColorBrush(Colors.Black),
2617
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2618
                                        ControlType = ControlType.OverlapWhite
2619
                                    };
2620

    
2621
                                    currentControl.CommentID = Commons.shortGuid();
2622
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2623
                                    currentControl.IsNew = true;
2624
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2625

    
2626
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2627
                                }
2628
                            }
2629
                        }
2630
                        break;
2631
                    case ControlType.ClipWhite:
2632
                        {
2633
                            if (e.LeftButton == MouseButtonState.Pressed)
2634
                            {
2635
                                if (currentControl is ClipWhiteControl)
2636
                                {
2637
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2638
                                    {
2639
                                        return;
2640
                                    }
2641

    
2642
                                    CreateCommand.Instance.Execute(currentControl);
2643

    
2644
                                    currentControl = null;
2645
                                    this.cursor = Cursors.Arrow;
2646
                                }
2647
                                else
2648
                                {
2649
                                    currentControl = new ClipWhiteControl
2650
                                    {
2651
                                        Background = new SolidColorBrush(Colors.Black),
2652
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2653
                                        ControlType = ControlType.ClipWhite
2654
                                    };
2655

    
2656
                                    currentControl.CommentID = Commons.shortGuid();
2657
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2658
                                    currentControl.IsNew = true;
2659
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2660

    
2661
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2662
                                }
2663
                            }
2664
                        }
2665
                        break;
2666
                    case ControlType.Rectangle:
2667
                        {
2668
                            if (e.LeftButton == MouseButtonState.Pressed)
2669
                            {
2670
                                if (currentControl is RectangleControl)
2671
                                {
2672
                                    //20180906 LJY TEST IsRotationDrawingEnable
2673
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2674
                                    {
2675
                                        return;
2676
                                    }
2677

    
2678
                                    CreateCommand.Instance.Execute(currentControl);
2679
                                    currentControl = null;
2680
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2681
                                }
2682
                                else
2683
                                {
2684
                                    currentControl = new RectangleControl
2685
                                    {
2686
                                        Background = new SolidColorBrush(Colors.Black),
2687
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2688
                                        ControlType = ControlType.Rectangle
2689
                                    };
2690

    
2691
                                    currentControl.CommentID = Commons.shortGuid();
2692
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2693
                                    currentControl.IsNew = true;
2694
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2695

    
2696
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2697
                                }
2698
                            }
2699
                        }
2700
                        break;
2701
                    case ControlType.RectCloud:
2702
                        {
2703
                            if (e.LeftButton == MouseButtonState.Pressed)
2704
                            {
2705
                                if (currentControl is RectCloudControl)
2706
                                {
2707
                                    //20180906 LJY TEST IsRotationDrawingEnable
2708
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2709
                                    {
2710
                                        return;
2711
                                    }
2712

    
2713
                                    CreateCommand.Instance.Execute(currentControl);
2714

    
2715
                                    currentControl = null;
2716
                                
2717
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2718
                                }
2719
                                else
2720
                                {
2721
                                    currentControl = new RectCloudControl
2722
                                    {
2723
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2724
                                        ControlType = ControlType.RectCloud,
2725
                                        Background = new SolidColorBrush(Colors.Black)
2726
                                    };
2727

    
2728
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2729
                                    currentControl.CommentID = Commons.shortGuid();
2730
                                    currentControl.IsNew = true;
2731
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2732
                                }
2733
                            }
2734
                        }
2735
                        break;
2736
                    case ControlType.Circle:
2737
                        {
2738
                            if (e.LeftButton == MouseButtonState.Pressed)
2739
                            {
2740
                                if (currentControl is CircleControl)
2741
                                {
2742
                                    //20180906 LJY TEST IsRotationDrawingEnable
2743
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2744
                                    {
2745
                                        return;
2746
                                    }
2747

    
2748
                                    CreateCommand.Instance.Execute(currentControl);
2749

    
2750
                                    currentControl = null;
2751
                                }
2752
                                else
2753
                                {
2754
                                    currentControl = new CircleControl
2755
                                    {
2756
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2757
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2758
                                        Background = new SolidColorBrush(Colors.Black)
2759
                                    };
2760

    
2761
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2762
                                    currentControl.CommentID = Commons.shortGuid();
2763
                                    currentControl.IsNew = true;
2764
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2765
                                }
2766
                            }
2767
                        }
2768
                        break;
2769
                    case ControlType.Triangle:
2770
                        {
2771
                            if (e.LeftButton == MouseButtonState.Pressed)
2772
                            {
2773
                                if (currentControl is TriControl)
2774
                                {
2775
                                    var content = currentControl as TriControl;
2776
                                    if (content.MidPoint == new Point(0, 0))
2777
                                    {
2778
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2779
                                    }
2780
                                    else
2781
                                    {
2782
                                        //20180906 LJY TEST IsRotationDrawingEnable
2783
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2784
                                        {
2785
                                            return;
2786
                                        }
2787

    
2788
                                        CreateCommand.Instance.Execute(currentControl);
2789

    
2790
                                        currentControl = null;
2791
                                    }
2792
                                }
2793
                                else
2794
                                {
2795
                                    currentControl = new TriControl
2796
                                    {
2797
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2798
                                        Background = new SolidColorBrush(Colors.Black),
2799
                                    };
2800

    
2801
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2802
                                    currentControl.CommentID = Commons.shortGuid();
2803
                                    currentControl.IsNew = true;
2804
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2805
                                }
2806
                            }
2807
                        }
2808
                        break;
2809
                    case ControlType.CancelLine:
2810
                    case ControlType.SingleLine:
2811
                    case ControlType.ArrowLine:
2812
                    case ControlType.TwinLine:
2813
                    case ControlType.DimLine:
2814
                        {
2815
                            if (e.LeftButton == MouseButtonState.Pressed)
2816
                            {
2817
                                if (currentControl is LineControl)
2818
                                {
2819
                                    //20180906 LJY TEST IsRotationDrawingEnable
2820
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2821
                                    {
2822
                                        return;
2823
                                    }
2824

    
2825
                                    CreateCommand.Instance.Execute(currentControl);
2826
                                    currentControl = null;
2827
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2828
                                }
2829
                                else
2830
                                {
2831
                                    currentControl = new LineControl
2832
                                    {
2833
                                        ControlType = this.controlType,
2834
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2835
                                        Background = new SolidColorBrush(Colors.Black)
2836
                                    };
2837

    
2838
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2839
                                    currentControl.CommentID = Commons.shortGuid();
2840
                                    currentControl.IsNew = true;
2841
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2842
                                    this.MainAngle.Visibility = Visibility.Visible;
2843
                                }
2844
                            }
2845
                        }
2846
                        break;
2847
                    case ControlType.PolygonControl:
2848
                        {
2849
                            if (currentControl is PolygonControl)
2850
                            {
2851
                                var control = currentControl as PolygonControl;
2852

    
2853
                                if (e.RightButton == MouseButtonState.Pressed)
2854
                                {
2855
                                    control.IsCompleted = true;
2856
                                }
2857

    
2858
                                if (!control.IsCompleted)
2859
                                {
2860
                                    control.PointSet.Add(control.EndPoint);
2861
                                }
2862
                                else
2863
                                {
2864
                                    //20180906 LJY TEST IsRotationDrawingEnable
2865
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2866
                                    {
2867
                                        return;
2868
                                    }
2869

    
2870
                                    var firstPoint = control.PointSet.First();
2871
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2872
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2873
                                    control.PointSet.Add(firstPoint);
2874

    
2875
                                    control.ApplyOverViewData();
2876

    
2877
                                    CreateCommand.Instance.Execute(currentControl);
2878
                                    control.UpdateControl();
2879
                                    currentControl = null;
2880
                                }
2881
                            }
2882
                            else
2883
                            {
2884
                                if (e.LeftButton == MouseButtonState.Pressed)
2885
                                {
2886
                                    currentControl = new PolygonControl
2887
                                    {
2888
                                        PointSet = new List<Point>(),
2889
                                    };
2890

    
2891
                                    var polygonControl = (currentControl as PolygonControl);
2892
                                    currentControl.CommentID = Commons.shortGuid();
2893
                                    currentControl.IsNew = true;
2894
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2895
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2896
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2897
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2898
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2899
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2900
                                    polygonControl.ApplyTemplate();
2901
                                    polygonControl.Visibility = Visibility.Visible;
2902
                                }
2903
                            }
2904
                        }
2905
                        break;
2906
                    case ControlType.ChainLine:
2907
                        {
2908
                            if (currentControl is PolygonControl)
2909
                            {
2910
                                var control = currentControl as PolygonControl;
2911

    
2912
                                if (e.RightButton == MouseButtonState.Pressed)
2913
                                {
2914
                                    //20180906 LJY TEST IsRotationDrawingEnable
2915
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2916
                                    {
2917
                                        return;
2918
                                    }
2919

    
2920
                                    CreateCommand.Instance.Execute(currentControl);
2921

    
2922
                                    currentControl = null;
2923
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2924
                                    return;
2925
                                }
2926

    
2927
                                if (!control.IsCompleted)
2928
                                {
2929
                                    control.PointSet.Add(control.EndPoint);
2930
                                    this.MainAngle.Visibility = Visibility.Visible;
2931
                                }
2932
                            }
2933
                            else
2934
                            {
2935
                                if (e.LeftButton == MouseButtonState.Pressed)
2936
                                {
2937
                                    MainAngle.Visibility = Visibility.Visible;
2938
                                    currentControl = new PolygonControl
2939
                                    {
2940
                                        PointSet = new List<Point>(),
2941
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2942
                                        ControlType = ControlType.ChainLine,
2943
                                        DashSize = ViewerDataModel.Instance.DashSize,
2944
                                        LineSize = ViewerDataModel.Instance.LineSize,
2945
                                        //PointC = new StylusPointSet()
2946
                                    };
2947

    
2948
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2949
                                    //{
2950
                                        var polygonControl = (currentControl as PolygonControl);
2951
                                        currentControl.CommentID = Commons.shortGuid();
2952
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2953
                                        currentControl.IsNew = true;
2954
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2955
                                        //currentControl.OnApplyTemplate();
2956
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2957
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2958
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2959
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2960
                                    //}
2961
                                }
2962
                            }
2963
                        }
2964
                        break;
2965
                    case ControlType.ArcLine:
2966
                        {
2967
                            if (e.LeftButton == MouseButtonState.Pressed)
2968
                            {
2969
                                if (currentControl is ArcControl)
2970
                                {
2971
                                    //20180906 LJY TEST IsRotationDrawingEnable
2972
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2973
                                    {
2974
                                        return;
2975
                                    }
2976

    
2977
                                    CreateCommand.Instance.Execute(currentControl);
2978

    
2979
                                    currentControl = null;
2980
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2981
                                }
2982
                                else
2983
                                {
2984
                                    currentControl = new ArcControl
2985
                                    {
2986
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2987
                                        Background = new SolidColorBrush(Colors.Black)
2988
                                    };
2989
                                    currentControl.CommentID = Commons.shortGuid();
2990
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2991
                                    currentControl.IsNew = true;
2992
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2993
                                    this.MainAngle.Visibility = Visibility.Visible;
2994
                                }
2995
                            }
2996
                            else if (e.RightButton == MouseButtonState.Pressed)
2997
                            {
2998
                                if (currentControl != null)
2999
                                {
3000
                                    (currentControl as ArcControl).setClock();
3001
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3002
                                }
3003
                            }
3004
                        }
3005
                        break;
3006
                    case ControlType.ArcArrow:
3007
                        {
3008
                            if (e.LeftButton == MouseButtonState.Pressed)
3009
                            {
3010
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3011
                                //{
3012
                                if (currentControl is ArrowArcControl)
3013
                                {
3014
                                    //20180906 LJY TEST IsRotationDrawingEnable
3015
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3016
                                    {
3017
                                        return;
3018
                                    }
3019

    
3020
                                    CreateCommand.Instance.Execute(currentControl);
3021

    
3022
                                    currentControl = null;
3023
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3024
                                }
3025
                                else
3026
                                {
3027
                                    currentControl = new ArrowArcControl
3028
                                    {
3029
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3030
                                        Background = new SolidColorBrush(Colors.Black)
3031
                                    };
3032
                                    currentControl.CommentID = Commons.shortGuid();
3033
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3034
                                    currentControl.IsNew = true;
3035
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3036
                                    this.MainAngle.Visibility = Visibility.Visible;
3037
                                }
3038
                                //}
3039
                            }
3040
                            else if (e.RightButton == MouseButtonState.Pressed)
3041
                            {
3042
                                if (currentControl != null)
3043
                                {
3044
                                    (currentControl as ArrowArcControl).setClock();
3045
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3046
                                    //(currentControl as ArcControl).ApplyTemplate();
3047
                                }
3048
                            }
3049
                        }
3050
                        break;
3051
                    case ControlType.ArrowMultiLine:
3052
                        {
3053
                            if (e.LeftButton == MouseButtonState.Pressed)
3054
                            {
3055
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3056
                                //{
3057

    
3058
                                    if (currentControl is ArrowControl_Multi)
3059
                                    {
3060
                                        var content = currentControl as ArrowControl_Multi;
3061
                                        if (content.MiddlePoint == new Point(0, 0))
3062
                                        {
3063
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3064
                                            {
3065
                                                content.MiddlePoint = content.EndPoint;
3066
                                            }
3067
                                            else
3068
                                            {
3069
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3070
                                            }
3071
                                        }
3072
                                        else
3073
                                        {
3074
                                            //20180906 LJY TEST IsRotationDrawingEnable
3075
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3076
                                            {
3077
                                                return;
3078
                                            }
3079

    
3080
                                            CreateCommand.Instance.Execute(currentControl);
3081

    
3082
                                            currentControl = null;
3083
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3084
                                        }
3085
                                    }
3086
                                    else
3087
                                    {
3088
                                        currentControl = new ArrowControl_Multi
3089
                                        {
3090
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3091
                                            Background = new SolidColorBrush(Colors.Black)
3092
                                        };
3093
                                        currentControl.CommentID = Commons.shortGuid();
3094
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3095
                                        currentControl.IsNew = true;
3096
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3097
                                        this.MainAngle.Visibility = Visibility.Visible;
3098
                                    }
3099
                                //}
3100
                            }
3101
                        }
3102
                        break;
3103
                    case ControlType.PolygonCloud:
3104
                        {
3105
                            if (currentControl is CloudControl)
3106
                            {
3107
                                var control = currentControl as CloudControl;
3108
                                if (e.RightButton == MouseButtonState.Pressed)
3109
                                {
3110
                                    control.IsCompleted = true;
3111
                                }
3112

    
3113
                                if (!control.IsCompleted)
3114
                                {
3115
                                    control.PointSet.Add(control.EndPoint);
3116
                                }
3117
                                else
3118
                                {
3119
                                    //20180906 LJY TEST IsRotationDrawingEnable
3120
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3121
                                    {
3122
                                        return;
3123
                                    }
3124

    
3125
                                    CreateCommand.Instance.Execute(currentControl);
3126

    
3127
                                    control.isTransOn = true;
3128
                                    var firstPoint = control.PointSet.First();
3129

    
3130
                                    control.PointSet.Add(firstPoint);
3131
                                    control.DrawingCloud();
3132
                                    control.ApplyOverViewData();
3133

    
3134
                                    currentControl = null;
3135
                                }
3136
                            }
3137
                            else
3138
                            {
3139
                                if (e.LeftButton == MouseButtonState.Pressed)
3140
                                {
3141
                                    currentControl = new CloudControl
3142
                                    {
3143
                                        PointSet = new List<Point>(),
3144
                                        PointC = new StylusPointSet()
3145
                                    };
3146

    
3147
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3148
                                    //{
3149
                                        var polygonControl = (currentControl as CloudControl);
3150
                                        currentControl.CommentID = Commons.shortGuid();
3151
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3152
                                        currentControl.IsNew = true;
3153
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3154

    
3155
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3156
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3157
                                    
3158
                                    //}
3159
                                }
3160
                            }
3161
                        }
3162
                        break;
3163
                    case ControlType.ImgControl:
3164
                        {
3165
                            if (e.LeftButton == MouseButtonState.Pressed)
3166
                            {
3167
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3168
                                //{
3169
                                    if (currentControl is ImgControl)
3170
                                    {
3171
                                        //20180906 LJY TEST IsRotationDrawingEnable
3172
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3173
                                        {
3174
                                            return;
3175
                                        }
3176

    
3177
                                        CreateCommand.Instance.Execute(currentControl);
3178
                                        controlType = ControlType.ImgControl;
3179
                                        currentControl = null;
3180
                                    }
3181
                                    else
3182
                                    {
3183
                                        
3184
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3185
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3186
                                        {
3187
                                            Image img = new Image();
3188
                                            if (filename.Contains(".svg"))
3189
                                            {
3190
                                                byte[] imageData = null;
3191
                                                DrawingImage image = null;
3192
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3193
                                                {
3194
                                                    imageData = web.DownloadData(new Uri(filename));
3195
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3196
                                                    image = SvgReader.Load(stream);
3197
                                                }
3198
                                                img.Source = image;
3199
                                            }
3200
                                            else
3201
                                            {
3202
                                                img.Source = new BitmapImage(new Uri(filename));
3203
                                            }
3204

    
3205
                                            currentControl = new ImgControl
3206
                                            {
3207
                                                    Background = new SolidColorBrush(Colors.Black),
3208
                                                    PointSet = new List<Point>(),
3209
                                                    FilePath = filename,
3210
                                                    ImageData = img.Source,
3211
                                                    StartPoint = canvasDrawingMouseDownPoint,
3212
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3213
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3214
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3215
                                                    ControlType = ControlType.ImgControl
3216
                                                };
3217

    
3218
                                        
3219
                                                currentControl.CommentID = Commons.shortGuid();                                            
3220
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3221
                                                currentControl.IsNew = true;
3222
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3223

    
3224
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3225
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3226
                                        }
3227
                                    }
3228
                                //}
3229
                            }
3230
                        }
3231
                        break;
3232
                    case ControlType.Date:
3233
                        {
3234
                            if (e.LeftButton == MouseButtonState.Pressed)
3235
                            {
3236
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3237
                                //{
3238
                                    if (currentControl is DateControl)
3239
                                    {
3240
                                        //20180906 LJY TEST IsRotationDrawingEnable
3241
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3242
                                        {
3243
                                            return;
3244
                                        }
3245

    
3246
                                        CreateCommand.Instance.Execute(currentControl);
3247
                                        currentControl = null;
3248

    
3249
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3250
                                        {
3251
                                            controlType = ControlType.None;
3252
                                            IsSwingMode = false;
3253
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3254
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3255
                                            mouseHandlingMode = MouseHandlingMode.None;
3256
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3257
                                            txtBatch.Visibility = Visibility.Collapsed;
3258

    
3259
                                        }
3260
                                    }
3261
                                    else
3262
                                    {
3263
                                        currentControl = new DateControl
3264
                                        {
3265
                                            StartPoint = canvasDrawingMouseDownPoint,
3266
                                            Background = new SolidColorBrush(Colors.Black)
3267
                                        };
3268
                                        currentControl.CommentID = Commons.shortGuid();
3269
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3270
                                        currentControl.IsNew = true;
3271
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3272

    
3273
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3274
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3275
                                }
3276
                                //}
3277
                            }
3278
                        }
3279
                        break;
3280
                    case ControlType.TextControl:
3281
                        {
3282
                            if (e.LeftButton == MouseButtonState.Pressed)
3283
                            {
3284
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3285
                                {
3286
                                    currentControl = new TextControl
3287
                                    {
3288
                                        ControlType = controlType
3289
                                    };
3290
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3291
                                    currentControl.CommentID = Commons.shortGuid();
3292
                                    currentControl.IsNew = true;
3293
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3294
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3295
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3296

    
3297
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3298
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3299
                                    
3300
                                    (currentControl as TextControl).ControlType_No = 0;
3301
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3302
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3303
                                    (currentControl as TextControl).ApplyTemplate();
3304
                                    (currentControl as TextControl).Base_TextBox.Focus();
3305
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3306
                                    CreateCommand.Instance.Execute(currentControl);
3307
                                }
3308
                            }
3309
                        }
3310
                        break;
3311
                    case ControlType.TextBorder:
3312
                        {
3313
                            if (e.LeftButton == MouseButtonState.Pressed)
3314
                            {
3315
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3316
                                {
3317
                                    currentControl = new TextControl
3318
                                    {
3319
                                        ControlType = controlType
3320
                                    };
3321

    
3322
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3323
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3324
                                    currentControl.CommentID = Commons.shortGuid();
3325
                                    currentControl.IsNew = true;
3326
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3327
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3328
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3329
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3330
                                    
3331
                                    (currentControl as TextControl).ControlType_No = 1;
3332
                                    (currentControl as TextControl).Angle = Ang;
3333
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3334
                                    (currentControl as TextControl).ApplyTemplate();
3335
                                    (currentControl as TextControl).Base_TextBox.Focus();
3336
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3337
                                    CreateCommand.Instance.Execute(currentControl);
3338
                                }
3339
                            }
3340
                        }
3341
                        break;
3342
                    case ControlType.TextCloud:
3343
                        {
3344
                            if (e.LeftButton == MouseButtonState.Pressed)
3345
                            {
3346
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3347
                                {
3348
                                    currentControl = new TextControl
3349
                                    {
3350
                                        ControlType = controlType
3351
                                    };
3352

    
3353
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3354
                                    currentControl.CommentID = Commons.shortGuid();
3355
                                    currentControl.IsNew = true;
3356
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3357
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3358

    
3359
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3360
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3361
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3362

    
3363
                                    (currentControl as TextControl).Angle = Ang;
3364
                                    (currentControl as TextControl).ControlType_No = 2;
3365
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3366
                                    (currentControl as TextControl).ApplyTemplate();
3367
                                    (currentControl as TextControl).Base_TextBox.Focus();
3368
                                    CreateCommand.Instance.Execute(currentControl);
3369
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3370
                                    //currentControl = null;
3371
                                }
3372
                            }
3373
                        }
3374
                        break;
3375
                    case ControlType.ArrowTextControl:
3376
                         {
3377
                            if (e.LeftButton == MouseButtonState.Pressed)
3378
                            {
3379
                                if (currentControl is ArrowTextControl)
3380
                                {
3381
                                    //20180906 LJY TEST IsRotationDrawingEnable
3382
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3383
                                    {
3384
                                        return;
3385
                                    }
3386

    
3387
                                    CreateCommand.Instance.Execute(currentControl);
3388

    
3389
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3390
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3391
                                    (currentControl as ArrowTextControl).IsNew = false;
3392
                                    currentControl = null;
3393
                                }
3394
                                else
3395
                                {
3396
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3397
                                    //{
3398
                                        currentControl = new ArrowTextControl();
3399
                                        currentControl.CommentID = Commons.shortGuid();
3400
                                        currentControl.IsNew = true;
3401
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3402
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3403

    
3404
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3405
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3406
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3407
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3408
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3409

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

    
3413
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3414
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3415
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3416
                                        this.MainAngle.Visibility = Visibility.Visible;
3417

    
3418
                                    
3419
                                    //}
3420
                                }
3421
                            }
3422
                        }
3423
                        break;
3424
                    case ControlType.ArrowTransTextControl:
3425
                        {
3426
                            if (e.LeftButton == MouseButtonState.Pressed)
3427
                            {
3428
                                if (currentControl is ArrowTextControl)
3429
                                {
3430
                                    //20180906 LJY TEST IsRotationDrawingEnable
3431
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3432
                                    {
3433
                                        return;
3434
                                    }
3435

    
3436
                                    CreateCommand.Instance.Execute(currentControl);
3437

    
3438
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3439
                                    
3440
                                    currentControl.IsNew = false;
3441
                                    currentControl = null;
3442
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3443
                                }
3444
                                else
3445
                                {
3446
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3447
                                    //{
3448
                                    currentControl = new ArrowTextControl()
3449
                                    {
3450
                                        ControlType = ControlType.ArrowTransTextControl
3451
                                    };
3452
                                    currentControl.CommentID = Commons.shortGuid();
3453
                                    currentControl.IsNew = true;
3454
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3455
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3456
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3457
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3458
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3459
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3460
                                    (currentControl as ArrowTextControl).isFixed = true;
3461
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3462

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

    
3466
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3467
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3468
                                    (currentControl as ArrowTextControl).isTrans = true;
3469
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3470
                                }
3471
                            }
3472
                        }
3473
                        break;
3474
                    case ControlType.ArrowTextBorderControl:
3475
                         {
3476
                            if (e.LeftButton == MouseButtonState.Pressed)
3477
                            {
3478
                                if (currentControl is ArrowTextControl)
3479
                                {
3480
                                    //20180906 LJY TEST IsRotationDrawingEnable
3481
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3482
                                    {
3483
                                        return;
3484
                                    }
3485

    
3486
                                    CreateCommand.Instance.Execute(currentControl);
3487
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3488
                                    currentControl.IsNew = false;
3489
                                    currentControl = null;
3490
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3491
                                }
3492
                                else
3493
                                {
3494
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3495
                                    //{
3496
                                        currentControl = new ArrowTextControl()
3497
                                        {
3498
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3499
                                        };
3500
                                        currentControl.CommentID = Commons.shortGuid();
3501
                                        currentControl.IsNew = true;
3502
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3503
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3504

    
3505
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3506

    
3507
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3508

    
3509
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3510
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3511
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3512
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3513
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3514
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3515
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3516
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3517
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3518
                                    //}
3519
                                }
3520
                            }
3521
                        }
3522
                        break;
3523
                    case ControlType.ArrowTransTextBorderControl:
3524
                        {
3525
                            if (e.LeftButton == MouseButtonState.Pressed)
3526
                            {
3527
                                if (currentControl is ArrowTextControl)
3528
                                {
3529
                                    //20180906 LJY TEST IsRotationDrawingEnable
3530
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3531
                                    {
3532
                                        return;
3533
                                    }
3534
                                    CreateCommand.Instance.Execute(currentControl);
3535
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3536
                                    currentControl.IsNew = false;
3537
                                    currentControl = null;
3538

    
3539
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3540
                                }
3541
                                else
3542
                                {
3543
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3544
                                    //{
3545
                                    
3546

    
3547
                                    currentControl = new ArrowTextControl()
3548
                                    {
3549
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3550
                                        ControlType = ControlType.ArrowTransTextBorderControl
3551

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

    
3558
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3559

    
3560
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3561
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3562
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3563
                                        (currentControl as ArrowTextControl).isFixed = true;
3564
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3565
                                     
3566
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3567
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3568
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3569
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3570
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3571
                                        this.MainAngle.Visibility = Visibility.Visible;
3572
                                    
3573
                                    //20180911 LJY
3574
                                        (currentControl as ArrowTextControl).isTrans = true;
3575
                                    
3576

    
3577
                                    //}
3578
                                }
3579
                            }
3580
                        }
3581
                        break;
3582
                    case ControlType.ArrowTextCloudControl:
3583
                        {
3584
                            if (e.LeftButton == MouseButtonState.Pressed)
3585
                            {
3586
                                if (currentControl is ArrowTextControl)
3587
                                {
3588
                                    //20180906 LJY TEST IsRotationDrawingEnable
3589
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3590
                                    {
3591
                                        return;
3592
                                    }
3593
                                    CreateCommand.Instance.Execute(currentControl);
3594
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3595
                                    currentControl.IsNew = false;
3596
                                    currentControl = null;
3597
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3598
                                }
3599
                                else
3600
                                {
3601
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3602
                                    //{
3603
                                        currentControl = new ArrowTextControl()
3604
                                        {
3605
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3606
                                        };
3607
                                        currentControl.CommentID = Commons.shortGuid();
3608
                                        currentControl.IsNew = true;
3609
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3610
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3611

    
3612
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3613
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3614
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3615
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3616
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3617
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3618
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3619
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3620
                                    
3621
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3622
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3623
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3624
                                    //}
3625
                                }
3626
                            }
3627
                        }
3628
                        break;
3629
                    case ControlType.ArrowTransTextCloudControl:
3630
                        {
3631
                            if (e.LeftButton == MouseButtonState.Pressed)
3632
                            {
3633
                                if (currentControl is ArrowTextControl)
3634
                                {
3635
                                    //20180906 LJY TEST IsRotationDrawingEnable
3636
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3637
                                    {
3638
                                        return;
3639
                                    }
3640
                                    CreateCommand.Instance.Execute(currentControl);
3641
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3642
                                    currentControl.IsNew = false;
3643
                                    currentControl = null;
3644
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3645
                                }
3646
                                else
3647
                                {
3648
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3649
                                    //{
3650
                                        currentControl = new ArrowTextControl()
3651
                                        {
3652
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3653
                                            ControlType = ControlType.ArrowTransTextCloudControl
3654

    
3655
                                        };
3656
                                        currentControl.CommentID = Commons.shortGuid();
3657
                                        currentControl.IsNew = true; 
3658
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3659
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3660
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3661

    
3662
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3663
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3664
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3665
                                        (currentControl as ArrowTextControl).isFixed = true;
3666
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3667

    
3668
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3669
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3670
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3671
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3672
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3673
                                        this.MainAngle.Visibility = Visibility.Visible;  
3674
                                    
3675
                                    //20180911 LJY
3676
                                        (currentControl as ArrowTextControl).isTrans = true;
3677
                                    //}
3678
                                }
3679
                            }
3680
                        }
3681
                        break;
3682
                    //강인구 추가
3683
                    case ControlType.Sign:
3684
                        {
3685
                            if (e.LeftButton == MouseButtonState.Pressed)
3686
                            {
3687
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3688
                                //{
3689
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3690

    
3691
                                    if (_sign == null)
3692
                                    {
3693
                                        txtBatch.Visibility = Visibility.Collapsed;
3694
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3695
                                        controlType = ControlType.None;
3696

    
3697
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3698
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3699
                                        return;
3700
                                    }
3701

    
3702
                                    if (currentControl is SignControl)
3703
                                    {
3704
                                        //20180906 LJY TEST IsRotationDrawingEnable
3705
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3706
                                        {
3707
                                            return;
3708
                                        }
3709

    
3710
                                        CreateCommand.Instance.Execute(currentControl);
3711
                                        currentControl = null;
3712
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3713
                                        {
3714
                                            txtBatch.Text = "Place Date";
3715
                                            controlType = ControlType.Date;
3716
                                        }
3717
                                    }
3718
                                    else
3719
                                    {
3720
                                        currentControl = new SignControl
3721
                                        {
3722
                                            Background = new SolidColorBrush(Colors.Black),
3723
                                            UserNumber = App.ViewInfo.UserID,
3724
                                            ProjectNO = App.ViewInfo.ProjectNO,
3725
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3726
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3727
                                            ControlType = ControlType.Sign
3728
                                        };
3729

    
3730
                                        currentControl.CommentID = Commons.shortGuid();
3731
                                        currentControl.IsNew = true;
3732
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3733
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3734

    
3735
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3736
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3737
                                }
3738
                                //}
3739
                            }
3740
                        }
3741
                        break;
3742
                    case ControlType.Mark:
3743
                        {
3744
                            if (e.LeftButton == MouseButtonState.Pressed)
3745
                            {
3746
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3747
                                //{
3748
                                    if (currentControl is RectangleControl)
3749
                                    {
3750
                                        //20180906 LJY TEST IsRotationDrawingEnable
3751
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3752
                                        {
3753
                                            return;
3754
                                        }
3755

    
3756
                                        CreateCommand.Instance.Execute(currentControl);
3757
                                        (currentControl as RectangleControl).ApplyOverViewData();
3758
                                        currentControl = null;
3759
                                    
3760
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3761

    
3762
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3763
                                        {
3764
                                            txtBatch.Text = "Place Signature";
3765
                                            controlType = ControlType.Sign;
3766
                                        }
3767
                                    }
3768
                                    else
3769
                                    {
3770
                                        currentControl = new RectangleControl
3771
                                        {
3772
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3773
                                            Background = new SolidColorBrush(Colors.Black),
3774
                                            ControlType = ControlType.Mark ,
3775
                                            Paint = PaintSet.Fill
3776
                                        };
3777

    
3778
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3779
                                        currentControl.CommentID = Commons.shortGuid();
3780
                                        currentControl.IsNew = true;
3781
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3782
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3783
                                    }
3784
                                //}
3785
                            }
3786
                        }
3787
                        break;
3788
                    case ControlType.Symbol:
3789
                        {
3790
                            if (e.LeftButton == MouseButtonState.Pressed)
3791
                            {
3792
                                if (currentControl is SymControl)
3793
                                {
3794
                                    //20180906 LJY TEST IsRotationDrawingEnable
3795
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3796
                                    {
3797
                                        return;
3798
                                    }
3799
                                    CreateCommand.Instance.Execute(currentControl);
3800
                                    currentControl = null;
3801
                                
3802
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3803
                                }
3804
                                else
3805
                                {
3806
                                    currentControl = new SymControl
3807
                                    {
3808
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3809
                                        Background = new SolidColorBrush(Colors.Black),
3810
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3811
                                        ControlType = ControlType.Symbol
3812
                                    };
3813

    
3814
                                    currentControl.IsNew = true;
3815
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3816
                                    currentControl.CommentID = Commons.shortGuid();
3817
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3818

    
3819
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3820
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3821
                                }
3822
                                //}
3823
                            }
3824
                        }
3825
                        break;
3826
                    case ControlType.Stamp:
3827
                        {
3828
                            if (e.LeftButton == MouseButtonState.Pressed)
3829
                            {
3830
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3831
                                //{
3832
                                    if (currentControl is SymControlN)
3833
                                    {
3834
                                        //20180906 LJY TEST IsRotationDrawingEnable
3835
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3836
                                        {
3837
                                            return;
3838
                                        }
3839

    
3840
                                        CreateCommand.Instance.Execute(currentControl);
3841
                                        currentControl = null;
3842
                                   
3843

    
3844
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3845
                                    }
3846
                                    else
3847
                                    {
3848
                                        currentControl = new SymControlN
3849
                                        {
3850
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3851
                                            Background = new SolidColorBrush(Colors.Black),
3852
                                            STAMP = App.SystemInfo.STAMP,                                            
3853
                                            ControlType = ControlType.Stamp
3854
                                        };
3855

    
3856
                                        currentControl.IsNew = true;
3857
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3858
                                        currentControl.CommentID = Commons.shortGuid();
3859
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3860
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3861
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3862
                                }                                    
3863
                                //}
3864
                            }
3865
                        }
3866
                        break;
3867
                    case ControlType.PenControl:
3868
                        {
3869
                            if (inkBoard.Tag.ToString() == "Ink")
3870
                            {
3871
                                inkBoard.IsEnabled = true;
3872
                                StartNewStroke(canvasDrawingMouseDownPoint);
3873
                            }
3874
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3875
                            {
3876
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3877
                            }
3878
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3879
                            {
3880
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3881
                            }
3882
                            IsDrawing = true;
3883
                            return;
3884
                        }
3885
                    default:
3886
                        if (currentControl != null)
3887
                        {
3888
                            currentControl.CommentID = null;
3889
                            currentControl.IsNew = false;
3890
                        }
3891
                        break;
3892
                }
3893
            }
3894
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3895
            {
3896
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3897
                {
3898
                    bool mouseOff = false;
3899
                    foreach (var item in SelectLayer.Children)
3900
                    {
3901
                        if (item is AdornerFinal)
3902
                        {
3903

    
3904
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3905
                            if (over != null)
3906
                            {
3907
                                mouseOff = true;
3908
                            }
3909
                        }
3910
                    }
3911

    
3912
                    if (!mouseOff)
3913
                    {
3914
                        SelectionSet.Instance.UnSelect(this);
3915
                    }
3916
                }
3917
                zoomAndPanControl.CaptureMouse();
3918
                e.Handled = true;
3919
            }
3920
          
3921
        }
3922

    
3923
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3924
        {
3925
            ///mouseButtonDown = e.ChangedButton;
3926
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3927
        }
3928

    
3929
        private void RemoveLineStroke(Point P)
3930
        {
3931
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3932
            if (control != null)
3933
            {
3934
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3935
            }
3936
        }
3937

    
3938
        private void RemovePointStroke(Point P)
3939
        {
3940
            foreach (Stroke hits in inkBoard.Strokes)
3941
            {
3942
                foreach (StylusPoint sty in hits.StylusPoints)
3943
                {
3944

    
3945
                }
3946
                if (hits.HitTest(P))
3947
                {
3948
                    inkBoard.Strokes.Remove(hits);
3949
                    return;
3950
                }
3951
            }
3952
        }
3953

    
3954
        private void StartNewStroke(Point P)
3955
        {
3956
            strokePoints = new StylusPointCollection();
3957
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3958
            strokePoints.Add(segment1Start);
3959
            stroke = new Stroke(strokePoints);
3960

    
3961
            stroke.DrawingAttributes.Color = Colors.Red;
3962
            stroke.DrawingAttributes.Width = 4;
3963
            stroke.DrawingAttributes.Height = 4;
3964

    
3965
            inkBoard.Strokes.Add(stroke);
3966
        }
3967

    
3968
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3969
        {
3970
            ConsolidationMethod();
3971
        }
3972

    
3973
        /// <summary>
3974
        /// execute TeamConsolidationCommand
3975
        /// </summary>
3976
        public void TeamConsolidationMethod()
3977
        {
3978
            this.UpdateMyMarkupList();
3979
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3980
            {
3981
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3982
            }
3983
            else
3984
            {
3985

    
3986
                ViewerDataModel.Instance.IsConsolidate = true;
3987
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3988

    
3989
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3990
                {
3991
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3992
                    {
3993
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3994
                        return;
3995
                    }                    
3996
                }
3997
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3998
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3999
                {
4000
                    MarkupInfoList.Add(item);
4001
                }
4002
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4003
            }
4004
        }
4005

    
4006
        public void ConsolidationMethod()
4007
        {
4008
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4009
            {
4010
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4011
            }
4012
            else
4013
            {
4014
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4015
                foreach (var item in this.gridViewMarkup.SelectedItems)
4016
                {
4017
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4018
                }
4019
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4020
                
4021
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4022
            }
4023
        }
4024

    
4025
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4026
        {
4027
            if (App.ViewInfo != null)
4028
            {
4029
                btnConsolidate = (sender as RadRibbonButton);
4030
                if (!App.ViewInfo.NewCommentPermission)
4031
                {
4032
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4033
                }
4034
            }
4035
        }
4036

    
4037
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4038
        {
4039
            TeamConsolidationMethod();
4040
        }
4041

    
4042
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4043
        {
4044
            btnTeamConsolidate = sender as RadRibbonButton;
4045
            if (App.ViewInfo != null)
4046
            {
4047
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4048
                {
4049
                    if (btnConsolidate != null)
4050
                    {
4051
                        btnConsolidate.Visibility = Visibility.Collapsed;
4052
                    }
4053

    
4054
                    if (!App.ViewInfo.NewCommentPermission)
4055
                    {
4056
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4057
                    }
4058
                }
4059
                else
4060
                {
4061
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4062
                }
4063
            }
4064
        }
4065

    
4066
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4067
        {
4068
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4069
            if(item != null)
4070
            {
4071
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4072
                {
4073
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4074
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4075
                }
4076
                else
4077
                {
4078
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4079
                }
4080
            }else{
4081
                //Consolidate 가 없는 경우
4082
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4083
            }
4084
            
4085
        }
4086

    
4087
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4088
        {
4089
            btnFinalPDF = sender as RadRibbonButton;
4090
            if (App.ViewInfo != null)
4091
            {
4092
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4093
                {
4094
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4095
                    if (btnConsolidate != null)
4096
                    {
4097
                        btnConsolidate.Visibility = Visibility.Collapsed;
4098
                    }
4099
                }
4100
            }
4101
        }
4102

    
4103
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4104
        {
4105
            UpdateMyMarkupList();
4106

    
4107
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4108
            {
4109
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4110
            }
4111
            else
4112
            {
4113
                ViewerDataModel.Instance.IsConsolidate = true;
4114
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4115
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4116

    
4117
                string project_no = App.ViewInfo.ProjectNO;
4118
                string doc_id = _DocInfo.ID;
4119
                string user_id = App.ViewInfo.UserID;
4120
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4121
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4122
                {
4123
                    markupInfoItems.Add(item);
4124
                }
4125
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4126
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4127
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4128
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4129

    
4130
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4131
                if (item2 != null)
4132
                {
4133
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4134

    
4135
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4136
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4137
                }
4138
                else
4139
                {
4140
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4141
                }
4142
            }
4143
        }
4144

    
4145
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4146
        {
4147
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4148

    
4149
            if (App.ViewInfo != null)
4150
            {
4151
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4152
                {
4153
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4154
                }
4155
            }
4156
        }
4157

    
4158
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4159
        {
4160
            SetCompareRect();
4161
        }
4162

    
4163
        private void Sync_Click(object sender, RoutedEventArgs e)
4164
        {
4165
            if (Sync.IsChecked)
4166
            {
4167
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4168
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4169
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4170
            }
4171
        }
4172

    
4173
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4174
        {
4175
            if (UserList.IsChecked)
4176
            {
4177
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4178
            }
4179
            else
4180
            {
4181
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4182
            }
4183
        }
4184

    
4185
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4186
        {
4187

    
4188
            if (BalanceMode.IsChecked)
4189
            {
4190
                ViewerDataModel.Instance.PageBalanceMode = true;
4191
            }
4192
            else
4193
            {
4194
                ViewerDataModel.Instance.PageBalanceMode = false;
4195
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4196
            }
4197
        }
4198

    
4199
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4200
        {
4201
            //초기화
4202
            testPanel2.IsHidden = true;
4203
            ViewerDataModel.Instance.PageBalanceMode = false;
4204
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4205
            ViewerDataModel.Instance.PageNumber = 0;
4206
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4207
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4208
            UserList.IsChecked = false;
4209
            BalanceMode.IsChecked = false;
4210
        }
4211

    
4212
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4213
        {
4214
            if ((sender as System.Windows.Controls.Control).Tag != null)
4215
            {
4216
                //Compare 초기화
4217
                CompareMode.IsChecked = false;
4218
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4219

    
4220
                if (ViewerDataModel.Instance.PageNumber == 0)
4221
                {
4222
                    ViewerDataModel.Instance.PageNumber = 1;
4223
                }
4224

    
4225
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4226
                {
4227
                }
4228
                else
4229
                {
4230
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4231
                }
4232

    
4233
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4234
                {
4235

    
4236
                }
4237
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4238
                {
4239
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4240
                }
4241

    
4242
                if (!testPanel2.IsHidden)
4243
                {
4244
                    if (IsSyncPDFMode)
4245
                    {
4246
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4247
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4248

    
4249
                        if (pdfpath.IsDownloading)
4250
                        {
4251
                            pdfpath.DownloadCompleted += (ex, arg) =>
4252
                            {
4253
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4254
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4255
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4256
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4257
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4258
                            };
4259
                        }
4260
                        else
4261
                        {
4262
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4263
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4264
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4265

    
4266
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4267
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4268
                        }
4269

    
4270
                    }
4271
                    else
4272
                    {
4273
                        string uri = this.GetImageURL(_ViewInfo.ProjectNO, ViewerDataModel.Instance.PageNumber);
4274

    
4275
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4276

    
4277
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4278
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4279
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4280

    
4281
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4282
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4283

    
4284
                        if (defaultBitmapImage_Compare.IsDownloading)
4285
                        {
4286
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4287
                            {
4288
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4289
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4290
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4291

    
4292
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4293
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4294
                            };
4295
                        }
4296
                    }
4297

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

    
4302
                    foreach (var item in gridSelectionRevItem)
4303
                    {
4304
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4305
                        {
4306
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4307
                        });
4308
                    }
4309

    
4310
                    //강인구 추가
4311
                    zoomAndPanControl2.ZoomTo(new Rect
4312
                    {
4313
                        X = 0,
4314
                        Y = 0,
4315
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4316
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4317
                    });
4318

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

    
4321
                }
4322
            }
4323
        }
4324

    
4325
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4326
        {
4327
            if (MarkupMode.IsChecked)
4328
            {
4329
                IsSyncPDFMode = true;
4330

    
4331
                var uri = CurrentRev.TO_VENDOR;
4332

    
4333
                if (ViewerDataModel.Instance.PageNumber == 0)
4334
                {
4335
                    ViewerDataModel.Instance.PageNumber = 1;
4336
                }
4337

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

    
4342
                if (pdfpath.IsDownloading)
4343
                {
4344
                    pdfpath.DownloadCompleted += (ex, arg) =>
4345
                    {
4346
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4347
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4348
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4349
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4350
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4351
                    };
4352
                }
4353
                else
4354
                {
4355
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4356
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4357
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4358

    
4359
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4360
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4361
                }
4362
            }
4363
            else
4364
            {
4365
                IsSyncPDFMode = false;
4366
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4367

    
4368
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4369

    
4370
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4371
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4372
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4373

    
4374
                if (defaultBitmapImage_Compare.IsDownloading)
4375
                {
4376
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4377
                    {
4378
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4379
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4380
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4381
                    };
4382
                }
4383
                zoomAndPanControl2.ApplyTemplate();
4384
                zoomAndPanControl2.UpdateLayout();
4385
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4386
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4387
            }
4388
        }
4389

    
4390
        /// <summary>
4391
        /// Compare된 영역을 초기화
4392
        /// </summary>
4393
        private void ClearCompareRect()
4394
        {
4395
            da.From = 1;
4396
            da.To = 1;
4397
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4398
            da.AutoReverse = false;
4399
            canvas_compareBorder.Children.Clear();
4400
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4401
        }
4402

    
4403
        /// <summary>
4404
        /// 문서 Comprare 
4405
        /// </summary>
4406
        private void SetCompareRect()
4407
        {
4408
            if (CompareMode.IsChecked)
4409
            {
4410
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4411
                {
4412
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4413
                }
4414
                if (ViewerDataModel.Instance.PageNumber == 0)
4415
                {
4416
                    ViewerDataModel.Instance.PageNumber = 1;
4417
                }
4418

    
4419
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4420
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4421
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4422

    
4423
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4424
            }
4425
            else
4426
            {
4427
                ClearCompareRect();
4428
            }
4429
        }
4430

    
4431
        private void RadButton_Click(object sender, RoutedEventArgs e)
4432
        {
4433
            gridViewHistory_Busy.IsBusy = true;
4434

    
4435
            RadButton instance = sender as RadButton;
4436
            if (instance.CommandParameter != null)
4437
            {
4438
                CurrentRev = instance.CommandParameter as VPRevision;
4439
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4440

    
4441
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4442
                {
4443
                    if (ea.Error == null && ea.Result != null)
4444
                    {
4445
                        testPanel2.IsHidden = false;
4446

    
4447
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4448
                        foreach(var info in ea.Result)
4449
                        {
4450
                            if(info.UserID == App.ViewInfo.UserID)
4451
                            {
4452
                                info.userDelete = true;
4453
                                info.DisplayColor = "FFFF0000";
4454
                            }
4455
                            else
4456
                            {
4457
                                info.userDelete = false;
4458
                            }
4459
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4460
                        }
4461
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4462

    
4463
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4464

    
4465
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4466

    
4467
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4468
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4469
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4470
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4471
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4472
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4473

    
4474
                        zoomAndPanControl2.ApplyTemplate();
4475
                        zoomAndPanControl2.UpdateLayout();
4476
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4477
                        {
4478
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4479
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4480
                        }
4481

    
4482
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4483
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4484
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4485

    
4486
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4487
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4488
                        gridViewHistory_Busy.IsBusy = false;
4489
                    }
4490

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

    
4493
                    if (GetSyncMarkupInfoItemshandler != null)
4494
                    {
4495
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4496
                    }
4497

    
4498
                    ClearCompareRect();
4499
                    SetCompareRect();
4500
                };
4501

    
4502
                /// 중복 실행이 발생하여 수정함.
4503
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4504
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4505

    
4506
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4507
            }
4508
        }
4509

    
4510
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4511
        {
4512
            try
4513
            {
4514
                if (sender is RadButton)
4515
                {
4516
                    if ((sender as RadButton).Tag != null)
4517
                    {
4518
                        var url = (sender as RadButton).Tag.ToString();
4519
                        System.Diagnostics.Process.Start(url);
4520
                    }
4521
                    else
4522
                    {
4523
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4524
                    }
4525
                }
4526
            }
4527
            catch (Exception ex)
4528
            {
4529
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4530
            }
4531
        }
4532

    
4533
        public void Sync_Event(VPRevision Currnet_Rev)
4534
        {
4535
            CurrentRev = Currnet_Rev;
4536

    
4537
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4538
            {
4539
                if (ea.Error == null && ea.Result != null)
4540
                {
4541
                    testPanel2.IsHidden = false;
4542

    
4543
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4544
                    foreach(var info in ea.Result)
4545
                    {
4546
                        if(info.UserID == App.ViewInfo.UserID)
4547
                        {
4548
                            info.userDelete = true;
4549
                            info.DisplayColor = "FFFF0000";
4550
                        }
4551
                        else
4552
                        {
4553
                            info.userDelete = false;
4554
                        }
4555
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4556
                    }
4557
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4558

    
4559
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4560

    
4561
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4562

    
4563
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4564

    
4565
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4566
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4567
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4568

    
4569
                    if (defaultBitmapImage_Compare.IsDownloading)
4570
                    {
4571
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4572
                        {
4573
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4574
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4575
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4576
                        };
4577
                    }
4578

    
4579

    
4580
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4581
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4582
                    zoomAndPanControl2.ApplyTemplate();
4583
                    zoomAndPanControl2.UpdateLayout();
4584

    
4585
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4586
                    {
4587
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4588
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4589
                    }
4590
                    //}
4591

    
4592
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4593
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4594
                    gridViewHistory_Busy.IsBusy = false;
4595
                }
4596
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4597

    
4598
            };
4599
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4600
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4601
        }
4602

    
4603
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4604
        {
4605
            if (sender is Image)
4606
            {
4607
                if ((sender as Image).Tag != null)
4608
                {
4609
                    var pdfUrl = (sender as Image).Tag.ToString();
4610
                    System.Diagnostics.Process.Start(pdfUrl);
4611
                }
4612
                else
4613
                {
4614
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4615
                }
4616
            }
4617
        }
4618

    
4619
        private void Create_Symbol(object sender, RoutedEventArgs e)
4620
        {
4621
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4622

    
4623
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4624
            {
4625
                DialogMessage_Alert("Please Select Controls", "Alert");
4626
            }
4627
            else //선택된 것이 있으면
4628
            {
4629
                string MarkupData = "";
4630
                adorner_ = new AdornerFinal();
4631

    
4632
                foreach (var item in SelectLayer.Children)
4633
                {
4634
                    if (item.GetType().Name == "AdornerFinal")
4635
                    {
4636
                        adorner_ = (item as Controls.AdornerFinal);
4637
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4638
                        {
4639
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4640
                            {
4641
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4642
                                MarkupData += markupReturn.ConvertData;
4643
                            }
4644
                        }
4645
                    }
4646
                }
4647
                DialogParameters parameters = new DialogParameters()
4648
                {
4649
                    Owner = Application.Current.MainWindow,
4650
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4651
                    DefaultPromptResultValue = "Custom State",
4652
                    Content = "Name :",
4653
                    Header = "Insert Custom Symbol Name",
4654
                    Theme = new VisualStudio2013Theme(),
4655
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4656
                };
4657
                RadWindow.Prompt(parameters);
4658
            }
4659

    
4660
        }
4661
        public int symbolselectindex = 0;
4662
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4663
        {
4664
            //Save save = new Save();
4665
            try
4666
            {
4667
                string svgfilename = null;
4668
                if (symbolname != null)
4669
                {
4670
                    if (symbolpng == true || symbolsvg == true)
4671
                    {
4672
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4673
                        string guid = Commons.shortGuid();
4674

    
4675
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4676
                        //Check_Uri.UriCheck();
4677
                        fileUploader.RunCompleted += (ex, arg) =>
4678
                        {
4679
                            filename = arg.Result;
4680
                            if (symbolpng == true)
4681
                            {
4682
                                if (filename != null)
4683
                                { 
4684
                                    if (symbolselectindex == 0)
4685
                                    {
4686
                                        SymbolSave(symbolname, filename, data);
4687
                                    }
4688
                                    else
4689
                                    {
4690
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4691
                                    }
4692
                                    DataBind();
4693
                                }                                
4694
                            }
4695

    
4696
                            if (symbolsvg == true)
4697
                            {
4698
                                try
4699
                                {
4700
                                    var defaultBitmapImage = new BitmapImage();
4701
                                    defaultBitmapImage.BeginInit();
4702
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4703
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4704
                                    Check_Uri.UriCheck(filename);
4705
                                    defaultBitmapImage.UriSource = new Uri(filename);
4706
                                    defaultBitmapImage.EndInit();
4707

    
4708
                                    System.Drawing.Bitmap image;
4709

    
4710
                                    if (defaultBitmapImage.IsDownloading)
4711
                                    {
4712
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4713
                                        {
4714
                                            defaultBitmapImage.Freeze();
4715
                                            image = GetBitmap(defaultBitmapImage);
4716
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4717
                                            Process potrace = new Process
4718
                                            {
4719
                                                StartInfo = new ProcessStartInfo
4720
                                                {
4721
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4722
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4723
                                                    RedirectStandardInput = true,
4724
                                                    RedirectStandardOutput = true,
4725
                                                    RedirectStandardError = true,
4726
                                                    UseShellExecute = false,
4727
                                                    CreateNoWindow = true,
4728
                                                    WindowStyle = ProcessWindowStyle.Hidden
4729
                                                },
4730
                                            };
4731

    
4732
                                            StringBuilder svgBuilder = new StringBuilder();
4733
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4734
                                            {
4735
                                                svgBuilder.AppendLine(e2.Data);
4736
                                            };
4737

    
4738
                                            potrace.EnableRaisingEvents = true;
4739
                                            potrace.Start();
4740
                                            potrace.Exited += (sender, e) =>
4741
                                            {
4742
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4743
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4744
                                                Check_Uri.UriCheck(svgfilename);
4745
                                                if (symbolselectindex == 0)
4746
                                                {
4747
                                                    SymbolSave(symbolname, svgfilename, data);
4748
                                                }
4749
                                                else
4750
                                                {
4751
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4752
                                                }
4753

    
4754
                                                DataBind();
4755
                                            };
4756
                                            potrace.WaitForExit();
4757
                                        };
4758
                                    }
4759
                                    else
4760
                                    {
4761
                                        //GC.Collect();
4762
                                    }
4763
                                }
4764
                                catch(Exception ee)
4765
                                {
4766
                                    DialogMessage_Alert("" + ee, "Alert");
4767
                                }
4768
                            }
4769
                        };                                             
4770
                    }
4771
                }
4772
            }
4773
            catch (Exception e)
4774
            {
4775
                //DialogMessage_Alert(e + "", "Alert");
4776
            }            
4777
        }
4778

    
4779
        public void SymbolSave(string Name, string Url, string Data)
4780
        {
4781
            try
4782
            {
4783
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4784
                {
4785
                    ID = Commons.shortGuid(),
4786
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4787
                    NAME = Name,
4788
                    IMAGE_URL = Url,
4789
                    DATA = Data
4790
                };
4791

    
4792
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4793
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4794
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4795
            }
4796
            catch (Exception)
4797
            {
4798
                throw;
4799
            }
4800
        }
4801

    
4802
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4803
        {
4804
            try
4805
            {
4806
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4807
                {
4808
                    ID = Commons.shortGuid(),
4809
                    DEPARTMENT = Department,
4810
                    NAME = Name,
4811
                    IMAGE_URL = Url,
4812
                    DATA = Data
4813
                };
4814
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4815
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4816
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4817
            }
4818
            catch (Exception)
4819
            {
4820
                throw;
4821
            }
4822
        }
4823

    
4824
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4825
        {           
4826
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4827
            DataBind();
4828
        }
4829

    
4830
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4831
        {
4832
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4833
            DataBind();
4834
        }
4835
        private void DataBind()
4836
        {
4837
            try
4838
            {
4839
                Symbol_Custom Custom = new Symbol_Custom();
4840
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4841
                
4842
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4843
                foreach (var item in symbol_Private)
4844
                {
4845
                    Custom.Name = item.NAME;
4846
                    Custom.ImageUri = item.IMAGE_URL;
4847
                    Custom.ID = item.ID;
4848
                    Custom_List.Add(Custom);
4849
                    Custom = new Symbol_Custom();
4850
                }
4851
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4852
                
4853
                Custom = new Symbol_Custom();
4854
                Custom_List = new List<Symbol_Custom>();
4855

    
4856
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4857

    
4858
                List<SYMBOL_PUBLIC> symbol_Public;
4859

    
4860
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4861
                {
4862
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4863
                }
4864
                else
4865
                {
4866
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4867
                }
4868
                foreach (var item in symbol_Public)
4869
                {
4870
                    Custom.Name = item.NAME;
4871
                    Custom.ImageUri = item.IMAGE_URL;
4872
                    Custom.ID = item.ID;
4873
                    Custom_List.Add(Custom);
4874
                    Custom = new Symbol_Custom();
4875
                }
4876
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4877
                BaseClient.Close();                
4878
            }
4879
            catch(Exception e)
4880
            {
4881
                //DialogMessage_Alert("DataBind", "Alert");
4882
            }
4883
            
4884
        }
4885
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4886
        {
4887
            try
4888
            {
4889
                if (args.PromptResult != null)
4890
                {
4891
                    if (args.DialogResult.Value)
4892
                    {
4893
                        PngBitmapEncoder _Encoder = symImage(data);
4894

    
4895
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4896
                        _Encoder.Save(fs);
4897
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4898

    
4899
                        byte[] Img_byte = fs.ToArray();
4900

    
4901
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4902
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4903
                        Check_Uri.UriCheck(filename);
4904
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4905
                        {
4906
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4907
                        }
4908
                        else
4909
                        {
4910
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4911
                        }
4912
                        DataBind();
4913
                    }
4914
                }
4915
            }
4916
            catch(Exception ex)
4917
            {
4918
                DialogMessage_Alert("" + ex, "Alert");
4919
            }
4920
        }
4921

    
4922
        public PngBitmapEncoder symImage(string data)
4923
        {
4924

    
4925
            Canvas _canvas = new Canvas();
4926
            _canvas.Background = Brushes.White;
4927
            _canvas.Width = adorner_.BorderSize.Width;
4928
            _canvas.Height = adorner_.BorderSize.Height;
4929
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4930

    
4931
            BitmapEncoder encoder = new PngBitmapEncoder();
4932

    
4933

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

    
4936
            DrawingVisual dv = new DrawingVisual();
4937

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

    
4941
            using (DrawingContext ctx = dv.RenderOpen())
4942
            {
4943
                VisualBrush vb = new VisualBrush(_canvas);
4944
                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)));
4945
            }
4946

    
4947
            try
4948
            {
4949
                renderBitmap.Render(dv);
4950

    
4951
                //GC.Collect();
4952
                GC.WaitForPendingFinalizers();
4953
                //GC.Collect();
4954
                // encode png data
4955
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4956
                // puch rendered bitmap into it
4957
                pngEncoder.Interlace = PngInterlaceOption.Off;
4958
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4959
                return pngEncoder;
4960

    
4961
            }
4962
            catch //(Exception ex)
4963
            {
4964
                return null;
4965
            }
4966

    
4967
        }
4968

    
4969
        public void DialogMessage_Alert(string content, string header)
4970
        {
4971
            DialogParameters parameters = new DialogParameters()
4972
            {
4973
                Owner = this.ParentOfType<MainWindow>(),
4974
                Content = new TextBlock()
4975
                { 
4976
                    MinWidth = 400,
4977
                    FontSize = 11,
4978
                    Text = content,
4979
                    TextWrapping = System.Windows.TextWrapping.Wrap
4980
                },
4981
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
4982
                Header = header,
4983
                Theme = new VisualStudio2013Theme(),
4984
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4985
            };            
4986
            RadWindow.Alert(parameters);
4987
        }
4988

    
4989
        #region 캡쳐 기능
4990

    
4991
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4992
        {
4993
            if (x < 0)
4994
            {
4995
                width += x;
4996
                x = 0;
4997
            }
4998
            if (y < 0)
4999
            {
5000
                height += y;
5001
                y = 0;
5002

    
5003
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5004
            }
5005
            if (x + width > zoomAndPanCanvas.ActualWidth)
5006
            {
5007
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5008
            }
5009
            if (y + height > zoomAndPanCanvas.ActualHeight)
5010
            {
5011
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5012
            }
5013

    
5014
            byte[] pixels = CopyPixels(x, y, width, height);
5015

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

    
5018
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5019
        }
5020

    
5021
        public byte[] CopyPixels(int x, int y, int width, int height)
5022
        {
5023
            byte[] pixels = new byte[width * height * 4];
5024
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5025

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

    
5029
            return pixels;
5030
        }
5031

    
5032
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5033
        {
5034
            DrawingVisual drawingVisual = new DrawingVisual();
5035
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5036

    
5037
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5038
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5039
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5040
            drawingContext.Close();
5041

    
5042
            // 비트맵으로 변환합니다.
5043
            RenderTargetBitmap target =
5044
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5045
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5046

    
5047
            target.Render(drawingVisual);
5048
            return target;
5049
        }
5050

    
5051
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5052
        {
5053
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5054
            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);
5055
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5056
            bmp.UnlockBits(data);
5057
            return bmp;
5058
        }
5059
        public string symbolname = null;
5060
        public bool symbolsvg = true;
5061
        public bool symbolpng = true;
5062

    
5063
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5064
        {
5065
            System.Drawing.Bitmap image = GetBitmap(source);
5066
            //흰색 제거
5067
            //image.MakeTransparent(System.Drawing.Color.White);
5068

    
5069
            var imageStream = new System.IO.MemoryStream();
5070
            byte[] imageBytes = null;
5071
            using (imageStream)
5072
            {
5073
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5074
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5075
                imageStream.Position = 0;
5076
                imageBytes = imageStream.ToArray();
5077
            }
5078

    
5079
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5080

    
5081
            RadWindow CheckPop = new RadWindow();
5082
            //Alert check = new Alert(Msg);
5083

    
5084
            CheckPop = new RadWindow
5085
            {
5086
                MinWidth = 400,
5087
                MinHeight = 100,
5088
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5089
                Header = "Alert",
5090
                Content = symbolPrompt,
5091
                //DialogResult = 
5092
                ResizeMode = System.Windows.ResizeMode.NoResize,
5093
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5094
                IsTopmost = true,
5095
            };
5096
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5097
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5098
            CheckPop.ShowDialog();
5099

    
5100
            /*
5101
            DialogParameters parameters = new DialogParameters()
5102
            {
5103
                Owner = Application.Current.MainWindow,
5104
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5105
                DefaultPromptResultValue = "Custom State",
5106
                Content = "Name :",
5107
                Header = "Insert Custom Symbol Name",
5108
                Theme = new VisualStudio2013Theme(),
5109
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5110
            };            
5111
            RadWindow.Prompt(parameters);
5112
            */
5113
        }
5114

    
5115
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5116
        {
5117
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5118
            KCOMDataModel.DataModel.CHECK_LIST check_;
5119
            string Result = streamToBase64.ImageToBase64(source);
5120
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5121
            string projectno = App.ViewInfo.ProjectNO;
5122
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5123

    
5124
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5125
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5126
            if (Item != null)
5127
            {
5128
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5129
            }
5130
            else
5131
            {
5132
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5133
            }
5134

    
5135
            if (Item == null)
5136
            {
5137
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5138
                {
5139
                    ID = Commons.shortGuid(),
5140
                    USER_ID = App.ViewInfo.UserID,
5141
                    IMAGE_URL = Result,
5142
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5143
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5144
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5145
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5146
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5147
                    STATUS = "False",
5148
                    CREATE_TIME = DateTime.Now,
5149
                    UPDATE_TIME = DateTime.Now,
5150
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5151
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5152
                };
5153
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5154
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5155
                //this.BaseClient.AddCheckList(projectno, check_);
5156
            }
5157
            else
5158
            {
5159
                Item.IMAGE_URL = Result;
5160
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5161
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5162
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5163
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5164
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5165
            }
5166

    
5167
        }
5168

    
5169
        public void Set_Capture()
5170
        {
5171
            double x = canvasDrawingMouseDownPoint.X;
5172
            double y = canvasDrawingMouseDownPoint.Y;
5173
            double width = dragCaptureBorder.Width;
5174
            double height = dragCaptureBorder.Height;
5175

    
5176
            if (width > 5 || height > 5)
5177
            {
5178
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5179
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5180
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5181
            }
5182
        }
5183
        #endregion
5184

    
5185
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5186
        {
5187
            multi_Undo_Data = new Multi_Undo_data();
5188

    
5189
            multi_Undo_Data.Markup = control;
5190

    
5191
            if ((control as IShapeControl) != null)
5192
            {
5193
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5194
            }
5195
            if ((control as IDashControl) != null)
5196
            {
5197
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5198
            }
5199
            if ((control as IPath) != null)
5200
            {
5201
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5202
            }
5203
            if ((control as UIElement) != null)
5204
            {
5205
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5206
            }
5207

    
5208
            return multi_Undo_Data;
5209
        }
5210

    
5211
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5212
        {
5213
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5214
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5215
            {
5216
                if (items.UserID == Select_ID)
5217
                {
5218
                    foreach (var item in items.MarkupList)
5219
                    {
5220
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5221
                        {
5222
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5223
                                items.MarkupInfoID, Commons.shortGuid());
5224
                        }
5225
                    }
5226
                }
5227
            }
5228
        }
5229

    
5230
        /// <summary>
5231
        /// convert inkcontrol to polygoncontrol
5232
        /// </summary>
5233
        public void ConvertInkControlToPolygon()
5234
        {
5235
            if (inkBoard.Strokes.Count > 0)
5236
            {
5237
                inkBoard.Strokes.ToList().ForEach(stroke =>
5238
                {
5239
                    InkToPath ip = new InkToPath();
5240

    
5241
                    List<Point> inkPointSet = new List<Point>();
5242
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5243

    
5244
                    PolygonControl pc = new PolygonControl()
5245
                    {
5246
                        Angle = 0,
5247
                        PointSet = inkPointSet,
5248
                        ControlType = ControlType.Ink
5249
                    };
5250
                    pc.StartPoint = inkPointSet[0];
5251
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5252
                    pc.LineSize = 3;
5253
                    pc.CommentID = Commons.shortGuid();
5254
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5255

    
5256
                    if (pc.PointSet.Count > 0)
5257
                    {
5258
                        CreateCommand.Instance.Execute(pc);
5259
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5260
                    }
5261
                });
5262
                inkBoard.Strokes.Clear();
5263
            }
5264
        }
5265

    
5266
        /// <summary>
5267
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5268
        /// </summary>
5269
        /// <author>ingu</author>
5270
        /// <date>2018.06.05</date>
5271
        /// <param name="getPoint"></param>
5272
        /// <returns></returns>
5273
        private bool IsGetoutpoint(Point getPoint)
5274
        {
5275
            if (getPoint == new Point())
5276
            {
5277
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5278
                currentControl = null;
5279
                return true;
5280
            }
5281

    
5282
            return false;
5283
        }
5284

    
5285
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5286
        {
5287
            e.Effects = DragDropEffects.Copy;
5288
        }
5289

    
5290
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5291
        {
5292
            e.Effects = DragDropEffects.Copy;
5293
        }
5294

    
5295
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5296
        {
5297
            e.Effects = DragDropEffects.None;
5298
        }
5299

    
5300
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5301
        {
5302
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5303
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5304

    
5305
            ScaleImage(pageWidth, pageHeight);
5306
        }
5307

    
5308
        /// <summary>
5309
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5310
        /// </summary>
5311
        /// <param name="pageWidth">원본 사이즈</param>
5312
        /// <param name="pageHeight">원본 사이즈</param>
5313
        /// <returns></returns>
5314
        private void ScaleImage(double pageWidth,double pageHeight)
5315
        {
5316
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5317
        }
5318

    
5319
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5320
        {
5321
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5322
        }
5323

    
5324

    
5325
        /*
5326
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5327
        {
5328
            try
5329
            {
5330
                if (e.Data.GetDataPresent(typeof(string)))
5331
                {
5332
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5333
                    string dragData = e.Data.GetData(typeof(string)) as string;
5334
                    Move_Symbol(sender, dragData);
5335
                }
5336
            }
5337
            catch (Exception ex)
5338
            {
5339
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5340
            }            
5341
        }
5342
        */
5343
    }
5344
}
클립보드 이미지 추가 (최대 크기: 500 MB)