프로젝트

일반

사용자정보

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

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

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

    
250
            //List<testItem> testItems = new List<testItem>
251
            //{
252
            //    new testItem{Title = "test1"},
253
            //    new testItem{Title = "test2"},
254
            //    new testItem{Title = "test3"},
255
            //    new testItem{Title = "test4"},
256
            //};
257

    
258
            //lstSymbolPrivate.ItemsSource = testItems;
259

    
260
            this.Loaded += MainMenu_Loaded;
261
        }
262

    
263
        public class TempDt
264
        {
265
            public int PageNumber { get; set; }
266
            public string CommentID { get; set; }
267
            public string ConvertData { get; set; }
268
            public int DATA_TYPE { get; set; }
269
            public string MarkupInfoID { get; set; }
270
            public int IsUpdate { get; set; }
271
        }
272

    
273
        List<TempDt> tempDtList = new List<TempDt>();
274

    
275
        private void SetCursor()
276
        {
277
            this.Cursor = cursor;
278
        }
279

    
280
        /// <summary>
281
        /// get image url
282
        /// </summary>
283
        /// <author>humkyung</author>
284
        /// <param name="sDocumentID"></param>
285
        /// <returns></returns>
286
        public string GetImageURL(string sDocumentID, int iPageNo)
287
        {
288
            string uri = string.Empty;
289

    
290
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
291
            if (userData.COMPANY != "EXT")
292
            {
293
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
294
            }
295
            else
296
            {
297
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
298
            }
299

    
300
            return uri;
301
        }
302

    
303
        /// <summary>
304
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
305
        /// </summary>
306
        /// <returns></returns>
307
        public string GetOriginalPDFURL()
308
        {
309
            string uri = string.Empty;
310
            string sDocumentID = this._DocItem.DOCUMENT_ID;
311
            string filename = string.Empty;
312
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
313
            {
314
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
315
            }
316
            else
317
            {
318
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
319
            }
320

    
321
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
322
            if (userData.COMPANY != "EXT")
323
            {
324
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
325
            }
326
            else
327
            {
328
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
329
            }
330
            uri = uri.Replace(".png", "");
331
            return uri;
332
        }
333

    
334
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
335
        {
336
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
337
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
338
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
339
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
340
            {
341
                return true;
342
            }
343

    
344
            return false;
345
        }
346

    
347
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
348
        {
349
            if (rotate.Angle == 90 || rotate.Angle == 270)
350
            {
351
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
352
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
353
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
354
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
355
                {
356
                    return true;
357
                }
358
            }
359
            else
360
            {
361
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
362
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
363
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
364
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
365
                {
366
                    return true;
367
                }
368
            }
369

    
370
            return false;
371
        }
372

    
373
        public void DeleteItem(MarkupInfoItem item)
374
        {
375
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
376
            {
377
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
378

    
379
            
380
            ViewerDataModel.Instance._markupInfoList.Remove(item);
381

    
382
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
383
            {
384
                ViewerDataModel.Instance.MarkupControls.Remove(a);
385
            });
386

    
387
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
388
            {
389
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
390
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
391
                null, Event_Type.Delete, a.CommentID, null);
392
            });
393

    
394
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
395
            {
396
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
397
                //임시파일에서도 삭제
398
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
399
            });
400

    
401
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
402

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

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

    
464
                        Button content = (sender as Button);
465
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
466

    
467
                        DeleteItem(item);
468
                    }
469
                }
470
            };
471
            RadWindow.Confirm(parameters);
472
        }
473

    
474
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
475

    
476
        private static Timer timer;
477
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
478
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
479
        {
480
            //InitializeComponent();            
481
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
482

    
483
            if (App.ParameterMode)
484
            {
485
                App.splashString(ISplashMessage.MAINMENU_1);
486
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
487
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
488
                imageViewer_Compare = new Image();
489
                ViewerDataModel.Instance.Capture_Opacity = 0;
490
                da.From = 0.8;
491
                da.To = 0;
492
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
493
                da.AutoReverse = true;
494
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
495

    
496
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
497
                {
498
                    this.SymbolPane.Visibility = Visibility.Collapsed;
499
                    this.FavoritePane.Visibility = Visibility.Collapsed;
500
                    this.drawingRotateCanvas.IsHitTestVisible = false;
501
                }
502
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
503
            }
504

    
505
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
506

    
507
        }
508

    
509
        private async Task DownloadOriginalFileAsync()
510
        {
511
            try
512
            {
513
                using (System.Net.WebClient client = new System.Net.WebClient())
514
                {
515
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
516
                    string downloadurl = GetOriginalPDFURL();
517
                    
518
                    // canceltoken을 위해서 상위에 선언
519
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
520

    
521
                    client.DownloadProgressChanged += (snd, evt) =>
522
                    {
523
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
524

    
525
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
526
                    };
527

    
528
                    await task;
529

    
530
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
531
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
532
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
533
                }
534
            }
535
            catch (Exception ex)
536
            {
537
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
538
            }
539
        }
540

    
541
        private void timercallback(Object o)
542
        {
543
            Stopwatch sw = new Stopwatch();
544
            sw.Start();
545
            TempFile.TempFileAdd();
546
            sw.Stop();
547

    
548
            Dispatcher.InvokeAsync(new Action(delegate
549
            {
550
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
551
                {
552
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
553
                }
554
            }));
555

    
556
            ////GC.Collect();
557
        }
558
        
559
        /// <summary>
560
        /// update my markuplist
561
        ///  - update existing markup data if already exist
562
        ///  - add new markup data if control is new
563
        /// </summary>
564
        public void UpdateMyMarkupList()
565
        {
566
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
567

    
568
            /// add or update markup list
569
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
570
            {
571
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
572

    
573
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
574
                if (exist != null) //신규 추가 된 코멘트
575
                {
576
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
577
                    {
578
                        exist.Data = root.ConvertData;
579
                        exist.IsUpdate = true;
580
                    }
581
                }
582
                else if (root.CommentID != null)
583
                {
584
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
585
                    {
586
                        ID = control.CommentID,
587
                        Data = root.ConvertData,
588
                        Data_Type = root.DATA_TYPE,
589
                        MarkupInfoID = App.Custom_ViewInfoId,
590
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
591
                        Symbol_ID = control.SymbolID,
592
                        //Group_ID = control.GroupID,
593
                    });
594
                }
595
            }
596

    
597
            /// delete markup list
598
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
599

    
600
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
601
                          where (markup.PageNumber == iPageNo) 
602
                          && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
603
                          select markup).ToList();
604

    
605
            foreach (var markup in deleted)
606
            {
607
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
608
            }
609
            /// up to here
610

    
611
            //if (modified)
612
            //{
613
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
614
            //    {
615
            //        ComingNewBieEnd = true;
616
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
617
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
618
            //        gridViewMarkup.ItemsSource = null;
619
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
620
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
621

    
622
            //        GroupDescriptor descriptor = new GroupDescriptor();
623
            //        descriptor.Member = "Depatment";
624
            //        descriptor.DisplayContent = "DEPT";
625
            //        descriptor.SortDirection = ListSortDirection.Ascending;
626
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
627
            //    }
628
            //}
629
        }
630

    
631
        DispatcherTimer renderTesttimer;
632

    
633
        /// <summary>
634
        /// start page changing
635
        ///  - save controls if page is modified
636
        ///  - starting download page image
637
        /// </summary>
638
        /// <param name="sender"></param>
639
        /// <param name="e"></param>
640
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
641
        {
642
            //await Task.Delay(300);
643

    
644
            // 마크업 로드
645
            await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
646

    
647
            // 페이지 이미지 변경
648
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
649
        }
650

    
651
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
652
        { 
653
            CompareMode.IsChecked = false;
654
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
655
           
656
            #region 페이지가 벗어난 경우
657

    
658
            if (BalancePoint < 1)
659
            {
660
                BalancePoint = 1;
661
                ViewerDataModel.Instance.PageBalanceNumber = 0;
662
            }
663

    
664
            if (pageNavigator.PageCount < BalancePoint)
665
            {
666
                BalancePoint = pageNavigator.PageCount;
667
                ViewerDataModel.Instance.PageBalanceNumber = 0;
668
            }
669

    
670
            #endregion
671

    
672
            ViewerDataModel.Instance.PageNumber = BalancePoint;
673

    
674
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
675
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
676
            var contentScale = zoomAndPanControl.ContentScale;
677

    
678
            #region 페이지 이미지 로딩 수정
679

    
680
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
681
       
682
            ScaleImage(pageWidth, pageHeight);
683

    
684
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
685
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
686

    
687
            zoomAndPanCanvas.Width = pageWidth;
688
            zoomAndPanCanvas.Height = pageHeight;
689

    
690
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
691
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
692

    
693
            inkBoard.Width = pageWidth;
694
            inkBoard.Height = pageHeight;
695

    
696
            #endregion
697

    
698
            if (!testPanel2.IsHidden)
699
            {
700
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
701
                //PDF모드일때 잠시 대기(강인구)
702
                if (IsSyncPDFMode)
703
                {
704
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
705
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
706

    
707
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
708
                    if (pdfpath.IsDownloading)
709
                    {
710
                        pdfpath.DownloadCompleted += (ex, arg) =>
711
                        {
712
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
713
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
714
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
715
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
716
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
717
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
718
                        };
719
                    }
720
                    else
721
                    {
722
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
723
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
724
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
725
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
726

    
727
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
728
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
729
                    }
730
                }
731
                else
732
                {
733
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
734
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
735

    
736
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
737
                    var defaultBitmapImage_Compare = new BitmapImage();
738
                    defaultBitmapImage_Compare.BeginInit();
739
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
740
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
741
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
742
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
743
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
744
                    defaultBitmapImage_Compare.EndInit();
745

    
746
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
747

    
748
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
749
                    zoomAndPanControl.ZoomTo(new Rect
750
                    {
751
                        X = 0,
752
                        Y = 0,
753
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
754
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
755
                    });
756

    
757
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
758
                    if (defaultBitmapImage_Compare.IsDownloading)
759
                    {
760
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
761
                        {
762
                            defaultBitmapImage_Compare.Freeze();
763
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
764
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
765
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
766
                            ComparePanel.UpdateLayout();
767
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
768
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
769

    
770
                            zoomAndPanControl.ZoomTo(new Rect
771
                            {
772
                                X = 0,
773
                                Y = 0,
774
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
775
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
776
                            });
777

    
778
                            //defaultBitmapImage_Compare dispose
779
                            defaultBitmapImage_Compare = null;
780
                            GC.Collect();
781
                        };
782
                    }
783
                }
784
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
785
            }
786

    
787
            SearchFocusBorder.Visibility = Visibility.Collapsed;
788

    
789
            this.pageNavigator.ChangePage(changePageNumber);
790
        }
791

    
792
        /// <summary>
793
        /// called after page is changed
794
        /// </summary>
795
        /// <param name="sender"></param>
796
        /// <param name="e"></param>
797
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
798
        {
799
            //if (zoomAndPanCanvas.Width.IsNaN())
800
            //{
801

    
802
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
803
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
804
                );
805
            //}
806

    
807

    
808
            var instanceMain = ViewerDataModel.Instance.SystemMain;
809

    
810
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
811
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
812

    
813
            instanceMain.dzTopMenu.rotateOffSet = 0;
814
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
815
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
816

    
817
            /// 페이지의 모든 마크업을 로드한 후 호출
818
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
819
            ViewerDataModel.Instance.LoadPageMarkup();
820
        }
821

    
822
        private void MarkupLoad(int pageNumber)
823
        { 
824
            /// 컨트롤을 새로 생성한다.
825
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
826
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
827
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
828
            { 
829
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
830
                if (info != null)
831
                {
832
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
833
                    if (info.UserID == App.ViewInfo.UserID)
834
                    {
835
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
836
                                        markup.MarkupInfoID, markup.ID);
837
                        control.Visibility = Visibility.Hidden;
838
                    }
839
                    else
840
                    {
841
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
842
                                                                markup.MarkupInfoID, markup.ID);
843
                        control.Visibility = Visibility.Hidden;
844
                    }
845
                }
846
            };
847
            /// up to here
848

    
849
            /// fire selection event
850
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
851
            this.gridViewMarkup.UnselectAll();
852
            this.gridViewMarkup.Select(gridSelectionItem);
853

    
854
            if (!testPanel2.IsHidden)
855
            {
856
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
857
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
858
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
859

    
860
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
861
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
862

    
863

    
864
                foreach (var item in gridSelectionRevItem)
865
                {
866
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
867
                    {
868
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
869
                    });
870
                }
871
            }
872
            
873
            SetCommentPages();
874

    
875
        }
876

    
877
        public void SetCommentPages()
878
        {
879
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
880
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
881
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
882
            {
883
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
884
                if(item.MarkupList != null)
885
                {
886
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
887
                    instance.UserName = item.UserName;
888
                    instance.Depart = item.Depatment;
889
                    instance.MarkupInfoID = item.MarkupInfoID;
890
                    instance.IsSelected = true;
891
                    instance.isConSolidation = item.Consolidate;
892
                    instance.SetColor = item.DisplayColor;
893
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
894
                    {
895
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
896
                    }
897
                    else
898
                    {
899
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
900
                    }
901
                    _pages.Add(instance);
902
                }                   
903
            }
904
            
905
            this.pageNavigator.SetCommentList(_pages.ToList());
906
        }
907

    
908
        public void MarkupitemViewUpdate(string markupinfo_id)
909
        {
910
            //db에 업데이트 한 list 를 view 에 업데이트
911
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
912
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
913
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
914
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
915
            if (dbinfo.MarkupList.Count > 0)
916
            {
917
                if (viewinfo.MarkupList != null)
918
                {
919
                    viewinfo.MarkupList.Clear();
920
                    viewinfo.MarkupList = null;
921
                }
922
                viewinfo.MarkupList = new List<MarkupItem>();
923
                foreach (var item in dbinfo.MarkupList)
924
                {
925
                    viewinfo.MarkupList.Add(item);
926
                }
927
            }
928
        }
929

    
930
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
931
        {
932
            var instance = ViewerDataModel.Instance;
933

    
934
            if(instance.IsWheelPageChanage)
935
            {
936
                return;
937
            }
938

    
939
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
940
            {
941
       
942
                int changePage = 0;
943
                
944
                if (e.Delta > 0)
945
                {
946
                    if (0 < instance.ContentOffsetY)
947
                    {
948
                        Vector dragOffset = new Vector(0, e.Delta);
949
                        MoveZoomAndPanControl(dragOffset);
950
                    }
951
                    //else
952
                    //{
953
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
954
                    //    {
955
                    //        instance.IsWheelPageChanage = true;
956
                    //        changePage -= 1;
957
                    //    }
958
                    //}
959
                }
960
                else if(e.Delta < 0)
961
                {
962
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
963
                    {
964
                        Vector dragOffset = new Vector(0,e.Delta);
965
                        MoveZoomAndPanControl(dragOffset);
966
                    }
967
                    //else
968
                    //{
969
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
970
                    //    {
971
                    //        instance.IsWheelPageChanage = true;
972
                    //        changePage += 1;
973
                    //    }
974
                    //}
975
                }
976

    
977
                //if (changePage != 0)
978
                //{
979
                //    await Task.Factory.StartNew(() =>
980
                //    {
981
                //        double beforeScale = instance.ContentScale;
982

    
983
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
984

    
985
                //        handler = (snd, evt) =>
986
                //        {
987
                //            /// 최상단으로 이전 zoomScale로 위치한다
988
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
989
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
990
                //            instance.IsWheelPageChanage = false;
991
                //            pageNavigator.PageChanged -= handler;
992
                //        };
993

    
994
                //        pageNavigator.PageChanged += handler;
995

    
996
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
997
                //    });
998
                    
999

    
1000
                //}
1001
            }
1002
            else
1003
            {
1004
                e.Handled = true;
1005
                if (e.Delta > 0)
1006
                {
1007
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1008
                    ZoomIn(currentContentMousePoint);
1009
                }
1010
                else
1011
                {
1012
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1013
                    ZoomOut(currentContentMousePoint);
1014
                }
1015
            }
1016
        }
1017

    
1018
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1019
        {
1020
            e.Handled = true;
1021
            if (e.Delta > 0)
1022
            {
1023
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1024
                ZoomIn_Sync(currentContentMousePoint);
1025
            }
1026
            else
1027
            {
1028
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1029
                ZoomOut_Sync(currentContentMousePoint);
1030
            }
1031
        }
1032

    
1033
        #region ZoomIn & ZoomOut
1034

    
1035
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1036
        {
1037
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1038
                zoomAndPanControl.ContentZoomFocusY));
1039
        }
1040

    
1041
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1042
        {
1043
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1044
                zoomAndPanControl.ContentZoomFocusY));
1045
        }
1046

    
1047

    
1048
        //강인구 추가 (줌 인아웃 수치 변경)
1049
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1050
        private void ZoomOut(Point contentZoomCenter)
1051
        {
1052
            if (zoomAndPanControl.ContentScale > 0.39)
1053
            {
1054
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1055
            }
1056
            else
1057
            {
1058
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1059
            }
1060

    
1061
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1062
            {
1063
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1064
            }
1065
        }
1066

    
1067
        private void ZoomIn(Point contentZoomCenter)
1068
        {
1069
            if (zoomAndPanControl.ContentScale > 0.19)
1070
            {
1071
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1072
            }
1073
            else
1074
            {
1075
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1076
            }
1077

    
1078
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1079
            {
1080
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1081
            }
1082

    
1083
        }
1084

    
1085
        private void ZoomOut_Sync(Point contentZoomCenter)
1086
        {
1087
            if (zoomAndPanControl2.ContentScale > 0.39)
1088
            {
1089
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1090
            }
1091
            else
1092
            {
1093
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1094
            }
1095

    
1096
            if (Sync.IsChecked)
1097
            {
1098
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1099
            }
1100
        }
1101

    
1102
        private void ZoomIn_Sync(Point contentZoomCenter)
1103
        {
1104
            if (zoomAndPanControl2.ContentScale > 0.19)
1105
            {
1106
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1107
            }
1108
            else
1109
            {
1110
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1111
            }
1112

    
1113
            if (Sync.IsChecked)
1114
            {
1115
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1116
            }
1117
        }
1118

    
1119
        private void ZoomOut()
1120
        {
1121
            zoomAndPanControl.ContentScale -= 0.1;
1122
            //if (zoomAndPanControl2 != null)
1123
            //{
1124
            //    zoomAndPanControl2.ContentScale -= 0.1;
1125
            //}
1126
        }
1127

    
1128
        private void ZoomIn()
1129
        {
1130
            zoomAndPanControl.ContentScale += 0.1;
1131
            //if (zoomAndPanControl2 != null)
1132
            //{
1133
            //    zoomAndPanControl2.ContentScale += 0.1;
1134
            //}
1135
        }
1136

    
1137
        #endregion
1138

    
1139
        private void init()
1140
        {
1141
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1142
            {
1143

    
1144
                ControlList.Clear();
1145
                listBox.Items.Clear();
1146
                selected_item.Clear();
1147

    
1148
                (item as IMarkupCommonData).IsSelected = false;
1149
            }
1150

    
1151
        }
1152

    
1153
        private HitTestResultBehavior MyCallback(HitTestResult result)
1154
        {
1155
            //this.cursor = Cursors.UpArrow;
1156
            var element = result.VisualHit;
1157
            while (element != null && !(element is CommentUserInfo))
1158
                element = VisualTreeHelper.GetParent(element);
1159

    
1160
            if (element == null)
1161
            {
1162
                return HitTestResultBehavior.Stop;
1163
            }
1164
            else
1165
            {
1166
                if (element is CommentUserInfo)
1167
                {
1168
                    if (!hitList.Contains(element))
1169
                    {
1170
                        hitList.Add((CommentUserInfo)element);
1171
                    }
1172
                    else
1173
                    {
1174
                        return HitTestResultBehavior.Stop;
1175
                    }
1176
                }
1177
            }
1178
            return HitTestResultBehavior.Continue;
1179
        }
1180

    
1181
        public void ReleaseSelectPath()
1182
        {
1183
            if (SelectionPath == null)
1184
            {
1185
                SelectionPath = new Path();
1186
                SelectionPath.Name = "";
1187
            }
1188
            if (SelectionPath.Name != "")
1189
            {
1190
                SelectionPath.Name = "None";
1191
            }
1192
            SelectionPath.Opacity = 0.01;
1193
            SelectionPath.RenderTransform = null;
1194
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1195
        }
1196

    
1197
        #region 컨트롤 초기화 
1198
        public void Control_Init(object control)
1199
        {
1200
            if (L_Size != 0 && (control as IPath) != null)
1201
            {
1202
                (control as IPath).LineSize = L_Size;
1203
                L_Size = 0;
1204
            }
1205

    
1206
            switch (control.GetType().Name)
1207
            {
1208
                case "RectangleControl":
1209
                    {
1210
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1211
                    }
1212
                    break;
1213
                case "CircleControl":
1214
                    {
1215
                        (control as CircleControl).StrokeColor = Brushes.Red;
1216
                    }
1217
                    break;
1218
                case "TriControl":
1219
                    {
1220
                        (control as TriControl).StrokeColor = Brushes.Red;
1221
                    }
1222
                    break;
1223
                case "RectCloudControl":
1224
                    {
1225
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1226
                    }
1227
                    break;
1228
                case "CloudControl":
1229
                    {
1230
                        (control as CloudControl).StrokeColor = Brushes.Red;
1231
                    }
1232
                    break;
1233
                case "PolygonControl":
1234
                    {
1235
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1236
                    }
1237
                    break;
1238
                case "ArcControl":
1239
                    {
1240
                        (control as ArcControl).StrokeColor = Brushes.Red;
1241
                    }
1242
                    break;
1243
                case "ArrowArcControl":
1244
                    {
1245
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1246
                    }
1247
                    break;
1248
                case "LineControl":
1249
                    {
1250
                        (control as LineControl).StrokeColor = Brushes.Red;
1251
                    }
1252
                    break;
1253
                case "ArrowControl_Multi":
1254
                    {
1255
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1256
                    }
1257
                    break;
1258
                case "TextControl":
1259
                    {
1260
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1261
                    }
1262
                    break;
1263
                case "ArrowTextControl":
1264
                    {
1265
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1266
                    }
1267
                    break;
1268
                case "InsideWhiteControl":
1269
                    {
1270
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1271
                    }
1272
                    break;
1273
                case "OverlapWhiteControl":
1274
                    {
1275
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1276
                    }
1277
                    break;
1278
                case "ClipWhiteControl":
1279
                    {
1280
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1281
                    }
1282
                    break;
1283
                case "CoordinateControl":
1284
                    {
1285
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1286
                    }
1287
                    break;
1288
            }
1289
        }
1290
        #endregion
1291

    
1292
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1293
        {
1294
            //Control_Init(e.Source);
1295
        }
1296
        //private Window _dragdropWindow = null;
1297

    
1298
        [DllImport("user32.dll")]
1299
        [return: MarshalAs(UnmanagedType.Bool)]
1300
        internal static extern bool GetCursorPos(ref Win32Point pt);
1301

    
1302
        [StructLayout(LayoutKind.Sequential)]
1303
        internal struct Win32Point
1304
        {
1305
            public Int32 X;
1306
            public Int32 Y;
1307
        };
1308
        /*
1309
       public string symbol_id = null;
1310
       public long symbol_group_id;
1311
       public int symbol_SelectedIndex;
1312
       public ImageSource symbol_img;
1313
       public string symbol_Data = null;
1314
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1315
       {
1316
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1317
               zoomAndPanCanvas.ActualHeight / 2));
1318

    
1319

    
1320
               if (this._dragdropWindow != null)
1321
               {
1322
                   this._dragdropWindow.Close();
1323
                   this._dragdropWindow = null;
1324
               }
1325

    
1326
               symbol_id = id;
1327
               symbol_group_id = group_id;
1328
               symbol_SelectedIndex = SelectedIndex;
1329
               symbol_Data = Data_;
1330
               symbol_img = img;
1331

    
1332

    
1333
               CreateDragDropWindow2(img);
1334
              
1335
    }
1336

    
1337
    private void CreateDragDropWindow2(ImageSource image)
1338
        {
1339
            this._dragdropWindow = new Window();
1340
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1341
            _dragdropWindow.WindowStyle = WindowStyle.None;
1342
            _dragdropWindow.AllowsTransparency = true;           
1343
            _dragdropWindow.AllowDrop = false;
1344
            _dragdropWindow.Background = null;
1345
            _dragdropWindow.IsHitTestVisible = false;
1346
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1347
            _dragdropWindow.Topmost = true;
1348
            _dragdropWindow.ShowInTaskbar = false;
1349
            
1350
            Rectangle r = new Rectangle();
1351
            r.Width = image.Width;
1352
            r.Height = image.Height;
1353
            r.Opacity = 0.5;            
1354
            r.Fill = new ImageBrush(image);
1355
            this._dragdropWindow.Content = r;
1356

    
1357
            Win32Point w32Mouse = new Win32Point();
1358
            GetCursorPos(ref w32Mouse);
1359

    
1360
            //w32Mouse.X = getCurrentPoint.X;
1361
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1362
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1363
            this._dragdropWindow.Show();
1364
        }
1365

    
1366
        
1367

    
1368
         */
1369

    
1370
        public void MoveZoomAndPanControl(Vector dragOffset)
1371
        {
1372
   
1373
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1374
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1375

    
1376
            if (Sync.IsChecked)
1377
            {
1378
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1379
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1380
            }
1381
        }
1382

    
1383
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1384
        {
1385
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1386
            {
1387
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1388

    
1389
                Point currentPos = e.GetPosition(rect);
1390

    
1391
                floatingTip.HorizontalOffset = currentPos.X + 20;
1392
                floatingTip.VerticalOffset = currentPos.Y;
1393
            }
1394

    
1395
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1396
            
1397
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1398
            {
1399
                SetCursor();
1400
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1401
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1402

    
1403
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1404

    
1405
                MoveZoomAndPanControl(dragOffset);
1406
            }
1407

    
1408
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1409
            {
1410
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1411
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1412
                SetCursor();
1413

    
1414
                if (currentControl != null)
1415
                {
1416
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1417
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1418
                    //강인구 추가
1419
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1420

    
1421
                    if ((currentControl as IPath) != null)
1422
                    {
1423
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1424
                    }
1425
                    if ((currentControl as LineControl) != null)
1426
                    {
1427
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1428
                    }
1429

    
1430
                    if ((currentControl as IShapeControl) != null)
1431
                    {
1432
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1433
                    }
1434
                    if ((currentControl as TextControl) != null)
1435
                    {
1436
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1437
                        {
1438
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1439
                        }
1440
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1441
                        {
1442
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1443
                        }
1444
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1445
                        {
1446
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1447
                        }
1448
                    }
1449
                    else if ((currentControl as ArrowTextControl) != null)
1450
                    {
1451
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1452
                        {
1453
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1454
                        }
1455
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1456
                        {
1457
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1458
                        }
1459
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1460
                        {
1461
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1462
                        }
1463
                    }
1464
                    else if ((currentControl as RectCloudControl) != null)
1465
                    {
1466
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1467
                    }
1468
                    else if ((currentControl as CloudControl) != null)
1469
                    {
1470
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1471
                    }
1472

    
1473

    
1474
                    #region // 모든 컨트롤의 공통기능 제어
1475
                    if (controlType != ControlType.PenControl)
1476
                    {
1477
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1478
                    }
1479

    
1480

    
1481
                    #endregion
1482

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

    
1485
                    switch (controlType)
1486
                    {
1487
                        case (ControlType.Coordinate):
1488
                            {
1489
                                var control = currentControl as CoordinateControl;
1490
                                if (control != null)
1491
                                {
1492
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1493
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1494
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1495
                                }
1496
                            }
1497
                            break;
1498
                        case (ControlType.InsideWhite):
1499
                            {
1500
                                var control = currentControl as InsideWhiteControl;
1501
                                if (control != null)
1502
                                {
1503
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1504
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1505
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1506
                                    control.Paint = PaintSet.Fill;
1507
                                }
1508
                            }
1509
                            break;
1510
                        case ControlType.OverlapWhite:
1511
                            {
1512
                                var control = currentControl as OverlapWhiteControl;
1513
                                if (control != null)
1514
                                {
1515
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1516
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1517
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1518
                                    control.Paint = PaintSet.Fill;
1519
                                }
1520
                            }
1521
                            break;
1522
                        case ControlType.ClipWhite:
1523
                            {
1524
                                var control = currentControl as ClipWhiteControl;
1525
                                if (control != null)
1526
                                {
1527
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1528
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1529
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1530
                                    control.Paint = PaintSet.Fill;
1531
                                }
1532
                            }
1533
                            break;
1534
                        case ControlType.RectCloud:
1535
                            {
1536
                                var control = currentControl as RectCloudControl;
1537
                                if (control != null)
1538
                                {
1539
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1540
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1541
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1542
                                }
1543
                            }
1544
                            break;
1545
                        case ControlType.SingleLine:
1546
                        case ControlType.CancelLine:
1547
                        case ControlType.ArrowLine:
1548
                        case ControlType.TwinLine:
1549
                        case ControlType.DimLine:
1550
                            {
1551
                                var control = currentControl as LineControl;
1552
                                if (control != null)
1553
                                {
1554
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1555
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1556
                                }
1557

    
1558
                            }
1559
                            break;
1560

    
1561
                        case ControlType.ArcLine:
1562
                            {
1563
                                var control = currentControl as ArcControl;
1564
                                if (control != null)
1565
                                {
1566
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1567
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1568
                                }
1569
                            }
1570
                            break;
1571

    
1572
                        case ControlType.ArcArrow:
1573
                            {
1574
                                var control = currentControl as ArrowArcControl;
1575
                                if (control != null)
1576
                                {
1577
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1578
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1579
                                }
1580
                            }
1581
                            break;
1582

    
1583
                        case ControlType.ArrowMultiLine:
1584
                            {
1585
                                var control = currentControl as ArrowControl_Multi;
1586
                                if (control != null)
1587
                                {
1588
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1589
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1590
                                }
1591
                            }
1592
                            break;
1593

    
1594
                        case ControlType.Circle:
1595
                            {
1596
                                var control = currentControl as CircleControl;
1597

    
1598
                                if (control != null)
1599
                                {
1600
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1601
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1602
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1603
                                }
1604
                            }
1605
                            break;
1606

    
1607
                        case ControlType.PolygonCloud:
1608
                            {
1609
                                var control = currentControl as CloudControl;
1610
                                if (control != null)
1611
                                {
1612
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1613
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1614
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1615
                                }
1616
                            }
1617
                            break;
1618

    
1619
                        case ControlType.Triangle:
1620
                            {
1621
                                var control = currentControl as TriControl;
1622
                                if (control != null)
1623
                                {
1624
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1625
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1626
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1627
                                }
1628
                            }
1629
                            break;
1630

    
1631
                        case ControlType.ImgControl:
1632
                            {
1633
                                var control = currentControl as ImgControl;
1634
                                if (control != null)
1635
                                {
1636
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1637
                                }
1638
                            }
1639
                            break;
1640

    
1641
                        case ControlType.Date:
1642
                            {
1643
                                var control = currentControl as DateControl;
1644
                                if (control != null)
1645
                                {
1646
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1647
                                }
1648
                            }
1649
                            break;
1650

    
1651
                        case ControlType.ArrowTextControl:
1652
                        case ControlType.ArrowTransTextControl:
1653
                        case ControlType.ArrowTextBorderControl:
1654
                        case ControlType.ArrowTransTextBorderControl:
1655
                        case ControlType.ArrowTextCloudControl:
1656
                        case ControlType.ArrowTransTextCloudControl:
1657
                            {
1658
                                var control = currentControl as ArrowTextControl;
1659
                                if (control != null)
1660
                                {
1661
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1662
                                }
1663
                            }
1664
                            break;
1665
                        case ControlType.PolygonControl:
1666
                        case ControlType.ChainLine:
1667
                            {
1668
                                var control = currentControl as PolygonControl;
1669
                                if (control != null)
1670
                                {
1671
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1672
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1673
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1674
                                }
1675
                            }
1676
                            break;
1677
                        case ControlType.Sign:
1678
                            {
1679
                                var control = currentControl as SignControl;
1680
                                if (control != null)
1681
                                {
1682
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1683
                                }
1684
                            }
1685
                            break;
1686
                        case ControlType.Symbol:
1687
                            {
1688
                                var control = currentControl as SymControl;
1689
                                if (control != null)
1690
                                {
1691
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1692
                                }
1693
                            }
1694
                            break;
1695
                        case ControlType.Stamp:
1696
                            {
1697
                                var control = currentControl as SymControlN;
1698
                                if (control != null)
1699
                                {
1700
                                    if (control.STAMP != null)
1701
                                    {
1702
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1703
                                    }
1704
                                    else
1705
                                    {
1706
                                        currentControl = null;
1707
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1708
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1709
                                    }
1710
                                }
1711
                            }
1712
                            break;
1713
                        case ControlType.Rectangle:
1714
                        case ControlType.Mark:
1715
                            {
1716
                                var control = currentControl as RectangleControl;
1717
                                if (control != null)
1718
                                {
1719
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1720
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1721
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1722
                                }
1723
                            }
1724
                            break;
1725
                        case ControlType.PenControl:
1726
                            {
1727
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1728
                                //inkBoard.Strokes.Add(stroke);
1729
                            }
1730
                            break;
1731
                        default:
1732
                            break;
1733
                    }
1734

    
1735
                    #endregion
1736
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1737
                    {
1738
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1739
                    }
1740
                }
1741
            }
1742
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1743
            {
1744
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1745
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1746
                SetCursor();
1747
                if (currentControl == null)
1748
                {
1749
                    switch (controlType)
1750
                    {
1751
                        case ControlType.PenControl:
1752
                            {
1753
                                if (inkBoard.Tag.ToString() == "Ink")
1754
                                {
1755
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1756
                                }
1757
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1758
                                {
1759
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1760
                                }
1761
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1762
                                {
1763
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1764
                                }
1765

    
1766
                                //inkBoard.Strokes.Add(stroke);
1767
                            }
1768
                            break;
1769
                    }
1770
                    return;
1771
                }
1772
            }
1773
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1774
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1775
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1776
            {
1777
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1778

    
1779
                if (isDraggingSelectionRect)
1780
                {
1781
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1782
                    e.Handled = true;
1783
                }
1784
                else if (isLeftMouseButtonDownOnWindow)
1785
                {
1786
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1787
                    double dragDistance = Math.Abs(dragDelta.Length);
1788

    
1789
                    if (dragDistance > DragThreshold)
1790
                    {
1791
                        isDraggingSelectionRect = true;
1792
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1793
                    }
1794

    
1795
                    e.Handled = true;
1796
                }
1797

    
1798
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1799
                {
1800
                }
1801
                else
1802
                {
1803
                    e.Handled = true;
1804
                }
1805
            }
1806
            /*
1807
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1808
            { //symbol      
1809
                if(_dragdropWindow != null)
1810
                {
1811
                    Win32Point w32Mouse = new Win32Point();
1812
                    GetCursorPos(ref w32Mouse);
1813

    
1814
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1815
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1816
                }                
1817
            }
1818
            */
1819
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1820
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1821
            {
1822
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1823
                if(control != null)
1824
                {
1825
                    this.cursor = Cursors.Hand;
1826
                    SetCursor();
1827
                }
1828
                else
1829
                {
1830
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1831
                    SetCursor();
1832
                }
1833
            }
1834
            else
1835
            {
1836
            }
1837
        }
1838

    
1839
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1840
        {
1841
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1842
            {
1843
                SetCursor();
1844
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1845
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1846

    
1847
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1848

    
1849
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1850
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1851

    
1852
                if (Sync.IsChecked)
1853
                {
1854
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1855
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1856
                }
1857
            }
1858
        }
1859

    
1860
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1861

    
1862
        private EllipseGeometry hitArea = new EllipseGeometry();
1863

    
1864
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1865
        {
1866
            IsDrawing = false;
1867
    
1868
            if (mouseHandlingMode != MouseHandlingMode.None)
1869
            {
1870
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1871
                {
1872
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1873

    
1874
                    SetCursor();
1875

    
1876
                    switch (controlType)
1877
                    {
1878
                        case ControlType.None:
1879
                            break;
1880
                        case ControlType.Rectangle:
1881
                            {
1882

    
1883
                            }
1884
                            break;
1885
                        case ControlType.PenControl:
1886
                            {
1887

    
1888
                            }
1889
                            break;
1890
                        default:
1891
                            break;
1892
                    }                    
1893
                }
1894
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1895
                {
1896
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1897

    
1898
                    if (isLeftMouseButtonDownOnWindow)
1899
                    {
1900
                        bool wasDragSelectionApplied = false;
1901

    
1902
                        if (isDraggingSelectionRect)
1903
                        {
1904
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1905
                            {
1906
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1907
                                mouseHandlingMode = MouseHandlingMode.None;
1908
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1909
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1910
                                Set_Symbol_Capture(endPoint);
1911
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1912
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1913
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1914
                            }
1915
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1916
                            {
1917
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1918
                                mouseHandlingMode = MouseHandlingMode.None;
1919
                                Set_Capture();
1920

    
1921
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1922
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1923
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1924
                            }
1925
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1926
                            {
1927
                                ApplyDragSelectionRect();
1928
                            }
1929
                            else
1930
                            {
1931
                                double x = Canvas.GetLeft(dragZoomBorder);
1932
                                double y = Canvas.GetTop(dragZoomBorder);
1933
                                double width = dragZoomBorder.Width;
1934
                                double height = dragZoomBorder.Height;
1935
                                Rect dragRect = new Rect(x, y, width, height);
1936

    
1937
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1938

    
1939
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1940
                            }
1941

    
1942
                            isDraggingSelectionRect = false;
1943
                            e.Handled = true;
1944
                            wasDragSelectionApplied = true;
1945
                        }
1946

    
1947
                        if (isLeftMouseButtonDownOnWindow)
1948
                        {
1949
                            isLeftMouseButtonDownOnWindow = false;
1950
                            this.ReleaseMouseCapture();
1951
                            e.Handled = true;
1952
                        }
1953

    
1954
                        if (!wasDragSelectionApplied)
1955
                        {
1956
                            init();
1957
                        }
1958
                    }
1959
                }
1960
                else if (e.RightButton == MouseButtonState.Pressed)
1961
                {
1962
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1963
                    SetCursor();
1964
                }
1965

    
1966
                zoomAndPanControl.ReleaseMouseCapture();
1967

    
1968

    
1969
                e.Handled = true;
1970
            }
1971
            else
1972
            {
1973
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1974
                SetCursor();
1975
            }
1976

    
1977
            ///mouseButtonDown = MouseButton.Left;
1978
            //controlType = ControlType.SingleLine;
1979
        }
1980

    
1981
        public void Set_Symbol_Capture(Point endPoint)
1982
        {       
1983
            double x = CanvasDrawingMouseDownPoint.X;
1984
            double y = CanvasDrawingMouseDownPoint.Y;
1985
            if(x > endPoint.X)
1986
            {
1987
                x = endPoint.X;
1988
                y = endPoint.Y;
1989
            }
1990

    
1991
            double width = dragCaptureBorder.Width;
1992
            double height = dragCaptureBorder.Height;
1993

    
1994
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1995

    
1996
            if (x < 0)
1997
            {
1998
                width += x;
1999
                x = 0;
2000
            }
2001
            if (y < 0)
2002
            {
2003
                height += y;
2004
                y = 0;
2005

    
2006
                width = (int)canvasImage.PixelWidth - x;
2007
            }
2008
            if (x + width > canvasImage.PixelWidth)
2009
            {
2010
                width = (int)canvasImage.PixelWidth - x;
2011
            }
2012
            if (y + height > canvasImage.PixelHeight)
2013
            {
2014
                height = (int)canvasImage.PixelHeight - y;
2015
            }
2016
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2017

    
2018
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2019
            var defaultBitmapImage = new BitmapImage();
2020
            defaultBitmapImage.BeginInit();
2021
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2022
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2023
            defaultBitmapImage.UriSource = new Uri(uri);
2024
            defaultBitmapImage.EndInit();
2025

    
2026
            //GC.Collect();
2027

    
2028
            if (defaultBitmapImage.IsDownloading)
2029
            {
2030
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2031
                {
2032
                    defaultBitmapImage.Freeze();
2033
                    //GC.Collect();
2034
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2035
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2036
                };
2037
            }
2038
        }
2039

    
2040
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2041
        {
2042
            ///mouseButtonDown = MouseButton.Left;
2043
        }
2044

    
2045
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2046
        {
2047
            ///mouseButtonDown = MouseButton.Left;
2048
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2049
        }
2050

    
2051
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2052
        {
2053

    
2054
        }
2055

    
2056
        /// <summary>
2057
        /// select items by dragging
2058
        /// </summary>
2059
        private void ApplyDragSelectionRect()
2060
        {
2061
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2062

    
2063
            double x = Canvas.GetLeft(dragSelectionBorder);
2064
            double y = Canvas.GetTop(dragSelectionBorder);
2065
            double width = dragSelectionBorder.Width;
2066
            double height = dragSelectionBorder.Height;
2067
            Boolean Flag = false;
2068
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2069
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2070

    
2071
            Rect dragRect = new Rect(x, y, width, height);
2072
            ///dragRect.Inflate(width / 10, height / 10);
2073

    
2074
            foreach (var item in Items)
2075
            {
2076
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2077

    
2078
                if (Flag)
2079
                {
2080
                    adornerSet.Add(item);
2081
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2082
                    Control_Style(item);
2083
                }
2084
            }
2085
            if (adornerSet.Count > 0)
2086
            {
2087
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2088
                SelectLayer.Children.Add(final);
2089
            }
2090
        }
2091

    
2092
        private void InitDragSelectionRect(Point pt1, Point pt2)
2093
        {
2094
            //캡쳐 중
2095
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2096
            {
2097
                dragCaptureBorder.Visibility = Visibility.Visible;
2098
            }
2099
            //선택 중
2100
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2101
            {
2102

    
2103
                dragSelectionBorder.Visibility = Visibility.Visible;
2104
            }
2105
            else
2106
            {
2107
                dragZoomBorder.Visibility = Visibility.Visible;
2108
            }
2109
            UpdateDragSelectionRect(pt1, pt2);
2110
        }
2111

    
2112
        /// <summary>
2113
        /// Update the position and size of the rectangle used for drag selection.
2114
        /// </summary>
2115
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2116
        {
2117
            double x, y, width, height;
2118

    
2119
            //
2120
            // Determine x,y,width and height of the rect inverting the points if necessary.
2121
            // 
2122

    
2123
            if (pt2.X < pt1.X)
2124
            {
2125
                x = pt2.X;
2126
                width = pt1.X - pt2.X;
2127
            }
2128
            else
2129
            {
2130
                x = pt1.X;
2131
                width = pt2.X - pt1.X;
2132
            }
2133

    
2134
            if (pt2.Y < pt1.Y)
2135
            {
2136
                y = pt2.Y;
2137
                height = pt1.Y - pt2.Y;
2138
            }
2139
            else
2140
            {
2141
                y = pt1.Y;
2142
                height = pt2.Y - pt1.Y;
2143
            }
2144

    
2145
            //
2146
            // Update the coordinates of the rectangle used for drag selection.
2147
            //
2148
            //캡쳐 중
2149
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2150
            {
2151
                Canvas.SetLeft(dragCaptureBorder, x);
2152
                Canvas.SetTop(dragCaptureBorder, y);
2153
                dragCaptureBorder.Width = width;
2154
                dragCaptureBorder.Height = height;
2155
            }
2156
            //선택 중
2157
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2158
            {
2159
                Canvas.SetLeft(dragSelectionBorder, x);
2160
                Canvas.SetTop(dragSelectionBorder, y);
2161
                dragSelectionBorder.Width = width;
2162
                dragSelectionBorder.Height = height;
2163
            }
2164
            else
2165
            {
2166
                Canvas.SetLeft(dragZoomBorder, x);
2167
                Canvas.SetTop(dragZoomBorder, y);
2168
                dragZoomBorder.Width = width;
2169
                dragZoomBorder.Height = height;
2170
            }
2171
        }
2172

    
2173
        private void drawingPannelRotate(double angle)
2174
        {
2175
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2176
            rotate.Angle = angle;
2177
            var rotationNum = Math.Abs((rotate.Angle / 90));
2178

    
2179
            if (angle == 90 || angle == 270)
2180
            {
2181
                double emptySize = zoomAndPanCanvas.Width;
2182
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2183
                zoomAndPanCanvas.Height = emptySize;
2184
            }
2185
            if (angle == 0)
2186
            {
2187
                translate.X = 0;
2188
                translate.Y = 0;
2189
            }
2190
            else if (angle == 90)
2191
            {
2192
                translate.X = zoomAndPanCanvas.Width;
2193
                translate.Y = 0;
2194
            }
2195
            else if (angle == 180)
2196
            {
2197
                translate.X = zoomAndPanCanvas.Width;
2198
                translate.Y = zoomAndPanCanvas.Height;
2199
            }
2200
            else
2201
            {
2202
                translate.X = 0;
2203
                translate.Y = zoomAndPanCanvas.Height;
2204
            }
2205

    
2206
            zoomAndPanControl.RotationAngle = rotate.Angle;
2207

    
2208

    
2209
            if (!testPanel2.IsHidden)
2210
            {
2211
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2212
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2213
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2214
            }
2215

    
2216
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2217
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2218
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2219
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2220
            ViewerDataModel.Instance.Angle = rotate.Angle;
2221
        }
2222

    
2223
        private void syncPannelRotate(double angle)
2224
        {
2225
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2226
            rotate.Angle = angle;
2227
            var rotationNum = Math.Abs((rotate.Angle / 90));
2228

    
2229
            if (angle == 90 || angle == 270)
2230
            {
2231
                double emptySize = zoomAndPanCanvas2.Width;
2232
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2233
                zoomAndPanCanvas2.Height = emptySize;
2234
            }
2235
            if (angle == 0)
2236
            {
2237
                translate2.X = 0;
2238
                translate2.Y = 0;
2239
            }
2240
            else if (angle == 90)
2241
            {
2242
                translate2.X = zoomAndPanCanvas2.Width;
2243
                translate2.Y = 0;
2244
            }
2245
            else if (angle == 180)
2246
            {
2247
                translate2.X = zoomAndPanCanvas2.Width;
2248
                translate2.Y = zoomAndPanCanvas2.Height;
2249
            }
2250
            else
2251
            {
2252
                translate2.X = 0;
2253
                translate2.Y = zoomAndPanCanvas2.Height;
2254
            }
2255

    
2256
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2257
        }
2258

    
2259
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2260
        {
2261
            string Data_ = "";
2262

    
2263
            try
2264
            {
2265
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2266
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2267
                if (Data_ != null || Data_ != "")
2268
                {
2269
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2270
                }
2271
                else
2272
                {
2273
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2274
                }
2275

    
2276
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2277
                //{
2278
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2279
                //    STATE = 0,
2280
                //};
2281
                if (Data_ != null)
2282
                {
2283
                    Image img = new Image();
2284
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2285
                    if (Data_.Contains(".svg"))
2286
                    {
2287
                        byte[] imageData = null;
2288
                        DrawingImage image = null;
2289
                        using (System.Net.WebClient web = new System.Net.WebClient())
2290
                        {
2291
                            imageData = web.DownloadData(new Uri(Data_));
2292
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2293
                            image = SvgReader.Load(stream);
2294
                        }
2295
                        img.Source = image;
2296
                    }
2297
                    else
2298
                    {
2299
                        img.Source = new BitmapImage(new Uri(Data_));
2300
                    }
2301

    
2302
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2303
                    {
2304
                        PointSet = new List<Point>(),
2305
                        FilePath = Data_,
2306
                        ImageData = img.Source,
2307
                        StartPoint = canvasZoomPanningMouseDownPoint,
2308
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2309
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2310
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2311
                        canvasZoomPanningMouseDownPoint.Y),
2312
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2313
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2314
                    };
2315

    
2316
                    currentControl.PointSet = new List<Point>
2317
                                        {
2318
                                            currentControl.StartPoint,
2319
                                            currentControl.LeftBottomPoint,
2320
                                            currentControl.EndPoint,
2321
                                            currentControl.TopRightPoint,
2322
                                        };
2323
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2324
                    UndoData = new Undo_data()
2325
                    {
2326
                        IsUndo = false,
2327
                        Event = Event_Type.Create,
2328
                        EventTime = DateTime.Now,
2329
                        Markup_List = new List<Multi_Undo_data>()
2330
                    };
2331
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2332
                    {
2333
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2334
                    });
2335

    
2336
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2337
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2338
                    UndoData.Markup_List.Add(multi_Undo_Data);
2339
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2340

    
2341
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2342
                    currentControl.CommentID = Commons.shortGuid();
2343
                    currentControl.SymbolID = id;
2344
                    currentControl.GroupID = group_id;
2345
                    currentControl.ApplyTemplate();
2346
                    currentControl.SetImage();
2347

    
2348
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2349
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2350
                    SelectLayer.Children.Add(final);
2351
                }
2352
            }
2353
            catch (Exception ex)
2354
            {
2355
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2356
            }
2357
        }
2358

    
2359
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2360
        {
2361
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2362
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2363
            {
2364
                set_option.Value = double.Parse(set_option.ContentText);
2365
                //set_option.Focusable = false;
2366
                zoomAndPanControl.Focus();
2367
            }
2368

    
2369
            ConvertInkControlToPolygon();
2370

    
2371
            ///TODO:
2372
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2373
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2374

    
2375
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2376
            {
2377
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2378
            }
2379
            /// up to here
2380

    
2381
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2382
            {
2383
                if (item as ArrowTextControl != null)
2384
                {
2385
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2386
                }
2387
                else if (item as TextControl != null)
2388
                {
2389
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2390
                }
2391
            }
2392

    
2393
            //if (currentControl != null)
2394
            {
2395
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2396
                if (text_item_ != null)
2397
                {
2398
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2399
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2400
                    (text_item_ as TextControl).IsEditingMode = false;                    
2401
                    currentControl = null;
2402
                }
2403

    
2404
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2405
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2406
                {
2407
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2408
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2409
                    currentControl = null;
2410
                }
2411
            }
2412

    
2413
            double Ang = 0;                                          
2414
            if (rotate.Angle != 0)
2415
            {
2416
                Ang = 360 - rotate.Angle;
2417
            }
2418

    
2419
            if (e.OriginalSource is System.Windows.Controls.Image)
2420
            {
2421
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2422
            }
2423
            /*
2424
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2425
            {                
2426
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2427
                if(symbol_id != null)
2428
                {
2429
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2430
                }                
2431
            }
2432

    
2433
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2434
            {
2435
                if (this._dragdropWindow != null)
2436
                {
2437
                    this._dragdropWindow.Close();
2438
                    this._dragdropWindow = null;
2439
                    symbol_id = null;
2440
                }
2441
            }
2442
            */
2443

    
2444
            if (e.LeftButton == MouseButtonState.Pressed)
2445
            {
2446
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2447
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2448

    
2449
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2450
                SetCursor();
2451

    
2452
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2453
            }
2454

    
2455
            if (e.MiddleButton == MouseButtonState.Pressed)
2456
            {
2457
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2458
                cursor = Cursors.SizeAll;
2459
                SetCursor();
2460
            }
2461
            if (e.RightButton == MouseButtonState.Pressed)
2462
            {
2463
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2464
                cursor = Cursors.SizeAll;
2465
                SetCursor();
2466
            }
2467
            else if (e.XButton1 == MouseButtonState.Pressed)
2468
            {
2469
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2470
                {
2471
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2472
                }
2473

    
2474
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2475

    
2476
            }
2477
            else if (e.XButton2 == MouseButtonState.Pressed)
2478
            {
2479
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2480
                {
2481
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2482
                }
2483
            }
2484

    
2485
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2486
            {
2487
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2488
                {
2489
                    if (SelectLayer.Children.Count == 0)
2490
                    {
2491
                        isLeftMouseButtonDownOnWindow = true;
2492
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2493
                    }
2494

    
2495
                    if (controlType == ControlType.None)
2496
                    {
2497
                        isLeftMouseButtonDownOnWindow = true;
2498
                    }
2499
                }
2500

    
2501
                /// 캡쳐 모드 설정
2502
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2503
                {
2504
                    dragCaptureBorder.Visibility = Visibility.Visible;
2505
                    isLeftMouseButtonDownOnWindow = true;
2506
                }
2507

    
2508
                /// 줌 모드 설정
2509
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2510
                {
2511
                    isLeftMouseButtonDownOnWindow = true;
2512
                }
2513

    
2514
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2515
                if (control != null)
2516
                {
2517
                    AdornerFinal final = null;
2518

    
2519
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2520
                    {
2521
                        /// 기존 selection 해제
2522
                        SelectionSet.Instance.UnSelect(this);
2523

    
2524
                        final = new AdornerFinal(control);
2525

    
2526
                        this.Control_Style(control);
2527

    
2528
                        if ((control as IPath) != null)
2529
                        {
2530
                            if ((control as IPath).LineSize != 0)
2531
                            {
2532
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2533
                            }
2534
                        }
2535
                        if ((control as IShapeControl) != null)
2536
                        {
2537
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2538
                            {
2539
                                ViewerDataModel.Instance.checkHatchShape = true;
2540
                            }
2541
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2542
                            {
2543
                                ViewerDataModel.Instance.checkFillShape = true;
2544
                            }
2545
                            else
2546
                            {
2547
                                ViewerDataModel.Instance.checkHatchShape = false;
2548
                                ViewerDataModel.Instance.checkFillShape = false;
2549
                            }
2550
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2551
                        }
2552

    
2553
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2554

    
2555
                        if ((control as TextControl) != null)
2556
                        {
2557
                            if(!((control as TextControl).EnableEditing)) {
2558
                                (control as TextControl).EnableEditing = true;
2559
                            }
2560
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2561
                            {
2562
                                ViewerDataModel.Instance.checkTextStyle = true;
2563
                            }
2564
                            else
2565
                            {
2566
                                ViewerDataModel.Instance.checkTextStyle = false;
2567
                            }
2568
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2569
                            {
2570
                                ViewerDataModel.Instance.checkTextWeight = true;
2571
                            }
2572
                            else
2573
                            {
2574
                                ViewerDataModel.Instance.checkTextWeight = false;
2575
                            }
2576
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2577
                            {
2578
                                ViewerDataModel.Instance.checkUnderLine = true;
2579
                            }
2580
                            else
2581
                            {
2582
                                ViewerDataModel.Instance.checkUnderLine = false;
2583
                            }
2584
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2585
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2586

    
2587
                        }
2588
                        else if ((control as ArrowTextControl) != null)
2589
                        {
2590
                            if (!((control as ArrowTextControl).EnableEditing))
2591
                            {
2592
                                (control as ArrowTextControl).EnableEditing = true;
2593
                            }
2594
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2595
                            {
2596
                                ViewerDataModel.Instance.checkTextStyle = true;
2597
                            }
2598
                            else
2599
                            {
2600
                                ViewerDataModel.Instance.checkTextStyle = false;
2601
                            }
2602
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2603
                            {
2604
                                ViewerDataModel.Instance.checkTextWeight = true;
2605
                            }
2606
                            else
2607
                            {
2608
                                ViewerDataModel.Instance.checkTextWeight = false;
2609
                            }
2610
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2611
                            {
2612
                                ViewerDataModel.Instance.checkUnderLine = true;
2613
                            }
2614
                            else
2615
                            {
2616
                                ViewerDataModel.Instance.checkUnderLine = false;
2617
                            }
2618
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2619
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2620
                        }
2621
                        else if ((control as RectCloudControl) != null)
2622
                        {
2623
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2624
                        }
2625
                        else if ((control as CloudControl) != null)
2626
                        {
2627
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2628
                        }
2629
                    }
2630
                    else
2631
                    {
2632
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2633
                        SelectionSet.Instance.UnSelect(this);
2634
                        comment.Add(control);
2635

    
2636
                        Control_Style(control);
2637

    
2638
                        final = new AdornerFinal(comment);
2639
                    }
2640

    
2641
                    if (final != null)
2642
                    {
2643
                        this.SelectLayer.Children.Add(final);
2644
                    }
2645
                }              
2646
            }
2647
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2648
            {               
2649
                init();
2650
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2651
                if (cursor != Cursors.SizeAll)
2652
                {
2653
                    cursor = Cursors.Cross;
2654
                    SetCursor();
2655
                }
2656
                bool init_user = false;
2657
                foreach (var user in gridViewMarkup.Items)
2658
                {
2659
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2660
                    {
2661
                        init_user = true;
2662
                    }
2663
                }
2664
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2665
                {
2666
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2667
                    RadWindow.Alert(new DialogParameters
2668
                    {
2669
                        Owner = Application.Current.MainWindow,
2670
                        Theme = new VisualStudio2013Theme(),
2671
                        Header = "Info",
2672
                        Content = "Existing comments already existed. Select from the user list first",
2673
                    });
2674
                    return;
2675
                }
2676
                else
2677
                {
2678
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2679
                    if (item != null)
2680
                    {
2681
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2682
                    }
2683
                }
2684

    
2685
                switch (controlType)
2686
                {
2687
                    case ControlType.Coordinate:
2688
                        {
2689
                            if (e.LeftButton == MouseButtonState.Pressed)
2690
                            {
2691
                                if (currentControl is CoordinateControl)
2692
                                {
2693
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2694
                                    {
2695
                                        return;
2696
                                    }
2697

    
2698
                                    CreateCommand.Instance.Execute(currentControl);
2699

    
2700
                                    currentControl = null;
2701
                                    this.cursor = Cursors.Arrow;
2702
                                }
2703
                                else
2704
                                {
2705
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2706
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2707
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2708
                                    {
2709
                                        currentControl = null;
2710
                                        this.cursor = Cursors.Arrow;
2711
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2712
                                        return;
2713
                                    }
2714
                                    else
2715
                                    {
2716
                                        currentControl = new CoordinateControl
2717
                                        {
2718
                                            Background = new SolidColorBrush(Colors.Black),
2719
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2720
                                            ControlType = ControlType.Coordinate
2721
                                        };
2722

    
2723
                                        currentControl.CommentID = Commons.shortGuid();
2724
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2725
                                        currentControl.IsNew = true;
2726

    
2727
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2728

    
2729
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2730
                                    }
2731
                                }
2732
                            }
2733
                        }
2734
                        break;
2735
                    case ControlType.InsideWhite:
2736
                        {
2737
                            if (e.LeftButton == MouseButtonState.Pressed)
2738
                            {
2739
                                if (currentControl is InsideWhiteControl)
2740
                                {
2741
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2742
                                    {
2743
                                        return;
2744
                                    }
2745

    
2746
                                    CreateCommand.Instance.Execute(currentControl);
2747

    
2748
                                    currentControl = null;
2749
                                    this.cursor = Cursors.Arrow;
2750
                                }
2751
                                else
2752
                                {
2753
                                    currentControl = new InsideWhiteControl
2754
                                    {
2755
                                        Background = new SolidColorBrush(Colors.Black),
2756
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2757
                                        ControlType = ControlType.InsideWhite
2758
                                    };
2759

    
2760
                                    currentControl.CommentID = Commons.shortGuid();
2761
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2762
                                    currentControl.IsNew = true;
2763
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2764

    
2765
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2766
                                }
2767
                            }
2768
                        }
2769
                        break;
2770
                    case ControlType.OverlapWhite:
2771
                        {
2772
                            if (e.LeftButton == MouseButtonState.Pressed)
2773
                            {
2774
                                if (currentControl is OverlapWhiteControl)
2775
                                {
2776
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2777
                                    {
2778
                                        return;
2779
                                    }
2780

    
2781
                                    CreateCommand.Instance.Execute(currentControl);
2782

    
2783
                                    currentControl = null;
2784
                                    this.cursor = Cursors.Arrow;
2785
                                }
2786
                                else
2787
                                {
2788
                                    currentControl = new OverlapWhiteControl
2789
                                    {
2790
                                        Background = new SolidColorBrush(Colors.Black),
2791
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2792
                                        ControlType = ControlType.OverlapWhite
2793
                                    };
2794

    
2795
                                    currentControl.CommentID = Commons.shortGuid();
2796
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2797
                                    currentControl.IsNew = true;
2798
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2799

    
2800
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2801
                                }
2802
                            }
2803
                        }
2804
                        break;
2805
                    case ControlType.ClipWhite:
2806
                        {
2807
                            if (e.LeftButton == MouseButtonState.Pressed)
2808
                            {
2809
                                if (currentControl is ClipWhiteControl)
2810
                                {
2811
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2812
                                    {
2813
                                        return;
2814
                                    }
2815

    
2816
                                    CreateCommand.Instance.Execute(currentControl);
2817

    
2818
                                    currentControl = null;
2819
                                    this.cursor = Cursors.Arrow;
2820
                                }
2821
                                else
2822
                                {
2823
                                    currentControl = new ClipWhiteControl
2824
                                    {
2825
                                        Background = new SolidColorBrush(Colors.Black),
2826
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2827
                                        ControlType = ControlType.ClipWhite
2828
                                    };
2829

    
2830
                                    currentControl.CommentID = Commons.shortGuid();
2831
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2832
                                    currentControl.IsNew = true;
2833
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2834

    
2835
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2836
                                }
2837
                            }
2838
                        }
2839
                        break;
2840
                    case ControlType.Rectangle:
2841
                        {
2842
                            if (e.LeftButton == MouseButtonState.Pressed)
2843
                            {
2844
                                if (currentControl is RectangleControl)
2845
                                {
2846
                                    //20180906 LJY TEST IsRotationDrawingEnable
2847
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2848
                                    {
2849
                                        return;
2850
                                    }
2851

    
2852
                                    CreateCommand.Instance.Execute(currentControl);
2853
                                    currentControl = null;
2854
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2855
                                }
2856
                                else
2857
                                {
2858
                                    currentControl = new RectangleControl
2859
                                    {
2860
                                        Background = new SolidColorBrush(Colors.Black),
2861
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2862
                                        ControlType = ControlType.Rectangle
2863
                                    };
2864

    
2865
                                    currentControl.CommentID = Commons.shortGuid();
2866
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2867
                                    currentControl.IsNew = true;
2868
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2869

    
2870
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2871
                                }
2872
                            }
2873
                        }
2874
                        break;
2875
                    case ControlType.RectCloud:
2876
                        {
2877
                            if (e.LeftButton == MouseButtonState.Pressed)
2878
                            {
2879
                                if (currentControl is RectCloudControl)
2880
                                {
2881
                                    //20180906 LJY TEST IsRotationDrawingEnable
2882
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2883
                                    {
2884
                                        return;
2885
                                    }
2886

    
2887
                                    CreateCommand.Instance.Execute(currentControl);
2888

    
2889
                                    currentControl = null;
2890
                                
2891
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2892
                                }
2893
                                else
2894
                                {
2895
                                    currentControl = new RectCloudControl
2896
                                    {
2897
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2898
                                        ControlType = ControlType.RectCloud,
2899
                                        Background = new SolidColorBrush(Colors.Black)
2900
                                    };
2901

    
2902
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2903
                                    currentControl.CommentID = Commons.shortGuid();
2904
                                    currentControl.IsNew = true;
2905
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2906
                                }
2907
                            }
2908
                        }
2909
                        break;
2910
                    case ControlType.Circle:
2911
                        {
2912
                            if (e.LeftButton == MouseButtonState.Pressed)
2913
                            {
2914
                                if (currentControl is CircleControl)
2915
                                {
2916
                                    //20180906 LJY TEST IsRotationDrawingEnable
2917
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2918
                                    {
2919
                                        return;
2920
                                    }
2921

    
2922
                                    CreateCommand.Instance.Execute(currentControl);
2923

    
2924
                                    currentControl = null;
2925
                                }
2926
                                else
2927
                                {
2928
                                    currentControl = new CircleControl
2929
                                    {
2930
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2931
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2932
                                        Background = new SolidColorBrush(Colors.Black)
2933
                                    };
2934

    
2935
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2936
                                    currentControl.CommentID = Commons.shortGuid();
2937
                                    currentControl.IsNew = true;
2938
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2939
                                }
2940
                            }
2941
                        }
2942
                        break;
2943
                    case ControlType.Triangle:
2944
                        {
2945
                            if (e.LeftButton == MouseButtonState.Pressed)
2946
                            {
2947
                                if (currentControl is TriControl)
2948
                                {
2949
                                    var content = currentControl as TriControl;
2950
                                    if (content.MidPoint == new Point(0, 0))
2951
                                    {
2952
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2953
                                    }
2954
                                    else
2955
                                    {
2956
                                        //20180906 LJY TEST IsRotationDrawingEnable
2957
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2958
                                        {
2959
                                            return;
2960
                                        }
2961

    
2962
                                        CreateCommand.Instance.Execute(currentControl);
2963

    
2964
                                        currentControl = null;
2965
                                    }
2966
                                }
2967
                                else
2968
                                {
2969
                                    currentControl = new TriControl
2970
                                    {
2971
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2972
                                        Background = new SolidColorBrush(Colors.Black),
2973
                                    };
2974

    
2975
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2976
                                    currentControl.CommentID = Commons.shortGuid();
2977
                                    currentControl.IsNew = true;
2978
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2979
                                }
2980
                            }
2981
                        }
2982
                        break;
2983
                    case ControlType.CancelLine:
2984
                    case ControlType.SingleLine:
2985
                    case ControlType.ArrowLine:
2986
                    case ControlType.TwinLine:
2987
                    case ControlType.DimLine:
2988
                        {
2989
                            if (e.LeftButton == MouseButtonState.Pressed)
2990
                            {
2991
                                if (currentControl is LineControl)
2992
                                {
2993
                                    //20180906 LJY TEST IsRotationDrawingEnable
2994
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2995
                                    {
2996
                                        return;
2997
                                    }
2998

    
2999
                                    CreateCommand.Instance.Execute(currentControl);
3000
                                    currentControl = null;
3001
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3002
                                }
3003
                                else
3004
                                {
3005
                                    currentControl = new LineControl
3006
                                    {
3007
                                        ControlType = this.controlType,
3008
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3009
                                        Background = new SolidColorBrush(Colors.Black)
3010
                                    };
3011

    
3012
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3013
                                    currentControl.CommentID = Commons.shortGuid();
3014
                                    currentControl.IsNew = true;
3015
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3016
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3017
                                }
3018
                            }
3019
                        }
3020
                        break;
3021
                    case ControlType.PolygonControl:
3022
                        {
3023
                            if (currentControl is PolygonControl)
3024
                            {
3025
                                var control = currentControl as PolygonControl;
3026

    
3027
                                if (e.RightButton == MouseButtonState.Pressed)
3028
                                {
3029
                                    control.IsCompleted = true;
3030
                                }
3031

    
3032
                                if (!control.IsCompleted)
3033
                                {
3034
                                    control.PointSet.Add(control.EndPoint);
3035
                                }
3036
                                else
3037
                                {
3038
                                    //20180906 LJY TEST IsRotationDrawingEnable
3039
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3040
                                    {
3041
                                        return;
3042
                                    }
3043

    
3044
                                    var firstPoint = control.PointSet.First();
3045
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3046
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3047
                                    control.PointSet.Add(firstPoint);
3048

    
3049
                                    control.ApplyOverViewData();
3050

    
3051
                                    CreateCommand.Instance.Execute(currentControl);
3052
                                    control.UpdateControl();
3053
                                    currentControl = null;
3054
                                }
3055
                            }
3056
                            else
3057
                            {
3058
                                if (e.LeftButton == MouseButtonState.Pressed)
3059
                                {
3060
                                    currentControl = new PolygonControl
3061
                                    {
3062
                                        PointSet = new List<Point>(),
3063
                                    };
3064

    
3065
                                    var polygonControl = (currentControl as PolygonControl);
3066
                                    currentControl.CommentID = Commons.shortGuid();
3067
                                    currentControl.IsNew = true;
3068
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3069
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3070
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3071
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3072
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3073
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3074
                                    polygonControl.ApplyTemplate();
3075
                                    polygonControl.Visibility = Visibility.Visible;
3076
                                }
3077
                            }
3078
                        }
3079
                        break;
3080
                    case ControlType.ChainLine:
3081
                        {
3082
                            if (currentControl is PolygonControl)
3083
                            {
3084
                                var control = currentControl as PolygonControl;
3085

    
3086
                                if (e.RightButton == MouseButtonState.Pressed)
3087
                                {
3088
                                    //20180906 LJY TEST IsRotationDrawingEnable
3089
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3090
                                    {
3091
                                        return;
3092
                                    }
3093

    
3094
                                    CreateCommand.Instance.Execute(currentControl);
3095

    
3096
                                    currentControl = null;
3097
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3098
                                    return;
3099
                                }
3100

    
3101
                                if (!control.IsCompleted)
3102
                                {
3103
                                    control.PointSet.Add(control.EndPoint);
3104
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3105
                                }
3106
                            }
3107
                            else
3108
                            {
3109
                                if (e.LeftButton == MouseButtonState.Pressed)
3110
                                {
3111
                                    MainAngle.Visibility = Visibility.Visible;
3112
                                    currentControl = new PolygonControl
3113
                                    {
3114
                                        PointSet = new List<Point>(),
3115
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3116
                                        ControlType = ControlType.ChainLine,
3117
                                        DashSize = ViewerDataModel.Instance.DashSize,
3118
                                        LineSize = ViewerDataModel.Instance.LineSize,
3119
                                        //PointC = new StylusPointSet()
3120
                                    };
3121

    
3122
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3123
                                    //{
3124
                                        var polygonControl = (currentControl as PolygonControl);
3125
                                        currentControl.CommentID = Commons.shortGuid();
3126
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3127
                                        currentControl.IsNew = true;
3128
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3129
                                        //currentControl.OnApplyTemplate();
3130
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3131
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3132
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3133
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3134
                                    //}
3135
                                }
3136
                            }
3137
                        }
3138
                        break;
3139
                    case ControlType.ArcLine:
3140
                        {
3141
                            if (e.LeftButton == MouseButtonState.Pressed)
3142
                            {
3143
                                if (currentControl is ArcControl)
3144
                                {
3145
                                    //20180906 LJY TEST IsRotationDrawingEnable
3146
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3147
                                    {
3148
                                        return;
3149
                                    }
3150

    
3151
                                    CreateCommand.Instance.Execute(currentControl);
3152

    
3153
                                    currentControl = null;
3154
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3155
                                }
3156
                                else
3157
                                {
3158
                                    currentControl = new ArcControl
3159
                                    {
3160
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3161
                                        Background = new SolidColorBrush(Colors.Black)
3162
                                    };
3163
                                    currentControl.CommentID = Commons.shortGuid();
3164
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3165
                                    currentControl.IsNew = true;
3166
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3167
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3168
                                }
3169
                            }
3170
                            else if (e.RightButton == MouseButtonState.Pressed)
3171
                            {
3172
                                if (currentControl != null)
3173
                                {
3174
                                    (currentControl as ArcControl).setClock();
3175
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3176
                                }
3177
                            }
3178
                        }
3179
                        break;
3180
                    case ControlType.ArcArrow:
3181
                        {
3182
                            if (e.LeftButton == MouseButtonState.Pressed)
3183
                            {
3184
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3185
                                //{
3186
                                if (currentControl is ArrowArcControl)
3187
                                {
3188
                                    //20180906 LJY TEST IsRotationDrawingEnable
3189
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3190
                                    {
3191
                                        return;
3192
                                    }
3193

    
3194
                                    CreateCommand.Instance.Execute(currentControl);
3195

    
3196
                                    currentControl = null;
3197
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3198
                                }
3199
                                else
3200
                                {
3201
                                    currentControl = new ArrowArcControl
3202
                                    {
3203
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3204
                                        Background = new SolidColorBrush(Colors.Black)
3205
                                    };
3206
                                    currentControl.CommentID = Commons.shortGuid();
3207
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3208
                                    currentControl.IsNew = true;
3209
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3210
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3211
                                }
3212
                                //}
3213
                            }
3214
                            else if (e.RightButton == MouseButtonState.Pressed)
3215
                            {
3216
                                if (currentControl != null)
3217
                                {
3218
                                    (currentControl as ArrowArcControl).setClock();
3219
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3220
                                    //(currentControl as ArcControl).ApplyTemplate();
3221
                                }
3222
                            }
3223
                        }
3224
                        break;
3225
                    case ControlType.ArrowMultiLine:
3226
                        {
3227
                            if (e.LeftButton == MouseButtonState.Pressed)
3228
                            {
3229
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3230
                                //{
3231

    
3232
                                    if (currentControl is ArrowControl_Multi)
3233
                                    {
3234
                                        var content = currentControl as ArrowControl_Multi;
3235
                                        if (content.MiddlePoint == new Point(0, 0))
3236
                                        {
3237
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3238
                                            {
3239
                                                content.MiddlePoint = content.EndPoint;
3240
                                            }
3241
                                            else
3242
                                            {
3243
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3244
                                            }
3245
                                        }
3246
                                        else
3247
                                        {
3248
                                            //20180906 LJY TEST IsRotationDrawingEnable
3249
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3250
                                            {
3251
                                                return;
3252
                                            }
3253

    
3254
                                            CreateCommand.Instance.Execute(currentControl);
3255

    
3256
                                            currentControl = null;
3257
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3258
                                        }
3259
                                    }
3260
                                    else
3261
                                    {
3262
                                        currentControl = new ArrowControl_Multi
3263
                                        {
3264
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3265
                                            Background = new SolidColorBrush(Colors.Black)
3266
                                        };
3267
                                        currentControl.CommentID = Commons.shortGuid();
3268
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3269
                                        currentControl.IsNew = true;
3270
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3271
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3272
                                    }
3273
                                //}
3274
                            }
3275
                        }
3276
                        break;
3277
                    case ControlType.PolygonCloud:
3278
                        {
3279
                            if (currentControl is CloudControl)
3280
                            {
3281
                                var control = currentControl as CloudControl;
3282
                                if (e.RightButton == MouseButtonState.Pressed)
3283
                                {
3284
                                    control.IsCompleted = true;
3285
                                }
3286

    
3287
                                if (!control.IsCompleted)
3288
                                {
3289
                                    control.PointSet.Add(control.EndPoint);
3290
                                }
3291
                                else
3292
                                {
3293
                                    //20180906 LJY TEST IsRotationDrawingEnable
3294
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3295
                                    {
3296
                                        return;
3297
                                    }
3298

    
3299
                                    CreateCommand.Instance.Execute(currentControl);
3300

    
3301
                                    control.isTransOn = true;
3302
                                    var firstPoint = control.PointSet.First();
3303

    
3304
                                    control.PointSet.Add(firstPoint);
3305
                                    control.DrawingCloud();
3306
                                    control.ApplyOverViewData();
3307

    
3308
                                    currentControl = null;
3309
                                }
3310
                            }
3311
                            else
3312
                            {
3313
                                if (e.LeftButton == MouseButtonState.Pressed)
3314
                                {
3315
                                    currentControl = new CloudControl
3316
                                    {
3317
                                        PointSet = new List<Point>(),
3318
                                        PointC = new StylusPointSet()
3319
                                    };
3320

    
3321
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3322
                                    //{
3323
                                        var polygonControl = (currentControl as CloudControl);
3324
                                        currentControl.CommentID = Commons.shortGuid();
3325
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3326
                                        currentControl.IsNew = true;
3327
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3328

    
3329
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3330
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3331
                                    
3332
                                    //}
3333
                                }
3334
                            }
3335
                        }
3336
                        break;
3337
                    case ControlType.ImgControl:
3338
                        {
3339
                            if (e.LeftButton == MouseButtonState.Pressed)
3340
                            {
3341
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3342
                                //{
3343
                                    if (currentControl is ImgControl)
3344
                                    {
3345
                                        //20180906 LJY TEST IsRotationDrawingEnable
3346
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3347
                                        {
3348
                                            return;
3349
                                        }
3350

    
3351
                                        CreateCommand.Instance.Execute(currentControl);
3352
                                        controlType = ControlType.ImgControl;
3353
                                        currentControl = null;
3354
                                    }
3355
                                    else
3356
                                    {
3357
                                        
3358
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3359
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3360
                                        {
3361
                                            Image img = new Image();
3362
                                            if (filename.Contains(".svg"))
3363
                                            {
3364
                                                byte[] imageData = null;
3365
                                                DrawingImage image = null;
3366
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3367
                                                {
3368
                                                    imageData = web.DownloadData(new Uri(filename));
3369
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3370
                                                    image = SvgReader.Load(stream);
3371
                                                }
3372
                                                img.Source = image;
3373
                                            }
3374
                                            else
3375
                                            {
3376
                                                img.Source = new BitmapImage(new Uri(filename));
3377
                                            }
3378

    
3379
                                            currentControl = new ImgControl
3380
                                            {
3381
                                                    Background = new SolidColorBrush(Colors.Black),
3382
                                                    PointSet = new List<Point>(),
3383
                                                    FilePath = filename,
3384
                                                    ImageData = img.Source,
3385
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3386
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3387
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3388
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3389
                                                    ControlType = ControlType.ImgControl
3390
                                                };
3391

    
3392
                                        
3393
                                                currentControl.CommentID = Commons.shortGuid();                                            
3394
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3395
                                                currentControl.IsNew = true;
3396
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3397

    
3398
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3399
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3400
                                    }
3401
                                    }
3402
                                //}
3403
                            }
3404
                        }
3405
                        break;
3406
                    case ControlType.Date:
3407
                        {
3408
                            if (e.LeftButton == MouseButtonState.Pressed)
3409
                            {
3410
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3411
                                //{
3412
                                if (currentControl is DateControl)
3413
                                {
3414
                                    //20180906 LJY TEST IsRotationDrawingEnable
3415
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3416
                                    {
3417
                                        return;
3418
                                    }
3419

    
3420
                                    CreateCommand.Instance.Execute(currentControl);
3421
                                    currentControl = null;
3422

    
3423
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3424
                                    {
3425
                                        controlType = ControlType.None;
3426
                                        IsSwingMode = false;
3427
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3428
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3429
                                        mouseHandlingMode = MouseHandlingMode.None;
3430
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3431
                                        txtBatch.Visibility = Visibility.Collapsed;
3432

    
3433
                                    }
3434
                                }
3435
                                else
3436
                                {
3437
                                    currentControl = new DateControl
3438
                                    {
3439
                                        StartPoint = CanvasDrawingMouseDownPoint,
3440
                                        Background = new SolidColorBrush(Colors.Black)
3441
                                    };
3442
                                    currentControl.CommentID = Commons.shortGuid();
3443
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3444
                                    currentControl.IsNew = true;
3445
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3446

    
3447
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3448
                                    if (currentControl is ImgControl)
3449
                                    {
3450
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3451
                                    }
3452
                                }
3453
                                //}
3454
                            }
3455
                        }
3456
                        break;
3457
                    case ControlType.TextControl:
3458
                        {
3459
                            if (e.LeftButton == MouseButtonState.Pressed)
3460
                            {
3461
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3462
                                {
3463
                                    currentControl = new TextControl
3464
                                    {
3465
                                        ControlType = controlType
3466
                                    };
3467
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3468
                                    currentControl.CommentID = Commons.shortGuid();
3469
                                    currentControl.IsNew = true;
3470
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3471
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3472
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3473

    
3474
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3475
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3476
                                    
3477
                                    (currentControl as TextControl).ControlType_No = 0;
3478
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3479
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3480
                                    (currentControl as TextControl).ApplyTemplate();
3481
                                    (currentControl as TextControl).Base_TextBox.Focus();
3482
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3483
                                    CreateCommand.Instance.Execute(currentControl);
3484
                                }
3485
                            }
3486
                        }
3487
                        break;
3488
                    case ControlType.TextBorder:
3489
                        {
3490
                            if (e.LeftButton == MouseButtonState.Pressed)
3491
                            {
3492
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3493
                                {
3494
                                    currentControl = new TextControl
3495
                                    {
3496
                                        ControlType = controlType
3497
                                    };
3498

    
3499
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3500
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3501
                                    currentControl.CommentID = Commons.shortGuid();
3502
                                    currentControl.IsNew = true;
3503
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3504
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3505
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3506
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3507
                                    
3508
                                    (currentControl as TextControl).ControlType_No = 1;
3509
                                    (currentControl as TextControl).CommentAngle = Ang;
3510
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3511
                                    (currentControl as TextControl).ApplyTemplate();
3512
                                    (currentControl as TextControl).Base_TextBox.Focus();
3513
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3514
                                    CreateCommand.Instance.Execute(currentControl);
3515
                                }
3516
                            }
3517
                        }
3518
                        break;
3519
                    case ControlType.TextCloud:
3520
                        {
3521
                            if (e.LeftButton == MouseButtonState.Pressed)
3522
                            {
3523
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3524
                                {
3525
                                    currentControl = new TextControl
3526
                                    {
3527
                                        ControlType = controlType
3528
                                    };
3529

    
3530
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3531
                                    currentControl.CommentID = Commons.shortGuid();
3532
                                    currentControl.IsNew = true;
3533
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3534
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3535

    
3536
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3537
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3538
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3539

    
3540
                                    (currentControl as TextControl).CommentAngle = Ang;
3541
                                    (currentControl as TextControl).ControlType_No = 2;
3542
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3543
                                    (currentControl as TextControl).ApplyTemplate();
3544
                                    (currentControl as TextControl).Base_TextBox.Focus();
3545
                                    CreateCommand.Instance.Execute(currentControl);
3546
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3547
                                    //currentControl = null;
3548
                                }
3549
                            }
3550
                        }
3551
                        break;
3552
                    case ControlType.ArrowTextControl:
3553
                         {
3554
                            if (e.LeftButton == MouseButtonState.Pressed)
3555
                            {
3556
                                if (currentControl is ArrowTextControl)
3557
                                {
3558
                                    //20180906 LJY TEST IsRotationDrawingEnable
3559
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3560
                                    {
3561
                                        return;
3562
                                    }
3563

    
3564
                                    CreateCommand.Instance.Execute(currentControl);
3565

    
3566
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3567
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3568
                                    (currentControl as ArrowTextControl).IsNew = false;
3569
                                    currentControl = null;
3570
                                }
3571
                                else
3572
                                {
3573
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3574
                                    //{
3575
                                        currentControl = new ArrowTextControl();
3576
                                        currentControl.CommentID = Commons.shortGuid();
3577
                                        currentControl.IsNew = true;
3578
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3579
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3580

    
3581
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3582
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3583
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3584
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3585
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3586

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

    
3590
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3591
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3592
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3593
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3594

    
3595
                                    
3596
                                    //}
3597
                                }
3598
                            }
3599
                        }
3600
                        break;
3601
                    case ControlType.ArrowTransTextControl:
3602
                        {
3603
                            if (e.LeftButton == MouseButtonState.Pressed)
3604
                            {
3605
                                if (currentControl is ArrowTextControl)
3606
                                {
3607
                                    //20180906 LJY TEST IsRotationDrawingEnable
3608
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3609
                                    {
3610
                                        return;
3611
                                    }
3612

    
3613
                                    CreateCommand.Instance.Execute(currentControl);
3614

    
3615
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3616
                                    
3617
                                    currentControl.IsNew = false;
3618
                                    currentControl = null;
3619
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3620
                                }
3621
                                else
3622
                                {
3623
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3624
                                    //{
3625
                                    currentControl = new ArrowTextControl()
3626
                                    {
3627
                                        ControlType = ControlType.ArrowTransTextControl
3628
                                    };
3629
                                    currentControl.CommentID = Commons.shortGuid();
3630
                                    currentControl.IsNew = true;
3631
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3632
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3633
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3634
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3635
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3636
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3637
                                    (currentControl as ArrowTextControl).isFixed = true;
3638
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3639

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

    
3643
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3644
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3645
                                    (currentControl as ArrowTextControl).isTrans = true;
3646
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3647
                                }
3648
                            }
3649
                        }
3650
                        break;
3651
                    case ControlType.ArrowTextBorderControl:
3652
                         {
3653
                            if (e.LeftButton == MouseButtonState.Pressed)
3654
                            {
3655
                                if (currentControl is ArrowTextControl)
3656
                                {
3657
                                    //20180906 LJY TEST IsRotationDrawingEnable
3658
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3659
                                    {
3660
                                        return;
3661
                                    }
3662

    
3663
                                    CreateCommand.Instance.Execute(currentControl);
3664
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3665
                                    currentControl.IsNew = false;
3666
                                    currentControl = null;
3667
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3668
                                }
3669
                                else
3670
                                {
3671
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3672
                                    //{
3673
                                        currentControl = new ArrowTextControl()
3674
                                        {
3675
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3676
                                        };
3677
                                        currentControl.CommentID = Commons.shortGuid();
3678
                                        currentControl.IsNew = true;
3679
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3680
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3681

    
3682
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3683

    
3684
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3685

    
3686
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3687
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3688
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3689
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3690
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3691
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3692
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3693
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3694
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                    
3695
                                    //}
3696
                                }
3697
                            }
3698
                        }
3699
                        break;
3700
                    case ControlType.ArrowTransTextBorderControl:
3701
                        {
3702
                            if (e.LeftButton == MouseButtonState.Pressed)
3703
                            {
3704
                                if (currentControl is ArrowTextControl)
3705
                                {
3706
                                    //20180906 LJY TEST IsRotationDrawingEnable
3707
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3708
                                    {
3709
                                        return;
3710
                                    }
3711
                                    CreateCommand.Instance.Execute(currentControl);
3712
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3713
                                    currentControl.IsNew = false;
3714
                                    currentControl = null;
3715

    
3716
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3717
                                }
3718
                                else
3719
                                {
3720
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3721
                                    //{
3722
                                    
3723

    
3724
                                    currentControl = new ArrowTextControl()
3725
                                    {
3726
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3727
                                        ControlType = ControlType.ArrowTransTextBorderControl
3728

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

    
3735
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3736

    
3737
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3738
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3739
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3740
                                        (currentControl as ArrowTextControl).isFixed = true;
3741
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3742
                                     
3743
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3744
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3745
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3746
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3747
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3748
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3749
                                    
3750
                                    //20180911 LJY
3751
                                        (currentControl as ArrowTextControl).isTrans = true;
3752
                                    
3753

    
3754
                                    //}
3755
                                }
3756
                            }
3757
                        }
3758
                        break;
3759
                    case ControlType.ArrowTextCloudControl:
3760
                        {
3761
                            if (e.LeftButton == MouseButtonState.Pressed)
3762
                            {
3763
                                if (currentControl is ArrowTextControl)
3764
                                {
3765
                                    //20180906 LJY TEST IsRotationDrawingEnable
3766
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3767
                                    {
3768
                                        return;
3769
                                    }
3770
                                    CreateCommand.Instance.Execute(currentControl);
3771
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3772
                                    currentControl.IsNew = false;
3773
                                    currentControl = null;
3774
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3775
                                }
3776
                                else
3777
                                {
3778
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3779
                                    //{
3780
                                        currentControl = new ArrowTextControl()
3781
                                        {
3782
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3783
                                        };
3784
                                        currentControl.CommentID = Commons.shortGuid();
3785
                                        currentControl.IsNew = true;
3786
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3787
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3788

    
3789
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3790
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3791
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                 
3792
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3793
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3794
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3795
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3796
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3797
                                    
3798
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3799
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3800
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                        
3801
                                    //}
3802
                                }
3803
                            }
3804
                        }
3805
                        break;
3806
                    case ControlType.ArrowTransTextCloudControl:
3807
                        {
3808
                            if (e.LeftButton == MouseButtonState.Pressed)
3809
                            {
3810
                                if (currentControl is ArrowTextControl)
3811
                                {
3812
                                    //20180906 LJY TEST IsRotationDrawingEnable
3813
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3814
                                    {
3815
                                        return;
3816
                                    }
3817
                                    CreateCommand.Instance.Execute(currentControl);
3818
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3819
                                    currentControl.IsNew = false;
3820
                                    currentControl = null;
3821
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3822
                                }
3823
                                else
3824
                                {
3825
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3826
                                    //{
3827
                                        currentControl = new ArrowTextControl()
3828
                                        {
3829
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3830
                                            ControlType = ControlType.ArrowTransTextCloudControl
3831

    
3832
                                        };
3833
                                        currentControl.CommentID = Commons.shortGuid();
3834
                                        currentControl.IsNew = true; 
3835
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3836
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3837
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3838

    
3839
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3840
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3841
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3842
                                        (currentControl as ArrowTextControl).isFixed = true;
3843
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3844

    
3845
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3846
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3847
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3848
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3849
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3850
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;  
3851
                                    
3852
                                    //20180911 LJY
3853
                                        (currentControl as ArrowTextControl).isTrans = true;
3854
                                    //}
3855
                                }
3856
                            }
3857
                        }
3858
                        break;
3859
                    //강인구 추가
3860
                    case ControlType.Sign:
3861
                        {
3862
                            if (e.LeftButton == MouseButtonState.Pressed)
3863
                            {
3864
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3865
                                //{
3866
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
3867

    
3868
                                if (_sign == null)
3869
                                    {
3870
                                        txtBatch.Visibility = Visibility.Collapsed;
3871
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3872
                                        controlType = ControlType.None;
3873

    
3874
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3875
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3876
                                        return;
3877
                                    }
3878

    
3879
                                    if (currentControl is SignControl)
3880
                                    {
3881
                                        //20180906 LJY TEST IsRotationDrawingEnable
3882
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3883
                                        {
3884
                                            return;
3885
                                        }
3886

    
3887
                                        CreateCommand.Instance.Execute(currentControl);
3888
                                        currentControl = null;
3889
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3890
                                        {
3891
                                            txtBatch.Text = "Place Date";
3892
                                            controlType = ControlType.Date;
3893
                                        }
3894
                                    }
3895
                                    else
3896
                                    {
3897
                                        currentControl = new SignControl
3898
                                        {
3899
                                            Background = new SolidColorBrush(Colors.Black),
3900
                                            UserNumber = App.ViewInfo.UserID,
3901
                                            ProjectNO = App.ViewInfo.ProjectNO,
3902
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3903
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3904
                                            ControlType = ControlType.Sign
3905
                                        };
3906

    
3907
                                        currentControl.CommentID = Commons.shortGuid();
3908
                                        currentControl.IsNew = true;
3909
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3910
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3911

    
3912
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3913
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3914
                                }
3915
                                //}
3916
                            }
3917
                        }
3918
                        break;
3919
                    case ControlType.Mark:
3920
                        {
3921
                            if (e.LeftButton == MouseButtonState.Pressed)
3922
                            {
3923
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3924
                                //{
3925
                                    if (currentControl is RectangleControl)
3926
                                    {
3927
                                        //20180906 LJY TEST IsRotationDrawingEnable
3928
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3929
                                        {
3930
                                            return;
3931
                                        }
3932

    
3933
                                        CreateCommand.Instance.Execute(currentControl);
3934
                                        (currentControl as RectangleControl).ApplyOverViewData();
3935
                                        currentControl = null;
3936
                                    
3937
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3938

    
3939
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3940
                                        {
3941
                                            txtBatch.Text = "Place Signature";
3942
                                            controlType = ControlType.Sign;
3943
                                        }
3944
                                    }
3945
                                    else
3946
                                    {
3947
                                        currentControl = new RectangleControl
3948
                                        {
3949
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3950
                                            Background = new SolidColorBrush(Colors.Black),
3951
                                            ControlType = ControlType.Mark ,
3952
                                            Paint = PaintSet.Fill
3953
                                        };
3954

    
3955
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3956
                                        currentControl.CommentID = Commons.shortGuid();
3957
                                        currentControl.IsNew = true;
3958
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3959
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3960
                                    }
3961
                                //}
3962
                            }
3963
                        }
3964
                        break;
3965
                    case ControlType.Symbol:
3966
                        {
3967
                            if (e.LeftButton == MouseButtonState.Pressed)
3968
                            {
3969
                                if (currentControl is SymControl)
3970
                                {
3971
                                    //20180906 LJY TEST IsRotationDrawingEnable
3972
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3973
                                    {
3974
                                        return;
3975
                                    }
3976
                                    CreateCommand.Instance.Execute(currentControl);
3977
                                    currentControl = null;
3978
                                
3979
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3980
                                }
3981
                                else
3982
                                {
3983
                                    currentControl = new SymControl
3984
                                    {
3985
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3986
                                        Background = new SolidColorBrush(Colors.Black),
3987
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3988
                                        ControlType = ControlType.Symbol
3989
                                    };
3990

    
3991
                                    currentControl.IsNew = true;
3992
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3993
                                    currentControl.CommentID = Commons.shortGuid();
3994
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3995

    
3996
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3997
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3998
                                }
3999
                                //}
4000
                            }
4001
                        }
4002
                        break;
4003
                    case ControlType.Stamp:
4004
                        {
4005
                            if (e.LeftButton == MouseButtonState.Pressed)
4006
                            {
4007
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4008
                                //{
4009
                                    if (currentControl is SymControlN)
4010
                                    {
4011
                                        //20180906 LJY TEST IsRotationDrawingEnable
4012
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4013
                                        {
4014
                                            return;
4015
                                        }
4016

    
4017
                                        CreateCommand.Instance.Execute(currentControl);
4018
                                        currentControl = null;
4019
                                   
4020

    
4021
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4022
                                    }
4023
                                    else
4024
                                    {
4025
                                        currentControl = new SymControlN
4026
                                        {
4027
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4028
                                            Background = new SolidColorBrush(Colors.Black),
4029
                                            STAMP = App.SystemInfo.STAMP,                                            
4030
                                            ControlType = ControlType.Stamp
4031
                                        };
4032

    
4033
                                        currentControl.IsNew = true;
4034
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4035
                                        currentControl.CommentID = Commons.shortGuid();
4036
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4037
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4038
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4039
                                }                                    
4040
                                //}
4041
                            }
4042
                        }
4043
                        break;
4044
                    case ControlType.PenControl:
4045
                        {
4046
                            if (inkBoard.Tag.ToString() == "Ink")
4047
                            {
4048
                                inkBoard.IsEnabled = true;
4049
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4050
                            }
4051
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4052
                            {
4053
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4054
                            }
4055
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4056
                            {
4057
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4058
                            }
4059
                            IsDrawing = true;
4060
                            return;
4061
                        }
4062
                    default:
4063
                        if (currentControl != null)
4064
                        {
4065
                            currentControl.CommentID = null;
4066
                            currentControl.IsNew = false;
4067
                        }
4068
                        break;
4069
                }
4070

    
4071
                if (currentControl != null)
4072
                {
4073
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4074
                }
4075
            }
4076
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4077
            {
4078
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4079
                {
4080
                    bool mouseOff = false;
4081
                    foreach (var item in SelectLayer.Children)
4082
                    {
4083
                        if (item is AdornerFinal)
4084
                        {
4085

    
4086
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4087
                            if (over != null)
4088
                            {
4089
                                mouseOff = true;
4090
                            }
4091
                        }
4092
                    }
4093

    
4094
                    if (!mouseOff)
4095
                    {
4096
                        SelectionSet.Instance.UnSelect(this);
4097
                    }
4098
                }
4099
                zoomAndPanControl.CaptureMouse();
4100
                e.Handled = true;
4101
            }
4102
          
4103
        }
4104

    
4105
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4106
        {
4107
            ///mouseButtonDown = e.ChangedButton;
4108
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4109
        }
4110

    
4111
        private void RemoveLineStroke(Point P)
4112
        {
4113
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4114
            if (control != null)
4115
            {
4116
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4117
            }
4118
        }
4119

    
4120
        private void RemovePointStroke(Point P)
4121
        {
4122
            foreach (Stroke hits in inkBoard.Strokes)
4123
            {
4124
                foreach (StylusPoint sty in hits.StylusPoints)
4125
                {
4126

    
4127
                }
4128
                if (hits.HitTest(P))
4129
                {
4130
                    inkBoard.Strokes.Remove(hits);
4131
                    return;
4132
                }
4133
            }
4134
        }
4135

    
4136
        private void StartNewStroke(Point P)
4137
        {
4138
            strokePoints = new StylusPointCollection();
4139
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4140
            strokePoints.Add(segment1Start);
4141
            stroke = new Stroke(strokePoints);
4142

    
4143
            stroke.DrawingAttributes.Color = Colors.Red;
4144
            stroke.DrawingAttributes.Width = 4;
4145
            stroke.DrawingAttributes.Height = 4;
4146

    
4147
            inkBoard.Strokes.Add(stroke);
4148
        }
4149

    
4150
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4151
        {
4152
            ConsolidationMethod();
4153
        }
4154

    
4155
        /// <summary>
4156
        /// execute TeamConsolidationCommand
4157
        /// </summary>
4158
        public void TeamConsolidationMethod()
4159
        {
4160
            this.UpdateMyMarkupList();
4161
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4162
            {
4163
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4164
            }
4165
            else
4166
            {
4167

    
4168
                ViewerDataModel.Instance.IsConsolidate = true;
4169
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4170

    
4171
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4172
                {
4173
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4174
                    {
4175
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4176
                        return;
4177
                    }                    
4178
                }
4179
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4180
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4181
                {
4182
                    MarkupInfoList.Add(item);
4183
                }
4184
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4185
            }
4186
        }
4187

    
4188
        public void ConsolidationMethod()
4189
        {
4190
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4191
            {
4192
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4193
            }
4194
            else
4195
            {
4196
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4197
                foreach (var item in this.gridViewMarkup.SelectedItems)
4198
                {
4199
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4200
                }
4201
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4202
                
4203
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4204
            }
4205
        }
4206

    
4207
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4208
        {
4209
            if (App.ViewInfo != null)
4210
            {
4211
                btnConsolidate = (sender as RadRibbonButton);
4212
                if (!App.ViewInfo.NewCommentPermission)
4213
                {
4214
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4215
                }
4216
            }
4217
        }
4218

    
4219
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4220
        {
4221
            TeamConsolidationMethod();
4222
        }
4223

    
4224
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4225
        {
4226
            btnTeamConsolidate = sender as RadRibbonButton;
4227
            if (App.ViewInfo != null)
4228
            {
4229
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4230
                {
4231
                    if (btnConsolidate != null)
4232
                    {
4233
                        btnConsolidate.Visibility = Visibility.Collapsed;
4234
                    }
4235

    
4236
                    if (!App.ViewInfo.NewCommentPermission)
4237
                    {
4238
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4239
                    }
4240
                }
4241
                else
4242
                {
4243
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4244
                }
4245
            }
4246
        }
4247

    
4248
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4249
        {
4250
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4251
            if(item != null)
4252
            {
4253
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4254
                {
4255
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4256
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4257
                }
4258
                else
4259
                {
4260
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4261
                }
4262
            }else{
4263
                //Consolidate 가 없는 경우
4264
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4265
            }
4266
            
4267
        }
4268

    
4269
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4270
        {
4271
            btnFinalPDF = sender as RadRibbonButton;
4272
            if (App.ViewInfo != null)
4273
            {
4274
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4275
                {
4276
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4277
                    if (btnConsolidate != null)
4278
                    {
4279
                        btnConsolidate.Visibility = Visibility.Collapsed;
4280
                    }
4281
                }
4282
            }
4283
        }
4284

    
4285
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4286
        {
4287
            UpdateMyMarkupList();
4288

    
4289
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4290
            {
4291
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4292
            }
4293
            else
4294
            {
4295
                ViewerDataModel.Instance.IsConsolidate = true;
4296
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4297
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4298

    
4299
                string project_no = App.ViewInfo.ProjectNO;
4300
                string doc_id = _DocInfo.ID;
4301
                string user_id = App.ViewInfo.UserID;
4302
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4303
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4304
                {
4305
                    markupInfoItems.Add(item);
4306
                }
4307
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4308
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4309
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4310
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4311

    
4312
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4313
                if (item2 != null)
4314
                {
4315
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4316

    
4317
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4318
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4319
                }
4320
                else
4321
                {
4322
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4323
                }
4324
            }
4325
        }
4326

    
4327
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4328
        {
4329
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4330

    
4331
            if (App.ViewInfo != null)
4332
            {
4333
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4334
                {
4335
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4336
                }
4337
            }
4338
        }
4339

    
4340
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4341
        {
4342
            SetCompareRect();
4343
        }
4344

    
4345
        private void Sync_Click(object sender, RoutedEventArgs e)
4346
        {
4347
            if (Sync.IsChecked)
4348
            {
4349
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4350
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4351
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4352
            }
4353
        }
4354

    
4355
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4356
        {
4357
            if (UserList.IsChecked)
4358
            {
4359
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4360
            }
4361
            else
4362
            {
4363
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4364
            }
4365
        }
4366

    
4367
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4368
        {
4369

    
4370
            if (BalanceMode.IsChecked)
4371
            {
4372
                ViewerDataModel.Instance.PageBalanceMode = true;
4373
            }
4374
            else
4375
            {
4376
                ViewerDataModel.Instance.PageBalanceMode = false;
4377
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4378
            }
4379
        }
4380

    
4381
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4382
        {
4383
            //초기화
4384
            testPanel2.IsHidden = true;
4385
            ViewerDataModel.Instance.PageBalanceMode = false;
4386
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4387
            ViewerDataModel.Instance.PageNumber = 0;
4388
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4389
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4390
            UserList.IsChecked = false;
4391
            BalanceMode.IsChecked = false;
4392
        }
4393

    
4394
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4395
        {
4396
            if ((sender as System.Windows.Controls.Control).Tag != null)
4397
            {
4398
                //Compare 초기화
4399
                CompareMode.IsChecked = false;
4400
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4401

    
4402
                if (ViewerDataModel.Instance.PageNumber == 0)
4403
                {
4404
                    ViewerDataModel.Instance.PageNumber = 1;
4405
                }
4406

    
4407
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4408
                {
4409
                }
4410
                else
4411
                {
4412
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4413
                }
4414

    
4415

    
4416

    
4417
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4418
                {
4419

    
4420
                }
4421
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4422
                {
4423
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4424
                }
4425

    
4426
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4427

    
4428
                if (!testPanel2.IsHidden)
4429
                {
4430
                    if (IsSyncPDFMode)
4431
                    {
4432
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4433
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4434

    
4435
                        if (pdfpath.IsDownloading)
4436
                        {
4437
                            pdfpath.DownloadCompleted += (ex, arg) =>
4438
                            {
4439
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4440
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4441
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4442
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4443
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4444
                            };
4445
                        }
4446
                        else
4447
                        {
4448
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4449
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4450
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4451

    
4452
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4453
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4454
                        }
4455

    
4456
                    }
4457
                    else
4458
                    {
4459
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4460

    
4461
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4462

    
4463
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4464
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4465
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4466

    
4467
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4468
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4469

    
4470
                        if (defaultBitmapImage_Compare.IsDownloading)
4471
                        {
4472
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4473
                            {
4474
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4475
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4476
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4477

    
4478
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4479
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4480
                            };
4481
                        }
4482
                    }
4483

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

    
4488
                    foreach (var item in gridSelectionRevItem)
4489
                    {
4490
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4491
                        {
4492
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4493
                        });
4494
                    }
4495

    
4496
                    //강인구 추가
4497
                    zoomAndPanControl2.ZoomTo(new Rect
4498
                    {
4499
                        X = 0,
4500
                        Y = 0,
4501
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4502
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4503
                    });
4504

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

    
4507
                }
4508
            }
4509
        }
4510

    
4511
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4512
        {
4513
            if (MarkupMode.IsChecked)
4514
            {
4515
                IsSyncPDFMode = true;
4516

    
4517
                var uri = CurrentRev.TO_VENDOR;
4518

    
4519
                if (ViewerDataModel.Instance.PageNumber == 0)
4520
                {
4521
                    ViewerDataModel.Instance.PageNumber = 1;
4522
                }
4523

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

    
4528
                if (pdfpath.IsDownloading)
4529
                {
4530
                    pdfpath.DownloadCompleted += (ex, arg) =>
4531
                    {
4532
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4533
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4534
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4535
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4536
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4537
                    };
4538
                }
4539
                else
4540
                {
4541
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4542
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4543
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4544

    
4545
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4546
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4547
                }
4548
            }
4549
            else
4550
            {
4551
                IsSyncPDFMode = false;
4552
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4553

    
4554
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4555

    
4556
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4557
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4558
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4559

    
4560
                if (defaultBitmapImage_Compare.IsDownloading)
4561
                {
4562
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4563
                    {
4564
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4565
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4566
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4567
                    };
4568
                }
4569
                zoomAndPanControl2.ApplyTemplate();
4570
                zoomAndPanControl2.UpdateLayout();
4571
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4572
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4573
            }
4574
        }
4575

    
4576
        /// <summary>
4577
        /// Compare된 영역을 초기화
4578
        /// </summary>
4579
        private void ClearCompareRect()
4580
        {
4581
            da.From = 1;
4582
            da.To = 1;
4583
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4584
            da.AutoReverse = false;
4585
            canvas_compareBorder.Children.Clear();
4586
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4587
        }
4588

    
4589
        /// <summary>
4590
        /// 문서 Comprare 
4591
        /// </summary>
4592
        private void SetCompareRect()
4593
        {
4594
            if (CompareMode.IsChecked)
4595
            {
4596
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4597
                {
4598
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4599
                }
4600
                if (ViewerDataModel.Instance.PageNumber == 0)
4601
                {
4602
                    ViewerDataModel.Instance.PageNumber = 1;
4603
                }
4604

    
4605
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4606
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4607
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4608

    
4609
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4610
            }
4611
            else
4612
            {
4613
                ClearCompareRect();
4614
            }
4615
        }
4616

    
4617
        private void RadButton_Click(object sender, RoutedEventArgs e)
4618
        {
4619
            gridViewHistory_Busy.IsBusy = true;
4620

    
4621
            RadButton instance = sender as RadButton;
4622
            if (instance.CommandParameter != null)
4623
            {
4624
                CurrentRev = instance.CommandParameter as VPRevision;
4625
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4626

    
4627
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4628
                {
4629
                    if (ea.Error == null && ea.Result != null)
4630
                    {
4631
                        testPanel2.IsHidden = false;
4632

    
4633
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4634
                        foreach(var info in ea.Result)
4635
                        {
4636
                            if(info.UserID == App.ViewInfo.UserID)
4637
                            {
4638
                                info.userDelete = true;
4639
                                info.DisplayColor = "FFFF0000";
4640
                            }
4641
                            else
4642
                            {
4643
                                info.userDelete = false;
4644
                            }
4645
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4646
                        }
4647
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4648

    
4649
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4650

    
4651
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4652

    
4653
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4654
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4655
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4656
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4657
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4658
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4659

    
4660
                        zoomAndPanControl2.ApplyTemplate();
4661
                        zoomAndPanControl2.UpdateLayout();
4662
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4663
                        {
4664
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4665
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4666
                        }
4667

    
4668
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4669
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4670
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4671

    
4672
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4673
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4674
                        gridViewHistory_Busy.IsBusy = false;
4675
                    }
4676

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

    
4679
                    if (GetSyncMarkupInfoItemshandler != null)
4680
                    {
4681
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4682
                    }
4683

    
4684
                    ClearCompareRect();
4685
                    SetCompareRect();
4686
                };
4687

    
4688
                /// 중복 실행이 발생하여 수정함.
4689
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4690
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4691

    
4692
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4693
            }
4694
        }
4695

    
4696
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4697
        {
4698
            try
4699
            {
4700
                if (sender is RadButton)
4701
                {
4702
                    if ((sender as RadButton).Tag != null)
4703
                    {
4704
                        var url = (sender as RadButton).Tag.ToString();
4705
                        System.Diagnostics.Process.Start(url);
4706
                    }
4707
                    else
4708
                    {
4709
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4710
                    }
4711
                }
4712
            }
4713
            catch (Exception ex)
4714
            {
4715
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4716
            }
4717
        }
4718

    
4719
        public void Sync_Event(VPRevision Currnet_Rev)
4720
        {
4721
            CurrentRev = Currnet_Rev;
4722

    
4723
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4724
            {
4725
                if (ea.Error == null && ea.Result != null)
4726
                {
4727
                    testPanel2.IsHidden = false;
4728

    
4729
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4730
                    foreach(var info in ea.Result)
4731
                    {
4732
                        if(info.UserID == App.ViewInfo.UserID)
4733
                        {
4734
                            info.userDelete = true;
4735
                            info.DisplayColor = "FFFF0000";
4736
                        }
4737
                        else
4738
                        {
4739
                            info.userDelete = false;
4740
                        }
4741
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4742
                    }
4743
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4744

    
4745
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4746

    
4747
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4748

    
4749
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4750

    
4751
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4752
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4753
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4754

    
4755
                    if (defaultBitmapImage_Compare.IsDownloading)
4756
                    {
4757
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4758
                        {
4759
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4760
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4761
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4762
                        };
4763
                    }
4764

    
4765

    
4766
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4767
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4768
                    zoomAndPanControl2.ApplyTemplate();
4769
                    zoomAndPanControl2.UpdateLayout();
4770

    
4771
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4772
                    {
4773
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4774
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4775
                    }
4776
                    //}
4777

    
4778
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4779
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4780
                    gridViewHistory_Busy.IsBusy = false;
4781
                }
4782
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4783

    
4784
            };
4785
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4786
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4787
        }
4788

    
4789
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4790
        {
4791
            if (sender is Image)
4792
            {
4793
                if ((sender as Image).Tag != null)
4794
                {
4795
                    var pdfUrl = (sender as Image).Tag.ToString();
4796
                    System.Diagnostics.Process.Start(pdfUrl);
4797
                }
4798
                else
4799
                {
4800
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4801
                }
4802
            }
4803
        }
4804

    
4805
        private void Create_Symbol(object sender, RoutedEventArgs e)
4806
        {
4807
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4808

    
4809
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4810
            {
4811
                DialogMessage_Alert("Please Select Controls", "Alert");
4812
            }
4813
            else //선택된 것이 있으면
4814
            {
4815
                string MarkupData = "";
4816
                adorner_ = new AdornerFinal();
4817

    
4818
                foreach (var item in SelectLayer.Children)
4819
                {
4820
                    if (item.GetType().Name == "AdornerFinal")
4821
                    {
4822
                        adorner_ = (item as Controls.AdornerFinal);
4823
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4824
                        {
4825
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4826
                            {
4827
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4828
                                MarkupData += markupReturn.ConvertData;
4829
                            }
4830
                        }
4831
                    }
4832
                }
4833
                DialogParameters parameters = new DialogParameters()
4834
                {
4835
                    Owner = Application.Current.MainWindow,
4836
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4837
                    DefaultPromptResultValue = "Custom State",
4838
                    Content = "Name :",
4839
                    Header = "Insert Custom Symbol Name",
4840
                    Theme = new VisualStudio2013Theme(),
4841
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4842
                };
4843
                RadWindow.Prompt(parameters);
4844
            }
4845

    
4846
        }
4847
        public int symbolselectindex = 0;
4848
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4849
        {
4850
            //Save save = new Save();
4851
            try
4852
            {
4853
                string svgfilename = null;
4854
                if (symbolname != null)
4855
                {
4856
                    if (symbolpng == true || symbolsvg == true)
4857
                    {
4858
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4859
                        string guid = Commons.shortGuid();
4860

    
4861
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4862
                        //Check_Uri.UriCheck();
4863
                        fileUploader.RunCompleted += (ex, arg) =>
4864
                        {
4865
                            filename = arg.Result;
4866
                            if (symbolpng == true)
4867
                            {
4868
                                if (filename != null)
4869
                                { 
4870
                                    if (symbolselectindex == 0)
4871
                                    {
4872
                                        SymbolSave(symbolname, filename, data);
4873
                                    }
4874
                                    else
4875
                                    {
4876
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4877
                                    }
4878
                                    DataBind();
4879
                                }                                
4880
                            }
4881

    
4882
                            if (symbolsvg == true)
4883
                            {
4884
                                try
4885
                                {
4886
                                    var defaultBitmapImage = new BitmapImage();
4887
                                    defaultBitmapImage.BeginInit();
4888
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4889
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4890
                                    Check_Uri.UriCheck(filename);
4891
                                    defaultBitmapImage.UriSource = new Uri(filename);
4892
                                    defaultBitmapImage.EndInit();
4893

    
4894
                                    System.Drawing.Bitmap image;
4895

    
4896
                                    if (defaultBitmapImage.IsDownloading)
4897
                                    {
4898
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4899
                                        {
4900
                                            defaultBitmapImage.Freeze();
4901
                                            image = GetBitmap(defaultBitmapImage);
4902
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4903
                                            Process potrace = new Process
4904
                                            {
4905
                                                StartInfo = new ProcessStartInfo
4906
                                                {
4907
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4908
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4909
                                                    RedirectStandardInput = true,
4910
                                                    RedirectStandardOutput = true,
4911
                                                    RedirectStandardError = true,
4912
                                                    UseShellExecute = false,
4913
                                                    CreateNoWindow = true,
4914
                                                    WindowStyle = ProcessWindowStyle.Hidden
4915
                                                },
4916
                                            };
4917

    
4918
                                            StringBuilder svgBuilder = new StringBuilder();
4919
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4920
                                            {
4921
                                                svgBuilder.AppendLine(e2.Data);
4922
                                            };
4923

    
4924
                                            potrace.EnableRaisingEvents = true;
4925
                                            potrace.Start();
4926
                                            potrace.Exited += (sender, e) =>
4927
                                            {
4928
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4929
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4930
                                                Check_Uri.UriCheck(svgfilename);
4931
                                                if (symbolselectindex == 0)
4932
                                                {
4933
                                                    SymbolSave(symbolname, svgfilename, data);
4934
                                                }
4935
                                                else
4936
                                                {
4937
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4938
                                                }
4939

    
4940
                                                DataBind();
4941
                                            };
4942
                                            potrace.WaitForExit();
4943
                                        };
4944
                                    }
4945
                                    else
4946
                                    {
4947
                                        //GC.Collect();
4948
                                    }
4949
                                }
4950
                                catch(Exception ee)
4951
                                {
4952
                                    DialogMessage_Alert("" + ee, "Alert");
4953
                                }
4954
                            }
4955
                        };                                             
4956
                    }
4957
                }
4958
            }
4959
            catch (Exception e)
4960
            {
4961
                //DialogMessage_Alert(e + "", "Alert");
4962
            }            
4963
        }
4964

    
4965
        public void SymbolSave(string Name, string Url, string Data)
4966
        {
4967
            try
4968
            {
4969
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4970
                {
4971
                    ID = Commons.shortGuid(),
4972
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4973
                    NAME = Name,
4974
                    IMAGE_URL = Url,
4975
                    DATA = Data
4976
                };
4977

    
4978
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4979
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4980
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4981
            }
4982
            catch (Exception)
4983
            {
4984
                throw;
4985
            }
4986
        }
4987

    
4988
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4989
        {
4990
            try
4991
            {
4992
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4993
                {
4994
                    ID = Commons.shortGuid(),
4995
                    DEPARTMENT = Department,
4996
                    NAME = Name,
4997
                    IMAGE_URL = Url,
4998
                    DATA = Data
4999
                };
5000
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5001
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5002
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5003
            }
5004
            catch (Exception)
5005
            {
5006
                throw;
5007
            }
5008
        }
5009

    
5010
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5011
        {           
5012
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5013
            DataBind();
5014
        }
5015

    
5016
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5017
        {
5018
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5019
            DataBind();
5020
        }
5021
        private void DataBind()
5022
        {
5023
            try
5024
            {
5025
                Symbol_Custom Custom = new Symbol_Custom();
5026
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5027
                
5028
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5029
                foreach (var item in symbol_Private)
5030
                {
5031
                    Custom.Name = item.NAME;
5032
                    Custom.ImageUri = item.IMAGE_URL;
5033
                    Custom.ID = item.ID;
5034
                    Custom_List.Add(Custom);
5035
                    Custom = new Symbol_Custom();
5036
                }
5037
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5038
                
5039
                Custom = new Symbol_Custom();
5040
                Custom_List = new List<Symbol_Custom>();
5041

    
5042
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5043

    
5044
                List<SYMBOL_PUBLIC> symbol_Public;
5045

    
5046
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5047
                {
5048
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5049
                }
5050
                else
5051
                {
5052
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5053
                }
5054
                foreach (var item in symbol_Public)
5055
                {
5056
                    Custom.Name = item.NAME;
5057
                    Custom.ImageUri = item.IMAGE_URL;
5058
                    Custom.ID = item.ID;
5059
                    Custom_List.Add(Custom);
5060
                    Custom = new Symbol_Custom();
5061
                }
5062
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5063
                BaseClient.Close();                
5064
            }
5065
            catch(Exception e)
5066
            {
5067
                //DialogMessage_Alert("DataBind", "Alert");
5068
            }
5069
            
5070
        }
5071
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5072
        {
5073
            try
5074
            {
5075
                if (args.PromptResult != null)
5076
                {
5077
                    if (args.DialogResult.Value)
5078
                    {
5079
                        PngBitmapEncoder _Encoder = symImage(data);
5080

    
5081
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5082
                        _Encoder.Save(fs);
5083
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5084

    
5085
                        byte[] Img_byte = fs.ToArray();
5086

    
5087
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5088
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5089
                        Check_Uri.UriCheck(filename);
5090
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5091
                        {
5092
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5093
                        }
5094
                        else
5095
                        {
5096
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5097
                        }
5098
                        DataBind();
5099
                    }
5100
                }
5101
            }
5102
            catch(Exception ex)
5103
            {
5104
                DialogMessage_Alert("" + ex, "Alert");
5105
            }
5106
        }
5107

    
5108
        public PngBitmapEncoder symImage(string data)
5109
        {
5110

    
5111
            Canvas _canvas = new Canvas();
5112
            _canvas.Background = Brushes.White;
5113
            _canvas.Width = adorner_.BorderSize.Width;
5114
            _canvas.Height = adorner_.BorderSize.Height;
5115
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5116

    
5117
            BitmapEncoder encoder = new PngBitmapEncoder();
5118

    
5119

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

    
5122
            DrawingVisual dv = new DrawingVisual();
5123

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

    
5127
            using (DrawingContext ctx = dv.RenderOpen())
5128
            {
5129
                VisualBrush vb = new VisualBrush(_canvas);
5130
                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)));
5131
            }
5132

    
5133
            try
5134
            {
5135
                renderBitmap.Render(dv);
5136

    
5137
                //GC.Collect();
5138
                GC.WaitForPendingFinalizers();
5139
                //GC.Collect();
5140
                // encode png data
5141
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5142
                // puch rendered bitmap into it
5143
                pngEncoder.Interlace = PngInterlaceOption.Off;
5144
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5145
                return pngEncoder;
5146

    
5147
            }
5148
            catch //(Exception ex)
5149
            {
5150
                return null;
5151
            }
5152

    
5153
        }
5154

    
5155
        public void DialogMessage_Alert(string content, string header)
5156
        {
5157
            DialogParameters parameters = new DialogParameters()
5158
            {
5159
                Owner = this.ParentOfType<MainWindow>(),
5160
                Content = new TextBlock()
5161
                { 
5162
                    MinWidth = 400,
5163
                    FontSize = 11,
5164
                    Text = content,
5165
                    TextWrapping = System.Windows.TextWrapping.Wrap
5166
                },
5167
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5168
                Header = header,
5169
                Theme = new VisualStudio2013Theme(),
5170
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5171
            };            
5172
            RadWindow.Alert(parameters);
5173
        }
5174

    
5175
        #region 캡쳐 기능
5176

    
5177
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5178
        {
5179
            if (x < 0)
5180
            {
5181
                width += x;
5182
                x = 0;
5183
            }
5184
            if (y < 0)
5185
            {
5186
                height += y;
5187
                y = 0;
5188

    
5189
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5190
            }
5191
            if (x + width > zoomAndPanCanvas.ActualWidth)
5192
            {
5193
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5194
            }
5195
            if (y + height > zoomAndPanCanvas.ActualHeight)
5196
            {
5197
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5198
            }
5199

    
5200
            byte[] pixels = CopyPixels(x, y, width, height);
5201

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

    
5204
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5205
        }
5206

    
5207
        public byte[] CopyPixels(int x, int y, int width, int height)
5208
        {
5209
            byte[] pixels = new byte[width * height * 4];
5210
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5211

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

    
5215
            return pixels;
5216
        }
5217

    
5218
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5219
        {
5220
            DrawingVisual drawingVisual = new DrawingVisual();
5221
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5222

    
5223
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5224
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5225
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5226
            drawingContext.Close();
5227

    
5228
            // 비트맵으로 변환합니다.
5229
            RenderTargetBitmap target =
5230
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5231
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5232

    
5233
            target.Render(drawingVisual);
5234
            return target;
5235
        }
5236

    
5237
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5238
        {
5239
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5240
            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);
5241
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5242
            bmp.UnlockBits(data);
5243
            return bmp;
5244
        }
5245
        public string symbolname = null;
5246
        public bool symbolsvg = true;
5247
        public bool symbolpng = true;
5248

    
5249
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5250
        {
5251
            System.Drawing.Bitmap image = GetBitmap(source);
5252
            //흰색 제거
5253
            //image.MakeTransparent(System.Drawing.Color.White);
5254

    
5255
            var imageStream = new System.IO.MemoryStream();
5256
            byte[] imageBytes = null;
5257
            using (imageStream)
5258
            {
5259
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5260
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5261
                imageStream.Position = 0;
5262
                imageBytes = imageStream.ToArray();
5263
            }
5264

    
5265
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5266

    
5267
            RadWindow CheckPop = new RadWindow();
5268
            //Alert check = new Alert(Msg);
5269

    
5270
            CheckPop = new RadWindow
5271
            {
5272
                MinWidth = 400,
5273
                MinHeight = 100,
5274
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5275
                Header = "Alert",
5276
                Content = symbolPrompt,
5277
                //DialogResult = 
5278
                ResizeMode = System.Windows.ResizeMode.NoResize,
5279
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5280
                IsTopmost = true,
5281
            };
5282
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5283
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5284
            CheckPop.ShowDialog();
5285

    
5286
            /*
5287
            DialogParameters parameters = new DialogParameters()
5288
            {
5289
                Owner = Application.Current.MainWindow,
5290
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5291
                DefaultPromptResultValue = "Custom State",
5292
                Content = "Name :",
5293
                Header = "Insert Custom Symbol Name",
5294
                Theme = new VisualStudio2013Theme(),
5295
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5296
            };            
5297
            RadWindow.Prompt(parameters);
5298
            */
5299
        }
5300

    
5301
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5302
        {
5303
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5304
            KCOMDataModel.DataModel.CHECK_LIST check_;
5305
            string Result = streamToBase64.ImageToBase64(source);
5306
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5307
            string projectno = App.ViewInfo.ProjectNO;
5308
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5309

    
5310
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5311
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5312
            if (Item != null)
5313
            {
5314
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5315
            }
5316
            else
5317
            {
5318
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5319
            }
5320

    
5321
            if (Item == null)
5322
            {
5323
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5324
                {
5325
                    ID = Commons.shortGuid(),
5326
                    USER_ID = App.ViewInfo.UserID,
5327
                    IMAGE_URL = Result,
5328
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5329
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5330
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5331
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5332
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5333
                    STATUS = "False",
5334
                    CREATE_TIME = DateTime.Now,
5335
                    UPDATE_TIME = DateTime.Now,
5336
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5337
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5338
                };
5339
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5340
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5341
                //this.BaseClient.AddCheckList(projectno, check_);
5342
            }
5343
            else
5344
            {
5345
                Item.IMAGE_URL = Result;
5346
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5347
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5348
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5349
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5350
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5351
            }
5352

    
5353
        }
5354

    
5355
        public void Set_Capture()
5356
        {
5357
            double x = CanvasDrawingMouseDownPoint.X;
5358
            double y = CanvasDrawingMouseDownPoint.Y;
5359
            double width = dragCaptureBorder.Width;
5360
            double height = dragCaptureBorder.Height;
5361

    
5362
            if (width > 5 || height > 5)
5363
            {
5364
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5365
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5366
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5367
            }
5368
        }
5369
        #endregion
5370

    
5371
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5372
        {
5373
            multi_Undo_Data = new Multi_Undo_data();
5374

    
5375
            multi_Undo_Data.Markup = control;
5376

    
5377
            if ((control as IShapeControl) != null)
5378
            {
5379
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5380
            }
5381
            if ((control as IDashControl) != null)
5382
            {
5383
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5384
            }
5385
            if ((control as IPath) != null)
5386
            {
5387
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5388
            }
5389
            if ((control as UIElement) != null)
5390
            {
5391
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5392
            }
5393

    
5394
            return multi_Undo_Data;
5395
        }
5396

    
5397
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5398
        {
5399
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5400
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5401
            {
5402
                if (items.UserID == Select_ID)
5403
                {
5404
                    foreach (var item in items.MarkupList)
5405
                    {
5406
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5407
                        {
5408
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5409
                                items.MarkupInfoID, Commons.shortGuid());
5410
                        }
5411
                    }
5412
                }
5413
            }
5414
        }
5415

    
5416
        /// <summary>
5417
        /// convert inkcontrol to polygoncontrol
5418
        /// </summary>
5419
        public void ConvertInkControlToPolygon()
5420
        {
5421
            if (inkBoard.Strokes.Count > 0)
5422
            {
5423
                inkBoard.Strokes.ToList().ForEach(stroke =>
5424
                {
5425
                    InkToPath ip = new InkToPath();
5426

    
5427
                    List<Point> inkPointSet = new List<Point>();
5428
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5429

    
5430
                    PolygonControl pc = new PolygonControl()
5431
                    {
5432
                        CommentAngle = 0,
5433
                        PointSet = inkPointSet,
5434
                        ControlType = ControlType.Ink
5435
                    };
5436
                    pc.StartPoint = inkPointSet[0];
5437
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5438
                    pc.LineSize = 3;
5439
                    pc.CommentID = Commons.shortGuid();
5440
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5441

    
5442
                    if (pc.PointSet.Count > 0)
5443
                    {
5444
                        CreateCommand.Instance.Execute(pc);
5445
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5446
                    }
5447
                });
5448
                inkBoard.Strokes.Clear();
5449
            }
5450
        }
5451

    
5452
        /// <summary>
5453
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5454
        /// </summary>
5455
        /// <author>ingu</author>
5456
        /// <date>2018.06.05</date>
5457
        /// <param name="getPoint"></param>
5458
        /// <returns></returns>
5459
        private bool IsGetoutpoint(Point getPoint)
5460
        {
5461
            if (getPoint == new Point())
5462
            {
5463
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5464
                currentControl = null;
5465
                return true;
5466
            }
5467

    
5468
            return false;
5469
        }
5470

    
5471
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5472
        {
5473
            e.Effects = DragDropEffects.Copy;
5474
        }
5475

    
5476
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5477
        {
5478
            e.Effects = DragDropEffects.Copy;
5479
        }
5480

    
5481
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5482
        {
5483
            e.Effects = DragDropEffects.None;
5484
        }
5485

    
5486
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5487
        {
5488
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5489
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5490

    
5491
            ScaleImage(pageWidth, pageHeight);
5492
        }
5493

    
5494
        /// <summary>
5495
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5496
        /// </summary>
5497
        /// <param name="pageWidth">원본 사이즈</param>
5498
        /// <param name="pageHeight">원본 사이즈</param>
5499
        /// <returns></returns>
5500
        private void ScaleImage(double pageWidth,double pageHeight)
5501
        {
5502
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5503
        }
5504

    
5505
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5506
        {
5507
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5508
        }
5509

    
5510

    
5511
        /*
5512
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5513
        {
5514
            try
5515
            {
5516
                if (e.Data.GetDataPresent(typeof(string)))
5517
                {
5518
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5519
                    string dragData = e.Data.GetData(typeof(string)) as string;
5520
                    Move_Symbol(sender, dragData);
5521
                }
5522
            }
5523
            catch (Exception ex)
5524
            {
5525
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5526
            }            
5527
        }
5528
        */
5529
    }
5530

    
5531
    public class testItem
5532
    {
5533
        public string Title { get; set; }
5534
    }
5535
}
클립보드 이미지 추가 (최대 크기: 500 MB)