프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (257 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
using System.Threading.Tasks;
47

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

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

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

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

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

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

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

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

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

    
122
    /// <summary>
123
    /// MainMenu.xaml에 대한 상호 작용 논리
124
    /// </summary>
125
    public partial class MainMenu : UserControl
126
    {
127
        #region 프로퍼티
128
        public CommentUserInfo currentControl { get; set; }
129
        public ControlType controlType { get; set; }
130
        private Move move = new Move();
131
        private double[] rotateValue = { 0, 90, 180, 270 };
132
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
133
        private static readonly double DragThreshold = 5;
134
        private System.Windows.Input.Cursor cursor { get; set; }
135

    
136
        /// <summary>
137
        ///  문서의 마우스 위치
138
        /// </summary>
139
        public Point CanvasDrawingMouseDownPoint;
140

    
141
        public string filename { get; set; }
142
        private Point canvasZoomPanningMouseDownPoint;
143
        public Point getCurrentPoint;
144
        private Point canvasZoommovingMouseDownPoint;
145
        List<object> ControlList = new List<object>();
146
        private ListBox listBox = new ListBox();
147
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
148
        private bool isDraggingSelectionRect = false;
149
        DrawingAttributes inkDA = new DrawingAttributes();
150
        private VPRevision CurrentRev { get; set; }
151
        public RadRibbonButton btnConsolidate { get; set; }
152
        public RadRibbonButton btnFinalPDF { get; set; }
153
        public RadRibbonButton btnTeamConsolidate { get; set; }
154
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
155

    
156
        public string Filename_ { get; set; }
157
        public double L_Size = 0;
158
        public AdornerFinal adorner_;
159
        public Multi_Undo_data multi_Undo_Data;
160
        public string Symbol_ID = "";
161
        /// <summary>
162
        /// Set to 'true' when the left mouse-button is down.
163
        /// </summary>
164
        public bool isLeftMouseButtonDownOnWindow = false;
165

    
166
        public InkPresenter _InkBoard = null;
167
        Stroke stroke;
168
        Boolean IsDrawing = false;
169
        StylusPointCollection strokePoints;
170
        //StylusPointCollection erasePoints;
171
        RenderTargetBitmap canvasImage;
172
        Point Sync_Offset_Point;
173

    
174
        //강인구 테스트
175
        private Path _SelectionPath { get; set; }
176
        public Path SelectionPath
177
        {
178
            get
179
            {
180
                return _SelectionPath;
181
            }
182
            set
183
            {
184
                if (_SelectionPath != value)
185
                {
186
                    _SelectionPath = value;
187
                    RaisePropertyChanged("SelectionPath");
188

    
189
                }
190
            }
191
        }
192

    
193
        private System.Windows.Controls.Image _imageViewer { get; set; }
194
        public System.Windows.Controls.Image imageViewer
195
        {
196
            get
197
            {
198
                if (_imageViewer == null)
199
                {
200
                    _imageViewer = new System.Windows.Controls.Image();
201
                    return _imageViewer;
202
                }
203
                else
204
                {
205
                    return _imageViewer;
206
                }
207
            }
208
            set
209
            {
210
                if (_imageViewer != value)
211
                {
212
                    _imageViewer = value;
213
                }
214
            }
215
        }
216

    
217
        public bool IsSyncPDFMode { get; set; }
218

    
219
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
220
        public System.Windows.Controls.Image imageViewer_Compare
221
        {
222
            get
223
            {
224
                if (_imageViewer_Compare == null)
225
                {
226
                    _imageViewer_Compare = new System.Windows.Controls.Image();
227
                    return _imageViewer_Compare;
228
                }
229
                else
230
                {
231
                    return _imageViewer_Compare;
232
                }
233
            }
234
            set
235
            {
236
                if (_imageViewer_Compare != value)
237
                {
238
                    _imageViewer_Compare = value;
239
                }
240
            }
241
        }
242

    
243
        #endregion
244

    
245
        public MainMenu()
246
        {
247
            App.splashString(ISplashMessage.MAINMENU_0);            
248
            //InitializeComponent();    
249
            this.Loaded += MainMenu_Loaded;
250
        }
251

    
252
        public class TempDt
253
        {
254
            public int PageNumber { get; set; }
255
            public string CommentID { get; set; }
256
            public string ConvertData { get; set; }
257
            public int DATA_TYPE { get; set; }
258
            public string MarkupInfoID { get; set; }
259
            public int IsUpdate { get; set; }
260
        }
261

    
262
        List<TempDt> tempDtList = new List<TempDt>();
263

    
264
        private void SetCursor()
265
        {
266
            this.Cursor = cursor;
267
        }
268

    
269
        /// <summary>
270
        /// get image url
271
        /// </summary>
272
        /// <author>humkyung</author>
273
        /// <param name="sDocumentID"></param>
274
        /// <returns></returns>
275
        public string GetImageURL(string sDocumentID, int iPageNo)
276
        {
277
            string uri = string.Empty;
278

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

    
289
            return uri;
290
        }
291

    
292
        /// <summary>
293
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
294
        /// </summary>
295
        /// <returns></returns>
296
        public string GetOriginalPDFURL()
297
        {
298
            string uri = string.Empty;
299
            string sDocumentID = this._DocItem.DOCUMENT_ID;
300
            string filename = string.Empty;
301
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
302
            {
303
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
304
            }
305
            else
306
            {
307
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
308
            }
309

    
310
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
311
            if (userData.COMPANY != "EXT")
312
            {
313
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
314
            }
315
            else
316
            {
317
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
318
            }
319
            uri = uri.Replace(".png", "");
320
            return uri;
321
        }
322

    
323
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
324
        {
325
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
326
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
327
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
328
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
329
            {
330
                return true;
331
            }
332

    
333
            return false;
334
        }
335

    
336
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
337
        {
338
            if (rotate.Angle == 90 || rotate.Angle == 270)
339
            {
340
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
341
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
342
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
343
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
344
                {
345
                    return true;
346
                }
347
            }
348
            else
349
            {
350
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
351
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
352
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
353
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
354
                {
355
                    return true;
356
                }
357
            }
358

    
359
            return false;
360
        }
361

    
362
        public void DeleteItem(MarkupInfoItem item)
363
        {
364
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
365
            {
366
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
367

    
368
            
369
            ViewerDataModel.Instance._markupInfoList.Remove(item);
370

    
371
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
372
            {
373
                ViewerDataModel.Instance.MarkupControls.Remove(a);
374
            });
375

    
376
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
377
            {
378
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
379
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
380
                null, Event_Type.Delete, a.CommentID, null);
381
            });
382

    
383
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
384
            {
385
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
386
                //임시파일에서도 삭제
387
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
388
            });
389

    
390
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
391

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

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

    
452
                        Button content = (sender as Button);
453
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
454

    
455
                        DeleteItem(item);
456
                    }
457
                }
458
            };
459
            RadWindow.Confirm(parameters);
460
        }
461

    
462
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
463

    
464
        private static Timer timer;
465
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
466
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
467
        {
468
            InitializeComponent();            
469
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
470

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

    
484
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
485
                {
486
                    this.SymbolPane.Visibility = Visibility.Collapsed;
487
                    this.FavoritePane.Visibility = Visibility.Collapsed;
488
                    this.drawingRotateCanvas.IsHitTestVisible = false;
489
                }
490
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
491
            }
492

    
493
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
494

    
495
        }
496

    
497
        private async Task DownloadOriginalFileAsync()
498
        {
499
            try
500
            {
501
                using (System.Net.WebClient client = new System.Net.WebClient())
502
                {
503
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
504
                    string downloadurl = GetOriginalPDFURL();
505
                    
506
                    // canceltoken을 위해서 상위에 선언
507
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
508

    
509
                    client.DownloadProgressChanged += (snd, evt) =>
510
                    {
511
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
512

    
513
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
514
                    };
515

    
516
                    await task;
517

    
518
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
519
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
520
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
521
                }
522
            }
523
            catch (Exception ex)
524
            {
525
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
526
            }
527
        }
528

    
529
        private void timercallback(Object o)
530
        {
531
            Stopwatch sw = new Stopwatch();
532
            sw.Start();
533
            TempFile.TempFileAdd();
534
            sw.Stop();
535

    
536
            Dispatcher.InvokeAsync(new Action(delegate
537
            {
538
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
539
                {
540
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
541
                }
542
            }));
543

    
544
            ////GC.Collect();
545
        }
546
        
547
        /// <summary>
548
        /// update my markuplist
549
        ///  - update existing markup data if already exist
550
        ///  - add new markup data if control is new
551
        /// </summary>
552
        public void UpdateMyMarkupList()
553
        {
554
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
555

    
556
            /// add or update markup list
557
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
558
            {
559
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
560

    
561
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
562
                if (exist != null) //신규 추가 된 코멘트
563
                {
564
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
565
                    {
566
                        exist.Data = root.ConvertData;
567
                        exist.IsUpdate = true;
568
                    }
569
                }
570
                else if (root.CommentID != null)
571
                {
572
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
573
                    {
574
                        ID = control.CommentID,
575
                        Data = root.ConvertData,
576
                        Data_Type = root.DATA_TYPE,
577
                        MarkupInfoID = App.Custom_ViewInfoId,
578
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
579
                        Symbol_ID = control.SymbolID,
580
                        //Group_ID = control.GroupID,
581
                    });
582
                }
583
            }
584

    
585
            /// delete markup list
586
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
587

    
588
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
589
                          where (markup.PageNumber == iPageNo) 
590
                          && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
591
                          select markup).ToList();
592

    
593
            foreach (var markup in deleted)
594
            {
595
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
596
            }
597
            /// up to here
598

    
599
            //if (modified)
600
            //{
601
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
602
            //    {
603
            //        ComingNewBieEnd = true;
604
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
605
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
606
            //        gridViewMarkup.ItemsSource = null;
607
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
608
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
609

    
610
            //        GroupDescriptor descriptor = new GroupDescriptor();
611
            //        descriptor.Member = "Depatment";
612
            //        descriptor.DisplayContent = "DEPT";
613
            //        descriptor.SortDirection = ListSortDirection.Ascending;
614
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
615
            //    }
616
            //}
617
        }
618

    
619
        DispatcherTimer renderTesttimer;
620

    
621
        /// <summary>
622
        /// start page changing
623
        ///  - save controls if page is modified
624
        ///  - starting download page image
625
        /// </summary>
626
        /// <param name="sender"></param>
627
        /// <param name="e"></param>
628
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
629
        {
630
            CompareMode.IsChecked = false;
631
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
632
           
633
            #region 페이지가 벗어난 경우
634

    
635
            if (BalancePoint < 1)
636
            {
637
                BalancePoint = 1;
638
                ViewerDataModel.Instance.PageBalanceNumber = 0;
639
            }
640

    
641
            if (pageNavigator.PageCount < BalancePoint)
642
            {
643
                BalancePoint = pageNavigator.PageCount;
644
                ViewerDataModel.Instance.PageBalanceNumber = 0;
645
            }
646

    
647
            #endregion
648

    
649
            ViewerDataModel.Instance.PageNumber = BalancePoint;
650

    
651
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
652
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
653
            var pageUri = pageNavigator.CurrentPage.PageUri;
654
            var contentScale = zoomAndPanControl.ContentScale;
655

    
656
            #region 페이지 이미지 로딩 수정
657

    
658
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
659
            try
660
            {
661
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
662
                
663
            }
664
            catch (Exception ex)
665
            {
666
                ViewerDataModel.Instance.ImageViewPath = null;
667
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
668
                DialogMessage_Alert(imgfailedmsg, "Warning");
669
                App.FileLogger.Fatal(ex);
670
            }
671
            ScaleImage(pageWidth, pageHeight);
672

    
673
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
674
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
675

    
676
            zoomAndPanCanvas.Width = pageWidth;
677
            zoomAndPanCanvas.Height = pageHeight;
678

    
679
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
680
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
681

    
682
            inkBoard.Width = pageWidth;
683
            inkBoard.Height = pageHeight;
684

    
685
            #endregion
686

    
687
            if (!testPanel2.IsHidden)
688
            {
689
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
690
                //PDF모드일때 잠시 대기(강인구)
691
                if (IsSyncPDFMode)
692
                {
693
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
694
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
695

    
696
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
697
                    if (pdfpath.IsDownloading)
698
                    {
699
                        pdfpath.DownloadCompleted += (ex, arg) =>
700
                        {
701
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
702
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
703
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
704
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
705
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
706
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
707
                        };
708
                    }
709
                    else
710
                    {
711
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
712
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
713
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
714
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
715

    
716
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
717
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
718
                    }
719
                }
720
                else
721
                {
722
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
723
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
724

    
725
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
726
                    var defaultBitmapImage_Compare = new BitmapImage();
727
                    defaultBitmapImage_Compare.BeginInit();
728
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
729
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
730
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
731
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
732
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
733
                    defaultBitmapImage_Compare.EndInit();
734

    
735
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
736

    
737
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
738
                    zoomAndPanControl.ZoomTo(new Rect
739
                    {
740
                        X = 0,
741
                        Y = 0,
742
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
743
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
744
                    });
745

    
746
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
747
                    if (defaultBitmapImage_Compare.IsDownloading)
748
                    {
749
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
750
                        {
751
                            defaultBitmapImage_Compare.Freeze();
752
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
753
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
754
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
755
                            ComparePanel.UpdateLayout();
756
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
757
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
758

    
759
                            zoomAndPanControl.ZoomTo(new Rect
760
                            {
761
                                X = 0,
762
                                Y = 0,
763
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
764
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
765
                            });
766

    
767
                            //defaultBitmapImage_Compare dispose
768
                            defaultBitmapImage_Compare = null;
769
                            GC.Collect();
770
                        };
771
                    }
772
                }
773
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
774
            }
775

    
776
            SearchFocusBorder.Visibility = Visibility.Collapsed;
777

    
778
            this.pageNavigator.ChangePage(e.PageNumber);
779
        }
780

    
781
        /// <summary>
782
        /// called after page is changed
783
        /// </summary>
784
        /// <param name="sender"></param>
785
        /// <param name="e"></param>
786
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
787
        {
788
            if (zoomAndPanCanvas2.Width.IsNaN())
789
            {
790
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
791
            }
792

    
793
            /// 컨트롤을 새로 생성한다.
794
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
795
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
796
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
797
            { 
798
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
799
                if (info != null)
800
                {
801
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
802
                    if (info.UserID == App.ViewInfo.UserID)
803
                    {
804
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
805
                                        markup.MarkupInfoID, markup.ID);
806
                        control.Visibility = Visibility.Hidden;
807
                    }
808
                    else
809
                    {
810
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
811
                                                                markup.MarkupInfoID, markup.ID);
812
                        control.Visibility = Visibility.Hidden;
813
                    }
814
                }
815
            };
816
            /// up to here
817

    
818
            /// fire selection event
819
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
820
            this.gridViewMarkup.UnselectAll();
821
            this.gridViewMarkup.Select(gridSelectionItem);
822

    
823
            if (!testPanel2.IsHidden)
824
            {
825
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
826
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
827
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
828

    
829
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
830
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
831

    
832

    
833
                foreach (var item in gridSelectionRevItem)
834
                {
835
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
836
                    {
837
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
838
                    });
839
                }
840
            }
841

    
842
            var instanceMain = this.ParentOfType<MainWindow>();
843
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
844
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
845

    
846
            instanceMain.dzTopMenu.rotateOffSet = 0;
847
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
848
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
849
            
850
            SetCommentPages(true);
851
        }
852

    
853
        public void SetCommentPages(bool onlyMe = false)
854
        {
855
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
856
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
857
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
858
            {
859
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
860
                if(item.MarkupList != null)
861
                {
862
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
863
                    instance.UserName = item.UserName;
864
                    instance.Depart = item.Depatment;
865
                    instance.MarkupInfoID = item.MarkupInfoID;
866
                    instance.IsSelected = true;
867
                    instance.isConSolidation = item.Consolidate;
868
                    instance.SetColor = item.DisplayColor;
869
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
870
                    {
871
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
872
                    }
873
                    else
874
                    {
875
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
876
                    }
877
                    _pages.Add(instance);
878
                }                   
879
            }
880
            
881
            this.pageNavigator.SetCommentList(_pages.ToList());
882
        }
883

    
884
        public void MarkupitemViewUpdate(string markupinfo_id)
885
        {
886
            //db에 업데이트 한 list 를 view 에 업데이트
887
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
888
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
889
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
890
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
891
            if (dbinfo.MarkupList.Count > 0)
892
            {
893
                if (viewinfo.MarkupList != null)
894
                {
895
                    viewinfo.MarkupList.Clear();
896
                    viewinfo.MarkupList = null;
897
                }
898
                viewinfo.MarkupList = new List<MarkupItem>();
899
                foreach (var item in dbinfo.MarkupList)
900
                {
901
                    viewinfo.MarkupList.Add(item);
902
                }
903
            }
904
        }
905

    
906
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
907
        {
908
            var instance = ViewerDataModel.Instance;
909

    
910
            if (instance.IsPressCtrl)
911
            {
912
                if (e.Delta > 0)
913
                {
914
                    if (0 < instance.ContentOffsetY + instance.ContentViewportHeight)
915
                    {
916
                        Vector dragOffset = new Vector(0, e.Delta);
917
                        MoveZoomAndPanControl(dragOffset);
918
                    }
919
                    //else
920
                    //{
921
                    //    pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
922
                    //}
923
                }
924
                else if(e.Delta < 0)
925
                {
926
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
927
                    {
928
                        Vector dragOffset = new Vector(0,e.Delta);
929
                        MoveZoomAndPanControl(dragOffset);
930
                    }
931
                    //else
932
                    //{
933
                    //    pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
934
                    //}
935
                }
936
            }
937
            else
938
            {
939
                e.Handled = true;
940
                if (e.Delta > 0)
941
                {
942
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
943
                    ZoomIn(currentContentMousePoint);
944
                }
945
                else
946
                {
947
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
948
                    ZoomOut(currentContentMousePoint);
949
                }
950
            }
951
        }
952

    
953
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
954
        {
955
            e.Handled = true;
956
            if (e.Delta > 0)
957
            {
958
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
959
                ZoomIn_Sync(currentContentMousePoint);
960
            }
961
            else
962
            {
963
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
964
                ZoomOut_Sync(currentContentMousePoint);
965
            }
966
        }
967

    
968
        #region ZoomIn & ZoomOut
969

    
970
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
971
        {
972
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
973
                zoomAndPanControl.ContentZoomFocusY));
974
        }
975

    
976
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
977
        {
978
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
979
                zoomAndPanControl.ContentZoomFocusY));
980
        }
981

    
982

    
983
        //강인구 추가 (줌 인아웃 수치 변경)
984
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
985
        private void ZoomOut(Point contentZoomCenter)
986
        {
987
            if (zoomAndPanControl.ContentScale > 0.39)
988
            {
989
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
990
            }
991
            else
992
            {
993
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
994
            }
995

    
996
            if (zoomAndPanControl2 != null && Sync.IsChecked)
997
            {
998
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
999
            }
1000
        }
1001

    
1002
        private void ZoomIn(Point contentZoomCenter)
1003
        {
1004
            if (zoomAndPanControl.ContentScale > 0.19)
1005
            {
1006
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1007
            }
1008
            else
1009
            {
1010
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1011
            }
1012

    
1013
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1014
            {
1015
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1016
            }
1017

    
1018
        }
1019

    
1020
        private void ZoomOut_Sync(Point contentZoomCenter)
1021
        {
1022
            if (zoomAndPanControl2.ContentScale > 0.39)
1023
            {
1024
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1025
            }
1026
            else
1027
            {
1028
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1029
            }
1030

    
1031
            if (Sync.IsChecked)
1032
            {
1033
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1034
            }
1035
        }
1036

    
1037
        private void ZoomIn_Sync(Point contentZoomCenter)
1038
        {
1039
            if (zoomAndPanControl2.ContentScale > 0.19)
1040
            {
1041
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1042
            }
1043
            else
1044
            {
1045
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1046
            }
1047

    
1048
            if (Sync.IsChecked)
1049
            {
1050
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1051
            }
1052
        }
1053

    
1054
        private void ZoomOut()
1055
        {
1056
            zoomAndPanControl.ContentScale -= 0.1;
1057
            //if (zoomAndPanControl2 != null)
1058
            //{
1059
            //    zoomAndPanControl2.ContentScale -= 0.1;
1060
            //}
1061
        }
1062

    
1063
        private void ZoomIn()
1064
        {
1065
            zoomAndPanControl.ContentScale += 0.1;
1066
            //if (zoomAndPanControl2 != null)
1067
            //{
1068
            //    zoomAndPanControl2.ContentScale += 0.1;
1069
            //}
1070
        }
1071

    
1072
        #endregion
1073

    
1074
        private void init()
1075
        {
1076
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1077
            {
1078

    
1079
                ControlList.Clear();
1080
                listBox.Items.Clear();
1081
                selected_item.Clear();
1082

    
1083
                (item as IMarkupCommonData).IsSelected = false;
1084
            }
1085

    
1086
        }
1087

    
1088
        private HitTestResultBehavior MyCallback(HitTestResult result)
1089
        {
1090
            //this.cursor = Cursors.UpArrow;
1091
            var element = result.VisualHit;
1092
            while (element != null && !(element is CommentUserInfo))
1093
                element = VisualTreeHelper.GetParent(element);
1094

    
1095
            if (element == null)
1096
            {
1097
                return HitTestResultBehavior.Stop;
1098
            }
1099
            else
1100
            {
1101
                if (element is CommentUserInfo)
1102
                {
1103
                    if (!hitList.Contains(element))
1104
                    {
1105
                        hitList.Add((CommentUserInfo)element);
1106
                    }
1107
                    else
1108
                    {
1109
                        return HitTestResultBehavior.Stop;
1110
                    }
1111
                }
1112
            }
1113
            return HitTestResultBehavior.Continue;
1114
        }
1115

    
1116
        public void ReleaseSelectPath()
1117
        {
1118
            if (SelectionPath == null)
1119
            {
1120
                SelectionPath = new Path();
1121
                SelectionPath.Name = "";
1122
            }
1123
            if (SelectionPath.Name != "")
1124
            {
1125
                SelectionPath.Name = "None";
1126
            }
1127
            SelectionPath.Opacity = 0.01;
1128
            SelectionPath.RenderTransform = null;
1129
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1130
        }
1131

    
1132
        #region 컨트롤 초기화 
1133
        public void Control_Init(object control)
1134
        {
1135
            if (L_Size != 0 && (control as IPath) != null)
1136
            {
1137
                (control as IPath).LineSize = L_Size;
1138
                L_Size = 0;
1139
            }
1140

    
1141
            switch (control.GetType().Name)
1142
            {
1143
                case "RectangleControl":
1144
                    {
1145
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1146
                    }
1147
                    break;
1148
                case "CircleControl":
1149
                    {
1150
                        (control as CircleControl).StrokeColor = Brushes.Red;
1151
                    }
1152
                    break;
1153
                case "TriControl":
1154
                    {
1155
                        (control as TriControl).StrokeColor = Brushes.Red;
1156
                    }
1157
                    break;
1158
                case "RectCloudControl":
1159
                    {
1160
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1161
                    }
1162
                    break;
1163
                case "CloudControl":
1164
                    {
1165
                        (control as CloudControl).StrokeColor = Brushes.Red;
1166
                    }
1167
                    break;
1168
                case "PolygonControl":
1169
                    {
1170
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1171
                    }
1172
                    break;
1173
                case "ArcControl":
1174
                    {
1175
                        (control as ArcControl).StrokeColor = Brushes.Red;
1176
                    }
1177
                    break;
1178
                case "ArrowArcControl":
1179
                    {
1180
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1181
                    }
1182
                    break;
1183
                case "LineControl":
1184
                    {
1185
                        (control as LineControl).StrokeColor = Brushes.Red;
1186
                    }
1187
                    break;
1188
                case "ArrowControl_Multi":
1189
                    {
1190
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1191
                    }
1192
                    break;
1193
                case "TextControl":
1194
                    {
1195
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1196
                    }
1197
                    break;
1198
                case "ArrowTextControl":
1199
                    {
1200
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1201
                    }
1202
                    break;
1203
                case "InsideWhiteControl":
1204
                    {
1205
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1206
                    }
1207
                    break;
1208
                case "OverlapWhiteControl":
1209
                    {
1210
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1211
                    }
1212
                    break;
1213
                case "ClipWhiteControl":
1214
                    {
1215
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1216
                    }
1217
                    break;
1218
                case "CoordinateControl":
1219
                    {
1220
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1221
                    }
1222
                    break;
1223
            }
1224
        }
1225
        #endregion
1226

    
1227
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1228
        {
1229
            //Control_Init(e.Source);
1230
        }
1231
        //private Window _dragdropWindow = null;
1232

    
1233
        [DllImport("user32.dll")]
1234
        [return: MarshalAs(UnmanagedType.Bool)]
1235
        internal static extern bool GetCursorPos(ref Win32Point pt);
1236

    
1237
        [StructLayout(LayoutKind.Sequential)]
1238
        internal struct Win32Point
1239
        {
1240
            public Int32 X;
1241
            public Int32 Y;
1242
        };
1243
        /*
1244
       public string symbol_id = null;
1245
       public long symbol_group_id;
1246
       public int symbol_SelectedIndex;
1247
       public ImageSource symbol_img;
1248
       public string symbol_Data = null;
1249
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1250
       {
1251
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1252
               zoomAndPanCanvas.ActualHeight / 2));
1253

    
1254

    
1255
               if (this._dragdropWindow != null)
1256
               {
1257
                   this._dragdropWindow.Close();
1258
                   this._dragdropWindow = null;
1259
               }
1260

    
1261
               symbol_id = id;
1262
               symbol_group_id = group_id;
1263
               symbol_SelectedIndex = SelectedIndex;
1264
               symbol_Data = Data_;
1265
               symbol_img = img;
1266

    
1267

    
1268
               CreateDragDropWindow2(img);
1269
              
1270
    }
1271

    
1272
    private void CreateDragDropWindow2(ImageSource image)
1273
        {
1274
            this._dragdropWindow = new Window();
1275
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1276
            _dragdropWindow.WindowStyle = WindowStyle.None;
1277
            _dragdropWindow.AllowsTransparency = true;           
1278
            _dragdropWindow.AllowDrop = false;
1279
            _dragdropWindow.Background = null;
1280
            _dragdropWindow.IsHitTestVisible = false;
1281
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1282
            _dragdropWindow.Topmost = true;
1283
            _dragdropWindow.ShowInTaskbar = false;
1284
            
1285
            Rectangle r = new Rectangle();
1286
            r.Width = image.Width;
1287
            r.Height = image.Height;
1288
            r.Opacity = 0.5;            
1289
            r.Fill = new ImageBrush(image);
1290
            this._dragdropWindow.Content = r;
1291

    
1292
            Win32Point w32Mouse = new Win32Point();
1293
            GetCursorPos(ref w32Mouse);
1294

    
1295
            //w32Mouse.X = getCurrentPoint.X;
1296
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1297
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1298
            this._dragdropWindow.Show();
1299
        }
1300

    
1301
        
1302

    
1303
         */
1304

    
1305
        public void MoveZoomAndPanControl(Vector dragOffset)
1306
        {
1307
   
1308
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1309
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1310

    
1311
            if (Sync.IsChecked)
1312
            {
1313
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1314
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1315
            }
1316
        }
1317

    
1318
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1319
        {
1320
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1321
            {
1322
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1323

    
1324
                Point currentPos = e.GetPosition(rect);
1325

    
1326
                floatingTip.HorizontalOffset = currentPos.X + 20;
1327
                floatingTip.VerticalOffset = currentPos.Y;
1328
            }
1329

    
1330
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1331
            
1332
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1333
            {
1334
                SetCursor();
1335
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1336
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1337

    
1338
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1339

    
1340
                MoveZoomAndPanControl(dragOffset);
1341
            }
1342

    
1343
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1344
            {
1345
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1346
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1347
                SetCursor();
1348

    
1349
                if (currentControl != null)
1350
                {
1351
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1352
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1353
                    //강인구 추가
1354
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1355

    
1356
                    if ((currentControl as IPath) != null)
1357
                    {
1358
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1359
                    }
1360
                    if ((currentControl as LineControl) != null)
1361
                    {
1362
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1363
                    }
1364

    
1365
                    if ((currentControl as IShapeControl) != null)
1366
                    {
1367
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1368
                    }
1369
                    if ((currentControl as TextControl) != null)
1370
                    {
1371
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1372
                        {
1373
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1374
                        }
1375
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1376
                        {
1377
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1378
                        }
1379
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1380
                        {
1381
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1382
                        }
1383
                    }
1384
                    else if ((currentControl as ArrowTextControl) != null)
1385
                    {
1386
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1387
                        {
1388
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1389
                        }
1390
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1391
                        {
1392
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1393
                        }
1394
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1395
                        {
1396
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1397
                        }
1398
                    }
1399
                    else if ((currentControl as RectCloudControl) != null)
1400
                    {
1401
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1402
                    }
1403
                    else if ((currentControl as CloudControl) != null)
1404
                    {
1405
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1406
                    }
1407

    
1408

    
1409
                    #region // 모든 컨트롤의 공통기능 제어
1410
                    if (controlType != ControlType.PenControl)
1411
                    {
1412
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1413
                    }
1414

    
1415

    
1416
                    #endregion
1417

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

    
1420
                    switch (controlType)
1421
                    {
1422
                        case (ControlType.Coordinate):
1423
                            {
1424
                                var control = currentControl as CoordinateControl;
1425
                                if (control != null)
1426
                                {
1427
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1428
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1429
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1430
                                }
1431
                            }
1432
                            break;
1433
                        case (ControlType.InsideWhite):
1434
                            {
1435
                                var control = currentControl as InsideWhiteControl;
1436
                                if (control != null)
1437
                                {
1438
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1439
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1440
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1441
                                    control.Paint = PaintSet.Fill;
1442
                                }
1443
                            }
1444
                            break;
1445
                        case ControlType.OverlapWhite:
1446
                            {
1447
                                var control = currentControl as OverlapWhiteControl;
1448
                                if (control != null)
1449
                                {
1450
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1451
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1452
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1453
                                    control.Paint = PaintSet.Fill;
1454
                                }
1455
                            }
1456
                            break;
1457
                        case ControlType.ClipWhite:
1458
                            {
1459
                                var control = currentControl as ClipWhiteControl;
1460
                                if (control != null)
1461
                                {
1462
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1463
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1464
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1465
                                    control.Paint = PaintSet.Fill;
1466
                                }
1467
                            }
1468
                            break;
1469
                        case ControlType.RectCloud:
1470
                            {
1471
                                var control = currentControl as RectCloudControl;
1472
                                if (control != null)
1473
                                {
1474
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1475
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1476
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1477
                                }
1478
                            }
1479
                            break;
1480
                        case ControlType.SingleLine:
1481
                        case ControlType.CancelLine:
1482
                        case ControlType.ArrowLine:
1483
                        case ControlType.TwinLine:
1484
                        case ControlType.DimLine:
1485
                            {
1486
                                var control = currentControl as LineControl;
1487
                                if (control != null)
1488
                                {
1489
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1490
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1491
                                }
1492

    
1493
                            }
1494
                            break;
1495

    
1496
                        case ControlType.ArcLine:
1497
                            {
1498
                                var control = currentControl as ArcControl;
1499
                                if (control != null)
1500
                                {
1501
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1502
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1503
                                }
1504
                            }
1505
                            break;
1506

    
1507
                        case ControlType.ArcArrow:
1508
                            {
1509
                                var control = currentControl as ArrowArcControl;
1510
                                if (control != null)
1511
                                {
1512
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1513
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1514
                                }
1515
                            }
1516
                            break;
1517

    
1518
                        case ControlType.ArrowMultiLine:
1519
                            {
1520
                                var control = currentControl as ArrowControl_Multi;
1521
                                if (control != null)
1522
                                {
1523
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1524
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1525
                                }
1526
                            }
1527
                            break;
1528

    
1529
                        case ControlType.Circle:
1530
                            {
1531
                                var control = currentControl as CircleControl;
1532

    
1533
                                if (control != null)
1534
                                {
1535
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1536
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1537
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1538
                                }
1539
                            }
1540
                            break;
1541

    
1542
                        case ControlType.PolygonCloud:
1543
                            {
1544
                                var control = currentControl as CloudControl;
1545
                                if (control != null)
1546
                                {
1547
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1548
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1549
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1550
                                }
1551
                            }
1552
                            break;
1553

    
1554
                        case ControlType.Triangle:
1555
                            {
1556
                                var control = currentControl as TriControl;
1557
                                if (control != null)
1558
                                {
1559
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1560
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1561
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1562
                                }
1563
                            }
1564
                            break;
1565

    
1566
                        case ControlType.ImgControl:
1567
                            {
1568
                                var control = currentControl as ImgControl;
1569
                                if (control != null)
1570
                                {
1571
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1572
                                }
1573
                            }
1574
                            break;
1575

    
1576
                        case ControlType.Date:
1577
                            {
1578
                                var control = currentControl as DateControl;
1579
                                if (control != null)
1580
                                {
1581
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1582
                                }
1583
                            }
1584
                            break;
1585

    
1586
                        case ControlType.ArrowTextControl:
1587
                        case ControlType.ArrowTransTextControl:
1588
                        case ControlType.ArrowTextBorderControl:
1589
                        case ControlType.ArrowTransTextBorderControl:
1590
                        case ControlType.ArrowTextCloudControl:
1591
                        case ControlType.ArrowTransTextCloudControl:
1592
                            {
1593
                                var control = currentControl as ArrowTextControl;
1594
                                if (control != null)
1595
                                {
1596
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1597
                                }
1598
                            }
1599
                            break;
1600
                        case ControlType.PolygonControl:
1601
                        case ControlType.ChainLine:
1602
                            {
1603
                                var control = currentControl as PolygonControl;
1604
                                if (control != null)
1605
                                {
1606
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1607
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1608
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1609
                                }
1610
                            }
1611
                            break;
1612
                        case ControlType.Sign:
1613
                            {
1614
                                var control = currentControl as SignControl;
1615
                                if (control != null)
1616
                                {
1617
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1618
                                }
1619
                            }
1620
                            break;
1621
                        case ControlType.Symbol:
1622
                            {
1623
                                var control = currentControl as SymControl;
1624
                                if (control != null)
1625
                                {
1626
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1627
                                }
1628
                            }
1629
                            break;
1630
                        case ControlType.Stamp:
1631
                            {
1632
                                var control = currentControl as SymControlN;
1633
                                if (control != null)
1634
                                {
1635
                                    if (control.STAMP != null)
1636
                                    {
1637
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1638
                                    }
1639
                                    else
1640
                                    {
1641
                                        currentControl = null;
1642
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1643
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1644
                                    }
1645
                                }
1646
                            }
1647
                            break;
1648
                        case ControlType.Rectangle:
1649
                        case ControlType.Mark:
1650
                            {
1651
                                var control = currentControl as RectangleControl;
1652
                                if (control != null)
1653
                                {
1654
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1655
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1656
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1657
                                }
1658
                            }
1659
                            break;
1660
                        case ControlType.PenControl:
1661
                            {
1662
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1663
                                //inkBoard.Strokes.Add(stroke);
1664
                            }
1665
                            break;
1666
                        default:
1667
                            break;
1668
                    }
1669

    
1670
                    #endregion
1671
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1672
                    {
1673
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1674
                    }
1675
                }
1676
            }
1677
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1678
            {
1679
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1680
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1681
                SetCursor();
1682
                if (currentControl == null)
1683
                {
1684
                    switch (controlType)
1685
                    {
1686
                        case ControlType.PenControl:
1687
                            {
1688
                                if (inkBoard.Tag.ToString() == "Ink")
1689
                                {
1690
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1691
                                }
1692
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1693
                                {
1694
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1695
                                }
1696
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1697
                                {
1698
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1699
                                }
1700

    
1701
                                //inkBoard.Strokes.Add(stroke);
1702
                            }
1703
                            break;
1704
                    }
1705
                    return;
1706
                }
1707
            }
1708
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1709
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1710
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1711
            {
1712
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1713

    
1714
                if (isDraggingSelectionRect)
1715
                {
1716
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1717
                    e.Handled = true;
1718
                }
1719
                else if (isLeftMouseButtonDownOnWindow)
1720
                {
1721
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1722
                    double dragDistance = Math.Abs(dragDelta.Length);
1723

    
1724
                    if (dragDistance > DragThreshold)
1725
                    {
1726
                        isDraggingSelectionRect = true;
1727
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1728
                    }
1729

    
1730
                    e.Handled = true;
1731
                }
1732

    
1733
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1734
                {
1735
                }
1736
                else
1737
                {
1738
                    e.Handled = true;
1739
                }
1740
            }
1741
            /*
1742
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1743
            { //symbol      
1744
                if(_dragdropWindow != null)
1745
                {
1746
                    Win32Point w32Mouse = new Win32Point();
1747
                    GetCursorPos(ref w32Mouse);
1748

    
1749
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1750
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1751
                }                
1752
            }
1753
            */
1754
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1755
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1756
            {
1757
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1758
                if(control != null)
1759
                {
1760
                    this.cursor = Cursors.Hand;
1761
                    SetCursor();
1762
                }
1763
                else
1764
                {
1765
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1766
                    SetCursor();
1767
                }
1768
            }
1769
            else
1770
            {
1771
            }
1772
        }
1773

    
1774
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1775
        {
1776
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1777
            {
1778
                SetCursor();
1779
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1780
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1781

    
1782
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1783

    
1784
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1785
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1786

    
1787
                if (Sync.IsChecked)
1788
                {
1789
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1790
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1791
                }
1792
            }
1793
        }
1794

    
1795
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1796

    
1797
        private EllipseGeometry hitArea = new EllipseGeometry();
1798

    
1799
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1800
        {
1801
            IsDrawing = false;
1802
    
1803
            if (mouseHandlingMode != MouseHandlingMode.None)
1804
            {
1805
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1806
                {
1807
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1808

    
1809
                    SetCursor();
1810

    
1811
                    switch (controlType)
1812
                    {
1813
                        case ControlType.None:
1814
                            break;
1815
                        case ControlType.Rectangle:
1816
                            {
1817

    
1818
                            }
1819
                            break;
1820
                        case ControlType.PenControl:
1821
                            {
1822

    
1823
                            }
1824
                            break;
1825
                        default:
1826
                            break;
1827
                    }                    
1828
                }
1829
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1830
                {
1831
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1832

    
1833
                    if (isLeftMouseButtonDownOnWindow)
1834
                    {
1835
                        bool wasDragSelectionApplied = false;
1836

    
1837
                        if (isDraggingSelectionRect)
1838
                        {
1839
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1840
                            {
1841
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1842
                                mouseHandlingMode = MouseHandlingMode.None;
1843
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1844
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1845
                                Set_Symbol_Capture(endPoint);
1846
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1847
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1848
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1849
                            }
1850
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1851
                            {
1852
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1853
                                mouseHandlingMode = MouseHandlingMode.None;
1854
                                Set_Capture();
1855

    
1856
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1857
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1858
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1859
                            }
1860
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1861
                            {
1862
                                ApplyDragSelectionRect();
1863
                            }
1864
                            else
1865
                            {
1866
                                double x = Canvas.GetLeft(dragZoomBorder);
1867
                                double y = Canvas.GetTop(dragZoomBorder);
1868
                                double width = dragZoomBorder.Width;
1869
                                double height = dragZoomBorder.Height;
1870
                                Rect dragRect = new Rect(x, y, width, height);
1871

    
1872
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1873

    
1874
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1875
                            }
1876

    
1877
                            isDraggingSelectionRect = false;
1878
                            e.Handled = true;
1879
                            wasDragSelectionApplied = true;
1880
                        }
1881

    
1882
                        if (isLeftMouseButtonDownOnWindow)
1883
                        {
1884
                            isLeftMouseButtonDownOnWindow = false;
1885
                            this.ReleaseMouseCapture();
1886
                            e.Handled = true;
1887
                        }
1888

    
1889
                        if (!wasDragSelectionApplied)
1890
                        {
1891
                            init();
1892
                        }
1893
                    }
1894
                }
1895
                else if (e.RightButton == MouseButtonState.Pressed)
1896
                {
1897
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1898
                    SetCursor();
1899
                }
1900

    
1901
                zoomAndPanControl.ReleaseMouseCapture();
1902

    
1903

    
1904
                e.Handled = true;
1905
            }
1906
            else
1907
            {
1908
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1909
                SetCursor();
1910
            }
1911

    
1912
            ///mouseButtonDown = MouseButton.Left;
1913
            //controlType = ControlType.SingleLine;
1914
        }
1915

    
1916
        public void Set_Symbol_Capture(Point endPoint)
1917
        {       
1918
            double x = CanvasDrawingMouseDownPoint.X;
1919
            double y = CanvasDrawingMouseDownPoint.Y;
1920
            if(x > endPoint.X)
1921
            {
1922
                x = endPoint.X;
1923
                y = endPoint.Y;
1924
            }
1925

    
1926
            double width = dragCaptureBorder.Width;
1927
            double height = dragCaptureBorder.Height;
1928

    
1929
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1930

    
1931
            if (x < 0)
1932
            {
1933
                width += x;
1934
                x = 0;
1935
            }
1936
            if (y < 0)
1937
            {
1938
                height += y;
1939
                y = 0;
1940

    
1941
                width = (int)canvasImage.PixelWidth - x;
1942
            }
1943
            if (x + width > canvasImage.PixelWidth)
1944
            {
1945
                width = (int)canvasImage.PixelWidth - x;
1946
            }
1947
            if (y + height > canvasImage.PixelHeight)
1948
            {
1949
                height = (int)canvasImage.PixelHeight - y;
1950
            }
1951
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1952

    
1953
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1954
            var defaultBitmapImage = new BitmapImage();
1955
            defaultBitmapImage.BeginInit();
1956
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1957
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1958
            defaultBitmapImage.UriSource = new Uri(uri);
1959
            defaultBitmapImage.EndInit();
1960

    
1961
            //GC.Collect();
1962

    
1963
            if (defaultBitmapImage.IsDownloading)
1964
            {
1965
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1966
                {
1967
                    defaultBitmapImage.Freeze();
1968
                    //GC.Collect();
1969
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1970
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1971
                };
1972
            }
1973
        }
1974

    
1975
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1976
        {
1977
            ///mouseButtonDown = MouseButton.Left;
1978
        }
1979

    
1980
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1981
        {
1982
            ///mouseButtonDown = MouseButton.Left;
1983
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1984
        }
1985

    
1986
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1987
        {
1988

    
1989
        }
1990

    
1991
        /// <summary>
1992
        /// select items by dragging
1993
        /// </summary>
1994
        private void ApplyDragSelectionRect()
1995
        {
1996
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1997

    
1998
            double x = Canvas.GetLeft(dragSelectionBorder);
1999
            double y = Canvas.GetTop(dragSelectionBorder);
2000
            double width = dragSelectionBorder.Width;
2001
            double height = dragSelectionBorder.Height;
2002
            Boolean Flag = false;
2003
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2004
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2005

    
2006
            Rect dragRect = new Rect(x, y, width, height);
2007
            ///dragRect.Inflate(width / 10, height / 10);
2008

    
2009
            foreach (var item in Items)
2010
            {
2011
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2012

    
2013
                if (Flag)
2014
                {
2015
                    adornerSet.Add(item);
2016
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2017
                    Control_Style(item);
2018
                }
2019
            }
2020
            if (adornerSet.Count > 0)
2021
            {
2022
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2023
                SelectLayer.Children.Add(final);
2024
            }
2025
        }
2026

    
2027
        private void InitDragSelectionRect(Point pt1, Point pt2)
2028
        {
2029
            //캡쳐 중
2030
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2031
            {
2032
                dragCaptureBorder.Visibility = Visibility.Visible;
2033
            }
2034
            //선택 중
2035
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2036
            {
2037

    
2038
                dragSelectionBorder.Visibility = Visibility.Visible;
2039
            }
2040
            else
2041
            {
2042
                dragZoomBorder.Visibility = Visibility.Visible;
2043
            }
2044
            UpdateDragSelectionRect(pt1, pt2);
2045
        }
2046

    
2047
        /// <summary>
2048
        /// Update the position and size of the rectangle used for drag selection.
2049
        /// </summary>
2050
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2051
        {
2052
            double x, y, width, height;
2053

    
2054
            //
2055
            // Determine x,y,width and height of the rect inverting the points if necessary.
2056
            // 
2057

    
2058
            if (pt2.X < pt1.X)
2059
            {
2060
                x = pt2.X;
2061
                width = pt1.X - pt2.X;
2062
            }
2063
            else
2064
            {
2065
                x = pt1.X;
2066
                width = pt2.X - pt1.X;
2067
            }
2068

    
2069
            if (pt2.Y < pt1.Y)
2070
            {
2071
                y = pt2.Y;
2072
                height = pt1.Y - pt2.Y;
2073
            }
2074
            else
2075
            {
2076
                y = pt1.Y;
2077
                height = pt2.Y - pt1.Y;
2078
            }
2079

    
2080
            //
2081
            // Update the coordinates of the rectangle used for drag selection.
2082
            //
2083
            //캡쳐 중
2084
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2085
            {
2086
                Canvas.SetLeft(dragCaptureBorder, x);
2087
                Canvas.SetTop(dragCaptureBorder, y);
2088
                dragCaptureBorder.Width = width;
2089
                dragCaptureBorder.Height = height;
2090
            }
2091
            //선택 중
2092
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2093
            {
2094
                Canvas.SetLeft(dragSelectionBorder, x);
2095
                Canvas.SetTop(dragSelectionBorder, y);
2096
                dragSelectionBorder.Width = width;
2097
                dragSelectionBorder.Height = height;
2098
            }
2099
            else
2100
            {
2101
                Canvas.SetLeft(dragZoomBorder, x);
2102
                Canvas.SetTop(dragZoomBorder, y);
2103
                dragZoomBorder.Width = width;
2104
                dragZoomBorder.Height = height;
2105
            }
2106
        }
2107

    
2108
        private void drawingPannelRotate(double angle)
2109
        {
2110
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2111
            rotate.Angle = angle;
2112
            var rotationNum = Math.Abs((rotate.Angle / 90));
2113

    
2114
            if (angle == 90 || angle == 270)
2115
            {
2116
                double emptySize = zoomAndPanCanvas.Width;
2117
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2118
                zoomAndPanCanvas.Height = emptySize;
2119
            }
2120
            if (angle == 0)
2121
            {
2122
                translate.X = 0;
2123
                translate.Y = 0;
2124
            }
2125
            else if (angle == 90)
2126
            {
2127
                translate.X = zoomAndPanCanvas.Width;
2128
                translate.Y = 0;
2129
            }
2130
            else if (angle == 180)
2131
            {
2132
                translate.X = zoomAndPanCanvas.Width;
2133
                translate.Y = zoomAndPanCanvas.Height;
2134
            }
2135
            else
2136
            {
2137
                translate.X = 0;
2138
                translate.Y = zoomAndPanCanvas.Height;
2139
            }
2140

    
2141
            zoomAndPanControl.RotationAngle = rotate.Angle;
2142

    
2143

    
2144
            if (!testPanel2.IsHidden)
2145
            {
2146
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2147
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2148
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2149
            }
2150

    
2151
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2152
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2153
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2154
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2155
            ViewerDataModel.Instance.Angle = rotate.Angle;
2156
        }
2157

    
2158
        private void syncPannelRotate(double angle)
2159
        {
2160
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2161
            rotate.Angle = angle;
2162
            var rotationNum = Math.Abs((rotate.Angle / 90));
2163

    
2164
            if (angle == 90 || angle == 270)
2165
            {
2166
                double emptySize = zoomAndPanCanvas2.Width;
2167
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2168
                zoomAndPanCanvas2.Height = emptySize;
2169
            }
2170
            if (angle == 0)
2171
            {
2172
                translate2.X = 0;
2173
                translate2.Y = 0;
2174
            }
2175
            else if (angle == 90)
2176
            {
2177
                translate2.X = zoomAndPanCanvas2.Width;
2178
                translate2.Y = 0;
2179
            }
2180
            else if (angle == 180)
2181
            {
2182
                translate2.X = zoomAndPanCanvas2.Width;
2183
                translate2.Y = zoomAndPanCanvas2.Height;
2184
            }
2185
            else
2186
            {
2187
                translate2.X = 0;
2188
                translate2.Y = zoomAndPanCanvas2.Height;
2189
            }
2190

    
2191
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2192
        }
2193

    
2194
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2195
        {
2196
            string Data_ = "";
2197

    
2198
            try
2199
            {
2200
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2201
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2202
                if (Data_ != null || Data_ != "")
2203
                {
2204
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2205
                }
2206
                else
2207
                {
2208
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2209
                }
2210

    
2211
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2212
                //{
2213
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2214
                //    STATE = 0,
2215
                //};
2216
                if (Data_ != null)
2217
                {
2218
                    Image img = new Image();
2219
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2220
                    if (Data_.Contains(".svg"))
2221
                    {
2222
                        byte[] imageData = null;
2223
                        DrawingImage image = null;
2224
                        using (System.Net.WebClient web = new System.Net.WebClient())
2225
                        {
2226
                            imageData = web.DownloadData(new Uri(Data_));
2227
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2228
                            image = SvgReader.Load(stream);
2229
                        }
2230
                        img.Source = image;
2231
                    }
2232
                    else
2233
                    {
2234
                        img.Source = new BitmapImage(new Uri(Data_));
2235
                    }
2236

    
2237
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2238
                    {
2239
                        PointSet = new List<Point>(),
2240
                        FilePath = Data_,
2241
                        ImageData = img.Source,
2242
                        StartPoint = canvasZoomPanningMouseDownPoint,
2243
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2244
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2245
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2246
                        canvasZoomPanningMouseDownPoint.Y),
2247
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2248
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2249
                    };
2250

    
2251
                    currentControl.PointSet = new List<Point>
2252
                                        {
2253
                                            currentControl.StartPoint,
2254
                                            currentControl.LeftBottomPoint,
2255
                                            currentControl.EndPoint,
2256
                                            currentControl.TopRightPoint,
2257
                                        };
2258
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2259
                    UndoData = new Undo_data()
2260
                    {
2261
                        IsUndo = false,
2262
                        Event = Event_Type.Create,
2263
                        EventTime = DateTime.Now,
2264
                        Markup_List = new List<Multi_Undo_data>()
2265
                    };
2266
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2267
                    {
2268
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2269
                    });
2270

    
2271
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2272
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2273
                    UndoData.Markup_List.Add(multi_Undo_Data);
2274
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2275

    
2276
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2277
                    currentControl.CommentID = Commons.shortGuid();
2278
                    currentControl.SymbolID = id;
2279
                    currentControl.GroupID = group_id;
2280
                    currentControl.ApplyTemplate();
2281
                    currentControl.SetImage();
2282

    
2283
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2284
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2285
                    SelectLayer.Children.Add(final);
2286
                }
2287
            }
2288
            catch (Exception ex)
2289
            {
2290
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2291
            }
2292
        }
2293

    
2294
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2295
        {            
2296
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2297
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2298
            {
2299
                set_option.Value = double.Parse(set_option.ContentText);
2300
                //set_option.Focusable = false;
2301
                zoomAndPanControl.Focus();
2302
            }
2303

    
2304
            ConvertInkControlToPolygon();
2305

    
2306
            ///TODO:
2307
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2308
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2309

    
2310
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2311
            {
2312
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2313
            }
2314
            /// up to here
2315

    
2316
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2317
            {
2318
                if (item as ArrowTextControl != null)
2319
                {
2320
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2321
                }
2322
                else if (item as TextControl != null)
2323
                {
2324
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2325
                }
2326
            }
2327

    
2328
            //if (currentControl != null)
2329
            {
2330
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2331
                if (text_item_ != null)
2332
                {
2333
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2334
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2335
                    (text_item_ as TextControl).IsEditingMode = false;                    
2336
                    currentControl = null;
2337
                }
2338

    
2339
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2340
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2341
                {
2342
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2343
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2344
                    currentControl = null;
2345
                }
2346
            }
2347

    
2348
            double Ang = 0;                                          
2349
            if (rotate.Angle != 0)
2350
            {
2351
                Ang = 360 - rotate.Angle;
2352
            }
2353

    
2354
            if (e.OriginalSource is System.Windows.Controls.Image)
2355
            {
2356
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2357
            }
2358
            /*
2359
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2360
            {                
2361
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2362
                if(symbol_id != null)
2363
                {
2364
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2365
                }                
2366
            }
2367

    
2368
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2369
            {
2370
                if (this._dragdropWindow != null)
2371
                {
2372
                    this._dragdropWindow.Close();
2373
                    this._dragdropWindow = null;
2374
                    symbol_id = null;
2375
                }
2376
            }
2377
            */
2378

    
2379
            if (e.LeftButton == MouseButtonState.Pressed)
2380
            {
2381
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2382
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2383

    
2384
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2385
                SetCursor();
2386

    
2387
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2388
            }
2389

    
2390
            if (e.MiddleButton == MouseButtonState.Pressed)
2391
            {
2392
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2393
                cursor = Cursors.SizeAll;
2394
                SetCursor();
2395
            }
2396
            if (e.RightButton == MouseButtonState.Pressed)
2397
            {
2398
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2399
                cursor = Cursors.SizeAll;
2400
                SetCursor();
2401
            }
2402
            else if (e.XButton1 == MouseButtonState.Pressed)
2403
            {
2404
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2405
                {
2406
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2407
                }
2408

    
2409
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2410

    
2411
            }
2412
            else if (e.XButton2 == MouseButtonState.Pressed)
2413
            {
2414
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2415
                {
2416
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2417
                }
2418
            }
2419

    
2420
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2421
            {
2422
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2423
                {
2424
                    if (SelectLayer.Children.Count == 0)
2425
                    {
2426
                        isLeftMouseButtonDownOnWindow = true;
2427
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2428
                    }
2429

    
2430
                    if (controlType == ControlType.None)
2431
                    {
2432
                        isLeftMouseButtonDownOnWindow = true;
2433
                    }
2434
                }
2435

    
2436
                /// 캡쳐 모드 설정
2437
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2438
                {
2439
                    dragCaptureBorder.Visibility = Visibility.Visible;
2440
                    isLeftMouseButtonDownOnWindow = true;
2441
                }
2442

    
2443
                /// 줌 모드 설정
2444
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2445
                {
2446
                    isLeftMouseButtonDownOnWindow = true;
2447
                }
2448

    
2449
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2450
                if (control != null)
2451
                {
2452
                    AdornerFinal final = null;
2453

    
2454
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2455
                    {
2456
                        /// 기존 selection 해제
2457
                        SelectionSet.Instance.UnSelect(this);
2458

    
2459
                        final = new AdornerFinal(control);
2460

    
2461
                        this.Control_Style(control);
2462

    
2463
                        if ((control as IPath) != null)
2464
                        {
2465
                            if ((control as IPath).LineSize != 0)
2466
                            {
2467
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2468
                            }
2469
                        }
2470
                        if ((control as IShapeControl) != null)
2471
                        {
2472
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2473
                            {
2474
                                ViewerDataModel.Instance.checkHatchShape = true;
2475
                            }
2476
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2477
                            {
2478
                                ViewerDataModel.Instance.checkFillShape = true;
2479
                            }
2480
                            else
2481
                            {
2482
                                ViewerDataModel.Instance.checkHatchShape = false;
2483
                                ViewerDataModel.Instance.checkFillShape = false;
2484
                            }
2485
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2486
                        }
2487

    
2488
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2489

    
2490
                        if ((control as TextControl) != null)
2491
                        {
2492
                            if(!((control as TextControl).EnableEditing)) {
2493
                                (control as TextControl).EnableEditing = true;
2494
                            }
2495
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2496
                            {
2497
                                ViewerDataModel.Instance.checkTextStyle = true;
2498
                            }
2499
                            else
2500
                            {
2501
                                ViewerDataModel.Instance.checkTextStyle = false;
2502
                            }
2503
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2504
                            {
2505
                                ViewerDataModel.Instance.checkTextWeight = true;
2506
                            }
2507
                            else
2508
                            {
2509
                                ViewerDataModel.Instance.checkTextWeight = false;
2510
                            }
2511
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2512
                            {
2513
                                ViewerDataModel.Instance.checkUnderLine = true;
2514
                            }
2515
                            else
2516
                            {
2517
                                ViewerDataModel.Instance.checkUnderLine = false;
2518
                            }
2519
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2520
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2521

    
2522
                        }
2523
                        else if ((control as ArrowTextControl) != null)
2524
                        {
2525
                            if (!((control as ArrowTextControl).EnableEditing))
2526
                            {
2527
                                (control as ArrowTextControl).EnableEditing = true;
2528
                            }
2529
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2530
                            {
2531
                                ViewerDataModel.Instance.checkTextStyle = true;
2532
                            }
2533
                            else
2534
                            {
2535
                                ViewerDataModel.Instance.checkTextStyle = false;
2536
                            }
2537
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2538
                            {
2539
                                ViewerDataModel.Instance.checkTextWeight = true;
2540
                            }
2541
                            else
2542
                            {
2543
                                ViewerDataModel.Instance.checkTextWeight = false;
2544
                            }
2545
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2546
                            {
2547
                                ViewerDataModel.Instance.checkUnderLine = true;
2548
                            }
2549
                            else
2550
                            {
2551
                                ViewerDataModel.Instance.checkUnderLine = false;
2552
                            }
2553
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2554
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2555
                        }
2556
                        else if ((control as RectCloudControl) != null)
2557
                        {
2558
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2559
                        }
2560
                        else if ((control as CloudControl) != null)
2561
                        {
2562
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2563
                        }
2564
                    }
2565
                    else
2566
                    {
2567
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2568
                        SelectionSet.Instance.UnSelect(this);
2569
                        comment.Add(control);
2570

    
2571
                        Control_Style(control);
2572

    
2573
                        final = new AdornerFinal(comment);
2574
                    }
2575

    
2576
                    if (final != null)
2577
                    {
2578
                        this.SelectLayer.Children.Add(final);
2579
                    }
2580
                }              
2581
            }
2582
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2583
            {               
2584
                init();
2585
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2586
                if (cursor != Cursors.SizeAll)
2587
                {
2588
                    cursor = Cursors.Cross;
2589
                    SetCursor();
2590
                }
2591
                bool init_user = false;
2592
                foreach (var user in gridViewMarkup.Items)
2593
                {
2594
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2595
                    {
2596
                        init_user = true;
2597
                    }
2598
                }
2599
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2600
                {
2601
                    RadWindow.Alert(new DialogParameters
2602
                    {
2603
                        Owner = Application.Current.MainWindow,
2604
                        Theme = new VisualStudio2013Theme(),
2605
                        Header = "안내",
2606
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2607
                    });
2608
                    return;
2609
                }
2610
                else
2611
                {
2612
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2613
                    if (item != null)
2614
                    {
2615
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2616
                    }
2617
                }
2618

    
2619
                switch (controlType)
2620
                {
2621
                    case ControlType.Coordinate:
2622
                        {
2623
                            if (e.LeftButton == MouseButtonState.Pressed)
2624
                            {
2625
                                if (currentControl is CoordinateControl)
2626
                                {
2627
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2628
                                    {
2629
                                        return;
2630
                                    }
2631

    
2632
                                    CreateCommand.Instance.Execute(currentControl);
2633

    
2634
                                    currentControl = null;
2635
                                    this.cursor = Cursors.Arrow;
2636
                                }
2637
                                else
2638
                                {
2639
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2640
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2641
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2642
                                    {
2643
                                        currentControl = null;
2644
                                        this.cursor = Cursors.Arrow;
2645
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2646
                                        return;
2647
                                    }
2648
                                    else
2649
                                    {
2650
                                        currentControl = new CoordinateControl
2651
                                        {
2652
                                            Background = new SolidColorBrush(Colors.Black),
2653
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2654
                                            ControlType = ControlType.Coordinate
2655
                                        };
2656

    
2657
                                        currentControl.CommentID = Commons.shortGuid();
2658
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2659
                                        currentControl.IsNew = true;
2660

    
2661
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2662

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

    
2680
                                    CreateCommand.Instance.Execute(currentControl);
2681

    
2682
                                    currentControl = null;
2683
                                    this.cursor = Cursors.Arrow;
2684
                                }
2685
                                else
2686
                                {
2687
                                    currentControl = new InsideWhiteControl
2688
                                    {
2689
                                        Background = new SolidColorBrush(Colors.Black),
2690
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2691
                                        ControlType = ControlType.InsideWhite
2692
                                    };
2693

    
2694
                                    currentControl.CommentID = Commons.shortGuid();
2695
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2696
                                    currentControl.IsNew = true;
2697
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2698

    
2699
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2700
                                }
2701
                            }
2702
                        }
2703
                        break;
2704
                    case ControlType.OverlapWhite:
2705
                        {
2706
                            if (e.LeftButton == MouseButtonState.Pressed)
2707
                            {
2708
                                if (currentControl is OverlapWhiteControl)
2709
                                {
2710
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2711
                                    {
2712
                                        return;
2713
                                    }
2714

    
2715
                                    CreateCommand.Instance.Execute(currentControl);
2716

    
2717
                                    currentControl = null;
2718
                                    this.cursor = Cursors.Arrow;
2719
                                }
2720
                                else
2721
                                {
2722
                                    currentControl = new OverlapWhiteControl
2723
                                    {
2724
                                        Background = new SolidColorBrush(Colors.Black),
2725
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2726
                                        ControlType = ControlType.OverlapWhite
2727
                                    };
2728

    
2729
                                    currentControl.CommentID = Commons.shortGuid();
2730
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2731
                                    currentControl.IsNew = true;
2732
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2733

    
2734
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2735
                                }
2736
                            }
2737
                        }
2738
                        break;
2739
                    case ControlType.ClipWhite:
2740
                        {
2741
                            if (e.LeftButton == MouseButtonState.Pressed)
2742
                            {
2743
                                if (currentControl is ClipWhiteControl)
2744
                                {
2745
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2746
                                    {
2747
                                        return;
2748
                                    }
2749

    
2750
                                    CreateCommand.Instance.Execute(currentControl);
2751

    
2752
                                    currentControl = null;
2753
                                    this.cursor = Cursors.Arrow;
2754
                                }
2755
                                else
2756
                                {
2757
                                    currentControl = new ClipWhiteControl
2758
                                    {
2759
                                        Background = new SolidColorBrush(Colors.Black),
2760
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2761
                                        ControlType = ControlType.ClipWhite
2762
                                    };
2763

    
2764
                                    currentControl.CommentID = Commons.shortGuid();
2765
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2766
                                    currentControl.IsNew = true;
2767
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2768

    
2769
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2770
                                }
2771
                            }
2772
                        }
2773
                        break;
2774
                    case ControlType.Rectangle:
2775
                        {
2776
                            if (e.LeftButton == MouseButtonState.Pressed)
2777
                            {
2778
                                if (currentControl is RectangleControl)
2779
                                {
2780
                                    //20180906 LJY TEST IsRotationDrawingEnable
2781
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2782
                                    {
2783
                                        return;
2784
                                    }
2785

    
2786
                                    CreateCommand.Instance.Execute(currentControl);
2787
                                    currentControl = null;
2788
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2789
                                }
2790
                                else
2791
                                {
2792
                                    currentControl = new RectangleControl
2793
                                    {
2794
                                        Background = new SolidColorBrush(Colors.Black),
2795
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2796
                                        ControlType = ControlType.Rectangle
2797
                                    };
2798

    
2799
                                    currentControl.CommentID = Commons.shortGuid();
2800
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2801
                                    currentControl.IsNew = true;
2802
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2803

    
2804
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2805
                                }
2806
                            }
2807
                        }
2808
                        break;
2809
                    case ControlType.RectCloud:
2810
                        {
2811
                            if (e.LeftButton == MouseButtonState.Pressed)
2812
                            {
2813
                                if (currentControl is RectCloudControl)
2814
                                {
2815
                                    //20180906 LJY TEST IsRotationDrawingEnable
2816
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2817
                                    {
2818
                                        return;
2819
                                    }
2820

    
2821
                                    CreateCommand.Instance.Execute(currentControl);
2822

    
2823
                                    currentControl = null;
2824
                                
2825
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2826
                                }
2827
                                else
2828
                                {
2829
                                    currentControl = new RectCloudControl
2830
                                    {
2831
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2832
                                        ControlType = ControlType.RectCloud,
2833
                                        Background = new SolidColorBrush(Colors.Black)
2834
                                    };
2835

    
2836
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2837
                                    currentControl.CommentID = Commons.shortGuid();
2838
                                    currentControl.IsNew = true;
2839
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2840
                                }
2841
                            }
2842
                        }
2843
                        break;
2844
                    case ControlType.Circle:
2845
                        {
2846
                            if (e.LeftButton == MouseButtonState.Pressed)
2847
                            {
2848
                                if (currentControl is CircleControl)
2849
                                {
2850
                                    //20180906 LJY TEST IsRotationDrawingEnable
2851
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2852
                                    {
2853
                                        return;
2854
                                    }
2855

    
2856
                                    CreateCommand.Instance.Execute(currentControl);
2857

    
2858
                                    currentControl = null;
2859
                                }
2860
                                else
2861
                                {
2862
                                    currentControl = new CircleControl
2863
                                    {
2864
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2865
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2866
                                        Background = new SolidColorBrush(Colors.Black)
2867
                                    };
2868

    
2869
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2870
                                    currentControl.CommentID = Commons.shortGuid();
2871
                                    currentControl.IsNew = true;
2872
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2873
                                }
2874
                            }
2875
                        }
2876
                        break;
2877
                    case ControlType.Triangle:
2878
                        {
2879
                            if (e.LeftButton == MouseButtonState.Pressed)
2880
                            {
2881
                                if (currentControl is TriControl)
2882
                                {
2883
                                    var content = currentControl as TriControl;
2884
                                    if (content.MidPoint == new Point(0, 0))
2885
                                    {
2886
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2887
                                    }
2888
                                    else
2889
                                    {
2890
                                        //20180906 LJY TEST IsRotationDrawingEnable
2891
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2892
                                        {
2893
                                            return;
2894
                                        }
2895

    
2896
                                        CreateCommand.Instance.Execute(currentControl);
2897

    
2898
                                        currentControl = null;
2899
                                    }
2900
                                }
2901
                                else
2902
                                {
2903
                                    currentControl = new TriControl
2904
                                    {
2905
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2906
                                        Background = new SolidColorBrush(Colors.Black),
2907
                                    };
2908

    
2909
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2910
                                    currentControl.CommentID = Commons.shortGuid();
2911
                                    currentControl.IsNew = true;
2912
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2913
                                }
2914
                            }
2915
                        }
2916
                        break;
2917
                    case ControlType.CancelLine:
2918
                    case ControlType.SingleLine:
2919
                    case ControlType.ArrowLine:
2920
                    case ControlType.TwinLine:
2921
                    case ControlType.DimLine:
2922
                        {
2923
                            if (e.LeftButton == MouseButtonState.Pressed)
2924
                            {
2925
                                if (currentControl is LineControl)
2926
                                {
2927
                                    //20180906 LJY TEST IsRotationDrawingEnable
2928
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2929
                                    {
2930
                                        return;
2931
                                    }
2932

    
2933
                                    CreateCommand.Instance.Execute(currentControl);
2934
                                    currentControl = null;
2935
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2936
                                }
2937
                                else
2938
                                {
2939
                                    currentControl = new LineControl
2940
                                    {
2941
                                        ControlType = this.controlType,
2942
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2943
                                        Background = new SolidColorBrush(Colors.Black)
2944
                                    };
2945

    
2946
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2947
                                    currentControl.CommentID = Commons.shortGuid();
2948
                                    currentControl.IsNew = true;
2949
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2950
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
2951
                                }
2952
                            }
2953
                        }
2954
                        break;
2955
                    case ControlType.PolygonControl:
2956
                        {
2957
                            if (currentControl is PolygonControl)
2958
                            {
2959
                                var control = currentControl as PolygonControl;
2960

    
2961
                                if (e.RightButton == MouseButtonState.Pressed)
2962
                                {
2963
                                    control.IsCompleted = true;
2964
                                }
2965

    
2966
                                if (!control.IsCompleted)
2967
                                {
2968
                                    control.PointSet.Add(control.EndPoint);
2969
                                }
2970
                                else
2971
                                {
2972
                                    //20180906 LJY TEST IsRotationDrawingEnable
2973
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2974
                                    {
2975
                                        return;
2976
                                    }
2977

    
2978
                                    var firstPoint = control.PointSet.First();
2979
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2980
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2981
                                    control.PointSet.Add(firstPoint);
2982

    
2983
                                    control.ApplyOverViewData();
2984

    
2985
                                    CreateCommand.Instance.Execute(currentControl);
2986
                                    control.UpdateControl();
2987
                                    currentControl = null;
2988
                                }
2989
                            }
2990
                            else
2991
                            {
2992
                                if (e.LeftButton == MouseButtonState.Pressed)
2993
                                {
2994
                                    currentControl = new PolygonControl
2995
                                    {
2996
                                        PointSet = new List<Point>(),
2997
                                    };
2998

    
2999
                                    var polygonControl = (currentControl as PolygonControl);
3000
                                    currentControl.CommentID = Commons.shortGuid();
3001
                                    currentControl.IsNew = true;
3002
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3003
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3004
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3005
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3006
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3007
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3008
                                    polygonControl.ApplyTemplate();
3009
                                    polygonControl.Visibility = Visibility.Visible;
3010
                                }
3011
                            }
3012
                        }
3013
                        break;
3014
                    case ControlType.ChainLine:
3015
                        {
3016
                            if (currentControl is PolygonControl)
3017
                            {
3018
                                var control = currentControl as PolygonControl;
3019

    
3020
                                if (e.RightButton == MouseButtonState.Pressed)
3021
                                {
3022
                                    //20180906 LJY TEST IsRotationDrawingEnable
3023
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3024
                                    {
3025
                                        return;
3026
                                    }
3027

    
3028
                                    CreateCommand.Instance.Execute(currentControl);
3029

    
3030
                                    currentControl = null;
3031
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3032
                                    return;
3033
                                }
3034

    
3035
                                if (!control.IsCompleted)
3036
                                {
3037
                                    control.PointSet.Add(control.EndPoint);
3038
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3039
                                }
3040
                            }
3041
                            else
3042
                            {
3043
                                if (e.LeftButton == MouseButtonState.Pressed)
3044
                                {
3045
                                    MainAngle.Visibility = Visibility.Visible;
3046
                                    currentControl = new PolygonControl
3047
                                    {
3048
                                        PointSet = new List<Point>(),
3049
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3050
                                        ControlType = ControlType.ChainLine,
3051
                                        DashSize = ViewerDataModel.Instance.DashSize,
3052
                                        LineSize = ViewerDataModel.Instance.LineSize,
3053
                                        //PointC = new StylusPointSet()
3054
                                    };
3055

    
3056
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3057
                                    //{
3058
                                        var polygonControl = (currentControl as PolygonControl);
3059
                                        currentControl.CommentID = Commons.shortGuid();
3060
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3061
                                        currentControl.IsNew = true;
3062
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3063
                                        //currentControl.OnApplyTemplate();
3064
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3065
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3066
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3067
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3068
                                    //}
3069
                                }
3070
                            }
3071
                        }
3072
                        break;
3073
                    case ControlType.ArcLine:
3074
                        {
3075
                            if (e.LeftButton == MouseButtonState.Pressed)
3076
                            {
3077
                                if (currentControl is ArcControl)
3078
                                {
3079
                                    //20180906 LJY TEST IsRotationDrawingEnable
3080
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3081
                                    {
3082
                                        return;
3083
                                    }
3084

    
3085
                                    CreateCommand.Instance.Execute(currentControl);
3086

    
3087
                                    currentControl = null;
3088
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3089
                                }
3090
                                else
3091
                                {
3092
                                    currentControl = new ArcControl
3093
                                    {
3094
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3095
                                        Background = new SolidColorBrush(Colors.Black)
3096
                                    };
3097
                                    currentControl.CommentID = Commons.shortGuid();
3098
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3099
                                    currentControl.IsNew = true;
3100
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3101
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3102
                                }
3103
                            }
3104
                            else if (e.RightButton == MouseButtonState.Pressed)
3105
                            {
3106
                                if (currentControl != null)
3107
                                {
3108
                                    (currentControl as ArcControl).setClock();
3109
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3110
                                }
3111
                            }
3112
                        }
3113
                        break;
3114
                    case ControlType.ArcArrow:
3115
                        {
3116
                            if (e.LeftButton == MouseButtonState.Pressed)
3117
                            {
3118
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3119
                                //{
3120
                                if (currentControl is ArrowArcControl)
3121
                                {
3122
                                    //20180906 LJY TEST IsRotationDrawingEnable
3123
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3124
                                    {
3125
                                        return;
3126
                                    }
3127

    
3128
                                    CreateCommand.Instance.Execute(currentControl);
3129

    
3130
                                    currentControl = null;
3131
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3132
                                }
3133
                                else
3134
                                {
3135
                                    currentControl = new ArrowArcControl
3136
                                    {
3137
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3138
                                        Background = new SolidColorBrush(Colors.Black)
3139
                                    };
3140
                                    currentControl.CommentID = Commons.shortGuid();
3141
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3142
                                    currentControl.IsNew = true;
3143
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3144
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3145
                                }
3146
                                //}
3147
                            }
3148
                            else if (e.RightButton == MouseButtonState.Pressed)
3149
                            {
3150
                                if (currentControl != null)
3151
                                {
3152
                                    (currentControl as ArrowArcControl).setClock();
3153
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3154
                                    //(currentControl as ArcControl).ApplyTemplate();
3155
                                }
3156
                            }
3157
                        }
3158
                        break;
3159
                    case ControlType.ArrowMultiLine:
3160
                        {
3161
                            if (e.LeftButton == MouseButtonState.Pressed)
3162
                            {
3163
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3164
                                //{
3165

    
3166
                                    if (currentControl is ArrowControl_Multi)
3167
                                    {
3168
                                        var content = currentControl as ArrowControl_Multi;
3169
                                        if (content.MiddlePoint == new Point(0, 0))
3170
                                        {
3171
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3172
                                            {
3173
                                                content.MiddlePoint = content.EndPoint;
3174
                                            }
3175
                                            else
3176
                                            {
3177
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3178
                                            }
3179
                                        }
3180
                                        else
3181
                                        {
3182
                                            //20180906 LJY TEST IsRotationDrawingEnable
3183
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3184
                                            {
3185
                                                return;
3186
                                            }
3187

    
3188
                                            CreateCommand.Instance.Execute(currentControl);
3189

    
3190
                                            currentControl = null;
3191
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3192
                                        }
3193
                                    }
3194
                                    else
3195
                                    {
3196
                                        currentControl = new ArrowControl_Multi
3197
                                        {
3198
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3199
                                            Background = new SolidColorBrush(Colors.Black)
3200
                                        };
3201
                                        currentControl.CommentID = Commons.shortGuid();
3202
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3203
                                        currentControl.IsNew = true;
3204
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3205
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3206
                                    }
3207
                                //}
3208
                            }
3209
                        }
3210
                        break;
3211
                    case ControlType.PolygonCloud:
3212
                        {
3213
                            if (currentControl is CloudControl)
3214
                            {
3215
                                var control = currentControl as CloudControl;
3216
                                if (e.RightButton == MouseButtonState.Pressed)
3217
                                {
3218
                                    control.IsCompleted = true;
3219
                                }
3220

    
3221
                                if (!control.IsCompleted)
3222
                                {
3223
                                    control.PointSet.Add(control.EndPoint);
3224
                                }
3225
                                else
3226
                                {
3227
                                    //20180906 LJY TEST IsRotationDrawingEnable
3228
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3229
                                    {
3230
                                        return;
3231
                                    }
3232

    
3233
                                    CreateCommand.Instance.Execute(currentControl);
3234

    
3235
                                    control.isTransOn = true;
3236
                                    var firstPoint = control.PointSet.First();
3237

    
3238
                                    control.PointSet.Add(firstPoint);
3239
                                    control.DrawingCloud();
3240
                                    control.ApplyOverViewData();
3241

    
3242
                                    currentControl = null;
3243
                                }
3244
                            }
3245
                            else
3246
                            {
3247
                                if (e.LeftButton == MouseButtonState.Pressed)
3248
                                {
3249
                                    currentControl = new CloudControl
3250
                                    {
3251
                                        PointSet = new List<Point>(),
3252
                                        PointC = new StylusPointSet()
3253
                                    };
3254

    
3255
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3256
                                    //{
3257
                                        var polygonControl = (currentControl as CloudControl);
3258
                                        currentControl.CommentID = Commons.shortGuid();
3259
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3260
                                        currentControl.IsNew = true;
3261
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3262

    
3263
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3264
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3265
                                    
3266
                                    //}
3267
                                }
3268
                            }
3269
                        }
3270
                        break;
3271
                    case ControlType.ImgControl:
3272
                        {
3273
                            if (e.LeftButton == MouseButtonState.Pressed)
3274
                            {
3275
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3276
                                //{
3277
                                    if (currentControl is ImgControl)
3278
                                    {
3279
                                        //20180906 LJY TEST IsRotationDrawingEnable
3280
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3281
                                        {
3282
                                            return;
3283
                                        }
3284

    
3285
                                        CreateCommand.Instance.Execute(currentControl);
3286
                                        controlType = ControlType.ImgControl;
3287
                                        currentControl = null;
3288
                                    }
3289
                                    else
3290
                                    {
3291
                                        
3292
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3293
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3294
                                        {
3295
                                            Image img = new Image();
3296
                                            if (filename.Contains(".svg"))
3297
                                            {
3298
                                                byte[] imageData = null;
3299
                                                DrawingImage image = null;
3300
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3301
                                                {
3302
                                                    imageData = web.DownloadData(new Uri(filename));
3303
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3304
                                                    image = SvgReader.Load(stream);
3305
                                                }
3306
                                                img.Source = image;
3307
                                            }
3308
                                            else
3309
                                            {
3310
                                                img.Source = new BitmapImage(new Uri(filename));
3311
                                            }
3312

    
3313
                                            currentControl = new ImgControl
3314
                                            {
3315
                                                    Background = new SolidColorBrush(Colors.Black),
3316
                                                    PointSet = new List<Point>(),
3317
                                                    FilePath = filename,
3318
                                                    ImageData = img.Source,
3319
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3320
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3321
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3322
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3323
                                                    ControlType = ControlType.ImgControl
3324
                                                };
3325

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

    
3332
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3333
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3334
                                    }
3335
                                    }
3336
                                //}
3337
                            }
3338
                        }
3339
                        break;
3340
                    case ControlType.Date:
3341
                        {
3342
                            if (e.LeftButton == MouseButtonState.Pressed)
3343
                            {
3344
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3345
                                //{
3346
                                if (currentControl is DateControl)
3347
                                {
3348
                                    //20180906 LJY TEST IsRotationDrawingEnable
3349
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3350
                                    {
3351
                                        return;
3352
                                    }
3353

    
3354
                                    CreateCommand.Instance.Execute(currentControl);
3355
                                    currentControl = null;
3356

    
3357
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3358
                                    {
3359
                                        controlType = ControlType.None;
3360
                                        IsSwingMode = false;
3361
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3362
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3363
                                        mouseHandlingMode = MouseHandlingMode.None;
3364
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3365
                                        txtBatch.Visibility = Visibility.Collapsed;
3366

    
3367
                                    }
3368
                                }
3369
                                else
3370
                                {
3371
                                    currentControl = new DateControl
3372
                                    {
3373
                                        StartPoint = CanvasDrawingMouseDownPoint,
3374
                                        Background = new SolidColorBrush(Colors.Black)
3375
                                    };
3376
                                    currentControl.CommentID = Commons.shortGuid();
3377
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3378
                                    currentControl.IsNew = true;
3379
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3380

    
3381
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3382
                                    if (currentControl is ImgControl)
3383
                                    {
3384
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3385
                                    }
3386
                                }
3387
                                //}
3388
                            }
3389
                        }
3390
                        break;
3391
                    case ControlType.TextControl:
3392
                        {
3393
                            if (e.LeftButton == MouseButtonState.Pressed)
3394
                            {
3395
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3396
                                {
3397
                                    currentControl = new TextControl
3398
                                    {
3399
                                        ControlType = controlType
3400
                                    };
3401
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3402
                                    currentControl.CommentID = Commons.shortGuid();
3403
                                    currentControl.IsNew = true;
3404
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3405
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3406
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3407

    
3408
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3409
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3410
                                    
3411
                                    (currentControl as TextControl).ControlType_No = 0;
3412
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3413
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3414
                                    (currentControl as TextControl).ApplyTemplate();
3415
                                    (currentControl as TextControl).Base_TextBox.Focus();
3416
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3417
                                    CreateCommand.Instance.Execute(currentControl);
3418
                                }
3419
                            }
3420
                        }
3421
                        break;
3422
                    case ControlType.TextBorder:
3423
                        {
3424
                            if (e.LeftButton == MouseButtonState.Pressed)
3425
                            {
3426
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3427
                                {
3428
                                    currentControl = new TextControl
3429
                                    {
3430
                                        ControlType = controlType
3431
                                    };
3432

    
3433
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3434
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3435
                                    currentControl.CommentID = Commons.shortGuid();
3436
                                    currentControl.IsNew = true;
3437
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3438
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3439
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3440
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3441
                                    
3442
                                    (currentControl as TextControl).ControlType_No = 1;
3443
                                    (currentControl as TextControl).CommentAngle = Ang;
3444
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3445
                                    (currentControl as TextControl).ApplyTemplate();
3446
                                    (currentControl as TextControl).Base_TextBox.Focus();
3447
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3448
                                    CreateCommand.Instance.Execute(currentControl);
3449
                                }
3450
                            }
3451
                        }
3452
                        break;
3453
                    case ControlType.TextCloud:
3454
                        {
3455
                            if (e.LeftButton == MouseButtonState.Pressed)
3456
                            {
3457
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3458
                                {
3459
                                    currentControl = new TextControl
3460
                                    {
3461
                                        ControlType = controlType
3462
                                    };
3463

    
3464
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3465
                                    currentControl.CommentID = Commons.shortGuid();
3466
                                    currentControl.IsNew = true;
3467
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3468
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3469

    
3470
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3471
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3472
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3473

    
3474
                                    (currentControl as TextControl).CommentAngle = Ang;
3475
                                    (currentControl as TextControl).ControlType_No = 2;
3476
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3477
                                    (currentControl as TextControl).ApplyTemplate();
3478
                                    (currentControl as TextControl).Base_TextBox.Focus();
3479
                                    CreateCommand.Instance.Execute(currentControl);
3480
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3481
                                    //currentControl = null;
3482
                                }
3483
                            }
3484
                        }
3485
                        break;
3486
                    case ControlType.ArrowTextControl:
3487
                         {
3488
                            if (e.LeftButton == MouseButtonState.Pressed)
3489
                            {
3490
                                if (currentControl is ArrowTextControl)
3491
                                {
3492
                                    //20180906 LJY TEST IsRotationDrawingEnable
3493
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3494
                                    {
3495
                                        return;
3496
                                    }
3497

    
3498
                                    CreateCommand.Instance.Execute(currentControl);
3499

    
3500
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3501
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3502
                                    (currentControl as ArrowTextControl).IsNew = false;
3503
                                    currentControl = null;
3504
                                }
3505
                                else
3506
                                {
3507
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3508
                                    //{
3509
                                        currentControl = new ArrowTextControl();
3510
                                        currentControl.CommentID = Commons.shortGuid();
3511
                                        currentControl.IsNew = true;
3512
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3513
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3514

    
3515
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3516
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3517
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3518
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3519
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3520

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

    
3524
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3525
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3526
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3527
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3528

    
3529
                                    
3530
                                    //}
3531
                                }
3532
                            }
3533
                        }
3534
                        break;
3535
                    case ControlType.ArrowTransTextControl:
3536
                        {
3537
                            if (e.LeftButton == MouseButtonState.Pressed)
3538
                            {
3539
                                if (currentControl is ArrowTextControl)
3540
                                {
3541
                                    //20180906 LJY TEST IsRotationDrawingEnable
3542
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3543
                                    {
3544
                                        return;
3545
                                    }
3546

    
3547
                                    CreateCommand.Instance.Execute(currentControl);
3548

    
3549
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3550
                                    
3551
                                    currentControl.IsNew = false;
3552
                                    currentControl = null;
3553
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3554
                                }
3555
                                else
3556
                                {
3557
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3558
                                    //{
3559
                                    currentControl = new ArrowTextControl()
3560
                                    {
3561
                                        ControlType = ControlType.ArrowTransTextControl
3562
                                    };
3563
                                    currentControl.CommentID = Commons.shortGuid();
3564
                                    currentControl.IsNew = true;
3565
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3566
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3567
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3568
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3569
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3570
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3571
                                    (currentControl as ArrowTextControl).isFixed = true;
3572
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3573

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

    
3577
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3578
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3579
                                    (currentControl as ArrowTextControl).isTrans = true;
3580
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3581
                                }
3582
                            }
3583
                        }
3584
                        break;
3585
                    case ControlType.ArrowTextBorderControl:
3586
                         {
3587
                            if (e.LeftButton == MouseButtonState.Pressed)
3588
                            {
3589
                                if (currentControl is ArrowTextControl)
3590
                                {
3591
                                    //20180906 LJY TEST IsRotationDrawingEnable
3592
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3593
                                    {
3594
                                        return;
3595
                                    }
3596

    
3597
                                    CreateCommand.Instance.Execute(currentControl);
3598
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3599
                                    currentControl.IsNew = false;
3600
                                    currentControl = null;
3601
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3602
                                }
3603
                                else
3604
                                {
3605
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3606
                                    //{
3607
                                        currentControl = new ArrowTextControl()
3608
                                        {
3609
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3610
                                        };
3611
                                        currentControl.CommentID = Commons.shortGuid();
3612
                                        currentControl.IsNew = true;
3613
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3614
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3615

    
3616
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3617

    
3618
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3619

    
3620
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3621
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3622
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3623
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3624
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3625
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3626
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3627
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3628
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                    
3629
                                    //}
3630
                                }
3631
                            }
3632
                        }
3633
                        break;
3634
                    case ControlType.ArrowTransTextBorderControl:
3635
                        {
3636
                            if (e.LeftButton == MouseButtonState.Pressed)
3637
                            {
3638
                                if (currentControl is ArrowTextControl)
3639
                                {
3640
                                    //20180906 LJY TEST IsRotationDrawingEnable
3641
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3642
                                    {
3643
                                        return;
3644
                                    }
3645
                                    CreateCommand.Instance.Execute(currentControl);
3646
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3647
                                    currentControl.IsNew = false;
3648
                                    currentControl = null;
3649

    
3650
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3651
                                }
3652
                                else
3653
                                {
3654
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3655
                                    //{
3656
                                    
3657

    
3658
                                    currentControl = new ArrowTextControl()
3659
                                    {
3660
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3661
                                        ControlType = ControlType.ArrowTransTextBorderControl
3662

    
3663
                                    };
3664
                                        currentControl.CommentID = Commons.shortGuid();
3665
                                        currentControl.IsNew = true;
3666
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3667
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3668

    
3669
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3670

    
3671
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3672
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3673
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3674
                                        (currentControl as ArrowTextControl).isFixed = true;
3675
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3676
                                     
3677
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3678
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3679
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3680
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3681
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3682
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3683
                                    
3684
                                    //20180911 LJY
3685
                                        (currentControl as ArrowTextControl).isTrans = true;
3686
                                    
3687

    
3688
                                    //}
3689
                                }
3690
                            }
3691
                        }
3692
                        break;
3693
                    case ControlType.ArrowTextCloudControl:
3694
                        {
3695
                            if (e.LeftButton == MouseButtonState.Pressed)
3696
                            {
3697
                                if (currentControl is ArrowTextControl)
3698
                                {
3699
                                    //20180906 LJY TEST IsRotationDrawingEnable
3700
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3701
                                    {
3702
                                        return;
3703
                                    }
3704
                                    CreateCommand.Instance.Execute(currentControl);
3705
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3706
                                    currentControl.IsNew = false;
3707
                                    currentControl = null;
3708
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3709
                                }
3710
                                else
3711
                                {
3712
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3713
                                    //{
3714
                                        currentControl = new ArrowTextControl()
3715
                                        {
3716
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3717
                                        };
3718
                                        currentControl.CommentID = Commons.shortGuid();
3719
                                        currentControl.IsNew = true;
3720
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3721
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3722

    
3723
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3724
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3725
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                 
3726
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3727
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3728
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3729
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3730
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3731
                                    
3732
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3733
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3734
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                        
3735
                                    //}
3736
                                }
3737
                            }
3738
                        }
3739
                        break;
3740
                    case ControlType.ArrowTransTextCloudControl:
3741
                        {
3742
                            if (e.LeftButton == MouseButtonState.Pressed)
3743
                            {
3744
                                if (currentControl is ArrowTextControl)
3745
                                {
3746
                                    //20180906 LJY TEST IsRotationDrawingEnable
3747
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3748
                                    {
3749
                                        return;
3750
                                    }
3751
                                    CreateCommand.Instance.Execute(currentControl);
3752
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3753
                                    currentControl.IsNew = false;
3754
                                    currentControl = null;
3755
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3756
                                }
3757
                                else
3758
                                {
3759
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3760
                                    //{
3761
                                        currentControl = new ArrowTextControl()
3762
                                        {
3763
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3764
                                            ControlType = ControlType.ArrowTransTextCloudControl
3765

    
3766
                                        };
3767
                                        currentControl.CommentID = Commons.shortGuid();
3768
                                        currentControl.IsNew = true; 
3769
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3770
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3771
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3772

    
3773
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3774
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3775
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3776
                                        (currentControl as ArrowTextControl).isFixed = true;
3777
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3778

    
3779
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3780
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3781
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3782
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3783
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3784
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;  
3785
                                    
3786
                                    //20180911 LJY
3787
                                        (currentControl as ArrowTextControl).isTrans = true;
3788
                                    //}
3789
                                }
3790
                            }
3791
                        }
3792
                        break;
3793
                    //강인구 추가
3794
                    case ControlType.Sign:
3795
                        {
3796
                            if (e.LeftButton == MouseButtonState.Pressed)
3797
                            {
3798
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3799
                                //{
3800
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3801

    
3802
                                    if (_sign == null)
3803
                                    {
3804
                                        txtBatch.Visibility = Visibility.Collapsed;
3805
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3806
                                        controlType = ControlType.None;
3807

    
3808
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3809
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3810
                                        return;
3811
                                    }
3812

    
3813
                                    if (currentControl is SignControl)
3814
                                    {
3815
                                        //20180906 LJY TEST IsRotationDrawingEnable
3816
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3817
                                        {
3818
                                            return;
3819
                                        }
3820

    
3821
                                        CreateCommand.Instance.Execute(currentControl);
3822
                                        currentControl = null;
3823
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3824
                                        {
3825
                                            txtBatch.Text = "Place Date";
3826
                                            controlType = ControlType.Date;
3827
                                        }
3828
                                    }
3829
                                    else
3830
                                    {
3831
                                        currentControl = new SignControl
3832
                                        {
3833
                                            Background = new SolidColorBrush(Colors.Black),
3834
                                            UserNumber = App.ViewInfo.UserID,
3835
                                            ProjectNO = App.ViewInfo.ProjectNO,
3836
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3837
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3838
                                            ControlType = ControlType.Sign
3839
                                        };
3840

    
3841
                                        currentControl.CommentID = Commons.shortGuid();
3842
                                        currentControl.IsNew = true;
3843
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3844
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3845

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

    
3867
                                        CreateCommand.Instance.Execute(currentControl);
3868
                                        (currentControl as RectangleControl).ApplyOverViewData();
3869
                                        currentControl = null;
3870
                                    
3871
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3872

    
3873
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3874
                                        {
3875
                                            txtBatch.Text = "Place Signature";
3876
                                            controlType = ControlType.Sign;
3877
                                        }
3878
                                    }
3879
                                    else
3880
                                    {
3881
                                        currentControl = new RectangleControl
3882
                                        {
3883
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3884
                                            Background = new SolidColorBrush(Colors.Black),
3885
                                            ControlType = ControlType.Mark ,
3886
                                            Paint = PaintSet.Fill
3887
                                        };
3888

    
3889
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3890
                                        currentControl.CommentID = Commons.shortGuid();
3891
                                        currentControl.IsNew = true;
3892
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3893
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3894
                                    }
3895
                                //}
3896
                            }
3897
                        }
3898
                        break;
3899
                    case ControlType.Symbol:
3900
                        {
3901
                            if (e.LeftButton == MouseButtonState.Pressed)
3902
                            {
3903
                                if (currentControl is SymControl)
3904
                                {
3905
                                    //20180906 LJY TEST IsRotationDrawingEnable
3906
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3907
                                    {
3908
                                        return;
3909
                                    }
3910
                                    CreateCommand.Instance.Execute(currentControl);
3911
                                    currentControl = null;
3912
                                
3913
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3914
                                }
3915
                                else
3916
                                {
3917
                                    currentControl = new SymControl
3918
                                    {
3919
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3920
                                        Background = new SolidColorBrush(Colors.Black),
3921
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3922
                                        ControlType = ControlType.Symbol
3923
                                    };
3924

    
3925
                                    currentControl.IsNew = true;
3926
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3927
                                    currentControl.CommentID = Commons.shortGuid();
3928
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3929

    
3930
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3931
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3932
                                }
3933
                                //}
3934
                            }
3935
                        }
3936
                        break;
3937
                    case ControlType.Stamp:
3938
                        {
3939
                            if (e.LeftButton == MouseButtonState.Pressed)
3940
                            {
3941
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3942
                                //{
3943
                                    if (currentControl is SymControlN)
3944
                                    {
3945
                                        //20180906 LJY TEST IsRotationDrawingEnable
3946
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3947
                                        {
3948
                                            return;
3949
                                        }
3950

    
3951
                                        CreateCommand.Instance.Execute(currentControl);
3952
                                        currentControl = null;
3953
                                   
3954

    
3955
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3956
                                    }
3957
                                    else
3958
                                    {
3959
                                        currentControl = new SymControlN
3960
                                        {
3961
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3962
                                            Background = new SolidColorBrush(Colors.Black),
3963
                                            STAMP = App.SystemInfo.STAMP,                                            
3964
                                            ControlType = ControlType.Stamp
3965
                                        };
3966

    
3967
                                        currentControl.IsNew = true;
3968
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3969
                                        currentControl.CommentID = Commons.shortGuid();
3970
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3971
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3972
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
3973
                                }                                    
3974
                                //}
3975
                            }
3976
                        }
3977
                        break;
3978
                    case ControlType.PenControl:
3979
                        {
3980
                            if (inkBoard.Tag.ToString() == "Ink")
3981
                            {
3982
                                inkBoard.IsEnabled = true;
3983
                                StartNewStroke(CanvasDrawingMouseDownPoint);
3984
                            }
3985
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3986
                            {
3987
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
3988
                            }
3989
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3990
                            {
3991
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
3992
                            }
3993
                            IsDrawing = true;
3994
                            return;
3995
                        }
3996
                    default:
3997
                        if (currentControl != null)
3998
                        {
3999
                            currentControl.CommentID = null;
4000
                            currentControl.IsNew = false;
4001
                        }
4002
                        break;
4003
                }
4004

    
4005
                if (currentControl != null)
4006
                {
4007
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4008
                }
4009
            }
4010
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4011
            {
4012
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4013
                {
4014
                    bool mouseOff = false;
4015
                    foreach (var item in SelectLayer.Children)
4016
                    {
4017
                        if (item is AdornerFinal)
4018
                        {
4019

    
4020
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4021
                            if (over != null)
4022
                            {
4023
                                mouseOff = true;
4024
                            }
4025
                        }
4026
                    }
4027

    
4028
                    if (!mouseOff)
4029
                    {
4030
                        SelectionSet.Instance.UnSelect(this);
4031
                    }
4032
                }
4033
                zoomAndPanControl.CaptureMouse();
4034
                e.Handled = true;
4035
            }
4036
          
4037
        }
4038

    
4039
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4040
        {
4041
            ///mouseButtonDown = e.ChangedButton;
4042
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4043
        }
4044

    
4045
        private void RemoveLineStroke(Point P)
4046
        {
4047
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4048
            if (control != null)
4049
            {
4050
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4051
            }
4052
        }
4053

    
4054
        private void RemovePointStroke(Point P)
4055
        {
4056
            foreach (Stroke hits in inkBoard.Strokes)
4057
            {
4058
                foreach (StylusPoint sty in hits.StylusPoints)
4059
                {
4060

    
4061
                }
4062
                if (hits.HitTest(P))
4063
                {
4064
                    inkBoard.Strokes.Remove(hits);
4065
                    return;
4066
                }
4067
            }
4068
        }
4069

    
4070
        private void StartNewStroke(Point P)
4071
        {
4072
            strokePoints = new StylusPointCollection();
4073
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4074
            strokePoints.Add(segment1Start);
4075
            stroke = new Stroke(strokePoints);
4076

    
4077
            stroke.DrawingAttributes.Color = Colors.Red;
4078
            stroke.DrawingAttributes.Width = 4;
4079
            stroke.DrawingAttributes.Height = 4;
4080

    
4081
            inkBoard.Strokes.Add(stroke);
4082
        }
4083

    
4084
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4085
        {
4086
            ConsolidationMethod();
4087
        }
4088

    
4089
        /// <summary>
4090
        /// execute TeamConsolidationCommand
4091
        /// </summary>
4092
        public void TeamConsolidationMethod()
4093
        {
4094
            this.UpdateMyMarkupList();
4095
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4096
            {
4097
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4098
            }
4099
            else
4100
            {
4101

    
4102
                ViewerDataModel.Instance.IsConsolidate = true;
4103
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4104

    
4105
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4106
                {
4107
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4108
                    {
4109
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4110
                        return;
4111
                    }                    
4112
                }
4113
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4114
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4115
                {
4116
                    MarkupInfoList.Add(item);
4117
                }
4118
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4119
            }
4120
        }
4121

    
4122
        public void ConsolidationMethod()
4123
        {
4124
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4125
            {
4126
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4127
            }
4128
            else
4129
            {
4130
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4131
                foreach (var item in this.gridViewMarkup.SelectedItems)
4132
                {
4133
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4134
                }
4135
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4136
                
4137
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4138
            }
4139
        }
4140

    
4141
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4142
        {
4143
            if (App.ViewInfo != null)
4144
            {
4145
                btnConsolidate = (sender as RadRibbonButton);
4146
                if (!App.ViewInfo.NewCommentPermission)
4147
                {
4148
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4149
                }
4150
            }
4151
        }
4152

    
4153
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4154
        {
4155
            TeamConsolidationMethod();
4156
        }
4157

    
4158
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4159
        {
4160
            btnTeamConsolidate = sender as RadRibbonButton;
4161
            if (App.ViewInfo != null)
4162
            {
4163
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4164
                {
4165
                    if (btnConsolidate != null)
4166
                    {
4167
                        btnConsolidate.Visibility = Visibility.Collapsed;
4168
                    }
4169

    
4170
                    if (!App.ViewInfo.NewCommentPermission)
4171
                    {
4172
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4173
                    }
4174
                }
4175
                else
4176
                {
4177
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4178
                }
4179
            }
4180
        }
4181

    
4182
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4183
        {
4184
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4185
            if(item != null)
4186
            {
4187
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4188
                {
4189
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4190
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4191
                }
4192
                else
4193
                {
4194
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4195
                }
4196
            }else{
4197
                //Consolidate 가 없는 경우
4198
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4199
            }
4200
            
4201
        }
4202

    
4203
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4204
        {
4205
            btnFinalPDF = sender as RadRibbonButton;
4206
            if (App.ViewInfo != null)
4207
            {
4208
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4209
                {
4210
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4211
                    if (btnConsolidate != null)
4212
                    {
4213
                        btnConsolidate.Visibility = Visibility.Collapsed;
4214
                    }
4215
                }
4216
            }
4217
        }
4218

    
4219
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4220
        {
4221
            UpdateMyMarkupList();
4222

    
4223
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4224
            {
4225
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4226
            }
4227
            else
4228
            {
4229
                ViewerDataModel.Instance.IsConsolidate = true;
4230
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4231
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4232

    
4233
                string project_no = App.ViewInfo.ProjectNO;
4234
                string doc_id = _DocInfo.ID;
4235
                string user_id = App.ViewInfo.UserID;
4236
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4237
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4238
                {
4239
                    markupInfoItems.Add(item);
4240
                }
4241
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4242
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4243
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4244
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4245

    
4246
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4247
                if (item2 != null)
4248
                {
4249
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4250

    
4251
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4252
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4253
                }
4254
                else
4255
                {
4256
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4257
                }
4258
            }
4259
        }
4260

    
4261
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4262
        {
4263
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4264

    
4265
            if (App.ViewInfo != null)
4266
            {
4267
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4268
                {
4269
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4270
                }
4271
            }
4272
        }
4273

    
4274
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4275
        {
4276
            SetCompareRect();
4277
        }
4278

    
4279
        private void Sync_Click(object sender, RoutedEventArgs e)
4280
        {
4281
            if (Sync.IsChecked)
4282
            {
4283
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4284
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4285
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4286
            }
4287
        }
4288

    
4289
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4290
        {
4291
            if (UserList.IsChecked)
4292
            {
4293
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4294
            }
4295
            else
4296
            {
4297
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4298
            }
4299
        }
4300

    
4301
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4302
        {
4303

    
4304
            if (BalanceMode.IsChecked)
4305
            {
4306
                ViewerDataModel.Instance.PageBalanceMode = true;
4307
            }
4308
            else
4309
            {
4310
                ViewerDataModel.Instance.PageBalanceMode = false;
4311
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4312
            }
4313
        }
4314

    
4315
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4316
        {
4317
            //초기화
4318
            testPanel2.IsHidden = true;
4319
            ViewerDataModel.Instance.PageBalanceMode = false;
4320
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4321
            ViewerDataModel.Instance.PageNumber = 0;
4322
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4323
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4324
            UserList.IsChecked = false;
4325
            BalanceMode.IsChecked = false;
4326
        }
4327

    
4328
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4329
        {
4330
            if ((sender as System.Windows.Controls.Control).Tag != null)
4331
            {
4332
                //Compare 초기화
4333
                CompareMode.IsChecked = false;
4334
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4335

    
4336
                if (ViewerDataModel.Instance.PageNumber == 0)
4337
                {
4338
                    ViewerDataModel.Instance.PageNumber = 1;
4339
                }
4340

    
4341
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4342
                {
4343
                }
4344
                else
4345
                {
4346
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4347
                }
4348

    
4349

    
4350

    
4351
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4352
                {
4353

    
4354
                }
4355
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4356
                {
4357
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4358
                }
4359

    
4360
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4361

    
4362
                if (!testPanel2.IsHidden)
4363
                {
4364
                    if (IsSyncPDFMode)
4365
                    {
4366
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4367
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4368

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

    
4386
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4387
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4388
                        }
4389

    
4390
                    }
4391
                    else
4392
                    {
4393
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4394

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

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

    
4401
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4402
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4403

    
4404
                        if (defaultBitmapImage_Compare.IsDownloading)
4405
                        {
4406
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4407
                            {
4408
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4409
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4410
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4411

    
4412
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4413
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4414
                            };
4415
                        }
4416
                    }
4417

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

    
4422
                    foreach (var item in gridSelectionRevItem)
4423
                    {
4424
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4425
                        {
4426
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4427
                        });
4428
                    }
4429

    
4430
                    //강인구 추가
4431
                    zoomAndPanControl2.ZoomTo(new Rect
4432
                    {
4433
                        X = 0,
4434
                        Y = 0,
4435
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4436
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4437
                    });
4438

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

    
4441
                }
4442
            }
4443
        }
4444

    
4445
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4446
        {
4447
            if (MarkupMode.IsChecked)
4448
            {
4449
                IsSyncPDFMode = true;
4450

    
4451
                var uri = CurrentRev.TO_VENDOR;
4452

    
4453
                if (ViewerDataModel.Instance.PageNumber == 0)
4454
                {
4455
                    ViewerDataModel.Instance.PageNumber = 1;
4456
                }
4457

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

    
4462
                if (pdfpath.IsDownloading)
4463
                {
4464
                    pdfpath.DownloadCompleted += (ex, arg) =>
4465
                    {
4466
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4467
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4468
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4469
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4470
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4471
                    };
4472
                }
4473
                else
4474
                {
4475
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4476
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4477
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4478

    
4479
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4480
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4481
                }
4482
            }
4483
            else
4484
            {
4485
                IsSyncPDFMode = false;
4486
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4487

    
4488
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4489

    
4490
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4491
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4492
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4493

    
4494
                if (defaultBitmapImage_Compare.IsDownloading)
4495
                {
4496
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4497
                    {
4498
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4499
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4500
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4501
                    };
4502
                }
4503
                zoomAndPanControl2.ApplyTemplate();
4504
                zoomAndPanControl2.UpdateLayout();
4505
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4506
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4507
            }
4508
        }
4509

    
4510
        /// <summary>
4511
        /// Compare된 영역을 초기화
4512
        /// </summary>
4513
        private void ClearCompareRect()
4514
        {
4515
            da.From = 1;
4516
            da.To = 1;
4517
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4518
            da.AutoReverse = false;
4519
            canvas_compareBorder.Children.Clear();
4520
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4521
        }
4522

    
4523
        /// <summary>
4524
        /// 문서 Comprare 
4525
        /// </summary>
4526
        private void SetCompareRect()
4527
        {
4528
            if (CompareMode.IsChecked)
4529
            {
4530
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4531
                {
4532
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4533
                }
4534
                if (ViewerDataModel.Instance.PageNumber == 0)
4535
                {
4536
                    ViewerDataModel.Instance.PageNumber = 1;
4537
                }
4538

    
4539
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4540
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4541
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4542

    
4543
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4544
            }
4545
            else
4546
            {
4547
                ClearCompareRect();
4548
            }
4549
        }
4550

    
4551
        private void RadButton_Click(object sender, RoutedEventArgs e)
4552
        {
4553
            gridViewHistory_Busy.IsBusy = true;
4554

    
4555
            RadButton instance = sender as RadButton;
4556
            if (instance.CommandParameter != null)
4557
            {
4558
                CurrentRev = instance.CommandParameter as VPRevision;
4559
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4560

    
4561
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4562
                {
4563
                    if (ea.Error == null && ea.Result != null)
4564
                    {
4565
                        testPanel2.IsHidden = false;
4566

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

    
4583
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4584

    
4585
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4586

    
4587
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4588
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4589
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4590
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4591
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4592
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4593

    
4594
                        zoomAndPanControl2.ApplyTemplate();
4595
                        zoomAndPanControl2.UpdateLayout();
4596
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4597
                        {
4598
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4599
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4600
                        }
4601

    
4602
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4603
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4604
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4605

    
4606
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4607
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4608
                        gridViewHistory_Busy.IsBusy = false;
4609
                    }
4610

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

    
4613
                    if (GetSyncMarkupInfoItemshandler != null)
4614
                    {
4615
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4616
                    }
4617

    
4618
                    ClearCompareRect();
4619
                    SetCompareRect();
4620
                };
4621

    
4622
                /// 중복 실행이 발생하여 수정함.
4623
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4624
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4625

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

    
4630
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4631
        {
4632
            try
4633
            {
4634
                if (sender is RadButton)
4635
                {
4636
                    if ((sender as RadButton).Tag != null)
4637
                    {
4638
                        var url = (sender as RadButton).Tag.ToString();
4639
                        System.Diagnostics.Process.Start(url);
4640
                    }
4641
                    else
4642
                    {
4643
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4644
                    }
4645
                }
4646
            }
4647
            catch (Exception ex)
4648
            {
4649
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4650
            }
4651
        }
4652

    
4653
        public void Sync_Event(VPRevision Currnet_Rev)
4654
        {
4655
            CurrentRev = Currnet_Rev;
4656

    
4657
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4658
            {
4659
                if (ea.Error == null && ea.Result != null)
4660
                {
4661
                    testPanel2.IsHidden = false;
4662

    
4663
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4664
                    foreach(var info in ea.Result)
4665
                    {
4666
                        if(info.UserID == App.ViewInfo.UserID)
4667
                        {
4668
                            info.userDelete = true;
4669
                            info.DisplayColor = "FFFF0000";
4670
                        }
4671
                        else
4672
                        {
4673
                            info.userDelete = false;
4674
                        }
4675
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4676
                    }
4677
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4678

    
4679
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4680

    
4681
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4682

    
4683
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4684

    
4685
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4686
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4687
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4688

    
4689
                    if (defaultBitmapImage_Compare.IsDownloading)
4690
                    {
4691
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4692
                        {
4693
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4694
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4695
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4696
                        };
4697
                    }
4698

    
4699

    
4700
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4701
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4702
                    zoomAndPanControl2.ApplyTemplate();
4703
                    zoomAndPanControl2.UpdateLayout();
4704

    
4705
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4706
                    {
4707
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4708
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4709
                    }
4710
                    //}
4711

    
4712
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4713
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4714
                    gridViewHistory_Busy.IsBusy = false;
4715
                }
4716
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4717

    
4718
            };
4719
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4720
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4721
        }
4722

    
4723
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4724
        {
4725
            if (sender is Image)
4726
            {
4727
                if ((sender as Image).Tag != null)
4728
                {
4729
                    var pdfUrl = (sender as Image).Tag.ToString();
4730
                    System.Diagnostics.Process.Start(pdfUrl);
4731
                }
4732
                else
4733
                {
4734
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4735
                }
4736
            }
4737
        }
4738

    
4739
        private void Create_Symbol(object sender, RoutedEventArgs e)
4740
        {
4741
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4742

    
4743
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4744
            {
4745
                DialogMessage_Alert("Please Select Controls", "Alert");
4746
            }
4747
            else //선택된 것이 있으면
4748
            {
4749
                string MarkupData = "";
4750
                adorner_ = new AdornerFinal();
4751

    
4752
                foreach (var item in SelectLayer.Children)
4753
                {
4754
                    if (item.GetType().Name == "AdornerFinal")
4755
                    {
4756
                        adorner_ = (item as Controls.AdornerFinal);
4757
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4758
                        {
4759
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4760
                            {
4761
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4762
                                MarkupData += markupReturn.ConvertData;
4763
                            }
4764
                        }
4765
                    }
4766
                }
4767
                DialogParameters parameters = new DialogParameters()
4768
                {
4769
                    Owner = Application.Current.MainWindow,
4770
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4771
                    DefaultPromptResultValue = "Custom State",
4772
                    Content = "Name :",
4773
                    Header = "Insert Custom Symbol Name",
4774
                    Theme = new VisualStudio2013Theme(),
4775
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4776
                };
4777
                RadWindow.Prompt(parameters);
4778
            }
4779

    
4780
        }
4781
        public int symbolselectindex = 0;
4782
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4783
        {
4784
            //Save save = new Save();
4785
            try
4786
            {
4787
                string svgfilename = null;
4788
                if (symbolname != null)
4789
                {
4790
                    if (symbolpng == true || symbolsvg == true)
4791
                    {
4792
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4793
                        string guid = Commons.shortGuid();
4794

    
4795
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4796
                        //Check_Uri.UriCheck();
4797
                        fileUploader.RunCompleted += (ex, arg) =>
4798
                        {
4799
                            filename = arg.Result;
4800
                            if (symbolpng == true)
4801
                            {
4802
                                if (filename != null)
4803
                                { 
4804
                                    if (symbolselectindex == 0)
4805
                                    {
4806
                                        SymbolSave(symbolname, filename, data);
4807
                                    }
4808
                                    else
4809
                                    {
4810
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4811
                                    }
4812
                                    DataBind();
4813
                                }                                
4814
                            }
4815

    
4816
                            if (symbolsvg == true)
4817
                            {
4818
                                try
4819
                                {
4820
                                    var defaultBitmapImage = new BitmapImage();
4821
                                    defaultBitmapImage.BeginInit();
4822
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4823
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4824
                                    Check_Uri.UriCheck(filename);
4825
                                    defaultBitmapImage.UriSource = new Uri(filename);
4826
                                    defaultBitmapImage.EndInit();
4827

    
4828
                                    System.Drawing.Bitmap image;
4829

    
4830
                                    if (defaultBitmapImage.IsDownloading)
4831
                                    {
4832
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4833
                                        {
4834
                                            defaultBitmapImage.Freeze();
4835
                                            image = GetBitmap(defaultBitmapImage);
4836
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4837
                                            Process potrace = new Process
4838
                                            {
4839
                                                StartInfo = new ProcessStartInfo
4840
                                                {
4841
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4842
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4843
                                                    RedirectStandardInput = true,
4844
                                                    RedirectStandardOutput = true,
4845
                                                    RedirectStandardError = true,
4846
                                                    UseShellExecute = false,
4847
                                                    CreateNoWindow = true,
4848
                                                    WindowStyle = ProcessWindowStyle.Hidden
4849
                                                },
4850
                                            };
4851

    
4852
                                            StringBuilder svgBuilder = new StringBuilder();
4853
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4854
                                            {
4855
                                                svgBuilder.AppendLine(e2.Data);
4856
                                            };
4857

    
4858
                                            potrace.EnableRaisingEvents = true;
4859
                                            potrace.Start();
4860
                                            potrace.Exited += (sender, e) =>
4861
                                            {
4862
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4863
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4864
                                                Check_Uri.UriCheck(svgfilename);
4865
                                                if (symbolselectindex == 0)
4866
                                                {
4867
                                                    SymbolSave(symbolname, svgfilename, data);
4868
                                                }
4869
                                                else
4870
                                                {
4871
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4872
                                                }
4873

    
4874
                                                DataBind();
4875
                                            };
4876
                                            potrace.WaitForExit();
4877
                                        };
4878
                                    }
4879
                                    else
4880
                                    {
4881
                                        //GC.Collect();
4882
                                    }
4883
                                }
4884
                                catch(Exception ee)
4885
                                {
4886
                                    DialogMessage_Alert("" + ee, "Alert");
4887
                                }
4888
                            }
4889
                        };                                             
4890
                    }
4891
                }
4892
            }
4893
            catch (Exception e)
4894
            {
4895
                //DialogMessage_Alert(e + "", "Alert");
4896
            }            
4897
        }
4898

    
4899
        public void SymbolSave(string Name, string Url, string Data)
4900
        {
4901
            try
4902
            {
4903
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4904
                {
4905
                    ID = Commons.shortGuid(),
4906
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4907
                    NAME = Name,
4908
                    IMAGE_URL = Url,
4909
                    DATA = Data
4910
                };
4911

    
4912
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4913
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4914
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4915
            }
4916
            catch (Exception)
4917
            {
4918
                throw;
4919
            }
4920
        }
4921

    
4922
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4923
        {
4924
            try
4925
            {
4926
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4927
                {
4928
                    ID = Commons.shortGuid(),
4929
                    DEPARTMENT = Department,
4930
                    NAME = Name,
4931
                    IMAGE_URL = Url,
4932
                    DATA = Data
4933
                };
4934
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4935
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4936
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4937
            }
4938
            catch (Exception)
4939
            {
4940
                throw;
4941
            }
4942
        }
4943

    
4944
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4945
        {           
4946
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4947
            DataBind();
4948
        }
4949

    
4950
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4951
        {
4952
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4953
            DataBind();
4954
        }
4955
        private void DataBind()
4956
        {
4957
            try
4958
            {
4959
                Symbol_Custom Custom = new Symbol_Custom();
4960
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4961
                
4962
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4963
                foreach (var item in symbol_Private)
4964
                {
4965
                    Custom.Name = item.NAME;
4966
                    Custom.ImageUri = item.IMAGE_URL;
4967
                    Custom.ID = item.ID;
4968
                    Custom_List.Add(Custom);
4969
                    Custom = new Symbol_Custom();
4970
                }
4971
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4972
                
4973
                Custom = new Symbol_Custom();
4974
                Custom_List = new List<Symbol_Custom>();
4975

    
4976
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4977

    
4978
                List<SYMBOL_PUBLIC> symbol_Public;
4979

    
4980
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4981
                {
4982
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4983
                }
4984
                else
4985
                {
4986
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4987
                }
4988
                foreach (var item in symbol_Public)
4989
                {
4990
                    Custom.Name = item.NAME;
4991
                    Custom.ImageUri = item.IMAGE_URL;
4992
                    Custom.ID = item.ID;
4993
                    Custom_List.Add(Custom);
4994
                    Custom = new Symbol_Custom();
4995
                }
4996
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4997
                BaseClient.Close();                
4998
            }
4999
            catch(Exception e)
5000
            {
5001
                //DialogMessage_Alert("DataBind", "Alert");
5002
            }
5003
            
5004
        }
5005
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5006
        {
5007
            try
5008
            {
5009
                if (args.PromptResult != null)
5010
                {
5011
                    if (args.DialogResult.Value)
5012
                    {
5013
                        PngBitmapEncoder _Encoder = symImage(data);
5014

    
5015
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5016
                        _Encoder.Save(fs);
5017
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5018

    
5019
                        byte[] Img_byte = fs.ToArray();
5020

    
5021
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5022
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5023
                        Check_Uri.UriCheck(filename);
5024
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5025
                        {
5026
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5027
                        }
5028
                        else
5029
                        {
5030
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5031
                        }
5032
                        DataBind();
5033
                    }
5034
                }
5035
            }
5036
            catch(Exception ex)
5037
            {
5038
                DialogMessage_Alert("" + ex, "Alert");
5039
            }
5040
        }
5041

    
5042
        public PngBitmapEncoder symImage(string data)
5043
        {
5044

    
5045
            Canvas _canvas = new Canvas();
5046
            _canvas.Background = Brushes.White;
5047
            _canvas.Width = adorner_.BorderSize.Width;
5048
            _canvas.Height = adorner_.BorderSize.Height;
5049
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5050

    
5051
            BitmapEncoder encoder = new PngBitmapEncoder();
5052

    
5053

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

    
5056
            DrawingVisual dv = new DrawingVisual();
5057

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

    
5061
            using (DrawingContext ctx = dv.RenderOpen())
5062
            {
5063
                VisualBrush vb = new VisualBrush(_canvas);
5064
                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)));
5065
            }
5066

    
5067
            try
5068
            {
5069
                renderBitmap.Render(dv);
5070

    
5071
                //GC.Collect();
5072
                GC.WaitForPendingFinalizers();
5073
                //GC.Collect();
5074
                // encode png data
5075
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5076
                // puch rendered bitmap into it
5077
                pngEncoder.Interlace = PngInterlaceOption.Off;
5078
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5079
                return pngEncoder;
5080

    
5081
            }
5082
            catch //(Exception ex)
5083
            {
5084
                return null;
5085
            }
5086

    
5087
        }
5088

    
5089
        public void DialogMessage_Alert(string content, string header)
5090
        {
5091
            DialogParameters parameters = new DialogParameters()
5092
            {
5093
                Owner = this.ParentOfType<MainWindow>(),
5094
                Content = new TextBlock()
5095
                { 
5096
                    MinWidth = 400,
5097
                    FontSize = 11,
5098
                    Text = content,
5099
                    TextWrapping = System.Windows.TextWrapping.Wrap
5100
                },
5101
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5102
                Header = header,
5103
                Theme = new VisualStudio2013Theme(),
5104
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5105
            };            
5106
            RadWindow.Alert(parameters);
5107
        }
5108

    
5109
        #region 캡쳐 기능
5110

    
5111
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5112
        {
5113
            if (x < 0)
5114
            {
5115
                width += x;
5116
                x = 0;
5117
            }
5118
            if (y < 0)
5119
            {
5120
                height += y;
5121
                y = 0;
5122

    
5123
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5124
            }
5125
            if (x + width > zoomAndPanCanvas.ActualWidth)
5126
            {
5127
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5128
            }
5129
            if (y + height > zoomAndPanCanvas.ActualHeight)
5130
            {
5131
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5132
            }
5133

    
5134
            byte[] pixels = CopyPixels(x, y, width, height);
5135

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

    
5138
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5139
        }
5140

    
5141
        public byte[] CopyPixels(int x, int y, int width, int height)
5142
        {
5143
            byte[] pixels = new byte[width * height * 4];
5144
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5145

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

    
5149
            return pixels;
5150
        }
5151

    
5152
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5153
        {
5154
            DrawingVisual drawingVisual = new DrawingVisual();
5155
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5156

    
5157
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5158
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5159
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5160
            drawingContext.Close();
5161

    
5162
            // 비트맵으로 변환합니다.
5163
            RenderTargetBitmap target =
5164
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5165
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5166

    
5167
            target.Render(drawingVisual);
5168
            return target;
5169
        }
5170

    
5171
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5172
        {
5173
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5174
            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);
5175
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5176
            bmp.UnlockBits(data);
5177
            return bmp;
5178
        }
5179
        public string symbolname = null;
5180
        public bool symbolsvg = true;
5181
        public bool symbolpng = true;
5182

    
5183
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5184
        {
5185
            System.Drawing.Bitmap image = GetBitmap(source);
5186
            //흰색 제거
5187
            //image.MakeTransparent(System.Drawing.Color.White);
5188

    
5189
            var imageStream = new System.IO.MemoryStream();
5190
            byte[] imageBytes = null;
5191
            using (imageStream)
5192
            {
5193
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5194
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5195
                imageStream.Position = 0;
5196
                imageBytes = imageStream.ToArray();
5197
            }
5198

    
5199
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5200

    
5201
            RadWindow CheckPop = new RadWindow();
5202
            //Alert check = new Alert(Msg);
5203

    
5204
            CheckPop = new RadWindow
5205
            {
5206
                MinWidth = 400,
5207
                MinHeight = 100,
5208
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5209
                Header = "Alert",
5210
                Content = symbolPrompt,
5211
                //DialogResult = 
5212
                ResizeMode = System.Windows.ResizeMode.NoResize,
5213
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5214
                IsTopmost = true,
5215
            };
5216
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5217
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5218
            CheckPop.ShowDialog();
5219

    
5220
            /*
5221
            DialogParameters parameters = new DialogParameters()
5222
            {
5223
                Owner = Application.Current.MainWindow,
5224
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5225
                DefaultPromptResultValue = "Custom State",
5226
                Content = "Name :",
5227
                Header = "Insert Custom Symbol Name",
5228
                Theme = new VisualStudio2013Theme(),
5229
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5230
            };            
5231
            RadWindow.Prompt(parameters);
5232
            */
5233
        }
5234

    
5235
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5236
        {
5237
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5238
            KCOMDataModel.DataModel.CHECK_LIST check_;
5239
            string Result = streamToBase64.ImageToBase64(source);
5240
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5241
            string projectno = App.ViewInfo.ProjectNO;
5242
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5243

    
5244
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5245
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5246
            if (Item != null)
5247
            {
5248
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5249
            }
5250
            else
5251
            {
5252
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5253
            }
5254

    
5255
            if (Item == null)
5256
            {
5257
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5258
                {
5259
                    ID = Commons.shortGuid(),
5260
                    USER_ID = App.ViewInfo.UserID,
5261
                    IMAGE_URL = Result,
5262
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5263
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5264
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5265
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5266
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5267
                    STATUS = "False",
5268
                    CREATE_TIME = DateTime.Now,
5269
                    UPDATE_TIME = DateTime.Now,
5270
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5271
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5272
                };
5273
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5274
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5275
                //this.BaseClient.AddCheckList(projectno, check_);
5276
            }
5277
            else
5278
            {
5279
                Item.IMAGE_URL = Result;
5280
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5281
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5282
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5283
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5284
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5285
            }
5286

    
5287
        }
5288

    
5289
        public void Set_Capture()
5290
        {
5291
            double x = CanvasDrawingMouseDownPoint.X;
5292
            double y = CanvasDrawingMouseDownPoint.Y;
5293
            double width = dragCaptureBorder.Width;
5294
            double height = dragCaptureBorder.Height;
5295

    
5296
            if (width > 5 || height > 5)
5297
            {
5298
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5299
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5300
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5301
            }
5302
        }
5303
        #endregion
5304

    
5305
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5306
        {
5307
            multi_Undo_Data = new Multi_Undo_data();
5308

    
5309
            multi_Undo_Data.Markup = control;
5310

    
5311
            if ((control as IShapeControl) != null)
5312
            {
5313
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5314
            }
5315
            if ((control as IDashControl) != null)
5316
            {
5317
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5318
            }
5319
            if ((control as IPath) != null)
5320
            {
5321
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5322
            }
5323
            if ((control as UIElement) != null)
5324
            {
5325
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5326
            }
5327

    
5328
            return multi_Undo_Data;
5329
        }
5330

    
5331
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5332
        {
5333
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5334
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5335
            {
5336
                if (items.UserID == Select_ID)
5337
                {
5338
                    foreach (var item in items.MarkupList)
5339
                    {
5340
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5341
                        {
5342
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5343
                                items.MarkupInfoID, Commons.shortGuid());
5344
                        }
5345
                    }
5346
                }
5347
            }
5348
        }
5349

    
5350
        /// <summary>
5351
        /// convert inkcontrol to polygoncontrol
5352
        /// </summary>
5353
        public void ConvertInkControlToPolygon()
5354
        {
5355
            if (inkBoard.Strokes.Count > 0)
5356
            {
5357
                inkBoard.Strokes.ToList().ForEach(stroke =>
5358
                {
5359
                    InkToPath ip = new InkToPath();
5360

    
5361
                    List<Point> inkPointSet = new List<Point>();
5362
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5363

    
5364
                    PolygonControl pc = new PolygonControl()
5365
                    {
5366
                        CommentAngle = 0,
5367
                        PointSet = inkPointSet,
5368
                        ControlType = ControlType.Ink
5369
                    };
5370
                    pc.StartPoint = inkPointSet[0];
5371
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5372
                    pc.LineSize = 3;
5373
                    pc.CommentID = Commons.shortGuid();
5374
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5375

    
5376
                    if (pc.PointSet.Count > 0)
5377
                    {
5378
                        CreateCommand.Instance.Execute(pc);
5379
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5380
                    }
5381
                });
5382
                inkBoard.Strokes.Clear();
5383
            }
5384
        }
5385

    
5386
        /// <summary>
5387
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5388
        /// </summary>
5389
        /// <author>ingu</author>
5390
        /// <date>2018.06.05</date>
5391
        /// <param name="getPoint"></param>
5392
        /// <returns></returns>
5393
        private bool IsGetoutpoint(Point getPoint)
5394
        {
5395
            if (getPoint == new Point())
5396
            {
5397
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5398
                currentControl = null;
5399
                return true;
5400
            }
5401

    
5402
            return false;
5403
        }
5404

    
5405
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5406
        {
5407
            e.Effects = DragDropEffects.Copy;
5408
        }
5409

    
5410
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5411
        {
5412
            e.Effects = DragDropEffects.Copy;
5413
        }
5414

    
5415
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5416
        {
5417
            e.Effects = DragDropEffects.None;
5418
        }
5419

    
5420
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5421
        {
5422
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5423
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5424

    
5425
            ScaleImage(pageWidth, pageHeight);
5426
        }
5427

    
5428
        /// <summary>
5429
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5430
        /// </summary>
5431
        /// <param name="pageWidth">원본 사이즈</param>
5432
        /// <param name="pageHeight">원본 사이즈</param>
5433
        /// <returns></returns>
5434
        private void ScaleImage(double pageWidth,double pageHeight)
5435
        {
5436
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5437
        }
5438

    
5439
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5440
        {
5441
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5442
        }
5443

    
5444

    
5445
        /*
5446
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5447
        {
5448
            try
5449
            {
5450
                if (e.Data.GetDataPresent(typeof(string)))
5451
                {
5452
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5453
                    string dragData = e.Data.GetData(typeof(string)) as string;
5454
                    Move_Symbol(sender, dragData);
5455
                }
5456
            }
5457
            catch (Exception ex)
5458
            {
5459
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5460
            }            
5461
        }
5462
        */
5463
    }
5464
}
클립보드 이미지 추가 (최대 크기: 500 MB)