프로젝트

일반

사용자정보

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

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

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

1

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

    
39
namespace KCOM.Views
40
{
41
    public static class ControlExtensions
42
    {
43
        public static T Clone<T>(this T controlToClone)
44
            where T : System.Windows.Controls.Control
45
        {
46
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
47

    
48
            T instance = Activator.CreateInstance<T>();
49

    
50
            foreach (PropertyInfo propInfo in controlProperties)
51
            {
52
                if (propInfo.CanWrite)
53
                {
54
                    if (propInfo.Name != "WindowTarget")
55
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
56
                }
57
            }
58
            return instance;
59
        }
60
    }
61

    
62
    public class MyConsole
63
    {
64
        private readonly System.Threading.ManualResetEvent _readLineSignal;
65
        private string _lastLine;
66
        public MyConsole()
67
        {
68
            _readLineSignal = new System.Threading.ManualResetEvent(false);
69
            Gui = new TextBox();
70
            Gui.AcceptsReturn = true;
71
            Gui.KeyUp += OnKeyUp;
72
        }
73

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

    
86
        public TextBox Gui { get; private set; }
87

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

    
101
        public void WriteLine(string line)
102
        {
103
            if (!Gui.Dispatcher.CheckAccess())
104
            {
105
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
106
                return;
107
            }
108

    
109
            Gui.Text += line + Environment.NewLine;
110
        }
111
    }
112

    
113
    /// <summary>
114
    /// MainMenu.xaml에 대한 상호 작용 논리
115
    /// </summary>
116
    public partial class MainMenu : UserControl
117
    {
118
        #region 프로퍼티
119
        public CommentUserInfo currentControl { get; set; }
120
        public ControlType controlType { get; set; }
121
        private Move move = new Move();
122
        private double[] rotateValue = { 0, 90, 180, 270 };
123
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
124
        private static readonly double DragThreshold = 5;
125
        private System.Windows.Input.Cursor cursor { get; set; }
126

    
127
        /// <summary>
128
        ///  문서의 마우스 위치
129
        /// </summary>
130
        public Point CanvasDrawingMouseDownPoint;
131

    
132
        public string filename { get; set; }
133
        private Point canvasZoomPanningMouseDownPoint;
134
        public Point getCurrentPoint;
135
        private Point canvasZoommovingMouseDownPoint;
136
        List<object> ControlList = new List<object>();
137
        private ListBox listBox = new ListBox();
138
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
139
        private bool isDraggingSelectionRect = false;
140
        DrawingAttributes inkDA = new DrawingAttributes();
141
        private VPRevision CurrentRev { get; set; }
142
        public RadRibbonButton btnConsolidate { get; set; }
143
        public RadRibbonButton btnFinalPDF { get; set; }
144
        public RadRibbonButton btnTeamConsolidate { get; set; }
145
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
146

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

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

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

    
180
                }
181
            }
182
        }
183

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

    
208
        public bool IsSyncPDFMode { get; set; }
209

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

    
234
        #endregion
235

    
236
        public MainMenu()
237
        {
238
            //App.splashString(ISplashMessage.MAINMENU_0);            
239
           InitializeComponent();
240

    
241
            //List<testItem> testItems = new List<testItem>
242
            //{
243
            //    new testItem{Title = "test1"},
244
            //    new testItem{Title = "test2"},
245
            //    new testItem{Title = "test3"},
246
            //    new testItem{Title = "test4"},
247
            //};
248

    
249
            //lstSymbolPrivate.ItemsSource = testItems;
250

    
251
            this.Loaded += MainMenu_Loaded;
252
        }
253

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

    
264
        List<TempDt> tempDtList = new List<TempDt>();
265

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

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

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

    
291
            return uri;
292
        }
293

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

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

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

    
335
            return false;
336
        }
337

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

    
361
            return false;
362
        }
363

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

    
370
            
371
            ViewerDataModel.Instance._markupInfoList.Remove(item);
372

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

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

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

    
392
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
393

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

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

    
455
                        Button content = (sender as Button);
456
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
457

    
458
                        DeleteItem(item);
459
                    }
460
                }
461
            };
462
            RadWindow.Confirm(parameters);
463
        }
464

    
465
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
466

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

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

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

    
496
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
497

    
498
        }
499

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

    
512
                    client.DownloadProgressChanged += (snd, evt) =>
513
                    {
514
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
515

    
516
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
517
                    };
518

    
519
                    await task;
520

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

    
532
        private void timercallback(Object o)
533
        {
534
            Stopwatch sw = new Stopwatch();
535
            sw.Start();
536
            TempFile.TempFileAdd();
537
            sw.Stop();
538

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

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

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

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

    
588
            if(this.pageNavigator.CurrentPage != null)
589
            { 
590
                /// delete markup list
591
                int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
592

    
593
                var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
594
                              where (markup.PageNumber == iPageNo) 
595
                              && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
596
                              select markup).ToList();
597

    
598
                foreach (var markup in deleted)
599
                {
600
                    ViewerDataModel.Instance.MyMarkupList.Remove(markup);
601
                }
602
            }
603
            else
604
            {
605
                System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
606
            }
607

    
608
            /// up to here
609

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

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

    
630
        DispatcherTimer renderTesttimer;
631

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

    
643
            // 마크업 로드
644
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
645
            await MarkupLoadAsync(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 async Task MarkupLoadAsync(int pageNumber)
823
        {
824
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
825
            stopwatch.Start();
826

    
827
            /// 컨트롤을 새로 생성한다.
828
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
829
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
830

    
831
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
832

    
833
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
834
            { 
835
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
836
                if (info != null)
837
                {
838
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
839
                    if (info.UserID == App.ViewInfo.UserID)
840
                    {
841
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
842
                                        markup.MarkupInfoID, markup.ID);
843
                        control.Visibility = Visibility.Hidden;
844
                    }
845
                    else
846
                    {
847
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
848
                                                                markup.MarkupInfoID, markup.ID);
849
                        control.Visibility = Visibility.Hidden;
850
                    }
851
                }
852
            };
853
            /// up to here
854

    
855
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
856

    
857
            /// fire selection event
858
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
859
            this.gridViewMarkup.UnselectAll();
860
            this.gridViewMarkup.Select(gridSelectionItem);
861

    
862
            if (!testPanel2.IsHidden)
863
            {
864
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
865
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
866
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
867

    
868
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
869
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
870

    
871

    
872
                foreach (var item in gridSelectionRevItem)
873
                {
874
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
875

    
876
                    foreach (var markupitem in markupitems)
877
                    {
878
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
879
                    }
880
                }
881
            }
882

    
883
            SetCommentPages();
884
        }
885

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

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

    
939
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
940
        {
941
            var instance = ViewerDataModel.Instance;
942

    
943
            if(instance.IsWheelPageChanage)
944
            {
945
                return;
946
            }
947

    
948
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
949
            {
950
       
951
                int changePage = 0;
952
                
953
                if (e.Delta > 0)
954
                {
955
                    if (0 < instance.ContentOffsetY)
956
                    {
957
                        Vector dragOffset = new Vector(0, e.Delta);
958
                        MoveZoomAndPanControl(dragOffset);
959
                    }
960
                    //else
961
                    //{
962
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
963
                    //    {
964
                    //        instance.IsWheelPageChanage = true;
965
                    //        changePage -= 1;
966
                    //    }
967
                    //}
968
                }
969
                else if(e.Delta < 0)
970
                {
971
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
972
                    {
973
                        Vector dragOffset = new Vector(0,e.Delta);
974
                        MoveZoomAndPanControl(dragOffset);
975
                    }
976
                    //else
977
                    //{
978
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
979
                    //    {
980
                    //        instance.IsWheelPageChanage = true;
981
                    //        changePage += 1;
982
                    //    }
983
                    //}
984
                }
985

    
986
                //if (changePage != 0)
987
                //{
988
                //    await Task.Factory.StartNew(() =>
989
                //    {
990
                //        double beforeScale = instance.ContentScale;
991

    
992
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
993

    
994
                //        handler = (snd, evt) =>
995
                //        {
996
                //            /// 최상단으로 이전 zoomScale로 위치한다
997
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
998
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
999
                //            instance.IsWheelPageChanage = false;
1000
                //            pageNavigator.PageChanged -= handler;
1001
                //        };
1002

    
1003
                //        pageNavigator.PageChanged += handler;
1004

    
1005
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1006
                //    });
1007
                    
1008

    
1009
                //}
1010
            }
1011
            else
1012
            {
1013
                e.Handled = true;
1014
                if (e.Delta > 0)
1015
                {
1016
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1017
                    ZoomIn(currentContentMousePoint);
1018
                }
1019
                else
1020
                {
1021
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1022
                    ZoomOut(currentContentMousePoint);
1023
                }
1024
            }
1025
        }
1026

    
1027
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1028
        {
1029
            e.Handled = true;
1030
            if (e.Delta > 0)
1031
            {
1032
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1033
                ZoomIn_Sync(currentContentMousePoint);
1034
            }
1035
            else
1036
            {
1037
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1038
                ZoomOut_Sync(currentContentMousePoint);
1039
            }
1040
        }
1041

    
1042
        #region ZoomIn & ZoomOut
1043

    
1044
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1045
        {
1046
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1047
                zoomAndPanControl.ContentZoomFocusY));
1048
        }
1049

    
1050
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1051
        {
1052
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1053
                zoomAndPanControl.ContentZoomFocusY));
1054
        }
1055

    
1056

    
1057
        //강인구 추가 (줌 인아웃 수치 변경)
1058
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1059
        private void ZoomOut(Point contentZoomCenter)
1060
        {
1061
            if (zoomAndPanControl.ContentScale > 0.39)
1062
            {
1063
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1064
            }
1065
            else
1066
            {
1067
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1068
            }
1069

    
1070
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1071
            {
1072
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1073
            }
1074
        }
1075

    
1076
        private void ZoomIn(Point contentZoomCenter)
1077
        {
1078
            if (zoomAndPanControl.ContentScale > 0.19)
1079
            {
1080
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1081
            }
1082
            else
1083
            {
1084
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1085
            }
1086

    
1087
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1088
            {
1089
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1090
            }
1091

    
1092
        }
1093

    
1094
        private void ZoomOut_Sync(Point contentZoomCenter)
1095
        {
1096
            if (zoomAndPanControl2.ContentScale > 0.39)
1097
            {
1098
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1099
            }
1100
            else
1101
            {
1102
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1103
            }
1104

    
1105
            if (Sync.IsChecked)
1106
            {
1107
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1108
            }
1109
        }
1110

    
1111
        private void ZoomIn_Sync(Point contentZoomCenter)
1112
        {
1113
            if (zoomAndPanControl2.ContentScale > 0.19)
1114
            {
1115
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1116
            }
1117
            else
1118
            {
1119
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1120
            }
1121

    
1122
            if (Sync.IsChecked)
1123
            {
1124
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1125
            }
1126
        }
1127

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

    
1137
        private void ZoomIn()
1138
        {
1139
            zoomAndPanControl.ContentScale += 0.1;
1140
            //if (zoomAndPanControl2 != null)
1141
            //{
1142
            //    zoomAndPanControl2.ContentScale += 0.1;
1143
            //}
1144
        }
1145

    
1146
        #endregion
1147

    
1148
        private void init()
1149
        {
1150
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1151
            {
1152

    
1153
                ControlList.Clear();
1154
                listBox.Items.Clear();
1155
                selected_item.Clear();
1156

    
1157
                (item as IMarkupCommonData).IsSelected = false;
1158
            }
1159

    
1160
        }
1161

    
1162
        private HitTestResultBehavior MyCallback(HitTestResult result)
1163
        {
1164
            //this.cursor = Cursors.UpArrow;
1165
            var element = result.VisualHit;
1166
            while (element != null && !(element is CommentUserInfo))
1167
                element = VisualTreeHelper.GetParent(element);
1168

    
1169
            if (element == null)
1170
            {
1171
                return HitTestResultBehavior.Stop;
1172
            }
1173
            else
1174
            {
1175
                if (element is CommentUserInfo)
1176
                {
1177
                    if (!hitList.Contains(element))
1178
                    {
1179
                        hitList.Add((CommentUserInfo)element);
1180
                    }
1181
                    else
1182
                    {
1183
                        return HitTestResultBehavior.Stop;
1184
                    }
1185
                }
1186
            }
1187
            return HitTestResultBehavior.Continue;
1188
        }
1189

    
1190
        public void ReleaseSelectPath()
1191
        {
1192
            if (SelectionPath == null)
1193
            {
1194
                SelectionPath = new Path();
1195
                SelectionPath.Name = "";
1196
            }
1197
            if (SelectionPath.Name != "")
1198
            {
1199
                SelectionPath.Name = "None";
1200
            }
1201
            SelectionPath.Opacity = 0.01;
1202
            SelectionPath.RenderTransform = null;
1203
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1204
        }
1205

    
1206
        #region 컨트롤 초기화 
1207
        public void Control_Init(object control)
1208
        {
1209
            if (L_Size != 0 && (control as IPath) != null)
1210
            {
1211
                (control as IPath).LineSize = L_Size;
1212
                L_Size = 0;
1213
            }
1214

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

    
1301
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1302
        {
1303
            //Control_Init(e.Source);
1304
        }
1305
        //private Window _dragdropWindow = null;
1306

    
1307
        [DllImport("user32.dll")]
1308
        [return: MarshalAs(UnmanagedType.Bool)]
1309
        internal static extern bool GetCursorPos(ref Win32Point pt);
1310

    
1311
        [StructLayout(LayoutKind.Sequential)]
1312
        internal struct Win32Point
1313
        {
1314
            public Int32 X;
1315
            public Int32 Y;
1316
        };
1317
        /*
1318
       public string symbol_id = null;
1319
       public long symbol_group_id;
1320
       public int symbol_SelectedIndex;
1321
       public ImageSource symbol_img;
1322
       public string symbol_Data = null;
1323
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1324
       {
1325
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1326
               zoomAndPanCanvas.ActualHeight / 2));
1327

    
1328

    
1329
               if (this._dragdropWindow != null)
1330
               {
1331
                   this._dragdropWindow.Close();
1332
                   this._dragdropWindow = null;
1333
               }
1334

    
1335
               symbol_id = id;
1336
               symbol_group_id = group_id;
1337
               symbol_SelectedIndex = SelectedIndex;
1338
               symbol_Data = Data_;
1339
               symbol_img = img;
1340

    
1341

    
1342
               CreateDragDropWindow2(img);
1343
              
1344
    }
1345

    
1346
    private void CreateDragDropWindow2(ImageSource image)
1347
        {
1348
            this._dragdropWindow = new Window();
1349
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1350
            _dragdropWindow.WindowStyle = WindowStyle.None;
1351
            _dragdropWindow.AllowsTransparency = true;           
1352
            _dragdropWindow.AllowDrop = false;
1353
            _dragdropWindow.Background = null;
1354
            _dragdropWindow.IsHitTestVisible = false;
1355
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1356
            _dragdropWindow.Topmost = true;
1357
            _dragdropWindow.ShowInTaskbar = false;
1358
            
1359
            Rectangle r = new Rectangle();
1360
            r.Width = image.Width;
1361
            r.Height = image.Height;
1362
            r.Opacity = 0.5;            
1363
            r.Fill = new ImageBrush(image);
1364
            this._dragdropWindow.Content = r;
1365

    
1366
            Win32Point w32Mouse = new Win32Point();
1367
            GetCursorPos(ref w32Mouse);
1368

    
1369
            //w32Mouse.X = getCurrentPoint.X;
1370
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1371
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1372
            this._dragdropWindow.Show();
1373
        }
1374

    
1375
        
1376

    
1377
         */
1378

    
1379
        public void MoveZoomAndPanControl(Vector dragOffset)
1380
        {
1381
   
1382
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1383
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1384

    
1385
            if (Sync.IsChecked)
1386
            {
1387
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1388
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1389
            }
1390
        }
1391

    
1392
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1393
        {
1394
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1395
            {
1396
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1397

    
1398
                Point currentPos = e.GetPosition(rect);
1399

    
1400
                floatingTip.HorizontalOffset = currentPos.X + 20;
1401
                floatingTip.VerticalOffset = currentPos.Y;
1402
            }
1403

    
1404
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1405
            
1406
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1407
            {
1408
                SetCursor();
1409
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1410
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1411

    
1412
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1413

    
1414
                MoveZoomAndPanControl(dragOffset);
1415
            }
1416

    
1417
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1418
            {
1419
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1420
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1421
                SetCursor();
1422

    
1423
                if (currentControl != null)
1424
                {
1425
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1426
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1427
                    //강인구 추가
1428
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1429

    
1430
                    if ((currentControl as IPath) != null)
1431
                    {
1432
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1433
                    }
1434
                    if ((currentControl as LineControl) != null)
1435
                    {
1436
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1437
                    }
1438

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

    
1482

    
1483
                    #region // 모든 컨트롤의 공통기능 제어
1484
                    if (controlType != ControlType.PenControl)
1485
                    {
1486
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1487
                    }
1488

    
1489

    
1490
                    #endregion
1491

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

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

    
1567
                            }
1568
                            break;
1569

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

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

    
1592
                        case ControlType.ArrowMultiLine:
1593
                            {
1594
                                var control = currentControl as ArrowControl_Multi;
1595
                                if (control != null)
1596
                                {
1597
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1598
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1599
                                }
1600
                            }
1601
                            break;
1602

    
1603
                        case ControlType.Circle:
1604
                            {
1605
                                var control = currentControl as CircleControl;
1606

    
1607
                                if (control != null)
1608
                                {
1609
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1610
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1611
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1612
                                }
1613
                            }
1614
                            break;
1615

    
1616
                        case ControlType.PolygonCloud:
1617
                            {
1618
                                var control = currentControl as CloudControl;
1619
                                if (control != null)
1620
                                {
1621
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1622
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1623
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1624
                                }
1625
                            }
1626
                            break;
1627

    
1628
                        case ControlType.Triangle:
1629
                            {
1630
                                var control = currentControl as TriControl;
1631
                                if (control != null)
1632
                                {
1633
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1634
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1635
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1636
                                }
1637
                            }
1638
                            break;
1639

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

    
1650
                        case ControlType.Date:
1651
                            {
1652
                                var control = currentControl as DateControl;
1653
                                if (control != null)
1654
                                {
1655
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1656
                                }
1657
                            }
1658
                            break;
1659

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

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

    
1775
                                //inkBoard.Strokes.Add(stroke);
1776
                            }
1777
                            break;
1778
                    }
1779
                    return;
1780
                }
1781
            }
1782
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1783
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1784
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1785
            {
1786
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1787

    
1788
                if (isDraggingSelectionRect)
1789
                {
1790
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1791
                    e.Handled = true;
1792
                }
1793
                else if (isLeftMouseButtonDownOnWindow)
1794
                {
1795
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1796
                    double dragDistance = Math.Abs(dragDelta.Length);
1797

    
1798
                    if (dragDistance > DragThreshold)
1799
                    {
1800
                        isDraggingSelectionRect = true;
1801
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1802
                    }
1803

    
1804
                    e.Handled = true;
1805
                }
1806

    
1807
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1808
                {
1809
                }
1810
                else
1811
                {
1812
                    e.Handled = true;
1813
                }
1814
            }
1815
            /*
1816
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1817
            { //symbol      
1818
                if(_dragdropWindow != null)
1819
                {
1820
                    Win32Point w32Mouse = new Win32Point();
1821
                    GetCursorPos(ref w32Mouse);
1822

    
1823
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1824
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1825
                }                
1826
            }
1827
            */
1828
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1829
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1830
            {
1831
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1832
                if(control != null)
1833
                {
1834
                    this.cursor = Cursors.Hand;
1835
                    SetCursor();
1836
                }
1837
                else
1838
                {
1839
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1840
                    SetCursor();
1841
                }
1842
            }
1843
            else
1844
            {
1845
            }
1846
        }
1847

    
1848
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1849
        {
1850
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1851
            {
1852
                SetCursor();
1853
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1854
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1855

    
1856
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1857

    
1858
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1859
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1860

    
1861
                if (Sync.IsChecked)
1862
                {
1863
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1864
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1865
                }
1866
            }
1867
        }
1868

    
1869
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1870

    
1871
        private EllipseGeometry hitArea = new EllipseGeometry();
1872

    
1873
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1874
        {
1875
            IsDrawing = false;
1876
    
1877
            if (mouseHandlingMode != MouseHandlingMode.None)
1878
            {
1879
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1880
                {
1881
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1882

    
1883
                    SetCursor();
1884

    
1885
                    switch (controlType)
1886
                    {
1887
                        case ControlType.None:
1888
                            break;
1889
                        case ControlType.Rectangle:
1890
                            {
1891

    
1892
                            }
1893
                            break;
1894
                        case ControlType.PenControl:
1895
                            {
1896

    
1897
                            }
1898
                            break;
1899
                        default:
1900
                            break;
1901
                    }                    
1902
                }
1903
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1904
                {
1905
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1906

    
1907
                    if (isLeftMouseButtonDownOnWindow)
1908
                    {
1909
                        bool wasDragSelectionApplied = false;
1910

    
1911
                        if (isDraggingSelectionRect)
1912
                        {
1913
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1914
                            {
1915
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1916
                                mouseHandlingMode = MouseHandlingMode.None;
1917
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1918
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1919
                                Set_Symbol_Capture(endPoint);
1920
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1921
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1922
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1923
                            }
1924
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1925
                            {
1926
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1927
                                mouseHandlingMode = MouseHandlingMode.None;
1928
                                Set_Capture();
1929

    
1930
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1931
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1932
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1933
                            }
1934
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1935
                            {
1936
                                ApplyDragSelectionRect();
1937
                            }
1938
                            else
1939
                            {
1940
                                double x = Canvas.GetLeft(dragZoomBorder);
1941
                                double y = Canvas.GetTop(dragZoomBorder);
1942
                                double width = dragZoomBorder.Width;
1943
                                double height = dragZoomBorder.Height;
1944
                                Rect dragRect = new Rect(x, y, width, height);
1945

    
1946
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1947

    
1948
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1949
                            }
1950

    
1951
                            isDraggingSelectionRect = false;
1952
                            e.Handled = true;
1953
                            wasDragSelectionApplied = true;
1954
                        }
1955

    
1956
                        if (isLeftMouseButtonDownOnWindow)
1957
                        {
1958
                            isLeftMouseButtonDownOnWindow = false;
1959
                            this.ReleaseMouseCapture();
1960
                            e.Handled = true;
1961
                        }
1962

    
1963
                        if (!wasDragSelectionApplied)
1964
                        {
1965
                            init();
1966
                        }
1967
                    }
1968
                }
1969
                else if (e.RightButton == MouseButtonState.Pressed)
1970
                {
1971
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1972
                    SetCursor();
1973
                }
1974

    
1975
                zoomAndPanControl.ReleaseMouseCapture();
1976

    
1977

    
1978
                e.Handled = true;
1979
            }
1980
            else
1981
            {
1982
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1983
                SetCursor();
1984
            }
1985

    
1986
            ///mouseButtonDown = MouseButton.Left;
1987
            //controlType = ControlType.SingleLine;
1988
        }
1989

    
1990
        public void Set_Symbol_Capture(Point endPoint)
1991
        {       
1992
            double x = CanvasDrawingMouseDownPoint.X;
1993
            double y = CanvasDrawingMouseDownPoint.Y;
1994
            if(x > endPoint.X)
1995
            {
1996
                x = endPoint.X;
1997
                y = endPoint.Y;
1998
            }
1999

    
2000
            double width = dragCaptureBorder.Width;
2001
            double height = dragCaptureBorder.Height;
2002

    
2003
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2004

    
2005
            if (x < 0)
2006
            {
2007
                width += x;
2008
                x = 0;
2009
            }
2010
            if (y < 0)
2011
            {
2012
                height += y;
2013
                y = 0;
2014

    
2015
                width = (int)canvasImage.PixelWidth - x;
2016
            }
2017
            if (x + width > canvasImage.PixelWidth)
2018
            {
2019
                width = (int)canvasImage.PixelWidth - x;
2020
            }
2021
            if (y + height > canvasImage.PixelHeight)
2022
            {
2023
                height = (int)canvasImage.PixelHeight - y;
2024
            }
2025
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2026

    
2027
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2028
            var defaultBitmapImage = new BitmapImage();
2029
            defaultBitmapImage.BeginInit();
2030
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2031
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2032
            defaultBitmapImage.UriSource = new Uri(uri);
2033
            defaultBitmapImage.EndInit();
2034

    
2035
            //GC.Collect();
2036

    
2037
            if (defaultBitmapImage.IsDownloading)
2038
            {
2039
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2040
                {
2041
                    defaultBitmapImage.Freeze();
2042
                    //GC.Collect();
2043
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2044
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2045
                };
2046
            }
2047
        }
2048

    
2049
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2050
        {
2051
            ///mouseButtonDown = MouseButton.Left;
2052
        }
2053

    
2054
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2055
        {
2056
            ///mouseButtonDown = MouseButton.Left;
2057
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2058
        }
2059

    
2060
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2061
        {
2062

    
2063
        }
2064

    
2065
        /// <summary>
2066
        /// select items by dragging
2067
        /// </summary>
2068
        private void ApplyDragSelectionRect()
2069
        {
2070
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2071

    
2072
            double x = Canvas.GetLeft(dragSelectionBorder);
2073
            double y = Canvas.GetTop(dragSelectionBorder);
2074
            double width = dragSelectionBorder.Width;
2075
            double height = dragSelectionBorder.Height;
2076
            Boolean Flag = false;
2077
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2078
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2079

    
2080
            Rect dragRect = new Rect(x, y, width, height);
2081
            ///dragRect.Inflate(width / 10, height / 10);
2082

    
2083
            foreach (var item in Items)
2084
            {
2085
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2086

    
2087
                if (Flag)
2088
                {
2089
                    adornerSet.Add(item);
2090
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2091
                    Control_Style(item);
2092
                }
2093
            }
2094
            if (adornerSet.Count > 0)
2095
            {
2096
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2097
                SelectLayer.Children.Add(final);
2098
            }
2099
        }
2100

    
2101
        private void InitDragSelectionRect(Point pt1, Point pt2)
2102
        {
2103
            //캡쳐 중
2104
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2105
            {
2106
                dragCaptureBorder.Visibility = Visibility.Visible;
2107
            }
2108
            //선택 중
2109
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2110
            {
2111

    
2112
                dragSelectionBorder.Visibility = Visibility.Visible;
2113
            }
2114
            else
2115
            {
2116
                dragZoomBorder.Visibility = Visibility.Visible;
2117
            }
2118
            UpdateDragSelectionRect(pt1, pt2);
2119
        }
2120

    
2121
        /// <summary>
2122
        /// Update the position and size of the rectangle used for drag selection.
2123
        /// </summary>
2124
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2125
        {
2126
            double x, y, width, height;
2127

    
2128
            //
2129
            // Determine x,y,width and height of the rect inverting the points if necessary.
2130
            // 
2131

    
2132
            if (pt2.X < pt1.X)
2133
            {
2134
                x = pt2.X;
2135
                width = pt1.X - pt2.X;
2136
            }
2137
            else
2138
            {
2139
                x = pt1.X;
2140
                width = pt2.X - pt1.X;
2141
            }
2142

    
2143
            if (pt2.Y < pt1.Y)
2144
            {
2145
                y = pt2.Y;
2146
                height = pt1.Y - pt2.Y;
2147
            }
2148
            else
2149
            {
2150
                y = pt1.Y;
2151
                height = pt2.Y - pt1.Y;
2152
            }
2153

    
2154
            //
2155
            // Update the coordinates of the rectangle used for drag selection.
2156
            //
2157
            //캡쳐 중
2158
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2159
            {
2160
                Canvas.SetLeft(dragCaptureBorder, x);
2161
                Canvas.SetTop(dragCaptureBorder, y);
2162
                dragCaptureBorder.Width = width;
2163
                dragCaptureBorder.Height = height;
2164
            }
2165
            //선택 중
2166
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2167
            {
2168
                Canvas.SetLeft(dragSelectionBorder, x);
2169
                Canvas.SetTop(dragSelectionBorder, y);
2170
                dragSelectionBorder.Width = width;
2171
                dragSelectionBorder.Height = height;
2172
            }
2173
            else
2174
            {
2175
                Canvas.SetLeft(dragZoomBorder, x);
2176
                Canvas.SetTop(dragZoomBorder, y);
2177
                dragZoomBorder.Width = width;
2178
                dragZoomBorder.Height = height;
2179
            }
2180
        }
2181

    
2182
        private void drawingPannelRotate(double angle)
2183
        {
2184
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2185
            rotate.Angle = angle;
2186
            var rotationNum = Math.Abs((rotate.Angle / 90));
2187

    
2188
            if (angle == 90 || angle == 270)
2189
            {
2190
                double emptySize = zoomAndPanCanvas.Width;
2191
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2192
                zoomAndPanCanvas.Height = emptySize;
2193
            }
2194
            if (angle == 0)
2195
            {
2196
                translate.X = 0;
2197
                translate.Y = 0;
2198
            }
2199
            else if (angle == 90)
2200
            {
2201
                translate.X = zoomAndPanCanvas.Width;
2202
                translate.Y = 0;
2203
            }
2204
            else if (angle == 180)
2205
            {
2206
                translate.X = zoomAndPanCanvas.Width;
2207
                translate.Y = zoomAndPanCanvas.Height;
2208
            }
2209
            else
2210
            {
2211
                translate.X = 0;
2212
                translate.Y = zoomAndPanCanvas.Height;
2213
            }
2214

    
2215
            zoomAndPanControl.RotationAngle = rotate.Angle;
2216

    
2217

    
2218
            if (!testPanel2.IsHidden)
2219
            {
2220
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2221
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2222
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2223
            }
2224

    
2225
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2226
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2227
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2228
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2229
            ViewerDataModel.Instance.Angle = rotate.Angle;
2230
        }
2231

    
2232
        private void syncPannelRotate(double angle)
2233
        {
2234
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2235
            rotate.Angle = angle;
2236
            var rotationNum = Math.Abs((rotate.Angle / 90));
2237

    
2238
            if (angle == 90 || angle == 270)
2239
            {
2240
                double emptySize = zoomAndPanCanvas2.Width;
2241
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2242
                zoomAndPanCanvas2.Height = emptySize;
2243
            }
2244
            if (angle == 0)
2245
            {
2246
                translate2.X = 0;
2247
                translate2.Y = 0;
2248
            }
2249
            else if (angle == 90)
2250
            {
2251
                translate2.X = zoomAndPanCanvas2.Width;
2252
                translate2.Y = 0;
2253
            }
2254
            else if (angle == 180)
2255
            {
2256
                translate2.X = zoomAndPanCanvas2.Width;
2257
                translate2.Y = zoomAndPanCanvas2.Height;
2258
            }
2259
            else
2260
            {
2261
                translate2.X = 0;
2262
                translate2.Y = zoomAndPanCanvas2.Height;
2263
            }
2264

    
2265
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2266
        }
2267

    
2268
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2269
        {
2270
            string Data_ = "";
2271

    
2272
            try
2273
            {
2274
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2275
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2276
                if (Data_ != null || Data_ != "")
2277
                {
2278
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2279
                }
2280
                else
2281
                {
2282
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2283
                }
2284

    
2285
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2286
                //{
2287
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2288
                //    STATE = 0,
2289
                //};
2290
                if (Data_ != null)
2291
                {
2292
                    Image img = new Image();
2293
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2294
                    if (Data_.Contains(".svg"))
2295
                    {
2296
                        byte[] imageData = null;
2297
                        DrawingImage image = null;
2298
                        using (System.Net.WebClient web = new System.Net.WebClient())
2299
                        {
2300
                            imageData = web.DownloadData(new Uri(Data_));
2301
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2302
                            image = SvgReader.Load(stream);
2303
                        }
2304
                        img.Source = image;
2305
                    }
2306
                    else
2307
                    {
2308
                        img.Source = new BitmapImage(new Uri(Data_));
2309
                    }
2310

    
2311
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2312
                    {
2313
                        PointSet = new List<Point>(),
2314
                        FilePath = Data_,
2315
                        ImageData = img.Source,
2316
                        StartPoint = canvasZoomPanningMouseDownPoint,
2317
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2318
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2319
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2320
                        canvasZoomPanningMouseDownPoint.Y),
2321
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2322
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2323
                    };
2324

    
2325
                    currentControl.PointSet = new List<Point>
2326
                                        {
2327
                                            currentControl.StartPoint,
2328
                                            currentControl.LeftBottomPoint,
2329
                                            currentControl.EndPoint,
2330
                                            currentControl.TopRightPoint,
2331
                                        };
2332
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2333
                    UndoData = new Undo_data()
2334
                    {
2335
                        IsUndo = false,
2336
                        Event = Event_Type.Create,
2337
                        EventTime = DateTime.Now,
2338
                        Markup_List = new List<Multi_Undo_data>()
2339
                    };
2340
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2341
                    {
2342
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2343
                    });
2344

    
2345
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2346
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2347
                    UndoData.Markup_List.Add(multi_Undo_Data);
2348
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2349

    
2350
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2351
                    currentControl.CommentID = Commons.shortGuid();
2352
                    currentControl.SymbolID = id;
2353
                    currentControl.GroupID = group_id;
2354
                    currentControl.ApplyTemplate();
2355
                    currentControl.SetImage();
2356

    
2357
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2358
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2359
                    SelectLayer.Children.Add(final);
2360
                }
2361
            }
2362
            catch (Exception ex)
2363
            {
2364
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2365
            }
2366
        }
2367

    
2368
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2369
        {
2370
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2371
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2372
            {
2373
                set_option.Value = double.Parse(set_option.ContentText);
2374
                //set_option.Focusable = false;
2375
                zoomAndPanControl.Focus();
2376
            }
2377

    
2378
            ConvertInkControlToPolygon();
2379

    
2380
            ///TODO:
2381
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2382
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2383

    
2384
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2385
            {
2386
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2387
            }
2388
            /// up to here
2389

    
2390
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2391
            {
2392
                if (item as ArrowTextControl != null)
2393
                {
2394
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2395
                }
2396
                else if (item as TextControl != null)
2397
                {
2398
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2399
                }
2400
            }
2401

    
2402
            //if (currentControl != null)
2403
            {
2404
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2405
                if (text_item_ != null)
2406
                {
2407
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2408
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2409
                    (text_item_ as TextControl).IsEditingMode = false;                    
2410
                    currentControl = null;
2411
                }
2412

    
2413
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2414
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2415
                {
2416
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2417
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2418
                    currentControl = null;
2419
                }
2420
            }
2421

    
2422
            double Ang = 0;                                          
2423
            if (rotate.Angle != 0)
2424
            {
2425
                Ang = 360 - rotate.Angle;
2426
            }
2427

    
2428
            if (e.OriginalSource is System.Windows.Controls.Image)
2429
            {
2430
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2431
            }
2432
            /*
2433
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2434
            {                
2435
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2436
                if(symbol_id != null)
2437
                {
2438
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2439
                }                
2440
            }
2441

    
2442
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2443
            {
2444
                if (this._dragdropWindow != null)
2445
                {
2446
                    this._dragdropWindow.Close();
2447
                    this._dragdropWindow = null;
2448
                    symbol_id = null;
2449
                }
2450
            }
2451
            */
2452

    
2453
            if (e.LeftButton == MouseButtonState.Pressed)
2454
            {
2455
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2456
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2457

    
2458
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2459
                SetCursor();
2460

    
2461
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2462
            }
2463

    
2464
            if (e.MiddleButton == MouseButtonState.Pressed)
2465
            {
2466
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2467
                cursor = Cursors.SizeAll;
2468
                SetCursor();
2469
            }
2470
            if (e.RightButton == MouseButtonState.Pressed)
2471
            {
2472
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2473
                cursor = Cursors.SizeAll;
2474
                SetCursor();
2475
            }
2476
            else if (e.XButton1 == MouseButtonState.Pressed)
2477
            {
2478
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2479
                {
2480
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2481
                }
2482

    
2483
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2484

    
2485
            }
2486
            else if (e.XButton2 == MouseButtonState.Pressed)
2487
            {
2488
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2489
                {
2490
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2491
                }
2492
            }
2493

    
2494
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2495
            {
2496
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2497
                {
2498
                    if (SelectLayer.Children.Count == 0)
2499
                    {
2500
                        isLeftMouseButtonDownOnWindow = true;
2501
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2502
                    }
2503

    
2504
                    if (controlType == ControlType.None)
2505
                    {
2506
                        isLeftMouseButtonDownOnWindow = true;
2507
                    }
2508
                }
2509

    
2510
                /// 캡쳐 모드 설정
2511
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2512
                {
2513
                    dragCaptureBorder.Visibility = Visibility.Visible;
2514
                    isLeftMouseButtonDownOnWindow = true;
2515
                }
2516

    
2517
                /// 줌 모드 설정
2518
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2519
                {
2520
                    isLeftMouseButtonDownOnWindow = true;
2521
                }
2522

    
2523
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2524
                if (control != null)
2525
                {
2526
                    AdornerFinal final = null;
2527

    
2528
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2529
                    {
2530
                        /// 기존 selection 해제
2531
                        SelectionSet.Instance.UnSelect(this);
2532

    
2533
                        final = new AdornerFinal(control);
2534

    
2535
                        this.Control_Style(control);
2536

    
2537
                        if ((control as IPath) != null)
2538
                        {
2539
                            if ((control as IPath).LineSize != 0)
2540
                            {
2541
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2542
                            }
2543
                        }
2544
                        if ((control as IShapeControl) != null)
2545
                        {
2546
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2547
                            {
2548
                                ViewerDataModel.Instance.checkHatchShape = true;
2549
                            }
2550
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2551
                            {
2552
                                ViewerDataModel.Instance.checkFillShape = true;
2553
                            }
2554
                            else
2555
                            {
2556
                                ViewerDataModel.Instance.checkHatchShape = false;
2557
                                ViewerDataModel.Instance.checkFillShape = false;
2558
                            }
2559
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2560
                        }
2561

    
2562
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2563

    
2564
                        if ((control as TextControl) != null)
2565
                        {
2566
                            if(!((control as TextControl).EnableEditing)) {
2567
                                (control as TextControl).EnableEditing = true;
2568
                            }
2569
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2570
                            {
2571
                                ViewerDataModel.Instance.checkTextStyle = true;
2572
                            }
2573
                            else
2574
                            {
2575
                                ViewerDataModel.Instance.checkTextStyle = false;
2576
                            }
2577
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2578
                            {
2579
                                ViewerDataModel.Instance.checkTextWeight = true;
2580
                            }
2581
                            else
2582
                            {
2583
                                ViewerDataModel.Instance.checkTextWeight = false;
2584
                            }
2585
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2586
                            {
2587
                                ViewerDataModel.Instance.checkUnderLine = true;
2588
                            }
2589
                            else
2590
                            {
2591
                                ViewerDataModel.Instance.checkUnderLine = false;
2592
                            }
2593
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2594
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2595

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

    
2645
                        Control_Style(control);
2646

    
2647
                        final = new AdornerFinal(comment);
2648
                    }
2649

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

    
2694
                switch (controlType)
2695
                {
2696
                    case ControlType.Coordinate:
2697
                        {
2698
                            if (e.LeftButton == MouseButtonState.Pressed)
2699
                            {
2700
                                if (currentControl is CoordinateControl)
2701
                                {
2702
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2703
                                    {
2704
                                        return;
2705
                                    }
2706

    
2707
                                    CreateCommand.Instance.Execute(currentControl);
2708

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

    
2732
                                        currentControl.CommentID = Commons.shortGuid();
2733
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2734
                                        currentControl.IsNew = true;
2735

    
2736
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2737

    
2738
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2739
                                    }
2740
                                }
2741
                            }
2742
                        }
2743
                        break;
2744
                    case ControlType.InsideWhite:
2745
                        {
2746
                            if (e.LeftButton == MouseButtonState.Pressed)
2747
                            {
2748
                                if (currentControl is InsideWhiteControl)
2749
                                {
2750
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2751
                                    {
2752
                                        return;
2753
                                    }
2754

    
2755
                                    CreateCommand.Instance.Execute(currentControl);
2756

    
2757
                                    currentControl = null;
2758
                                    this.cursor = Cursors.Arrow;
2759
                                }
2760
                                else
2761
                                {
2762
                                    currentControl = new InsideWhiteControl
2763
                                    {
2764
                                        Background = new SolidColorBrush(Colors.Black),
2765
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2766
                                        ControlType = ControlType.InsideWhite
2767
                                    };
2768

    
2769
                                    currentControl.CommentID = Commons.shortGuid();
2770
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2771
                                    currentControl.IsNew = true;
2772
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2773

    
2774
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2775
                                }
2776
                            }
2777
                        }
2778
                        break;
2779
                    case ControlType.OverlapWhite:
2780
                        {
2781
                            if (e.LeftButton == MouseButtonState.Pressed)
2782
                            {
2783
                                if (currentControl is OverlapWhiteControl)
2784
                                {
2785
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2786
                                    {
2787
                                        return;
2788
                                    }
2789

    
2790
                                    CreateCommand.Instance.Execute(currentControl);
2791

    
2792
                                    currentControl = null;
2793
                                    this.cursor = Cursors.Arrow;
2794
                                }
2795
                                else
2796
                                {
2797
                                    currentControl = new OverlapWhiteControl
2798
                                    {
2799
                                        Background = new SolidColorBrush(Colors.Black),
2800
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2801
                                        ControlType = ControlType.OverlapWhite
2802
                                    };
2803

    
2804
                                    currentControl.CommentID = Commons.shortGuid();
2805
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2806
                                    currentControl.IsNew = true;
2807
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2808

    
2809
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2810
                                }
2811
                            }
2812
                        }
2813
                        break;
2814
                    case ControlType.ClipWhite:
2815
                        {
2816
                            if (e.LeftButton == MouseButtonState.Pressed)
2817
                            {
2818
                                if (currentControl is ClipWhiteControl)
2819
                                {
2820
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2821
                                    {
2822
                                        return;
2823
                                    }
2824

    
2825
                                    CreateCommand.Instance.Execute(currentControl);
2826

    
2827
                                    currentControl = null;
2828
                                    this.cursor = Cursors.Arrow;
2829
                                }
2830
                                else
2831
                                {
2832
                                    currentControl = new ClipWhiteControl
2833
                                    {
2834
                                        Background = new SolidColorBrush(Colors.Black),
2835
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2836
                                        ControlType = ControlType.ClipWhite
2837
                                    };
2838

    
2839
                                    currentControl.CommentID = Commons.shortGuid();
2840
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2841
                                    currentControl.IsNew = true;
2842
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2843

    
2844
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2845
                                }
2846
                            }
2847
                        }
2848
                        break;
2849
                    case ControlType.Rectangle:
2850
                        {
2851
                            if (e.LeftButton == MouseButtonState.Pressed)
2852
                            {
2853
                                if (currentControl is RectangleControl)
2854
                                {
2855
                                    //20180906 LJY TEST IsRotationDrawingEnable
2856
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2857
                                    {
2858
                                        return;
2859
                                    }
2860

    
2861
                                    CreateCommand.Instance.Execute(currentControl);
2862
                                    currentControl = null;
2863
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2864
                                }
2865
                                else
2866
                                {
2867
                                    currentControl = new RectangleControl
2868
                                    {
2869
                                        Background = new SolidColorBrush(Colors.Black),
2870
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2871
                                        ControlType = ControlType.Rectangle
2872
                                    };
2873

    
2874
                                    currentControl.CommentID = Commons.shortGuid();
2875
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2876
                                    currentControl.IsNew = true;
2877
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2878

    
2879
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2880
                                }
2881
                            }
2882
                        }
2883
                        break;
2884
                    case ControlType.RectCloud:
2885
                        {
2886
                            if (e.LeftButton == MouseButtonState.Pressed)
2887
                            {
2888
                                if (currentControl is RectCloudControl)
2889
                                {
2890
                                    //20180906 LJY TEST IsRotationDrawingEnable
2891
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2892
                                    {
2893
                                        return;
2894
                                    }
2895

    
2896
                                    CreateCommand.Instance.Execute(currentControl);
2897

    
2898
                                    currentControl = null;
2899
                                
2900
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2901
                                }
2902
                                else
2903
                                {
2904
                                    currentControl = new RectCloudControl
2905
                                    {
2906
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2907
                                        ControlType = ControlType.RectCloud,
2908
                                        Background = new SolidColorBrush(Colors.Black)
2909
                                    };
2910

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

    
2931
                                    CreateCommand.Instance.Execute(currentControl);
2932

    
2933
                                    currentControl = null;
2934
                                }
2935
                                else
2936
                                {
2937
                                    currentControl = new CircleControl
2938
                                    {
2939
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2940
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2941
                                        Background = new SolidColorBrush(Colors.Black)
2942
                                    };
2943

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

    
2971
                                        CreateCommand.Instance.Execute(currentControl);
2972

    
2973
                                        currentControl = null;
2974
                                    }
2975
                                }
2976
                                else
2977
                                {
2978
                                    currentControl = new TriControl
2979
                                    {
2980
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2981
                                        Background = new SolidColorBrush(Colors.Black),
2982
                                    };
2983

    
2984
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2985
                                    currentControl.CommentID = Commons.shortGuid();
2986
                                    currentControl.IsNew = true;
2987
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2988
                                }
2989
                            }
2990
                        }
2991
                        break;
2992
                    case ControlType.CancelLine:
2993
                    case ControlType.SingleLine:
2994
                    case ControlType.ArrowLine:
2995
                    case ControlType.TwinLine:
2996
                    case ControlType.DimLine:
2997
                        {
2998
                            if (e.LeftButton == MouseButtonState.Pressed)
2999
                            {
3000
                                if (currentControl is LineControl)
3001
                                {
3002
                                    //20180906 LJY TEST IsRotationDrawingEnable
3003
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3004
                                    {
3005
                                        return;
3006
                                    }
3007

    
3008
                                    CreateCommand.Instance.Execute(currentControl);
3009
                                    currentControl = null;
3010
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3011
                                }
3012
                                else
3013
                                {
3014
                                    currentControl = new LineControl
3015
                                    {
3016
                                        ControlType = this.controlType,
3017
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3018
                                        Background = new SolidColorBrush(Colors.Black)
3019
                                    };
3020

    
3021
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3022
                                    currentControl.CommentID = Commons.shortGuid();
3023
                                    currentControl.IsNew = true;
3024
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3025
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3026
                                }
3027
                            }
3028
                        }
3029
                        break;
3030
                    case ControlType.PolygonControl:
3031
                        {
3032
                            if (currentControl is PolygonControl)
3033
                            {
3034
                                var control = currentControl as PolygonControl;
3035

    
3036
                                if (e.RightButton == MouseButtonState.Pressed)
3037
                                {
3038
                                    control.IsCompleted = true;
3039
                                }
3040

    
3041
                                if (!control.IsCompleted)
3042
                                {
3043
                                    control.PointSet.Add(control.EndPoint);
3044
                                }
3045
                                else
3046
                                {
3047
                                    //20180906 LJY TEST IsRotationDrawingEnable
3048
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3049
                                    {
3050
                                        return;
3051
                                    }
3052

    
3053
                                    var firstPoint = control.PointSet.First();
3054
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3055
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3056
                                    control.PointSet.Add(firstPoint);
3057

    
3058
                                    control.ApplyOverViewData();
3059

    
3060
                                    CreateCommand.Instance.Execute(currentControl);
3061
                                    control.UpdateControl();
3062
                                    currentControl = null;
3063
                                }
3064
                            }
3065
                            else
3066
                            {
3067
                                if (e.LeftButton == MouseButtonState.Pressed)
3068
                                {
3069
                                    currentControl = new PolygonControl
3070
                                    {
3071
                                        PointSet = new List<Point>(),
3072
                                    };
3073

    
3074
                                    var polygonControl = (currentControl as PolygonControl);
3075
                                    currentControl.CommentID = Commons.shortGuid();
3076
                                    currentControl.IsNew = true;
3077
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3078
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3079
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3080
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3081
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3082
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3083
                                    polygonControl.ApplyTemplate();
3084
                                    polygonControl.Visibility = Visibility.Visible;
3085
                                }
3086
                            }
3087
                        }
3088
                        break;
3089
                    case ControlType.ChainLine:
3090
                        {
3091
                            if (currentControl is PolygonControl)
3092
                            {
3093
                                var control = currentControl as PolygonControl;
3094

    
3095
                                if (e.RightButton == MouseButtonState.Pressed)
3096
                                {
3097
                                    //20180906 LJY TEST IsRotationDrawingEnable
3098
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3099
                                    {
3100
                                        return;
3101
                                    }
3102

    
3103
                                    CreateCommand.Instance.Execute(currentControl);
3104

    
3105
                                    currentControl = null;
3106
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3107
                                    return;
3108
                                }
3109

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

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

    
3160
                                    CreateCommand.Instance.Execute(currentControl);
3161

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

    
3203
                                    CreateCommand.Instance.Execute(currentControl);
3204

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

    
3241
                                    if (currentControl is ArrowControl_Multi)
3242
                                    {
3243
                                        var content = currentControl as ArrowControl_Multi;
3244
                                        if (content.MiddlePoint == new Point(0, 0))
3245
                                        {
3246
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3247
                                            {
3248
                                                content.MiddlePoint = content.EndPoint;
3249
                                            }
3250
                                            else
3251
                                            {
3252
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3253
                                            }
3254
                                        }
3255
                                        else
3256
                                        {
3257
                                            //20180906 LJY TEST IsRotationDrawingEnable
3258
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3259
                                            {
3260
                                                return;
3261
                                            }
3262

    
3263
                                            CreateCommand.Instance.Execute(currentControl);
3264

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

    
3296
                                if (!control.IsCompleted)
3297
                                {
3298
                                    control.PointSet.Add(control.EndPoint);
3299
                                }
3300
                                else
3301
                                {
3302
                                    //20180906 LJY TEST IsRotationDrawingEnable
3303
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3304
                                    {
3305
                                        return;
3306
                                    }
3307

    
3308
                                    CreateCommand.Instance.Execute(currentControl);
3309

    
3310
                                    control.isTransOn = true;
3311
                                    var firstPoint = control.PointSet.First();
3312

    
3313
                                    control.PointSet.Add(firstPoint);
3314
                                    control.DrawingCloud();
3315
                                    control.ApplyOverViewData();
3316

    
3317
                                    currentControl = null;
3318
                                }
3319
                            }
3320
                            else
3321
                            {
3322
                                if (e.LeftButton == MouseButtonState.Pressed)
3323
                                {
3324
                                    currentControl = new CloudControl
3325
                                    {
3326
                                        PointSet = new List<Point>(),
3327
                                        PointC = new StylusPointSet()
3328
                                    };
3329

    
3330
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3331
                                    //{
3332
                                        var polygonControl = (currentControl as CloudControl);
3333
                                        currentControl.CommentID = Commons.shortGuid();
3334
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3335
                                        currentControl.IsNew = true;
3336
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3337

    
3338
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3339
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3340
                                    
3341
                                    //}
3342
                                }
3343
                            }
3344
                        }
3345
                        break;
3346
                    case ControlType.ImgControl:
3347
                        {
3348
                            if (e.LeftButton == MouseButtonState.Pressed)
3349
                            {
3350
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3351
                                //{
3352
                                    if (currentControl is ImgControl)
3353
                                    {
3354
                                        //20180906 LJY TEST IsRotationDrawingEnable
3355
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3356
                                        {
3357
                                            return;
3358
                                        }
3359

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

    
3388
                                            currentControl = new ImgControl
3389
                                            {
3390
                                                    Background = new SolidColorBrush(Colors.Black),
3391
                                                    PointSet = new List<Point>(),
3392
                                                    FilePath = filename,
3393
                                                    ImageData = img.Source,
3394
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3395
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3396
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3397
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3398
                                                    ControlType = ControlType.ImgControl
3399
                                                };
3400

    
3401
                                        
3402
                                                currentControl.CommentID = Commons.shortGuid();                                            
3403
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3404
                                                currentControl.IsNew = true;
3405
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3406

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

    
3429
                                    CreateCommand.Instance.Execute(currentControl);
3430
                                    currentControl = null;
3431

    
3432
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3433
                                    {
3434
                                        controlType = ControlType.None;
3435
                                        IsSwingMode = false;
3436
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3437
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3438
                                        mouseHandlingMode = MouseHandlingMode.None;
3439
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3440
                                        txtBatch.Visibility = Visibility.Collapsed;
3441

    
3442
                                    }
3443
                                }
3444
                                else
3445
                                {
3446
                                    currentControl = new DateControl
3447
                                    {
3448
                                        StartPoint = CanvasDrawingMouseDownPoint,
3449
                                        Background = new SolidColorBrush(Colors.Black)
3450
                                    };
3451
                                    currentControl.CommentID = Commons.shortGuid();
3452
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3453
                                    currentControl.IsNew = true;
3454
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3455

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

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

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

    
3539
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3540
                                    currentControl.CommentID = Commons.shortGuid();
3541
                                    currentControl.IsNew = true;
3542
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3543
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3544

    
3545
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3546
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3547
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3548

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

    
3573
                                    CreateCommand.Instance.Execute(currentControl);
3574

    
3575
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3576
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3577
                                    (currentControl as ArrowTextControl).IsNew = false;
3578
                                    currentControl = null;
3579
                                }
3580
                                else
3581
                                {
3582
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3583
                                    //{
3584
                                        currentControl = new ArrowTextControl();
3585
                                        currentControl.CommentID = Commons.shortGuid();
3586
                                        currentControl.IsNew = true;
3587
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3588
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3589

    
3590
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3591
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3592
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3593
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3594
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3595

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

    
3599
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3600
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3601
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3602
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3603

    
3604
                                    
3605
                                    //}
3606
                                }
3607
                            }
3608
                        }
3609
                        break;
3610
                    case ControlType.ArrowTransTextControl:
3611
                        {
3612
                            if (e.LeftButton == MouseButtonState.Pressed)
3613
                            {
3614
                                if (currentControl is ArrowTextControl)
3615
                                {
3616
                                    //20180906 LJY TEST IsRotationDrawingEnable
3617
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3618
                                    {
3619
                                        return;
3620
                                    }
3621

    
3622
                                    CreateCommand.Instance.Execute(currentControl);
3623

    
3624
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3625
                                    
3626
                                    currentControl.IsNew = false;
3627
                                    currentControl = null;
3628
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3629
                                }
3630
                                else
3631
                                {
3632
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3633
                                    //{
3634
                                    currentControl = new ArrowTextControl()
3635
                                    {
3636
                                        ControlType = ControlType.ArrowTransTextControl
3637
                                    };
3638
                                    currentControl.CommentID = Commons.shortGuid();
3639
                                    currentControl.IsNew = true;
3640
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3641
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3642
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3643
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3644
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3645
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3646
                                    (currentControl as ArrowTextControl).isFixed = true;
3647
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3648

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

    
3652
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3653
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3654
                                    (currentControl as ArrowTextControl).isTrans = true;
3655
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3656
                                }
3657
                            }
3658
                        }
3659
                        break;
3660
                    case ControlType.ArrowTextBorderControl:
3661
                         {
3662
                            if (e.LeftButton == MouseButtonState.Pressed)
3663
                            {
3664
                                if (currentControl is ArrowTextControl)
3665
                                {
3666
                                    //20180906 LJY TEST IsRotationDrawingEnable
3667
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3668
                                    {
3669
                                        return;
3670
                                    }
3671

    
3672
                                    CreateCommand.Instance.Execute(currentControl);
3673
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3674
                                    currentControl.IsNew = false;
3675
                                    currentControl = null;
3676
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3677
                                }
3678
                                else
3679
                                {
3680
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3681
                                    //{
3682
                                        currentControl = new ArrowTextControl()
3683
                                        {
3684
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3685
                                        };
3686
                                        currentControl.CommentID = Commons.shortGuid();
3687
                                        currentControl.IsNew = true;
3688
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3689
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3690

    
3691
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3692

    
3693
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3694

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

    
3725
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3726
                                }
3727
                                else
3728
                                {
3729
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3730
                                    //{
3731
                                    
3732

    
3733
                                    currentControl = new ArrowTextControl()
3734
                                    {
3735
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3736
                                        ControlType = ControlType.ArrowTransTextBorderControl
3737

    
3738
                                    };
3739
                                        currentControl.CommentID = Commons.shortGuid();
3740
                                        currentControl.IsNew = true;
3741
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3742
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3743

    
3744
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3745

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

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

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

    
3841
                                        };
3842
                                        currentControl.CommentID = Commons.shortGuid();
3843
                                        currentControl.IsNew = true; 
3844
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3845
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3846
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3847

    
3848
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3849
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3850
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3851
                                        (currentControl as ArrowTextControl).isFixed = true;
3852
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3853

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

    
3877
                                if (_sign == null)
3878
                                    {
3879
                                        txtBatch.Visibility = Visibility.Collapsed;
3880
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3881
                                        controlType = ControlType.None;
3882

    
3883
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3884
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3885
                                        return;
3886
                                    }
3887

    
3888
                                    if (currentControl is SignControl)
3889
                                    {
3890
                                        //20180906 LJY TEST IsRotationDrawingEnable
3891
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3892
                                        {
3893
                                            return;
3894
                                        }
3895

    
3896
                                        CreateCommand.Instance.Execute(currentControl);
3897
                                        currentControl = null;
3898
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3899
                                        {
3900
                                            txtBatch.Text = "Place Date";
3901
                                            controlType = ControlType.Date;
3902
                                        }
3903
                                    }
3904
                                    else
3905
                                    {
3906
                                        currentControl = new SignControl
3907
                                        {
3908
                                            Background = new SolidColorBrush(Colors.Black),
3909
                                            UserNumber = App.ViewInfo.UserID,
3910
                                            ProjectNO = App.ViewInfo.ProjectNO,
3911
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3912
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3913
                                            ControlType = ControlType.Sign
3914
                                        };
3915

    
3916
                                        currentControl.CommentID = Commons.shortGuid();
3917
                                        currentControl.IsNew = true;
3918
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3919
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3920

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

    
3942
                                        CreateCommand.Instance.Execute(currentControl);
3943
                                        (currentControl as RectangleControl).ApplyOverViewData();
3944
                                        currentControl = null;
3945
                                    
3946
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3947

    
3948
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3949
                                        {
3950
                                            txtBatch.Text = "Place Signature";
3951
                                            controlType = ControlType.Sign;
3952
                                        }
3953
                                    }
3954
                                    else
3955
                                    {
3956
                                        currentControl = new RectangleControl
3957
                                        {
3958
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3959
                                            Background = new SolidColorBrush(Colors.Black),
3960
                                            ControlType = ControlType.Mark ,
3961
                                            Paint = PaintSet.Fill
3962
                                        };
3963

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

    
4000
                                    currentControl.IsNew = true;
4001
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4002
                                    currentControl.CommentID = Commons.shortGuid();
4003
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4004

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

    
4026
                                        CreateCommand.Instance.Execute(currentControl);
4027
                                        currentControl = null;
4028
                                   
4029

    
4030
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4031
                                    }
4032
                                    else
4033
                                    {
4034
                                        currentControl = new SymControlN
4035
                                        {
4036
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4037
                                            Background = new SolidColorBrush(Colors.Black),
4038
                                            STAMP = App.SystemInfo.STAMP,                                            
4039
                                            ControlType = ControlType.Stamp
4040
                                        };
4041

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

    
4080
                if (currentControl != null)
4081
                {
4082
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4083
                }
4084
            }
4085
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4086
            {
4087
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4088
                {
4089
                    bool mouseOff = false;
4090
                    foreach (var item in SelectLayer.Children)
4091
                    {
4092
                        if (item is AdornerFinal)
4093
                        {
4094

    
4095
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4096
                            if (over != null)
4097
                            {
4098
                                mouseOff = true;
4099
                            }
4100
                        }
4101
                    }
4102

    
4103
                    if (!mouseOff)
4104
                    {
4105
                        SelectionSet.Instance.UnSelect(this);
4106
                    }
4107
                }
4108
                zoomAndPanControl.CaptureMouse();
4109
                e.Handled = true;
4110
            }
4111
          
4112
        }
4113

    
4114
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4115
        {
4116
            ///mouseButtonDown = e.ChangedButton;
4117
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4118
        }
4119

    
4120
        private void RemoveLineStroke(Point P)
4121
        {
4122
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4123
            if (control != null)
4124
            {
4125
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4126
            }
4127
        }
4128

    
4129
        private void RemovePointStroke(Point P)
4130
        {
4131
            foreach (Stroke hits in inkBoard.Strokes)
4132
            {
4133
                foreach (StylusPoint sty in hits.StylusPoints)
4134
                {
4135

    
4136
                }
4137
                if (hits.HitTest(P))
4138
                {
4139
                    inkBoard.Strokes.Remove(hits);
4140
                    return;
4141
                }
4142
            }
4143
        }
4144

    
4145
        private void StartNewStroke(Point P)
4146
        {
4147
            strokePoints = new StylusPointCollection();
4148
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4149
            strokePoints.Add(segment1Start);
4150
            stroke = new Stroke(strokePoints);
4151

    
4152
            stroke.DrawingAttributes.Color = Colors.Red;
4153
            stroke.DrawingAttributes.Width = 4;
4154
            stroke.DrawingAttributes.Height = 4;
4155

    
4156
            inkBoard.Strokes.Add(stroke);
4157
        }
4158

    
4159
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4160
        {
4161
            ConsolidationMethod();
4162
        }
4163

    
4164
        /// <summary>
4165
        /// execute TeamConsolidationCommand
4166
        /// </summary>
4167
        public void TeamConsolidationMethod()
4168
        {
4169
            this.UpdateMyMarkupList();
4170
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4171
            {
4172
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4173
            }
4174
            else
4175
            {
4176

    
4177
                ViewerDataModel.Instance.IsConsolidate = true;
4178
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4179

    
4180
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4181
                {
4182
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4183
                    {
4184
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4185
                        return;
4186
                    }                    
4187
                }
4188
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4189
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4190
                {
4191
                    MarkupInfoList.Add(item);
4192
                }
4193
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4194
            }
4195
        }
4196

    
4197
        public void ConsolidationMethod()
4198
        {
4199
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4200
            {
4201
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4202
            }
4203
            else
4204
            {
4205
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4206
                foreach (var item in this.gridViewMarkup.SelectedItems)
4207
                {
4208
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4209
                }
4210
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4211
                
4212
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4213
            }
4214
        }
4215

    
4216
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4217
        {
4218
            if (App.ViewInfo != null)
4219
            {
4220
                btnConsolidate = (sender as RadRibbonButton);
4221
                if (!App.ViewInfo.NewCommentPermission)
4222
                {
4223
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4224
                }
4225
            }
4226
        }
4227

    
4228
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4229
        {
4230
            TeamConsolidationMethod();
4231
        }
4232

    
4233
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4234
        {
4235
            btnTeamConsolidate = sender as RadRibbonButton;
4236
            if (App.ViewInfo != null)
4237
            {
4238
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4239
                {
4240
                    if (btnConsolidate != null)
4241
                    {
4242
                        btnConsolidate.Visibility = Visibility.Collapsed;
4243
                    }
4244

    
4245
                    if (!App.ViewInfo.NewCommentPermission)
4246
                    {
4247
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4248
                    }
4249
                }
4250
                else
4251
                {
4252
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4253
                }
4254
            }
4255
        }
4256

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

    
4278
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4279
        {
4280
            btnFinalPDF = sender as RadRibbonButton;
4281
            if (App.ViewInfo != null)
4282
            {
4283
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4284
                {
4285
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4286
                    if (btnConsolidate != null)
4287
                    {
4288
                        btnConsolidate.Visibility = Visibility.Collapsed;
4289
                    }
4290
                }
4291
            }
4292
        }
4293

    
4294
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4295
        {
4296
            UpdateMyMarkupList();
4297

    
4298
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4299
            {
4300
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4301
            }
4302
            else
4303
            {
4304
                ViewerDataModel.Instance.IsConsolidate = true;
4305
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4306
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4307

    
4308
                string project_no = App.ViewInfo.ProjectNO;
4309
                string doc_id = _DocInfo.ID;
4310
                string user_id = App.ViewInfo.UserID;
4311
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4312
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4313
                {
4314
                    markupInfoItems.Add(item);
4315
                }
4316
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4317
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4318
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4319
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4320

    
4321
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4322
                if (item2 != null)
4323
                {
4324
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4325

    
4326
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4327
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4328
                }
4329
                else
4330
                {
4331
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4332
                }
4333
            }
4334
        }
4335

    
4336
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4337
        {
4338
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4339
#if Hyosung
4340
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4341
#else
4342
            if (App.ViewInfo != null)
4343
            {
4344
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4345
                {
4346
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4347
                }
4348
            }
4349
#endif
4350
        }
4351

    
4352
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4353
        {
4354
            SetCompareRect();
4355
        }
4356

    
4357
        private void Sync_Click(object sender, RoutedEventArgs e)
4358
        {
4359
            if (Sync.IsChecked)
4360
            {
4361
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4362
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4363
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4364
            }
4365
        }
4366

    
4367
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4368
        {
4369
            if (UserList.IsChecked)
4370
            {
4371
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4372
            }
4373
            else
4374
            {
4375
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4376
            }
4377
        }
4378

    
4379
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4380
        {
4381

    
4382
            if (BalanceMode.IsChecked)
4383
            {
4384
                ViewerDataModel.Instance.PageBalanceMode = true;
4385
            }
4386
            else
4387
            {
4388
                ViewerDataModel.Instance.PageBalanceMode = false;
4389
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4390
            }
4391
        }
4392

    
4393
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4394
        {
4395
            //초기화
4396
            testPanel2.IsHidden = true;
4397
            ViewerDataModel.Instance.PageBalanceMode = false;
4398
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4399
            ViewerDataModel.Instance.PageNumber = 0;
4400
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4401
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4402
            UserList.IsChecked = false;
4403
            BalanceMode.IsChecked = false;
4404
        }
4405

    
4406
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4407
        {
4408
            if ((sender as System.Windows.Controls.Control).Tag != null)
4409
            {
4410
                //Compare 초기화
4411
                CompareMode.IsChecked = false;
4412
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4413

    
4414
                if (ViewerDataModel.Instance.PageNumber == 0)
4415
                {
4416
                    ViewerDataModel.Instance.PageNumber = 1;
4417
                }
4418

    
4419
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4420
                {
4421
                }
4422
                else
4423
                {
4424
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4425
                }
4426

    
4427

    
4428

    
4429
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4430
                {
4431

    
4432
                }
4433
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4434
                {
4435
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4436
                }
4437

    
4438
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4439

    
4440
                if (!testPanel2.IsHidden)
4441
                {
4442
                    if (IsSyncPDFMode)
4443
                    {
4444
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4445
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4446

    
4447
                        if (pdfpath.IsDownloading)
4448
                        {
4449
                            pdfpath.DownloadCompleted += (ex, arg) =>
4450
                            {
4451
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4452
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4453
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4454
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4455
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4456
                            };
4457
                        }
4458
                        else
4459
                        {
4460
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4461
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4462
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4463

    
4464
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4465
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4466
                        }
4467

    
4468
                    }
4469
                    else
4470
                    {
4471
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4472

    
4473
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4474

    
4475
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4476
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4477
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4478

    
4479
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4480
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4481

    
4482
                        if (defaultBitmapImage_Compare.IsDownloading)
4483
                        {
4484
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4485
                            {
4486
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4487
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4488
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4489

    
4490
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4491
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4492
                            };
4493
                        }
4494
                    }
4495

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

    
4500
                    foreach (var item in gridSelectionRevItem)
4501
                    {
4502
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4503
                        foreach (var markupitem in markupitems)
4504
                        {
4505
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4506
                        }
4507
                    }
4508

    
4509
                    //강인구 추가
4510
                    zoomAndPanControl2.ZoomTo(new Rect
4511
                    {
4512
                        X = 0,
4513
                        Y = 0,
4514
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4515
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4516
                    });
4517

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

    
4520
                }
4521
            }
4522
        }
4523

    
4524
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4525
        {
4526
            if (MarkupMode.IsChecked)
4527
            {
4528
                IsSyncPDFMode = true;
4529

    
4530
                var uri = CurrentRev.TO_VENDOR;
4531

    
4532
                if (ViewerDataModel.Instance.PageNumber == 0)
4533
                {
4534
                    ViewerDataModel.Instance.PageNumber = 1;
4535
                }
4536

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

    
4541
                if (pdfpath.IsDownloading)
4542
                {
4543
                    pdfpath.DownloadCompleted += (ex, arg) =>
4544
                    {
4545
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4546
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4547
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4548
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4549
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4550
                    };
4551
                }
4552
                else
4553
                {
4554
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4555
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4556
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4557

    
4558
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4559
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4560
                }
4561
            }
4562
            else
4563
            {
4564
                IsSyncPDFMode = false;
4565
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4566

    
4567
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4568

    
4569
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4570
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4571
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4572

    
4573
                if (defaultBitmapImage_Compare.IsDownloading)
4574
                {
4575
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4576
                    {
4577
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4578
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4579
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4580
                    };
4581
                }
4582
                zoomAndPanControl2.ApplyTemplate();
4583
                zoomAndPanControl2.UpdateLayout();
4584
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4585
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4586
            }
4587
        }
4588

    
4589
        /// <summary>
4590
        /// Compare된 영역을 초기화
4591
        /// </summary>
4592
        private void ClearCompareRect()
4593
        {
4594
            da.From = 1;
4595
            da.To = 1;
4596
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4597
            da.AutoReverse = false;
4598
            canvas_compareBorder.Children.Clear();
4599
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4600
        }
4601

    
4602
        /// <summary>
4603
        /// 문서 Comprare 
4604
        /// </summary>
4605
        private void SetCompareRect()
4606
        {
4607
            if (CompareMode.IsChecked)
4608
            {
4609
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4610
                {
4611
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4612
                }
4613
                if (ViewerDataModel.Instance.PageNumber == 0)
4614
                {
4615
                    ViewerDataModel.Instance.PageNumber = 1;
4616
                }
4617

    
4618
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4619
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4620
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4621

    
4622
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4623
            }
4624
            else
4625
            {
4626
                ClearCompareRect();
4627
            }
4628
        }
4629

    
4630
        private void RadButton_Click(object sender, RoutedEventArgs e)
4631
        {
4632
            gridViewHistory_Busy.IsBusy = true;
4633

    
4634
            RadButton instance = sender as RadButton;
4635
            if (instance.CommandParameter != null)
4636
            {
4637
                CurrentRev = instance.CommandParameter as VPRevision;
4638
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4639

    
4640
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4641
                {
4642
                    if (ea.Error == null && ea.Result != null)
4643
                    {
4644
                        testPanel2.IsHidden = false;
4645

    
4646
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4647
                        foreach(var info in ea.Result)
4648
                        {
4649
                            if(info.UserID == App.ViewInfo.UserID)
4650
                            {
4651
                                info.userDelete = true;
4652
                                info.DisplayColor = "FFFF0000";
4653
                            }
4654
                            else
4655
                            {
4656
                                info.userDelete = false;
4657
                            }
4658
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4659
                        }
4660
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4661

    
4662
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4663

    
4664
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4665

    
4666
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4667
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4668
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4669
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4670
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4671
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4672

    
4673
                        zoomAndPanControl2.ApplyTemplate();
4674
                        zoomAndPanControl2.UpdateLayout();
4675
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4676
                        {
4677
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4678
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4679
                        }
4680

    
4681
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4682
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4683
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4684

    
4685
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4686
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4687
                        gridViewHistory_Busy.IsBusy = false;
4688
                    }
4689

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

    
4692
                    if (GetSyncMarkupInfoItemshandler != null)
4693
                    {
4694
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4695
                    }
4696

    
4697
                    ClearCompareRect();
4698
                    SetCompareRect();
4699
                };
4700

    
4701
                /// 중복 실행이 발생하여 수정함.
4702
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4703
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4704

    
4705
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4706
            }
4707
        }
4708

    
4709
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4710
        {
4711
            try
4712
            {
4713
                if (sender is RadButton)
4714
                {
4715
                    if ((sender as RadButton).Tag != null)
4716
                    {
4717
                        var url = (sender as RadButton).Tag.ToString();
4718
                        System.Diagnostics.Process.Start(url);
4719
                    }
4720
                    else
4721
                    {
4722
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4723
                    }
4724
                }
4725
            }
4726
            catch (Exception ex)
4727
            {
4728
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4729
            }
4730
        }
4731

    
4732
        public void Sync_Event(VPRevision Currnet_Rev)
4733
        {
4734
            CurrentRev = Currnet_Rev;
4735

    
4736
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4737
            {
4738
                if (ea.Error == null && ea.Result != null)
4739
                {
4740
                    testPanel2.IsHidden = false;
4741

    
4742
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4743
                    foreach(var info in ea.Result)
4744
                    {
4745
                        if(info.UserID == App.ViewInfo.UserID)
4746
                        {
4747
                            info.userDelete = true;
4748
                            info.DisplayColor = "FFFF0000";
4749
                        }
4750
                        else
4751
                        {
4752
                            info.userDelete = false;
4753
                        }
4754
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4755
                    }
4756
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4757

    
4758
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4759

    
4760
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4761

    
4762
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4763

    
4764
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4765
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4766
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4767

    
4768
                    if (defaultBitmapImage_Compare.IsDownloading)
4769
                    {
4770
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4771
                        {
4772
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4773
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4774
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4775
                        };
4776
                    }
4777

    
4778

    
4779
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4780
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4781
                    zoomAndPanControl2.ApplyTemplate();
4782
                    zoomAndPanControl2.UpdateLayout();
4783

    
4784
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4785
                    {
4786
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4787
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4788
                    }
4789
                    //}
4790

    
4791
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4792
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4793
                    gridViewHistory_Busy.IsBusy = false;
4794
                }
4795
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4796

    
4797
            };
4798
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4799
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4800
        }
4801

    
4802
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4803
        {
4804
            if (sender is Image)
4805
            {
4806
                if ((sender as Image).Tag != null)
4807
                {
4808
                    var pdfUrl = (sender as Image).Tag.ToString();
4809
                    System.Diagnostics.Process.Start(pdfUrl);
4810
                }
4811
                else
4812
                {
4813
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4814
                }
4815
            }
4816
        }
4817

    
4818
        private void Create_Symbol(object sender, RoutedEventArgs e)
4819
        {
4820
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4821

    
4822
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4823
            {
4824
                DialogMessage_Alert("Please Select Controls", "Alert");
4825
            }
4826
            else //선택된 것이 있으면
4827
            {
4828
                string MarkupData = "";
4829
                adorner_ = new AdornerFinal();
4830

    
4831
                foreach (var item in SelectLayer.Children)
4832
                {
4833
                    if (item.GetType().Name == "AdornerFinal")
4834
                    {
4835
                        adorner_ = (item as Controls.AdornerFinal);
4836
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4837
                        {
4838
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4839
                            {
4840
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4841
                                MarkupData += markupReturn.ConvertData;
4842
                            }
4843
                        }
4844
                    }
4845
                }
4846
                DialogParameters parameters = new DialogParameters()
4847
                {
4848
                    Owner = Application.Current.MainWindow,
4849
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4850
                    DefaultPromptResultValue = "Custom State",
4851
                    Content = "Name :",
4852
                    Header = "Insert Custom Symbol Name",
4853
                    Theme = new VisualStudio2013Theme(),
4854
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4855
                };
4856
                RadWindow.Prompt(parameters);
4857
            }
4858

    
4859
        }
4860
        public int symbolselectindex = 0;
4861
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4862
        {
4863
            //Save save = new Save();
4864
            try
4865
            {
4866
                string svgfilename = null;
4867
                if (symbolname != null)
4868
                {
4869
                    if (symbolpng == true || symbolsvg == true)
4870
                    {
4871
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4872
                        string guid = Commons.shortGuid();
4873

    
4874
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4875
                        //Check_Uri.UriCheck();
4876
                        fileUploader.RunCompleted += (ex, arg) =>
4877
                        {
4878
                            filename = arg.Result;
4879
                            if (symbolpng == true)
4880
                            {
4881
                                if (filename != null)
4882
                                { 
4883
                                    if (symbolselectindex == 0)
4884
                                    {
4885
                                        SymbolSave(symbolname, filename, data);
4886
                                    }
4887
                                    else
4888
                                    {
4889
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4890
                                    }
4891
                                    DataBind();
4892
                                }                                
4893
                            }
4894

    
4895
                            if (symbolsvg == true)
4896
                            {
4897
                                try
4898
                                {
4899
                                    var defaultBitmapImage = new BitmapImage();
4900
                                    defaultBitmapImage.BeginInit();
4901
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4902
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4903
                                    Check_Uri.UriCheck(filename);
4904
                                    defaultBitmapImage.UriSource = new Uri(filename);
4905
                                    defaultBitmapImage.EndInit();
4906

    
4907
                                    System.Drawing.Bitmap image;
4908

    
4909
                                    if (defaultBitmapImage.IsDownloading)
4910
                                    {
4911
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4912
                                        {
4913
                                            defaultBitmapImage.Freeze();
4914
                                            image = GetBitmap(defaultBitmapImage);
4915
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4916
                                            Process potrace = new Process
4917
                                            {
4918
                                                StartInfo = new ProcessStartInfo
4919
                                                {
4920
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4921
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4922
                                                    RedirectStandardInput = true,
4923
                                                    RedirectStandardOutput = true,
4924
                                                    RedirectStandardError = true,
4925
                                                    UseShellExecute = false,
4926
                                                    CreateNoWindow = true,
4927
                                                    WindowStyle = ProcessWindowStyle.Hidden
4928
                                                },
4929
                                            };
4930

    
4931
                                            StringBuilder svgBuilder = new StringBuilder();
4932
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4933
                                            {
4934
                                                svgBuilder.AppendLine(e2.Data);
4935
                                            };
4936

    
4937
                                            potrace.EnableRaisingEvents = true;
4938
                                            potrace.Start();
4939
                                            potrace.Exited += (sender, e) =>
4940
                                            {
4941
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4942
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4943
                                                Check_Uri.UriCheck(svgfilename);
4944
                                                if (symbolselectindex == 0)
4945
                                                {
4946
                                                    SymbolSave(symbolname, svgfilename, data);
4947
                                                }
4948
                                                else
4949
                                                {
4950
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4951
                                                }
4952

    
4953
                                                DataBind();
4954
                                            };
4955
                                            potrace.WaitForExit();
4956
                                        };
4957
                                    }
4958
                                    else
4959
                                    {
4960
                                        //GC.Collect();
4961
                                    }
4962
                                }
4963
                                catch(Exception ee)
4964
                                {
4965
                                    DialogMessage_Alert("" + ee, "Alert");
4966
                                }
4967
                            }
4968
                        };                                             
4969
                    }
4970
                }
4971
            }
4972
            catch (Exception e)
4973
            {
4974
                //DialogMessage_Alert(e + "", "Alert");
4975
            }            
4976
        }
4977

    
4978
        public void SymbolSave(string Name, string Url, string Data)
4979
        {
4980
            try
4981
            {
4982
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4983
                {
4984
                    ID = Commons.shortGuid(),
4985
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4986
                    NAME = Name,
4987
                    IMAGE_URL = Url,
4988
                    DATA = Data
4989
                };
4990

    
4991
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4992
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4993
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4994
            }
4995
            catch (Exception)
4996
            {
4997
                throw;
4998
            }
4999
        }
5000

    
5001
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5002
        {
5003
            try
5004
            {
5005
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5006
                {
5007
                    ID = Commons.shortGuid(),
5008
                    DEPARTMENT = Department,
5009
                    NAME = Name,
5010
                    IMAGE_URL = Url,
5011
                    DATA = Data
5012
                };
5013
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5014
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5015
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5016
            }
5017
            catch (Exception)
5018
            {
5019
                throw;
5020
            }
5021
        }
5022

    
5023
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5024
        {           
5025
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5026
            DataBind();
5027
        }
5028

    
5029
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5030
        {
5031
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5032
            DataBind();
5033
        }
5034
        private void DataBind()
5035
        {
5036
            try
5037
            {
5038
                Symbol_Custom Custom = new Symbol_Custom();
5039
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5040
                
5041
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5042
                foreach (var item in symbol_Private)
5043
                {
5044
                    Custom.Name = item.NAME;
5045
                    Custom.ImageUri = item.IMAGE_URL;
5046
                    Custom.ID = item.ID;
5047
                    Custom_List.Add(Custom);
5048
                    Custom = new Symbol_Custom();
5049
                }
5050
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5051
                
5052
                Custom = new Symbol_Custom();
5053
                Custom_List = new List<Symbol_Custom>();
5054

    
5055
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5056

    
5057
                List<SYMBOL_PUBLIC> symbol_Public;
5058

    
5059
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5060
                {
5061
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5062
                }
5063
                else
5064
                {
5065
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5066
                }
5067
                foreach (var item in symbol_Public)
5068
                {
5069
                    Custom.Name = item.NAME;
5070
                    Custom.ImageUri = item.IMAGE_URL;
5071
                    Custom.ID = item.ID;
5072
                    Custom_List.Add(Custom);
5073
                    Custom = new Symbol_Custom();
5074
                }
5075
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5076
                BaseClient.Close();                
5077
            }
5078
            catch(Exception e)
5079
            {
5080
                //DialogMessage_Alert("DataBind", "Alert");
5081
            }
5082
            
5083
        }
5084
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5085
        {
5086
            try
5087
            {
5088
                if (args.PromptResult != null)
5089
                {
5090
                    if (args.DialogResult.Value)
5091
                    {
5092
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5093

    
5094
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5095
                        _Encoder.Save(fs);
5096
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5097

    
5098
                        byte[] Img_byte = fs.ToArray();
5099

    
5100
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5101
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5102
                        Check_Uri.UriCheck(filename);
5103
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5104
                        {
5105
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5106
                        }
5107
                        else
5108
                        {
5109
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5110
                        }
5111
                        DataBind();
5112
                    }
5113
                }
5114
            }
5115
            catch(Exception ex)
5116
            {
5117
                DialogMessage_Alert("" + ex, "Alert");
5118
            }
5119
        }
5120

    
5121
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5122
        {
5123

    
5124
            Canvas _canvas = new Canvas();
5125
            _canvas.Background = Brushes.White;
5126
            _canvas.Width = adorner_.BorderSize.Width;
5127
            _canvas.Height = adorner_.BorderSize.Height;
5128
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5129

    
5130
            BitmapEncoder encoder = new PngBitmapEncoder();
5131

    
5132

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

    
5135
            DrawingVisual dv = new DrawingVisual();
5136

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

    
5140
            using (DrawingContext ctx = dv.RenderOpen())
5141
            {
5142
                VisualBrush vb = new VisualBrush(_canvas);
5143
                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)));
5144
            }
5145

    
5146
            try
5147
            {
5148
                renderBitmap.Render(dv);
5149

    
5150
                //GC.Collect();
5151
                GC.WaitForPendingFinalizers();
5152
                //GC.Collect();
5153
                // encode png data
5154
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5155
                // puch rendered bitmap into it
5156
                pngEncoder.Interlace = PngInterlaceOption.Off;
5157
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5158
                return pngEncoder;
5159

    
5160
            }
5161
            catch //(Exception ex)
5162
            {
5163
                return null;
5164
            }
5165

    
5166
        }
5167

    
5168
        public void DialogMessage_Alert(string content, string header)
5169
        {
5170
            DialogParameters parameters = new DialogParameters()
5171
            {
5172
                Owner = this.ParentOfType<MainWindow>(),
5173
                Content = new TextBlock()
5174
                { 
5175
                    MinWidth = 400,
5176
                    FontSize = 11,
5177
                    Text = content,
5178
                    TextWrapping = System.Windows.TextWrapping.Wrap
5179
                },
5180
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5181
                Header = header,
5182
                Theme = new VisualStudio2013Theme(),
5183
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5184
            };            
5185
            RadWindow.Alert(parameters);
5186
        }
5187

    
5188
#region 캡쳐 기능
5189

    
5190
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5191
        {
5192
            if (x < 0)
5193
            {
5194
                width += x;
5195
                x = 0;
5196
            }
5197
            if (y < 0)
5198
            {
5199
                height += y;
5200
                y = 0;
5201

    
5202
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5203
            }
5204
            if (x + width > zoomAndPanCanvas.ActualWidth)
5205
            {
5206
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5207
            }
5208
            if (y + height > zoomAndPanCanvas.ActualHeight)
5209
            {
5210
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5211
            }
5212

    
5213
            byte[] pixels = CopyPixels(x, y, width, height);
5214

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

    
5217
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5218
        }
5219

    
5220
        public byte[] CopyPixels(int x, int y, int width, int height)
5221
        {
5222
            byte[] pixels = new byte[width * height * 4];
5223
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5224

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

    
5228
            return pixels;
5229
        }
5230

    
5231
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5232
        {
5233
            DrawingVisual drawingVisual = new DrawingVisual();
5234
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5235

    
5236
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5237
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5238
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5239
            drawingContext.Close();
5240

    
5241
            // 비트맵으로 변환합니다.
5242
            RenderTargetBitmap target =
5243
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5244
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5245

    
5246
            target.Render(drawingVisual);
5247
            return target;
5248
        }
5249

    
5250
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5251
        {
5252
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5253
            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);
5254
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5255
            bmp.UnlockBits(data);
5256
            return bmp;
5257
        }
5258
        public string symbolname = null;
5259
        public bool symbolsvg = true;
5260
        public bool symbolpng = true;
5261

    
5262
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5263
        {
5264
            System.Drawing.Bitmap image = GetBitmap(source);
5265
            //흰색 제거
5266
            //image.MakeTransparent(System.Drawing.Color.White);
5267

    
5268
            var imageStream = new System.IO.MemoryStream();
5269
            byte[] imageBytes = null;
5270
            using (imageStream)
5271
            {
5272
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5273
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5274
                imageStream.Position = 0;
5275
                imageBytes = imageStream.ToArray();
5276
            }
5277

    
5278
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5279

    
5280
            RadWindow CheckPop = new RadWindow();
5281
            //Alert check = new Alert(Msg);
5282

    
5283
            CheckPop = new RadWindow
5284
            {
5285
                MinWidth = 400,
5286
                MinHeight = 100,
5287
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5288
                Header = "Alert",
5289
                Content = symbolPrompt,
5290
                //DialogResult = 
5291
                ResizeMode = System.Windows.ResizeMode.NoResize,
5292
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5293
                IsTopmost = true,
5294
            };
5295
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5296
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5297
            CheckPop.ShowDialog();
5298

    
5299
            /*
5300
            DialogParameters parameters = new DialogParameters()
5301
            {
5302
                Owner = Application.Current.MainWindow,
5303
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5304
                DefaultPromptResultValue = "Custom State",
5305
                Content = "Name :",
5306
                Header = "Insert Custom Symbol Name",
5307
                Theme = new VisualStudio2013Theme(),
5308
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5309
            };            
5310
            RadWindow.Prompt(parameters);
5311
            */
5312
        }
5313

    
5314
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5315
        {
5316
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5317
            KCOMDataModel.DataModel.CHECK_LIST check_;
5318
            string Result = streamToBase64.ImageToBase64(source);
5319
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5320
            string projectno = App.ViewInfo.ProjectNO;
5321
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5322

    
5323
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5324
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5325
            if (Item != null)
5326
            {
5327
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5328
            }
5329
            else
5330
            {
5331
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5332
            }
5333

    
5334
            if (Item == null)
5335
            {
5336
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5337
                {
5338
                    ID = Commons.shortGuid(),
5339
                    USER_ID = App.ViewInfo.UserID,
5340
                    IMAGE_URL = Result,
5341
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5342
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5343
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5344
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5345
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5346
                    STATUS = "False",
5347
                    CREATE_TIME = DateTime.Now,
5348
                    UPDATE_TIME = DateTime.Now,
5349
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5350
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5351
                };
5352
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5353
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5354
                //this.BaseClient.AddCheckList(projectno, check_);
5355
            }
5356
            else
5357
            {
5358
                Item.IMAGE_URL = Result;
5359
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5360
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5361
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5362
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5363
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5364
            }
5365

    
5366
        }
5367

    
5368
        public void Set_Capture()
5369
        {
5370
            double x = CanvasDrawingMouseDownPoint.X;
5371
            double y = CanvasDrawingMouseDownPoint.Y;
5372
            double width = dragCaptureBorder.Width;
5373
            double height = dragCaptureBorder.Height;
5374

    
5375
            if (width > 5 || height > 5)
5376
            {
5377
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5378
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5379
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5380
            }
5381
        }
5382
#endregion
5383

    
5384
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5385
        {
5386
            multi_Undo_Data = new Multi_Undo_data();
5387

    
5388
            multi_Undo_Data.Markup = control;
5389

    
5390
            if ((control as IShapeControl) != null)
5391
            {
5392
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5393
            }
5394
            if ((control as IDashControl) != null)
5395
            {
5396
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5397
            }
5398
            if ((control as IPath) != null)
5399
            {
5400
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5401
            }
5402
            if ((control as UIElement) != null)
5403
            {
5404
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5405
            }
5406

    
5407
            return multi_Undo_Data;
5408
        }
5409

    
5410
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5411
        {
5412
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5413
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5414
            {
5415
                if (items.UserID == Select_ID)
5416
                {
5417
                    foreach (var item in items.MarkupList)
5418
                    {
5419
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5420
                        {
5421
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5422
                                items.MarkupInfoID, Commons.shortGuid());
5423
                        }
5424
                    }
5425
                }
5426
            }
5427
        }
5428

    
5429
        /// <summary>
5430
        /// convert inkcontrol to polygoncontrol
5431
        /// </summary>
5432
        public void ConvertInkControlToPolygon()
5433
        {
5434
            if (inkBoard.Strokes.Count > 0)
5435
            {
5436
                inkBoard.Strokes.ToList().ForEach(stroke =>
5437
                {
5438
                    InkToPath ip = new InkToPath();
5439

    
5440
                    List<Point> inkPointSet = new List<Point>();
5441
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5442

    
5443
                    PolygonControl pc = new PolygonControl()
5444
                    {
5445
                        CommentAngle = 0,
5446
                        PointSet = inkPointSet,
5447
                        ControlType = ControlType.Ink
5448
                    };
5449
                    pc.StartPoint = inkPointSet[0];
5450
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5451
                    pc.LineSize = 3;
5452
                    pc.CommentID = Commons.shortGuid();
5453
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5454

    
5455
                    if (pc.PointSet.Count > 0)
5456
                    {
5457
                        CreateCommand.Instance.Execute(pc);
5458
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5459
                    }
5460
                });
5461
                inkBoard.Strokes.Clear();
5462
            }
5463
        }
5464

    
5465
        /// <summary>
5466
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5467
        /// </summary>
5468
        /// <author>ingu</author>
5469
        /// <date>2018.06.05</date>
5470
        /// <param name="getPoint"></param>
5471
        /// <returns></returns>
5472
        private bool IsGetoutpoint(Point getPoint)
5473
        {
5474
            if (getPoint == new Point())
5475
            {
5476
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5477
                currentControl = null;
5478
                return true;
5479
            }
5480

    
5481
            return false;
5482
        }
5483

    
5484
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5485
        {
5486
            e.Effects = DragDropEffects.Copy;
5487
        }
5488

    
5489
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5490
        {
5491
            e.Effects = DragDropEffects.Copy;
5492
        }
5493

    
5494
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5495
        {
5496
            e.Effects = DragDropEffects.None;
5497
        }
5498

    
5499
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5500
        {
5501
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5502
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5503

    
5504
            ScaleImage(pageWidth, pageHeight);
5505
        }
5506

    
5507
        /// <summary>
5508
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5509
        /// </summary>
5510
        /// <param name="pageWidth">원본 사이즈</param>
5511
        /// <param name="pageHeight">원본 사이즈</param>
5512
        /// <returns></returns>
5513
        private void ScaleImage(double pageWidth,double pageHeight)
5514
        {
5515
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5516
        }
5517

    
5518
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5519
        {
5520
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5521
        }
5522

    
5523

    
5524
        /*
5525
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5526
        {
5527
            try
5528
            {
5529
                if (e.Data.GetDataPresent(typeof(string)))
5530
                {
5531
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5532
                    string dragData = e.Data.GetData(typeof(string)) as string;
5533
                    Move_Symbol(sender, dragData);
5534
                }
5535
            }
5536
            catch (Exception ex)
5537
            {
5538
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5539
            }            
5540
        }
5541
        */
5542
    }
5543

    
5544
    public class testItem
5545
    {
5546
        public string Title { get; set; }
5547
    }
5548
}
클립보드 이미지 추가 (최대 크기: 500 MB)