프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 84605c0c

이력 | 보기 | 이력해설 | 다운로드 (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
            /// delete markup list
589
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
590

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

    
596
            foreach (var markup in deleted)
597
            {
598
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
599
            }
600
            /// up to here
601

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

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

    
622
        DispatcherTimer renderTesttimer;
623

    
624
        /// <summary>
625
        /// start page changing
626
        ///  - save controls if page is modified
627
        ///  - starting download page image
628
        /// </summary>
629
        /// <param name="sender"></param>
630
        /// <param name="e"></param>
631
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
632
        {
633
            await Task.Delay(10);
634

    
635
            // 마크업 로드
636
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
637
            await MarkupLoadAsync(e.PageNumber);
638

    
639
            // 페이지 이미지 변경
640
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
641
        }
642

    
643
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
644
        { 
645
            CompareMode.IsChecked = false;
646
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
647
           
648
            #region 페이지가 벗어난 경우
649

    
650
            if (BalancePoint < 1)
651
            {
652
                BalancePoint = 1;
653
                ViewerDataModel.Instance.PageBalanceNumber = 0;
654
            }
655

    
656
            if (pageNavigator.PageCount < BalancePoint)
657
            {
658
                BalancePoint = pageNavigator.PageCount;
659
                ViewerDataModel.Instance.PageBalanceNumber = 0;
660
            }
661

    
662
            #endregion
663

    
664
            ViewerDataModel.Instance.PageNumber = BalancePoint;
665

    
666
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
667
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
668
            var contentScale = zoomAndPanControl.ContentScale;
669

    
670
            #region 페이지 이미지 로딩 수정
671

    
672
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
673
       
674
            ScaleImage(pageWidth, pageHeight);
675

    
676
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
677
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
678

    
679
            zoomAndPanCanvas.Width = pageWidth;
680
            zoomAndPanCanvas.Height = pageHeight;
681

    
682
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
683
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
684

    
685
            inkBoard.Width = pageWidth;
686
            inkBoard.Height = pageHeight;
687

    
688
            #endregion
689

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

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

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

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

    
738
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
739

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

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

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

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

    
779
            SearchFocusBorder.Visibility = Visibility.Collapsed;
780

    
781
            this.pageNavigator.ChangePage(changePageNumber);
782
        }
783

    
784
        /// <summary>
785
        /// called after page is changed
786
        /// </summary>
787
        /// <param name="sender"></param>
788
        /// <param name="e"></param>
789
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
790
        {
791
            //if (zoomAndPanCanvas.Width.IsNaN())
792
            //{
793

    
794
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
795
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
796
                );
797
            //}
798

    
799

    
800
            var instanceMain = ViewerDataModel.Instance.SystemMain;
801

    
802
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
803
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
804

    
805
            instanceMain.dzTopMenu.rotateOffSet = 0;
806
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
807
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
808

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

    
814
        private async Task MarkupLoadAsync(int pageNumber)
815
        {
816
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
817
            stopwatch.Start();
818

    
819
            /// 컨트롤을 새로 생성한다.
820
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
821
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
822

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

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

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

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

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

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

    
863

    
864
                foreach (var item in gridSelectionRevItem)
865
                {
866
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
867

    
868
                    foreach (var markupitem in markupitems)
869
                    {
870
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
871
                    }
872
                }
873
            }
874

    
875
            SetCommentPages();
876
        }
877

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

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

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

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

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

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

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

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

    
995
                //        pageNavigator.PageChanged += handler;
996

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

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

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

    
1034
        #region ZoomIn & ZoomOut
1035

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

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

    
1048

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

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

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

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

    
1084
        }
1085

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

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

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

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

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

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

    
1138
        #endregion
1139

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

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

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

    
1152
        }
1153

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

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

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

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

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

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

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

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

    
1320

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

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

    
1333

    
1334
               CreateDragDropWindow2(img);
1335
              
1336
    }
1337

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

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

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

    
1367
        
1368

    
1369
         */
1370

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

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

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

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

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

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

    
1404
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1405

    
1406
                MoveZoomAndPanControl(dragOffset);
1407
            }
1408

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

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

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

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

    
1474

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

    
1481

    
1482
                    #endregion
1483

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

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

    
1559
                            }
1560
                            break;
1561

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1796
                    e.Handled = true;
1797
                }
1798

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

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

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

    
1848
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1849

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

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

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

    
1863
        private EllipseGeometry hitArea = new EllipseGeometry();
1864

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

    
1875
                    SetCursor();
1876

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

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

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

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

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

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

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

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

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

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

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

    
1967
                zoomAndPanControl.ReleaseMouseCapture();
1968

    
1969

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

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

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

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

    
1995
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1996

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

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

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

    
2027
            //GC.Collect();
2028

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

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

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

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

    
2055
        }
2056

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2207
            zoomAndPanControl.RotationAngle = rotate.Angle;
2208

    
2209

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2370
            ConvertInkControlToPolygon();
2371

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2525
                        final = new AdornerFinal(control);
2526

    
2527
                        this.Control_Style(control);
2528

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

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

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

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

    
2637
                        Control_Style(control);
2638

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

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

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

    
2699
                                    CreateCommand.Instance.Execute(currentControl);
2700

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

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

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

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

    
2747
                                    CreateCommand.Instance.Execute(currentControl);
2748

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

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

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

    
2782
                                    CreateCommand.Instance.Execute(currentControl);
2783

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

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

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

    
2817
                                    CreateCommand.Instance.Execute(currentControl);
2818

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

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

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

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

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

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

    
2888
                                    CreateCommand.Instance.Execute(currentControl);
2889

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

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

    
2923
                                    CreateCommand.Instance.Execute(currentControl);
2924

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

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

    
2963
                                        CreateCommand.Instance.Execute(currentControl);
2964

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

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

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

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

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

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

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

    
3050
                                    control.ApplyOverViewData();
3051

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

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

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

    
3095
                                    CreateCommand.Instance.Execute(currentControl);
3096

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

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

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

    
3152
                                    CreateCommand.Instance.Execute(currentControl);
3153

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

    
3195
                                    CreateCommand.Instance.Execute(currentControl);
3196

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

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

    
3255
                                            CreateCommand.Instance.Execute(currentControl);
3256

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

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

    
3300
                                    CreateCommand.Instance.Execute(currentControl);
3301

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3565
                                    CreateCommand.Instance.Execute(currentControl);
3566

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

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

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

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

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

    
3614
                                    CreateCommand.Instance.Execute(currentControl);
3615

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4328
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4329
        {
4330
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4331
#if Hyosung
4332
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4333
#else
4334
            if (App.ViewInfo != null)
4335
            {
4336
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4337
                {
4338
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4339
                }
4340
            }
4341
#endif
4342
        }
4343

    
4344
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4345
        {
4346
            SetCompareRect();
4347
        }
4348

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

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

    
4371
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4372
        {
4373

    
4374
            if (BalanceMode.IsChecked)
4375
            {
4376
                ViewerDataModel.Instance.PageBalanceMode = true;
4377
            }
4378
            else
4379
            {
4380
                ViewerDataModel.Instance.PageBalanceMode = false;
4381
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4382
            }
4383
        }
4384

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

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

    
4406
                if (ViewerDataModel.Instance.PageNumber == 0)
4407
                {
4408
                    ViewerDataModel.Instance.PageNumber = 1;
4409
                }
4410

    
4411
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4412
                {
4413
                }
4414
                else
4415
                {
4416
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4417
                }
4418

    
4419

    
4420

    
4421
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4422
                {
4423

    
4424
                }
4425
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4426
                {
4427
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4428
                }
4429

    
4430
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4431

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

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

    
4456
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4457
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4458
                        }
4459

    
4460
                    }
4461
                    else
4462
                    {
4463
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4464

    
4465
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4466

    
4467
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4468
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4469
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4470

    
4471
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4472
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4473

    
4474
                        if (defaultBitmapImage_Compare.IsDownloading)
4475
                        {
4476
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4477
                            {
4478
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4479
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4480
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4481

    
4482
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4483
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4484
                            };
4485
                        }
4486
                    }
4487

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

    
4492
                    foreach (var item in gridSelectionRevItem)
4493
                    {
4494
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4495
                        foreach (var markupitem in markupitems)
4496
                        {
4497
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4498
                        }
4499
                    }
4500

    
4501
                    //강인구 추가
4502
                    zoomAndPanControl2.ZoomTo(new Rect
4503
                    {
4504
                        X = 0,
4505
                        Y = 0,
4506
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4507
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4508
                    });
4509

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

    
4512
                }
4513
            }
4514
        }
4515

    
4516
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4517
        {
4518
            if (MarkupMode.IsChecked)
4519
            {
4520
                IsSyncPDFMode = true;
4521

    
4522
                var uri = CurrentRev.TO_VENDOR;
4523

    
4524
                if (ViewerDataModel.Instance.PageNumber == 0)
4525
                {
4526
                    ViewerDataModel.Instance.PageNumber = 1;
4527
                }
4528

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

    
4533
                if (pdfpath.IsDownloading)
4534
                {
4535
                    pdfpath.DownloadCompleted += (ex, arg) =>
4536
                    {
4537
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4538
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4539
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4540
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4541
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4542
                    };
4543
                }
4544
                else
4545
                {
4546
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4547
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4548
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4549

    
4550
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4551
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4552
                }
4553
            }
4554
            else
4555
            {
4556
                IsSyncPDFMode = false;
4557
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4558

    
4559
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4560

    
4561
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4562
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4563
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4564

    
4565
                if (defaultBitmapImage_Compare.IsDownloading)
4566
                {
4567
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                }
4574
                zoomAndPanControl2.ApplyTemplate();
4575
                zoomAndPanControl2.UpdateLayout();
4576
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4577
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4578
            }
4579
        }
4580

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

    
4594
        /// <summary>
4595
        /// 문서 Comprare 
4596
        /// </summary>
4597
        private void SetCompareRect()
4598
        {
4599
            if (CompareMode.IsChecked)
4600
            {
4601
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4602
                {
4603
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4604
                }
4605
                if (ViewerDataModel.Instance.PageNumber == 0)
4606
                {
4607
                    ViewerDataModel.Instance.PageNumber = 1;
4608
                }
4609

    
4610
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4611
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4612
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4613

    
4614
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4615
            }
4616
            else
4617
            {
4618
                ClearCompareRect();
4619
            }
4620
        }
4621

    
4622
        private void RadButton_Click(object sender, RoutedEventArgs e)
4623
        {
4624
            gridViewHistory_Busy.IsBusy = true;
4625

    
4626
            RadButton instance = sender as RadButton;
4627
            if (instance.CommandParameter != null)
4628
            {
4629
                CurrentRev = instance.CommandParameter as VPRevision;
4630
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4631

    
4632
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4633
                {
4634
                    if (ea.Error == null && ea.Result != null)
4635
                    {
4636
                        testPanel2.IsHidden = false;
4637

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

    
4654
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4655

    
4656
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4657

    
4658
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4659
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4660
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4661
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4662
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4663
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4664

    
4665
                        zoomAndPanControl2.ApplyTemplate();
4666
                        zoomAndPanControl2.UpdateLayout();
4667
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4668
                        {
4669
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4670
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4671
                        }
4672

    
4673
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4674
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4675
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4676

    
4677
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4678
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4679
                        gridViewHistory_Busy.IsBusy = false;
4680
                    }
4681

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

    
4684
                    if (GetSyncMarkupInfoItemshandler != null)
4685
                    {
4686
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4687
                    }
4688

    
4689
                    ClearCompareRect();
4690
                    SetCompareRect();
4691
                };
4692

    
4693
                /// 중복 실행이 발생하여 수정함.
4694
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4695
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4696

    
4697
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4698
            }
4699
        }
4700

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

    
4724
        public void Sync_Event(VPRevision Currnet_Rev)
4725
        {
4726
            CurrentRev = Currnet_Rev;
4727

    
4728
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4729
            {
4730
                if (ea.Error == null && ea.Result != null)
4731
                {
4732
                    testPanel2.IsHidden = false;
4733

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

    
4750
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4751

    
4752
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4753

    
4754
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4755

    
4756
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4757
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4758
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4759

    
4760
                    if (defaultBitmapImage_Compare.IsDownloading)
4761
                    {
4762
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
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
                    }
4769

    
4770

    
4771
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4772
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4773
                    zoomAndPanControl2.ApplyTemplate();
4774
                    zoomAndPanControl2.UpdateLayout();
4775

    
4776
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4777
                    {
4778
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4779
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4780
                    }
4781
                    //}
4782

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

    
4789
            };
4790
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4791
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4792
        }
4793

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

    
4810
        private void Create_Symbol(object sender, RoutedEventArgs e)
4811
        {
4812
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4813

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

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

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

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

    
4887
                            if (symbolsvg == true)
4888
                            {
4889
                                try
4890
                                {
4891
                                    var defaultBitmapImage = new BitmapImage();
4892
                                    defaultBitmapImage.BeginInit();
4893
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4894
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4895
                                    Check_Uri.UriCheck(filename);
4896
                                    defaultBitmapImage.UriSource = new Uri(filename);
4897
                                    defaultBitmapImage.EndInit();
4898

    
4899
                                    System.Drawing.Bitmap image;
4900

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

    
4923
                                            StringBuilder svgBuilder = new StringBuilder();
4924
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4925
                                            {
4926
                                                svgBuilder.AppendLine(e2.Data);
4927
                                            };
4928

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

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

    
4970
        public void SymbolSave(string Name, string Url, string Data)
4971
        {
4972
            try
4973
            {
4974
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4975
                {
4976
                    ID = Commons.shortGuid(),
4977
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4978
                    NAME = Name,
4979
                    IMAGE_URL = Url,
4980
                    DATA = Data
4981
                };
4982

    
4983
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4984
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4985
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4986
            }
4987
            catch (Exception)
4988
            {
4989
                throw;
4990
            }
4991
        }
4992

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

    
5015
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5016
        {           
5017
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5018
            DataBind();
5019
        }
5020

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

    
5047
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5048

    
5049
                List<SYMBOL_PUBLIC> symbol_Public;
5050

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

    
5086
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5087
                        _Encoder.Save(fs);
5088
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5089

    
5090
                        byte[] Img_byte = fs.ToArray();
5091

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

    
5113
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5114
        {
5115

    
5116
            Canvas _canvas = new Canvas();
5117
            _canvas.Background = Brushes.White;
5118
            _canvas.Width = adorner_.BorderSize.Width;
5119
            _canvas.Height = adorner_.BorderSize.Height;
5120
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5121

    
5122
            BitmapEncoder encoder = new PngBitmapEncoder();
5123

    
5124

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

    
5127
            DrawingVisual dv = new DrawingVisual();
5128

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

    
5132
            using (DrawingContext ctx = dv.RenderOpen())
5133
            {
5134
                VisualBrush vb = new VisualBrush(_canvas);
5135
                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)));
5136
            }
5137

    
5138
            try
5139
            {
5140
                renderBitmap.Render(dv);
5141

    
5142
                //GC.Collect();
5143
                GC.WaitForPendingFinalizers();
5144
                //GC.Collect();
5145
                // encode png data
5146
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5147
                // puch rendered bitmap into it
5148
                pngEncoder.Interlace = PngInterlaceOption.Off;
5149
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5150
                return pngEncoder;
5151

    
5152
            }
5153
            catch //(Exception ex)
5154
            {
5155
                return null;
5156
            }
5157

    
5158
        }
5159

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

    
5180
#region 캡쳐 기능
5181

    
5182
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5183
        {
5184
            if (x < 0)
5185
            {
5186
                width += x;
5187
                x = 0;
5188
            }
5189
            if (y < 0)
5190
            {
5191
                height += y;
5192
                y = 0;
5193

    
5194
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5195
            }
5196
            if (x + width > zoomAndPanCanvas.ActualWidth)
5197
            {
5198
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5199
            }
5200
            if (y + height > zoomAndPanCanvas.ActualHeight)
5201
            {
5202
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5203
            }
5204

    
5205
            byte[] pixels = CopyPixels(x, y, width, height);
5206

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

    
5209
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5210
        }
5211

    
5212
        public byte[] CopyPixels(int x, int y, int width, int height)
5213
        {
5214
            byte[] pixels = new byte[width * height * 4];
5215
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5216

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

    
5220
            return pixels;
5221
        }
5222

    
5223
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5224
        {
5225
            DrawingVisual drawingVisual = new DrawingVisual();
5226
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5227

    
5228
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5229
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5230
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5231
            drawingContext.Close();
5232

    
5233
            // 비트맵으로 변환합니다.
5234
            RenderTargetBitmap target =
5235
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5236
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5237

    
5238
            target.Render(drawingVisual);
5239
            return target;
5240
        }
5241

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

    
5254
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5255
        {
5256
            System.Drawing.Bitmap image = GetBitmap(source);
5257
            //흰색 제거
5258
            //image.MakeTransparent(System.Drawing.Color.White);
5259

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

    
5270
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5271

    
5272
            RadWindow CheckPop = new RadWindow();
5273
            //Alert check = new Alert(Msg);
5274

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

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

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

    
5315
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5316
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5317
            if (Item != null)
5318
            {
5319
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5320
            }
5321
            else
5322
            {
5323
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5324
            }
5325

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

    
5358
        }
5359

    
5360
        public void Set_Capture()
5361
        {
5362
            double x = CanvasDrawingMouseDownPoint.X;
5363
            double y = CanvasDrawingMouseDownPoint.Y;
5364
            double width = dragCaptureBorder.Width;
5365
            double height = dragCaptureBorder.Height;
5366

    
5367
            if (width > 5 || height > 5)
5368
            {
5369
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5370
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5371
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5372
            }
5373
        }
5374
#endregion
5375

    
5376
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5377
        {
5378
            multi_Undo_Data = new Multi_Undo_data();
5379

    
5380
            multi_Undo_Data.Markup = control;
5381

    
5382
            if ((control as IShapeControl) != null)
5383
            {
5384
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5385
            }
5386
            if ((control as IDashControl) != null)
5387
            {
5388
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5389
            }
5390
            if ((control as IPath) != null)
5391
            {
5392
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5393
            }
5394
            if ((control as UIElement) != null)
5395
            {
5396
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5397
            }
5398

    
5399
            return multi_Undo_Data;
5400
        }
5401

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

    
5421
        /// <summary>
5422
        /// convert inkcontrol to polygoncontrol
5423
        /// </summary>
5424
        public void ConvertInkControlToPolygon()
5425
        {
5426
            if (inkBoard.Strokes.Count > 0)
5427
            {
5428
                inkBoard.Strokes.ToList().ForEach(stroke =>
5429
                {
5430
                    InkToPath ip = new InkToPath();
5431

    
5432
                    List<Point> inkPointSet = new List<Point>();
5433
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5434

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

    
5447
                    if (pc.PointSet.Count > 0)
5448
                    {
5449
                        CreateCommand.Instance.Execute(pc);
5450
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5451
                    }
5452
                });
5453
                inkBoard.Strokes.Clear();
5454
            }
5455
        }
5456

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

    
5473
            return false;
5474
        }
5475

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

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

    
5486
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5487
        {
5488
            e.Effects = DragDropEffects.None;
5489
        }
5490

    
5491
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5492
        {
5493
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5494
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5495

    
5496
            ScaleImage(pageWidth, pageHeight);
5497
        }
5498

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

    
5510
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5511
        {
5512
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5513
        }
5514

    
5515

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

    
5536
    public class testItem
5537
    {
5538
        public string Title { get; set; }
5539
    }
5540
}
클립보드 이미지 추가 (최대 크기: 500 MB)