프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (258 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
            // 마크업 로드
634
            await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
635

    
636
            // 페이지 이미지 변경
637
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
638
        }
639

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

    
647
            if (BalancePoint < 1)
648
            {
649
                BalancePoint = 1;
650
                ViewerDataModel.Instance.PageBalanceNumber = 0;
651
            }
652

    
653
            if (pageNavigator.PageCount < BalancePoint)
654
            {
655
                BalancePoint = pageNavigator.PageCount;
656
                ViewerDataModel.Instance.PageBalanceNumber = 0;
657
            }
658

    
659
            #endregion
660

    
661
            ViewerDataModel.Instance.PageNumber = BalancePoint;
662

    
663
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
664
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
665
            var contentScale = zoomAndPanControl.ContentScale;
666

    
667
            #region 페이지 이미지 로딩 수정
668

    
669
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
670
       
671
            ScaleImage(pageWidth, pageHeight);
672

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

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

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

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

    
685
            #endregion
686

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

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

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

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

    
735
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
736

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

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

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

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

    
776
            SearchFocusBorder.Visibility = Visibility.Collapsed;
777

    
778
            this.pageNavigator.ChangePage(changePageNumber);
779
        }
780

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

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

    
796

    
797
            var instanceMain = ViewerDataModel.Instance.SystemMain;
798

    
799
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
800
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
801

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

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

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

    
838
            /// fire selection event
839
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
840
            this.gridViewMarkup.UnselectAll();
841
            this.gridViewMarkup.Select(gridSelectionItem);
842

    
843
            if (!testPanel2.IsHidden)
844
            {
845
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
846
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
847
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
848

    
849
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
850
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
851

    
852

    
853
                foreach (var item in gridSelectionRevItem)
854
                {
855
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
856
                    {
857
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
858
                    });
859
                }
860
            }
861
            
862
            SetCommentPages();
863

    
864
        }
865

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

    
897
        public void MarkupitemViewUpdate(string markupinfo_id)
898
        {
899
            //db에 업데이트 한 list 를 view 에 업데이트
900
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
901
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
902
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
903
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
904
            if (dbinfo.MarkupList.Count > 0)
905
            {
906
                if (viewinfo.MarkupList != null)
907
                {
908
                    viewinfo.MarkupList.Clear();
909
                    viewinfo.MarkupList = null;
910
                }
911
                viewinfo.MarkupList = new List<MarkupItem>();
912
                foreach (var item in dbinfo.MarkupList)
913
                {
914
                    viewinfo.MarkupList.Add(item);
915
                }
916
            }
917
        }
918

    
919
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
920
        {
921
            var instance = ViewerDataModel.Instance;
922

    
923
            if(instance.IsWheelPageChanage)
924
            {
925
                return;
926
            }
927

    
928
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
929
            {
930
       
931
                int changePage = 0;
932
                
933
                if (e.Delta > 0)
934
                {
935
                    if (0 < instance.ContentOffsetY)
936
                    {
937
                        Vector dragOffset = new Vector(0, e.Delta);
938
                        MoveZoomAndPanControl(dragOffset);
939
                    }
940
                    //else
941
                    //{
942
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
943
                    //    {
944
                    //        instance.IsWheelPageChanage = true;
945
                    //        changePage -= 1;
946
                    //    }
947
                    //}
948
                }
949
                else if(e.Delta < 0)
950
                {
951
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
952
                    {
953
                        Vector dragOffset = new Vector(0,e.Delta);
954
                        MoveZoomAndPanControl(dragOffset);
955
                    }
956
                    //else
957
                    //{
958
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
959
                    //    {
960
                    //        instance.IsWheelPageChanage = true;
961
                    //        changePage += 1;
962
                    //    }
963
                    //}
964
                }
965

    
966
                //if (changePage != 0)
967
                //{
968
                //    await Task.Factory.StartNew(() =>
969
                //    {
970
                //        double beforeScale = instance.ContentScale;
971

    
972
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
973

    
974
                //        handler = (snd, evt) =>
975
                //        {
976
                //            /// 최상단으로 이전 zoomScale로 위치한다
977
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
978
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
979
                //            instance.IsWheelPageChanage = false;
980
                //            pageNavigator.PageChanged -= handler;
981
                //        };
982

    
983
                //        pageNavigator.PageChanged += handler;
984

    
985
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
986
                //    });
987
                    
988

    
989
                //}
990
            }
991
            else
992
            {
993
                e.Handled = true;
994
                if (e.Delta > 0)
995
                {
996
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
997
                    ZoomIn(currentContentMousePoint);
998
                }
999
                else
1000
                {
1001
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1002
                    ZoomOut(currentContentMousePoint);
1003
                }
1004
            }
1005
        }
1006

    
1007
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1008
        {
1009
            e.Handled = true;
1010
            if (e.Delta > 0)
1011
            {
1012
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1013
                ZoomIn_Sync(currentContentMousePoint);
1014
            }
1015
            else
1016
            {
1017
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1018
                ZoomOut_Sync(currentContentMousePoint);
1019
            }
1020
        }
1021

    
1022
        #region ZoomIn & ZoomOut
1023

    
1024
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1025
        {
1026
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1027
                zoomAndPanControl.ContentZoomFocusY));
1028
        }
1029

    
1030
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1031
        {
1032
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1033
                zoomAndPanControl.ContentZoomFocusY));
1034
        }
1035

    
1036

    
1037
        //강인구 추가 (줌 인아웃 수치 변경)
1038
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1039
        private void ZoomOut(Point contentZoomCenter)
1040
        {
1041
            if (zoomAndPanControl.ContentScale > 0.39)
1042
            {
1043
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1044
            }
1045
            else
1046
            {
1047
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1048
            }
1049

    
1050
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1051
            {
1052
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1053
            }
1054
        }
1055

    
1056
        private void ZoomIn(Point contentZoomCenter)
1057
        {
1058
            if (zoomAndPanControl.ContentScale > 0.19)
1059
            {
1060
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1061
            }
1062
            else
1063
            {
1064
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1065
            }
1066

    
1067
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1068
            {
1069
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1070
            }
1071

    
1072
        }
1073

    
1074
        private void ZoomOut_Sync(Point contentZoomCenter)
1075
        {
1076
            if (zoomAndPanControl2.ContentScale > 0.39)
1077
            {
1078
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1079
            }
1080
            else
1081
            {
1082
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1083
            }
1084

    
1085
            if (Sync.IsChecked)
1086
            {
1087
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1088
            }
1089
        }
1090

    
1091
        private void ZoomIn_Sync(Point contentZoomCenter)
1092
        {
1093
            if (zoomAndPanControl2.ContentScale > 0.19)
1094
            {
1095
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1096
            }
1097
            else
1098
            {
1099
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1100
            }
1101

    
1102
            if (Sync.IsChecked)
1103
            {
1104
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1105
            }
1106
        }
1107

    
1108
        private void ZoomOut()
1109
        {
1110
            zoomAndPanControl.ContentScale -= 0.1;
1111
            //if (zoomAndPanControl2 != null)
1112
            //{
1113
            //    zoomAndPanControl2.ContentScale -= 0.1;
1114
            //}
1115
        }
1116

    
1117
        private void ZoomIn()
1118
        {
1119
            zoomAndPanControl.ContentScale += 0.1;
1120
            //if (zoomAndPanControl2 != null)
1121
            //{
1122
            //    zoomAndPanControl2.ContentScale += 0.1;
1123
            //}
1124
        }
1125

    
1126
        #endregion
1127

    
1128
        private void init()
1129
        {
1130
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1131
            {
1132

    
1133
                ControlList.Clear();
1134
                listBox.Items.Clear();
1135
                selected_item.Clear();
1136

    
1137
                (item as IMarkupCommonData).IsSelected = false;
1138
            }
1139

    
1140
        }
1141

    
1142
        private HitTestResultBehavior MyCallback(HitTestResult result)
1143
        {
1144
            //this.cursor = Cursors.UpArrow;
1145
            var element = result.VisualHit;
1146
            while (element != null && !(element is CommentUserInfo))
1147
                element = VisualTreeHelper.GetParent(element);
1148

    
1149
            if (element == null)
1150
            {
1151
                return HitTestResultBehavior.Stop;
1152
            }
1153
            else
1154
            {
1155
                if (element is CommentUserInfo)
1156
                {
1157
                    if (!hitList.Contains(element))
1158
                    {
1159
                        hitList.Add((CommentUserInfo)element);
1160
                    }
1161
                    else
1162
                    {
1163
                        return HitTestResultBehavior.Stop;
1164
                    }
1165
                }
1166
            }
1167
            return HitTestResultBehavior.Continue;
1168
        }
1169

    
1170
        public void ReleaseSelectPath()
1171
        {
1172
            if (SelectionPath == null)
1173
            {
1174
                SelectionPath = new Path();
1175
                SelectionPath.Name = "";
1176
            }
1177
            if (SelectionPath.Name != "")
1178
            {
1179
                SelectionPath.Name = "None";
1180
            }
1181
            SelectionPath.Opacity = 0.01;
1182
            SelectionPath.RenderTransform = null;
1183
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1184
        }
1185

    
1186
        #region 컨트롤 초기화 
1187
        public void Control_Init(object control)
1188
        {
1189
            if (L_Size != 0 && (control as IPath) != null)
1190
            {
1191
                (control as IPath).LineSize = L_Size;
1192
                L_Size = 0;
1193
            }
1194

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

    
1281
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1282
        {
1283
            //Control_Init(e.Source);
1284
        }
1285
        //private Window _dragdropWindow = null;
1286

    
1287
        [DllImport("user32.dll")]
1288
        [return: MarshalAs(UnmanagedType.Bool)]
1289
        internal static extern bool GetCursorPos(ref Win32Point pt);
1290

    
1291
        [StructLayout(LayoutKind.Sequential)]
1292
        internal struct Win32Point
1293
        {
1294
            public Int32 X;
1295
            public Int32 Y;
1296
        };
1297
        /*
1298
       public string symbol_id = null;
1299
       public long symbol_group_id;
1300
       public int symbol_SelectedIndex;
1301
       public ImageSource symbol_img;
1302
       public string symbol_Data = null;
1303
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1304
       {
1305
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1306
               zoomAndPanCanvas.ActualHeight / 2));
1307

    
1308

    
1309
               if (this._dragdropWindow != null)
1310
               {
1311
                   this._dragdropWindow.Close();
1312
                   this._dragdropWindow = null;
1313
               }
1314

    
1315
               symbol_id = id;
1316
               symbol_group_id = group_id;
1317
               symbol_SelectedIndex = SelectedIndex;
1318
               symbol_Data = Data_;
1319
               symbol_img = img;
1320

    
1321

    
1322
               CreateDragDropWindow2(img);
1323
              
1324
    }
1325

    
1326
    private void CreateDragDropWindow2(ImageSource image)
1327
        {
1328
            this._dragdropWindow = new Window();
1329
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1330
            _dragdropWindow.WindowStyle = WindowStyle.None;
1331
            _dragdropWindow.AllowsTransparency = true;           
1332
            _dragdropWindow.AllowDrop = false;
1333
            _dragdropWindow.Background = null;
1334
            _dragdropWindow.IsHitTestVisible = false;
1335
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1336
            _dragdropWindow.Topmost = true;
1337
            _dragdropWindow.ShowInTaskbar = false;
1338
            
1339
            Rectangle r = new Rectangle();
1340
            r.Width = image.Width;
1341
            r.Height = image.Height;
1342
            r.Opacity = 0.5;            
1343
            r.Fill = new ImageBrush(image);
1344
            this._dragdropWindow.Content = r;
1345

    
1346
            Win32Point w32Mouse = new Win32Point();
1347
            GetCursorPos(ref w32Mouse);
1348

    
1349
            //w32Mouse.X = getCurrentPoint.X;
1350
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1351
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1352
            this._dragdropWindow.Show();
1353
        }
1354

    
1355
        
1356

    
1357
         */
1358

    
1359
        public void MoveZoomAndPanControl(Vector dragOffset)
1360
        {
1361
   
1362
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1363
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1364

    
1365
            if (Sync.IsChecked)
1366
            {
1367
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1368
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1369
            }
1370
        }
1371

    
1372
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1373
        {
1374
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1375
            {
1376
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1377

    
1378
                Point currentPos = e.GetPosition(rect);
1379

    
1380
                floatingTip.HorizontalOffset = currentPos.X + 20;
1381
                floatingTip.VerticalOffset = currentPos.Y;
1382
            }
1383

    
1384
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1385
            
1386
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1387
            {
1388
                SetCursor();
1389
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1390
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1391

    
1392
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1393

    
1394
                MoveZoomAndPanControl(dragOffset);
1395
            }
1396

    
1397
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1398
            {
1399
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1400
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1401
                SetCursor();
1402

    
1403
                if (currentControl != null)
1404
                {
1405
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1406
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1407
                    //강인구 추가
1408
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1409

    
1410
                    if ((currentControl as IPath) != null)
1411
                    {
1412
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1413
                    }
1414
                    if ((currentControl as LineControl) != null)
1415
                    {
1416
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1417
                    }
1418

    
1419
                    if ((currentControl as IShapeControl) != null)
1420
                    {
1421
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1422
                    }
1423
                    if ((currentControl as TextControl) != null)
1424
                    {
1425
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1426
                        {
1427
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1428
                        }
1429
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1430
                        {
1431
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1432
                        }
1433
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1434
                        {
1435
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1436
                        }
1437
                    }
1438
                    else if ((currentControl as ArrowTextControl) != null)
1439
                    {
1440
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1441
                        {
1442
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1443
                        }
1444
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1445
                        {
1446
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1447
                        }
1448
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1449
                        {
1450
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1451
                        }
1452
                    }
1453
                    else if ((currentControl as RectCloudControl) != null)
1454
                    {
1455
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1456
                    }
1457
                    else if ((currentControl as CloudControl) != null)
1458
                    {
1459
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1460
                    }
1461

    
1462

    
1463
                    #region // 모든 컨트롤의 공통기능 제어
1464
                    if (controlType != ControlType.PenControl)
1465
                    {
1466
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1467
                    }
1468

    
1469

    
1470
                    #endregion
1471

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

    
1474
                    switch (controlType)
1475
                    {
1476
                        case (ControlType.Coordinate):
1477
                            {
1478
                                var control = currentControl as CoordinateControl;
1479
                                if (control != null)
1480
                                {
1481
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1482
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1483
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1484
                                }
1485
                            }
1486
                            break;
1487
                        case (ControlType.InsideWhite):
1488
                            {
1489
                                var control = currentControl as InsideWhiteControl;
1490
                                if (control != null)
1491
                                {
1492
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1493
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1494
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1495
                                    control.Paint = PaintSet.Fill;
1496
                                }
1497
                            }
1498
                            break;
1499
                        case ControlType.OverlapWhite:
1500
                            {
1501
                                var control = currentControl as OverlapWhiteControl;
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.ClipWhite:
1512
                            {
1513
                                var control = currentControl as ClipWhiteControl;
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.RectCloud:
1524
                            {
1525
                                var control = currentControl as RectCloudControl;
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
                                }
1532
                            }
1533
                            break;
1534
                        case ControlType.SingleLine:
1535
                        case ControlType.CancelLine:
1536
                        case ControlType.ArrowLine:
1537
                        case ControlType.TwinLine:
1538
                        case ControlType.DimLine:
1539
                            {
1540
                                var control = currentControl as LineControl;
1541
                                if (control != null)
1542
                                {
1543
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1544
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1545
                                }
1546

    
1547
                            }
1548
                            break;
1549

    
1550
                        case ControlType.ArcLine:
1551
                            {
1552
                                var control = currentControl as ArcControl;
1553
                                if (control != null)
1554
                                {
1555
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1556
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1557
                                }
1558
                            }
1559
                            break;
1560

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

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

    
1583
                        case ControlType.Circle:
1584
                            {
1585
                                var control = currentControl as CircleControl;
1586

    
1587
                                if (control != null)
1588
                                {
1589
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1590
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1591
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1592
                                }
1593
                            }
1594
                            break;
1595

    
1596
                        case ControlType.PolygonCloud:
1597
                            {
1598
                                var control = currentControl as CloudControl;
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.Triangle:
1609
                            {
1610
                                var control = currentControl as TriControl;
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.ImgControl:
1621
                            {
1622
                                var control = currentControl as ImgControl;
1623
                                if (control != null)
1624
                                {
1625
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1626
                                }
1627
                            }
1628
                            break;
1629

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

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

    
1724
                    #endregion
1725
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1726
                    {
1727
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1728
                    }
1729
                }
1730
            }
1731
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1732
            {
1733
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1734
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1735
                SetCursor();
1736
                if (currentControl == null)
1737
                {
1738
                    switch (controlType)
1739
                    {
1740
                        case ControlType.PenControl:
1741
                            {
1742
                                if (inkBoard.Tag.ToString() == "Ink")
1743
                                {
1744
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1745
                                }
1746
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1747
                                {
1748
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1749
                                }
1750
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1751
                                {
1752
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1753
                                }
1754

    
1755
                                //inkBoard.Strokes.Add(stroke);
1756
                            }
1757
                            break;
1758
                    }
1759
                    return;
1760
                }
1761
            }
1762
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1763
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1764
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1765
            {
1766
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1767

    
1768
                if (isDraggingSelectionRect)
1769
                {
1770
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1771
                    e.Handled = true;
1772
                }
1773
                else if (isLeftMouseButtonDownOnWindow)
1774
                {
1775
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1776
                    double dragDistance = Math.Abs(dragDelta.Length);
1777

    
1778
                    if (dragDistance > DragThreshold)
1779
                    {
1780
                        isDraggingSelectionRect = true;
1781
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1782
                    }
1783

    
1784
                    e.Handled = true;
1785
                }
1786

    
1787
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1788
                {
1789
                }
1790
                else
1791
                {
1792
                    e.Handled = true;
1793
                }
1794
            }
1795
            /*
1796
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1797
            { //symbol      
1798
                if(_dragdropWindow != null)
1799
                {
1800
                    Win32Point w32Mouse = new Win32Point();
1801
                    GetCursorPos(ref w32Mouse);
1802

    
1803
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1804
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1805
                }                
1806
            }
1807
            */
1808
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1809
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1810
            {
1811
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1812
                if(control != null)
1813
                {
1814
                    this.cursor = Cursors.Hand;
1815
                    SetCursor();
1816
                }
1817
                else
1818
                {
1819
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1820
                    SetCursor();
1821
                }
1822
            }
1823
            else
1824
            {
1825
            }
1826
        }
1827

    
1828
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1829
        {
1830
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1831
            {
1832
                SetCursor();
1833
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1834
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1835

    
1836
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1837

    
1838
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1839
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1840

    
1841
                if (Sync.IsChecked)
1842
                {
1843
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1844
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1845
                }
1846
            }
1847
        }
1848

    
1849
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1850

    
1851
        private EllipseGeometry hitArea = new EllipseGeometry();
1852

    
1853
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1854
        {
1855
            IsDrawing = false;
1856
    
1857
            if (mouseHandlingMode != MouseHandlingMode.None)
1858
            {
1859
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1860
                {
1861
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1862

    
1863
                    SetCursor();
1864

    
1865
                    switch (controlType)
1866
                    {
1867
                        case ControlType.None:
1868
                            break;
1869
                        case ControlType.Rectangle:
1870
                            {
1871

    
1872
                            }
1873
                            break;
1874
                        case ControlType.PenControl:
1875
                            {
1876

    
1877
                            }
1878
                            break;
1879
                        default:
1880
                            break;
1881
                    }                    
1882
                }
1883
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1884
                {
1885
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1886

    
1887
                    if (isLeftMouseButtonDownOnWindow)
1888
                    {
1889
                        bool wasDragSelectionApplied = false;
1890

    
1891
                        if (isDraggingSelectionRect)
1892
                        {
1893
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1894
                            {
1895
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1896
                                mouseHandlingMode = MouseHandlingMode.None;
1897
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1898
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1899
                                Set_Symbol_Capture(endPoint);
1900
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1901
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1902
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1903
                            }
1904
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1905
                            {
1906
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1907
                                mouseHandlingMode = MouseHandlingMode.None;
1908
                                Set_Capture();
1909

    
1910
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1911
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1912
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1913
                            }
1914
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1915
                            {
1916
                                ApplyDragSelectionRect();
1917
                            }
1918
                            else
1919
                            {
1920
                                double x = Canvas.GetLeft(dragZoomBorder);
1921
                                double y = Canvas.GetTop(dragZoomBorder);
1922
                                double width = dragZoomBorder.Width;
1923
                                double height = dragZoomBorder.Height;
1924
                                Rect dragRect = new Rect(x, y, width, height);
1925

    
1926
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1927

    
1928
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1929
                            }
1930

    
1931
                            isDraggingSelectionRect = false;
1932
                            e.Handled = true;
1933
                            wasDragSelectionApplied = true;
1934
                        }
1935

    
1936
                        if (isLeftMouseButtonDownOnWindow)
1937
                        {
1938
                            isLeftMouseButtonDownOnWindow = false;
1939
                            this.ReleaseMouseCapture();
1940
                            e.Handled = true;
1941
                        }
1942

    
1943
                        if (!wasDragSelectionApplied)
1944
                        {
1945
                            init();
1946
                        }
1947
                    }
1948
                }
1949
                else if (e.RightButton == MouseButtonState.Pressed)
1950
                {
1951
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1952
                    SetCursor();
1953
                }
1954

    
1955
                zoomAndPanControl.ReleaseMouseCapture();
1956

    
1957

    
1958
                e.Handled = true;
1959
            }
1960
            else
1961
            {
1962
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1963
                SetCursor();
1964
            }
1965

    
1966
            ///mouseButtonDown = MouseButton.Left;
1967
            //controlType = ControlType.SingleLine;
1968
        }
1969

    
1970
        public void Set_Symbol_Capture(Point endPoint)
1971
        {       
1972
            double x = CanvasDrawingMouseDownPoint.X;
1973
            double y = CanvasDrawingMouseDownPoint.Y;
1974
            if(x > endPoint.X)
1975
            {
1976
                x = endPoint.X;
1977
                y = endPoint.Y;
1978
            }
1979

    
1980
            double width = dragCaptureBorder.Width;
1981
            double height = dragCaptureBorder.Height;
1982

    
1983
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1984

    
1985
            if (x < 0)
1986
            {
1987
                width += x;
1988
                x = 0;
1989
            }
1990
            if (y < 0)
1991
            {
1992
                height += y;
1993
                y = 0;
1994

    
1995
                width = (int)canvasImage.PixelWidth - x;
1996
            }
1997
            if (x + width > canvasImage.PixelWidth)
1998
            {
1999
                width = (int)canvasImage.PixelWidth - x;
2000
            }
2001
            if (y + height > canvasImage.PixelHeight)
2002
            {
2003
                height = (int)canvasImage.PixelHeight - y;
2004
            }
2005
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2006

    
2007
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2008
            var defaultBitmapImage = new BitmapImage();
2009
            defaultBitmapImage.BeginInit();
2010
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2011
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2012
            defaultBitmapImage.UriSource = new Uri(uri);
2013
            defaultBitmapImage.EndInit();
2014

    
2015
            //GC.Collect();
2016

    
2017
            if (defaultBitmapImage.IsDownloading)
2018
            {
2019
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2020
                {
2021
                    defaultBitmapImage.Freeze();
2022
                    //GC.Collect();
2023
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2024
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2025
                };
2026
            }
2027
        }
2028

    
2029
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2030
        {
2031
            ///mouseButtonDown = MouseButton.Left;
2032
        }
2033

    
2034
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2035
        {
2036
            ///mouseButtonDown = MouseButton.Left;
2037
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2038
        }
2039

    
2040
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2041
        {
2042

    
2043
        }
2044

    
2045
        /// <summary>
2046
        /// select items by dragging
2047
        /// </summary>
2048
        private void ApplyDragSelectionRect()
2049
        {
2050
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2051

    
2052
            double x = Canvas.GetLeft(dragSelectionBorder);
2053
            double y = Canvas.GetTop(dragSelectionBorder);
2054
            double width = dragSelectionBorder.Width;
2055
            double height = dragSelectionBorder.Height;
2056
            Boolean Flag = false;
2057
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2058
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2059

    
2060
            Rect dragRect = new Rect(x, y, width, height);
2061
            ///dragRect.Inflate(width / 10, height / 10);
2062

    
2063
            foreach (var item in Items)
2064
            {
2065
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2066

    
2067
                if (Flag)
2068
                {
2069
                    adornerSet.Add(item);
2070
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2071
                    Control_Style(item);
2072
                }
2073
            }
2074
            if (adornerSet.Count > 0)
2075
            {
2076
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2077
                SelectLayer.Children.Add(final);
2078
            }
2079
        }
2080

    
2081
        private void InitDragSelectionRect(Point pt1, Point pt2)
2082
        {
2083
            //캡쳐 중
2084
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2085
            {
2086
                dragCaptureBorder.Visibility = Visibility.Visible;
2087
            }
2088
            //선택 중
2089
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2090
            {
2091

    
2092
                dragSelectionBorder.Visibility = Visibility.Visible;
2093
            }
2094
            else
2095
            {
2096
                dragZoomBorder.Visibility = Visibility.Visible;
2097
            }
2098
            UpdateDragSelectionRect(pt1, pt2);
2099
        }
2100

    
2101
        /// <summary>
2102
        /// Update the position and size of the rectangle used for drag selection.
2103
        /// </summary>
2104
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2105
        {
2106
            double x, y, width, height;
2107

    
2108
            //
2109
            // Determine x,y,width and height of the rect inverting the points if necessary.
2110
            // 
2111

    
2112
            if (pt2.X < pt1.X)
2113
            {
2114
                x = pt2.X;
2115
                width = pt1.X - pt2.X;
2116
            }
2117
            else
2118
            {
2119
                x = pt1.X;
2120
                width = pt2.X - pt1.X;
2121
            }
2122

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

    
2134
            //
2135
            // Update the coordinates of the rectangle used for drag selection.
2136
            //
2137
            //캡쳐 중
2138
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2139
            {
2140
                Canvas.SetLeft(dragCaptureBorder, x);
2141
                Canvas.SetTop(dragCaptureBorder, y);
2142
                dragCaptureBorder.Width = width;
2143
                dragCaptureBorder.Height = height;
2144
            }
2145
            //선택 중
2146
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2147
            {
2148
                Canvas.SetLeft(dragSelectionBorder, x);
2149
                Canvas.SetTop(dragSelectionBorder, y);
2150
                dragSelectionBorder.Width = width;
2151
                dragSelectionBorder.Height = height;
2152
            }
2153
            else
2154
            {
2155
                Canvas.SetLeft(dragZoomBorder, x);
2156
                Canvas.SetTop(dragZoomBorder, y);
2157
                dragZoomBorder.Width = width;
2158
                dragZoomBorder.Height = height;
2159
            }
2160
        }
2161

    
2162
        private void drawingPannelRotate(double angle)
2163
        {
2164
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2165
            rotate.Angle = angle;
2166
            var rotationNum = Math.Abs((rotate.Angle / 90));
2167

    
2168
            if (angle == 90 || angle == 270)
2169
            {
2170
                double emptySize = zoomAndPanCanvas.Width;
2171
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2172
                zoomAndPanCanvas.Height = emptySize;
2173
            }
2174
            if (angle == 0)
2175
            {
2176
                translate.X = 0;
2177
                translate.Y = 0;
2178
            }
2179
            else if (angle == 90)
2180
            {
2181
                translate.X = zoomAndPanCanvas.Width;
2182
                translate.Y = 0;
2183
            }
2184
            else if (angle == 180)
2185
            {
2186
                translate.X = zoomAndPanCanvas.Width;
2187
                translate.Y = zoomAndPanCanvas.Height;
2188
            }
2189
            else
2190
            {
2191
                translate.X = 0;
2192
                translate.Y = zoomAndPanCanvas.Height;
2193
            }
2194

    
2195
            zoomAndPanControl.RotationAngle = rotate.Angle;
2196

    
2197

    
2198
            if (!testPanel2.IsHidden)
2199
            {
2200
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2201
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2202
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2203
            }
2204

    
2205
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2206
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2207
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2208
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2209
            ViewerDataModel.Instance.Angle = rotate.Angle;
2210
        }
2211

    
2212
        private void syncPannelRotate(double angle)
2213
        {
2214
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2215
            rotate.Angle = angle;
2216
            var rotationNum = Math.Abs((rotate.Angle / 90));
2217

    
2218
            if (angle == 90 || angle == 270)
2219
            {
2220
                double emptySize = zoomAndPanCanvas2.Width;
2221
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2222
                zoomAndPanCanvas2.Height = emptySize;
2223
            }
2224
            if (angle == 0)
2225
            {
2226
                translate2.X = 0;
2227
                translate2.Y = 0;
2228
            }
2229
            else if (angle == 90)
2230
            {
2231
                translate2.X = zoomAndPanCanvas2.Width;
2232
                translate2.Y = 0;
2233
            }
2234
            else if (angle == 180)
2235
            {
2236
                translate2.X = zoomAndPanCanvas2.Width;
2237
                translate2.Y = zoomAndPanCanvas2.Height;
2238
            }
2239
            else
2240
            {
2241
                translate2.X = 0;
2242
                translate2.Y = zoomAndPanCanvas2.Height;
2243
            }
2244

    
2245
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2246
        }
2247

    
2248
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2249
        {
2250
            string Data_ = "";
2251

    
2252
            try
2253
            {
2254
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2255
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2256
                if (Data_ != null || Data_ != "")
2257
                {
2258
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2259
                }
2260
                else
2261
                {
2262
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2263
                }
2264

    
2265
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2266
                //{
2267
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2268
                //    STATE = 0,
2269
                //};
2270
                if (Data_ != null)
2271
                {
2272
                    Image img = new Image();
2273
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2274
                    if (Data_.Contains(".svg"))
2275
                    {
2276
                        byte[] imageData = null;
2277
                        DrawingImage image = null;
2278
                        using (System.Net.WebClient web = new System.Net.WebClient())
2279
                        {
2280
                            imageData = web.DownloadData(new Uri(Data_));
2281
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2282
                            image = SvgReader.Load(stream);
2283
                        }
2284
                        img.Source = image;
2285
                    }
2286
                    else
2287
                    {
2288
                        img.Source = new BitmapImage(new Uri(Data_));
2289
                    }
2290

    
2291
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2292
                    {
2293
                        PointSet = new List<Point>(),
2294
                        FilePath = Data_,
2295
                        ImageData = img.Source,
2296
                        StartPoint = canvasZoomPanningMouseDownPoint,
2297
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2298
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2299
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2300
                        canvasZoomPanningMouseDownPoint.Y),
2301
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2302
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2303
                    };
2304

    
2305
                    currentControl.PointSet = new List<Point>
2306
                                        {
2307
                                            currentControl.StartPoint,
2308
                                            currentControl.LeftBottomPoint,
2309
                                            currentControl.EndPoint,
2310
                                            currentControl.TopRightPoint,
2311
                                        };
2312
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2313
                    UndoData = new Undo_data()
2314
                    {
2315
                        IsUndo = false,
2316
                        Event = Event_Type.Create,
2317
                        EventTime = DateTime.Now,
2318
                        Markup_List = new List<Multi_Undo_data>()
2319
                    };
2320
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2321
                    {
2322
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2323
                    });
2324

    
2325
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2326
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2327
                    UndoData.Markup_List.Add(multi_Undo_Data);
2328
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2329

    
2330
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2331
                    currentControl.CommentID = Commons.shortGuid();
2332
                    currentControl.SymbolID = id;
2333
                    currentControl.GroupID = group_id;
2334
                    currentControl.ApplyTemplate();
2335
                    currentControl.SetImage();
2336

    
2337
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2338
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2339
                    SelectLayer.Children.Add(final);
2340
                }
2341
            }
2342
            catch (Exception ex)
2343
            {
2344
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2345
            }
2346
        }
2347

    
2348
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2349
        {
2350
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2351
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2352
            {
2353
                set_option.Value = double.Parse(set_option.ContentText);
2354
                //set_option.Focusable = false;
2355
                zoomAndPanControl.Focus();
2356
            }
2357

    
2358
            ConvertInkControlToPolygon();
2359

    
2360
            ///TODO:
2361
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2362
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2363

    
2364
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2365
            {
2366
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2367
            }
2368
            /// up to here
2369

    
2370
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2371
            {
2372
                if (item as ArrowTextControl != null)
2373
                {
2374
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2375
                }
2376
                else if (item as TextControl != null)
2377
                {
2378
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2379
                }
2380
            }
2381

    
2382
            //if (currentControl != null)
2383
            {
2384
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2385
                if (text_item_ != null)
2386
                {
2387
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2388
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2389
                    (text_item_ as TextControl).IsEditingMode = false;                    
2390
                    currentControl = null;
2391
                }
2392

    
2393
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2394
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2395
                {
2396
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2397
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2398
                    currentControl = null;
2399
                }
2400
            }
2401

    
2402
            double Ang = 0;                                          
2403
            if (rotate.Angle != 0)
2404
            {
2405
                Ang = 360 - rotate.Angle;
2406
            }
2407

    
2408
            if (e.OriginalSource is System.Windows.Controls.Image)
2409
            {
2410
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2411
            }
2412
            /*
2413
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2414
            {                
2415
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2416
                if(symbol_id != null)
2417
                {
2418
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2419
                }                
2420
            }
2421

    
2422
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2423
            {
2424
                if (this._dragdropWindow != null)
2425
                {
2426
                    this._dragdropWindow.Close();
2427
                    this._dragdropWindow = null;
2428
                    symbol_id = null;
2429
                }
2430
            }
2431
            */
2432

    
2433
            if (e.LeftButton == MouseButtonState.Pressed)
2434
            {
2435
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2436
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2437

    
2438
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2439
                SetCursor();
2440

    
2441
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2442
            }
2443

    
2444
            if (e.MiddleButton == MouseButtonState.Pressed)
2445
            {
2446
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2447
                cursor = Cursors.SizeAll;
2448
                SetCursor();
2449
            }
2450
            if (e.RightButton == MouseButtonState.Pressed)
2451
            {
2452
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2453
                cursor = Cursors.SizeAll;
2454
                SetCursor();
2455
            }
2456
            else if (e.XButton1 == MouseButtonState.Pressed)
2457
            {
2458
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2459
                {
2460
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2461
                }
2462

    
2463
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2464

    
2465
            }
2466
            else if (e.XButton2 == MouseButtonState.Pressed)
2467
            {
2468
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2469
                {
2470
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2471
                }
2472
            }
2473

    
2474
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2475
            {
2476
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2477
                {
2478
                    if (SelectLayer.Children.Count == 0)
2479
                    {
2480
                        isLeftMouseButtonDownOnWindow = true;
2481
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2482
                    }
2483

    
2484
                    if (controlType == ControlType.None)
2485
                    {
2486
                        isLeftMouseButtonDownOnWindow = true;
2487
                    }
2488
                }
2489

    
2490
                /// 캡쳐 모드 설정
2491
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2492
                {
2493
                    dragCaptureBorder.Visibility = Visibility.Visible;
2494
                    isLeftMouseButtonDownOnWindow = true;
2495
                }
2496

    
2497
                /// 줌 모드 설정
2498
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2499
                {
2500
                    isLeftMouseButtonDownOnWindow = true;
2501
                }
2502

    
2503
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2504
                if (control != null)
2505
                {
2506
                    AdornerFinal final = null;
2507

    
2508
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2509
                    {
2510
                        /// 기존 selection 해제
2511
                        SelectionSet.Instance.UnSelect(this);
2512

    
2513
                        final = new AdornerFinal(control);
2514

    
2515
                        this.Control_Style(control);
2516

    
2517
                        if ((control as IPath) != null)
2518
                        {
2519
                            if ((control as IPath).LineSize != 0)
2520
                            {
2521
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2522
                            }
2523
                        }
2524
                        if ((control as IShapeControl) != null)
2525
                        {
2526
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2527
                            {
2528
                                ViewerDataModel.Instance.checkHatchShape = true;
2529
                            }
2530
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2531
                            {
2532
                                ViewerDataModel.Instance.checkFillShape = true;
2533
                            }
2534
                            else
2535
                            {
2536
                                ViewerDataModel.Instance.checkHatchShape = false;
2537
                                ViewerDataModel.Instance.checkFillShape = false;
2538
                            }
2539
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2540
                        }
2541

    
2542
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2543

    
2544
                        if ((control as TextControl) != null)
2545
                        {
2546
                            if(!((control as TextControl).EnableEditing)) {
2547
                                (control as TextControl).EnableEditing = true;
2548
                            }
2549
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2550
                            {
2551
                                ViewerDataModel.Instance.checkTextStyle = true;
2552
                            }
2553
                            else
2554
                            {
2555
                                ViewerDataModel.Instance.checkTextStyle = false;
2556
                            }
2557
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2558
                            {
2559
                                ViewerDataModel.Instance.checkTextWeight = true;
2560
                            }
2561
                            else
2562
                            {
2563
                                ViewerDataModel.Instance.checkTextWeight = false;
2564
                            }
2565
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2566
                            {
2567
                                ViewerDataModel.Instance.checkUnderLine = true;
2568
                            }
2569
                            else
2570
                            {
2571
                                ViewerDataModel.Instance.checkUnderLine = false;
2572
                            }
2573
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2574
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2575

    
2576
                        }
2577
                        else if ((control as ArrowTextControl) != null)
2578
                        {
2579
                            if (!((control as ArrowTextControl).EnableEditing))
2580
                            {
2581
                                (control as ArrowTextControl).EnableEditing = true;
2582
                            }
2583
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2584
                            {
2585
                                ViewerDataModel.Instance.checkTextStyle = true;
2586
                            }
2587
                            else
2588
                            {
2589
                                ViewerDataModel.Instance.checkTextStyle = false;
2590
                            }
2591
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2592
                            {
2593
                                ViewerDataModel.Instance.checkTextWeight = true;
2594
                            }
2595
                            else
2596
                            {
2597
                                ViewerDataModel.Instance.checkTextWeight = false;
2598
                            }
2599
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2600
                            {
2601
                                ViewerDataModel.Instance.checkUnderLine = true;
2602
                            }
2603
                            else
2604
                            {
2605
                                ViewerDataModel.Instance.checkUnderLine = false;
2606
                            }
2607
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2608
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2609
                        }
2610
                        else if ((control as RectCloudControl) != null)
2611
                        {
2612
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2613
                        }
2614
                        else if ((control as CloudControl) != null)
2615
                        {
2616
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2617
                        }
2618
                    }
2619
                    else
2620
                    {
2621
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2622
                        SelectionSet.Instance.UnSelect(this);
2623
                        comment.Add(control);
2624

    
2625
                        Control_Style(control);
2626

    
2627
                        final = new AdornerFinal(comment);
2628
                    }
2629

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

    
2674
                switch (controlType)
2675
                {
2676
                    case ControlType.Coordinate:
2677
                        {
2678
                            if (e.LeftButton == MouseButtonState.Pressed)
2679
                            {
2680
                                if (currentControl is CoordinateControl)
2681
                                {
2682
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2683
                                    {
2684
                                        return;
2685
                                    }
2686

    
2687
                                    CreateCommand.Instance.Execute(currentControl);
2688

    
2689
                                    currentControl = null;
2690
                                    this.cursor = Cursors.Arrow;
2691
                                }
2692
                                else
2693
                                {
2694
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2695
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2696
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2697
                                    {
2698
                                        currentControl = null;
2699
                                        this.cursor = Cursors.Arrow;
2700
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2701
                                        return;
2702
                                    }
2703
                                    else
2704
                                    {
2705
                                        currentControl = new CoordinateControl
2706
                                        {
2707
                                            Background = new SolidColorBrush(Colors.Black),
2708
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2709
                                            ControlType = ControlType.Coordinate
2710
                                        };
2711

    
2712
                                        currentControl.CommentID = Commons.shortGuid();
2713
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2714
                                        currentControl.IsNew = true;
2715

    
2716
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2717

    
2718
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2719
                                    }
2720
                                }
2721
                            }
2722
                        }
2723
                        break;
2724
                    case ControlType.InsideWhite:
2725
                        {
2726
                            if (e.LeftButton == MouseButtonState.Pressed)
2727
                            {
2728
                                if (currentControl is InsideWhiteControl)
2729
                                {
2730
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2731
                                    {
2732
                                        return;
2733
                                    }
2734

    
2735
                                    CreateCommand.Instance.Execute(currentControl);
2736

    
2737
                                    currentControl = null;
2738
                                    this.cursor = Cursors.Arrow;
2739
                                }
2740
                                else
2741
                                {
2742
                                    currentControl = new InsideWhiteControl
2743
                                    {
2744
                                        Background = new SolidColorBrush(Colors.Black),
2745
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2746
                                        ControlType = ControlType.InsideWhite
2747
                                    };
2748

    
2749
                                    currentControl.CommentID = Commons.shortGuid();
2750
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2751
                                    currentControl.IsNew = true;
2752
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2753

    
2754
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2755
                                }
2756
                            }
2757
                        }
2758
                        break;
2759
                    case ControlType.OverlapWhite:
2760
                        {
2761
                            if (e.LeftButton == MouseButtonState.Pressed)
2762
                            {
2763
                                if (currentControl is OverlapWhiteControl)
2764
                                {
2765
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2766
                                    {
2767
                                        return;
2768
                                    }
2769

    
2770
                                    CreateCommand.Instance.Execute(currentControl);
2771

    
2772
                                    currentControl = null;
2773
                                    this.cursor = Cursors.Arrow;
2774
                                }
2775
                                else
2776
                                {
2777
                                    currentControl = new OverlapWhiteControl
2778
                                    {
2779
                                        Background = new SolidColorBrush(Colors.Black),
2780
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2781
                                        ControlType = ControlType.OverlapWhite
2782
                                    };
2783

    
2784
                                    currentControl.CommentID = Commons.shortGuid();
2785
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2786
                                    currentControl.IsNew = true;
2787
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2788

    
2789
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2790
                                }
2791
                            }
2792
                        }
2793
                        break;
2794
                    case ControlType.ClipWhite:
2795
                        {
2796
                            if (e.LeftButton == MouseButtonState.Pressed)
2797
                            {
2798
                                if (currentControl is ClipWhiteControl)
2799
                                {
2800
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2801
                                    {
2802
                                        return;
2803
                                    }
2804

    
2805
                                    CreateCommand.Instance.Execute(currentControl);
2806

    
2807
                                    currentControl = null;
2808
                                    this.cursor = Cursors.Arrow;
2809
                                }
2810
                                else
2811
                                {
2812
                                    currentControl = new ClipWhiteControl
2813
                                    {
2814
                                        Background = new SolidColorBrush(Colors.Black),
2815
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2816
                                        ControlType = ControlType.ClipWhite
2817
                                    };
2818

    
2819
                                    currentControl.CommentID = Commons.shortGuid();
2820
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2821
                                    currentControl.IsNew = true;
2822
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2823

    
2824
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2825
                                }
2826
                            }
2827
                        }
2828
                        break;
2829
                    case ControlType.Rectangle:
2830
                        {
2831
                            if (e.LeftButton == MouseButtonState.Pressed)
2832
                            {
2833
                                if (currentControl is RectangleControl)
2834
                                {
2835
                                    //20180906 LJY TEST IsRotationDrawingEnable
2836
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2837
                                    {
2838
                                        return;
2839
                                    }
2840

    
2841
                                    CreateCommand.Instance.Execute(currentControl);
2842
                                    currentControl = null;
2843
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2844
                                }
2845
                                else
2846
                                {
2847
                                    currentControl = new RectangleControl
2848
                                    {
2849
                                        Background = new SolidColorBrush(Colors.Black),
2850
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2851
                                        ControlType = ControlType.Rectangle
2852
                                    };
2853

    
2854
                                    currentControl.CommentID = Commons.shortGuid();
2855
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2856
                                    currentControl.IsNew = true;
2857
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2858

    
2859
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2860
                                }
2861
                            }
2862
                        }
2863
                        break;
2864
                    case ControlType.RectCloud:
2865
                        {
2866
                            if (e.LeftButton == MouseButtonState.Pressed)
2867
                            {
2868
                                if (currentControl is RectCloudControl)
2869
                                {
2870
                                    //20180906 LJY TEST IsRotationDrawingEnable
2871
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2872
                                    {
2873
                                        return;
2874
                                    }
2875

    
2876
                                    CreateCommand.Instance.Execute(currentControl);
2877

    
2878
                                    currentControl = null;
2879
                                
2880
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2881
                                }
2882
                                else
2883
                                {
2884
                                    currentControl = new RectCloudControl
2885
                                    {
2886
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2887
                                        ControlType = ControlType.RectCloud,
2888
                                        Background = new SolidColorBrush(Colors.Black)
2889
                                    };
2890

    
2891
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2892
                                    currentControl.CommentID = Commons.shortGuid();
2893
                                    currentControl.IsNew = true;
2894
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2895
                                }
2896
                            }
2897
                        }
2898
                        break;
2899
                    case ControlType.Circle:
2900
                        {
2901
                            if (e.LeftButton == MouseButtonState.Pressed)
2902
                            {
2903
                                if (currentControl is CircleControl)
2904
                                {
2905
                                    //20180906 LJY TEST IsRotationDrawingEnable
2906
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2907
                                    {
2908
                                        return;
2909
                                    }
2910

    
2911
                                    CreateCommand.Instance.Execute(currentControl);
2912

    
2913
                                    currentControl = null;
2914
                                }
2915
                                else
2916
                                {
2917
                                    currentControl = new CircleControl
2918
                                    {
2919
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2920
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2921
                                        Background = new SolidColorBrush(Colors.Black)
2922
                                    };
2923

    
2924
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2925
                                    currentControl.CommentID = Commons.shortGuid();
2926
                                    currentControl.IsNew = true;
2927
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2928
                                }
2929
                            }
2930
                        }
2931
                        break;
2932
                    case ControlType.Triangle:
2933
                        {
2934
                            if (e.LeftButton == MouseButtonState.Pressed)
2935
                            {
2936
                                if (currentControl is TriControl)
2937
                                {
2938
                                    var content = currentControl as TriControl;
2939
                                    if (content.MidPoint == new Point(0, 0))
2940
                                    {
2941
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2942
                                    }
2943
                                    else
2944
                                    {
2945
                                        //20180906 LJY TEST IsRotationDrawingEnable
2946
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2947
                                        {
2948
                                            return;
2949
                                        }
2950

    
2951
                                        CreateCommand.Instance.Execute(currentControl);
2952

    
2953
                                        currentControl = null;
2954
                                    }
2955
                                }
2956
                                else
2957
                                {
2958
                                    currentControl = new TriControl
2959
                                    {
2960
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2961
                                        Background = new SolidColorBrush(Colors.Black),
2962
                                    };
2963

    
2964
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2965
                                    currentControl.CommentID = Commons.shortGuid();
2966
                                    currentControl.IsNew = true;
2967
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2968
                                }
2969
                            }
2970
                        }
2971
                        break;
2972
                    case ControlType.CancelLine:
2973
                    case ControlType.SingleLine:
2974
                    case ControlType.ArrowLine:
2975
                    case ControlType.TwinLine:
2976
                    case ControlType.DimLine:
2977
                        {
2978
                            if (e.LeftButton == MouseButtonState.Pressed)
2979
                            {
2980
                                if (currentControl is LineControl)
2981
                                {
2982
                                    //20180906 LJY TEST IsRotationDrawingEnable
2983
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2984
                                    {
2985
                                        return;
2986
                                    }
2987

    
2988
                                    CreateCommand.Instance.Execute(currentControl);
2989
                                    currentControl = null;
2990
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2991
                                }
2992
                                else
2993
                                {
2994
                                    currentControl = new LineControl
2995
                                    {
2996
                                        ControlType = this.controlType,
2997
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2998
                                        Background = new SolidColorBrush(Colors.Black)
2999
                                    };
3000

    
3001
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3002
                                    currentControl.CommentID = Commons.shortGuid();
3003
                                    currentControl.IsNew = true;
3004
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3005
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3006
                                }
3007
                            }
3008
                        }
3009
                        break;
3010
                    case ControlType.PolygonControl:
3011
                        {
3012
                            if (currentControl is PolygonControl)
3013
                            {
3014
                                var control = currentControl as PolygonControl;
3015

    
3016
                                if (e.RightButton == MouseButtonState.Pressed)
3017
                                {
3018
                                    control.IsCompleted = true;
3019
                                }
3020

    
3021
                                if (!control.IsCompleted)
3022
                                {
3023
                                    control.PointSet.Add(control.EndPoint);
3024
                                }
3025
                                else
3026
                                {
3027
                                    //20180906 LJY TEST IsRotationDrawingEnable
3028
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3029
                                    {
3030
                                        return;
3031
                                    }
3032

    
3033
                                    var firstPoint = control.PointSet.First();
3034
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3035
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3036
                                    control.PointSet.Add(firstPoint);
3037

    
3038
                                    control.ApplyOverViewData();
3039

    
3040
                                    CreateCommand.Instance.Execute(currentControl);
3041
                                    control.UpdateControl();
3042
                                    currentControl = null;
3043
                                }
3044
                            }
3045
                            else
3046
                            {
3047
                                if (e.LeftButton == MouseButtonState.Pressed)
3048
                                {
3049
                                    currentControl = new PolygonControl
3050
                                    {
3051
                                        PointSet = new List<Point>(),
3052
                                    };
3053

    
3054
                                    var polygonControl = (currentControl as PolygonControl);
3055
                                    currentControl.CommentID = Commons.shortGuid();
3056
                                    currentControl.IsNew = true;
3057
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3058
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3059
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3060
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3061
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3062
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3063
                                    polygonControl.ApplyTemplate();
3064
                                    polygonControl.Visibility = Visibility.Visible;
3065
                                }
3066
                            }
3067
                        }
3068
                        break;
3069
                    case ControlType.ChainLine:
3070
                        {
3071
                            if (currentControl is PolygonControl)
3072
                            {
3073
                                var control = currentControl as PolygonControl;
3074

    
3075
                                if (e.RightButton == MouseButtonState.Pressed)
3076
                                {
3077
                                    //20180906 LJY TEST IsRotationDrawingEnable
3078
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3079
                                    {
3080
                                        return;
3081
                                    }
3082

    
3083
                                    CreateCommand.Instance.Execute(currentControl);
3084

    
3085
                                    currentControl = null;
3086
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3087
                                    return;
3088
                                }
3089

    
3090
                                if (!control.IsCompleted)
3091
                                {
3092
                                    control.PointSet.Add(control.EndPoint);
3093
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3094
                                }
3095
                            }
3096
                            else
3097
                            {
3098
                                if (e.LeftButton == MouseButtonState.Pressed)
3099
                                {
3100
                                    MainAngle.Visibility = Visibility.Visible;
3101
                                    currentControl = new PolygonControl
3102
                                    {
3103
                                        PointSet = new List<Point>(),
3104
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3105
                                        ControlType = ControlType.ChainLine,
3106
                                        DashSize = ViewerDataModel.Instance.DashSize,
3107
                                        LineSize = ViewerDataModel.Instance.LineSize,
3108
                                        //PointC = new StylusPointSet()
3109
                                    };
3110

    
3111
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3112
                                    //{
3113
                                        var polygonControl = (currentControl as PolygonControl);
3114
                                        currentControl.CommentID = Commons.shortGuid();
3115
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3116
                                        currentControl.IsNew = true;
3117
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3118
                                        //currentControl.OnApplyTemplate();
3119
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3120
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3121
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3122
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3123
                                    //}
3124
                                }
3125
                            }
3126
                        }
3127
                        break;
3128
                    case ControlType.ArcLine:
3129
                        {
3130
                            if (e.LeftButton == MouseButtonState.Pressed)
3131
                            {
3132
                                if (currentControl is ArcControl)
3133
                                {
3134
                                    //20180906 LJY TEST IsRotationDrawingEnable
3135
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3136
                                    {
3137
                                        return;
3138
                                    }
3139

    
3140
                                    CreateCommand.Instance.Execute(currentControl);
3141

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

    
3183
                                    CreateCommand.Instance.Execute(currentControl);
3184

    
3185
                                    currentControl = null;
3186
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3187
                                }
3188
                                else
3189
                                {
3190
                                    currentControl = new ArrowArcControl
3191
                                    {
3192
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3193
                                        Background = new SolidColorBrush(Colors.Black)
3194
                                    };
3195
                                    currentControl.CommentID = Commons.shortGuid();
3196
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3197
                                    currentControl.IsNew = true;
3198
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3199
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3200
                                }
3201
                                //}
3202
                            }
3203
                            else if (e.RightButton == MouseButtonState.Pressed)
3204
                            {
3205
                                if (currentControl != null)
3206
                                {
3207
                                    (currentControl as ArrowArcControl).setClock();
3208
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3209
                                    //(currentControl as ArcControl).ApplyTemplate();
3210
                                }
3211
                            }
3212
                        }
3213
                        break;
3214
                    case ControlType.ArrowMultiLine:
3215
                        {
3216
                            if (e.LeftButton == MouseButtonState.Pressed)
3217
                            {
3218
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3219
                                //{
3220

    
3221
                                    if (currentControl is ArrowControl_Multi)
3222
                                    {
3223
                                        var content = currentControl as ArrowControl_Multi;
3224
                                        if (content.MiddlePoint == new Point(0, 0))
3225
                                        {
3226
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3227
                                            {
3228
                                                content.MiddlePoint = content.EndPoint;
3229
                                            }
3230
                                            else
3231
                                            {
3232
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3233
                                            }
3234
                                        }
3235
                                        else
3236
                                        {
3237
                                            //20180906 LJY TEST IsRotationDrawingEnable
3238
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3239
                                            {
3240
                                                return;
3241
                                            }
3242

    
3243
                                            CreateCommand.Instance.Execute(currentControl);
3244

    
3245
                                            currentControl = null;
3246
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3247
                                        }
3248
                                    }
3249
                                    else
3250
                                    {
3251
                                        currentControl = new ArrowControl_Multi
3252
                                        {
3253
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3254
                                            Background = new SolidColorBrush(Colors.Black)
3255
                                        };
3256
                                        currentControl.CommentID = Commons.shortGuid();
3257
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3258
                                        currentControl.IsNew = true;
3259
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3260
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3261
                                    }
3262
                                //}
3263
                            }
3264
                        }
3265
                        break;
3266
                    case ControlType.PolygonCloud:
3267
                        {
3268
                            if (currentControl is CloudControl)
3269
                            {
3270
                                var control = currentControl as CloudControl;
3271
                                if (e.RightButton == MouseButtonState.Pressed)
3272
                                {
3273
                                    control.IsCompleted = true;
3274
                                }
3275

    
3276
                                if (!control.IsCompleted)
3277
                                {
3278
                                    control.PointSet.Add(control.EndPoint);
3279
                                }
3280
                                else
3281
                                {
3282
                                    //20180906 LJY TEST IsRotationDrawingEnable
3283
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3284
                                    {
3285
                                        return;
3286
                                    }
3287

    
3288
                                    CreateCommand.Instance.Execute(currentControl);
3289

    
3290
                                    control.isTransOn = true;
3291
                                    var firstPoint = control.PointSet.First();
3292

    
3293
                                    control.PointSet.Add(firstPoint);
3294
                                    control.DrawingCloud();
3295
                                    control.ApplyOverViewData();
3296

    
3297
                                    currentControl = null;
3298
                                }
3299
                            }
3300
                            else
3301
                            {
3302
                                if (e.LeftButton == MouseButtonState.Pressed)
3303
                                {
3304
                                    currentControl = new CloudControl
3305
                                    {
3306
                                        PointSet = new List<Point>(),
3307
                                        PointC = new StylusPointSet()
3308
                                    };
3309

    
3310
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3311
                                    //{
3312
                                        var polygonControl = (currentControl as CloudControl);
3313
                                        currentControl.CommentID = Commons.shortGuid();
3314
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3315
                                        currentControl.IsNew = true;
3316
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3317

    
3318
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3319
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3320
                                    
3321
                                    //}
3322
                                }
3323
                            }
3324
                        }
3325
                        break;
3326
                    case ControlType.ImgControl:
3327
                        {
3328
                            if (e.LeftButton == MouseButtonState.Pressed)
3329
                            {
3330
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3331
                                //{
3332
                                    if (currentControl is ImgControl)
3333
                                    {
3334
                                        //20180906 LJY TEST IsRotationDrawingEnable
3335
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3336
                                        {
3337
                                            return;
3338
                                        }
3339

    
3340
                                        CreateCommand.Instance.Execute(currentControl);
3341
                                        controlType = ControlType.ImgControl;
3342
                                        currentControl = null;
3343
                                    }
3344
                                    else
3345
                                    {
3346
                                        
3347
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3348
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3349
                                        {
3350
                                            Image img = new Image();
3351
                                            if (filename.Contains(".svg"))
3352
                                            {
3353
                                                byte[] imageData = null;
3354
                                                DrawingImage image = null;
3355
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3356
                                                {
3357
                                                    imageData = web.DownloadData(new Uri(filename));
3358
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3359
                                                    image = SvgReader.Load(stream);
3360
                                                }
3361
                                                img.Source = image;
3362
                                            }
3363
                                            else
3364
                                            {
3365
                                                img.Source = new BitmapImage(new Uri(filename));
3366
                                            }
3367

    
3368
                                            currentControl = new ImgControl
3369
                                            {
3370
                                                    Background = new SolidColorBrush(Colors.Black),
3371
                                                    PointSet = new List<Point>(),
3372
                                                    FilePath = filename,
3373
                                                    ImageData = img.Source,
3374
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3375
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3376
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3377
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3378
                                                    ControlType = ControlType.ImgControl
3379
                                                };
3380

    
3381
                                        
3382
                                                currentControl.CommentID = Commons.shortGuid();                                            
3383
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3384
                                                currentControl.IsNew = true;
3385
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3386

    
3387
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3388
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3389
                                    }
3390
                                    }
3391
                                //}
3392
                            }
3393
                        }
3394
                        break;
3395
                    case ControlType.Date:
3396
                        {
3397
                            if (e.LeftButton == MouseButtonState.Pressed)
3398
                            {
3399
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3400
                                //{
3401
                                if (currentControl is DateControl)
3402
                                {
3403
                                    //20180906 LJY TEST IsRotationDrawingEnable
3404
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3405
                                    {
3406
                                        return;
3407
                                    }
3408

    
3409
                                    CreateCommand.Instance.Execute(currentControl);
3410
                                    currentControl = null;
3411

    
3412
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3413
                                    {
3414
                                        controlType = ControlType.None;
3415
                                        IsSwingMode = false;
3416
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3417
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3418
                                        mouseHandlingMode = MouseHandlingMode.None;
3419
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3420
                                        txtBatch.Visibility = Visibility.Collapsed;
3421

    
3422
                                    }
3423
                                }
3424
                                else
3425
                                {
3426
                                    currentControl = new DateControl
3427
                                    {
3428
                                        StartPoint = CanvasDrawingMouseDownPoint,
3429
                                        Background = new SolidColorBrush(Colors.Black)
3430
                                    };
3431
                                    currentControl.CommentID = Commons.shortGuid();
3432
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3433
                                    currentControl.IsNew = true;
3434
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3435

    
3436
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3437
                                    if (currentControl is ImgControl)
3438
                                    {
3439
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3440
                                    }
3441
                                }
3442
                                //}
3443
                            }
3444
                        }
3445
                        break;
3446
                    case ControlType.TextControl:
3447
                        {
3448
                            if (e.LeftButton == MouseButtonState.Pressed)
3449
                            {
3450
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3451
                                {
3452
                                    currentControl = new TextControl
3453
                                    {
3454
                                        ControlType = controlType
3455
                                    };
3456
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3457
                                    currentControl.CommentID = Commons.shortGuid();
3458
                                    currentControl.IsNew = true;
3459
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3460
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3461
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3462

    
3463
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3464
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3465
                                    
3466
                                    (currentControl as TextControl).ControlType_No = 0;
3467
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3468
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3469
                                    (currentControl as TextControl).ApplyTemplate();
3470
                                    (currentControl as TextControl).Base_TextBox.Focus();
3471
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3472
                                    CreateCommand.Instance.Execute(currentControl);
3473
                                }
3474
                            }
3475
                        }
3476
                        break;
3477
                    case ControlType.TextBorder:
3478
                        {
3479
                            if (e.LeftButton == MouseButtonState.Pressed)
3480
                            {
3481
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3482
                                {
3483
                                    currentControl = new TextControl
3484
                                    {
3485
                                        ControlType = controlType
3486
                                    };
3487

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

    
3519
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3520
                                    currentControl.CommentID = Commons.shortGuid();
3521
                                    currentControl.IsNew = true;
3522
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3523
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3524

    
3525
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3526
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3527
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3528

    
3529
                                    (currentControl as TextControl).CommentAngle = Ang;
3530
                                    (currentControl as TextControl).ControlType_No = 2;
3531
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3532
                                    (currentControl as TextControl).ApplyTemplate();
3533
                                    (currentControl as TextControl).Base_TextBox.Focus();
3534
                                    CreateCommand.Instance.Execute(currentControl);
3535
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3536
                                    //currentControl = null;
3537
                                }
3538
                            }
3539
                        }
3540
                        break;
3541
                    case ControlType.ArrowTextControl:
3542
                         {
3543
                            if (e.LeftButton == MouseButtonState.Pressed)
3544
                            {
3545
                                if (currentControl is ArrowTextControl)
3546
                                {
3547
                                    //20180906 LJY TEST IsRotationDrawingEnable
3548
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3549
                                    {
3550
                                        return;
3551
                                    }
3552

    
3553
                                    CreateCommand.Instance.Execute(currentControl);
3554

    
3555
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3556
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3557
                                    (currentControl as ArrowTextControl).IsNew = false;
3558
                                    currentControl = null;
3559
                                }
3560
                                else
3561
                                {
3562
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3563
                                    //{
3564
                                        currentControl = new ArrowTextControl();
3565
                                        currentControl.CommentID = Commons.shortGuid();
3566
                                        currentControl.IsNew = true;
3567
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3568
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3569

    
3570
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3571
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3572
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3573
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3574
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3575

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

    
3579
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3580
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3581
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3582
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3583

    
3584
                                    
3585
                                    //}
3586
                                }
3587
                            }
3588
                        }
3589
                        break;
3590
                    case ControlType.ArrowTransTextControl:
3591
                        {
3592
                            if (e.LeftButton == MouseButtonState.Pressed)
3593
                            {
3594
                                if (currentControl is ArrowTextControl)
3595
                                {
3596
                                    //20180906 LJY TEST IsRotationDrawingEnable
3597
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3598
                                    {
3599
                                        return;
3600
                                    }
3601

    
3602
                                    CreateCommand.Instance.Execute(currentControl);
3603

    
3604
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3605
                                    
3606
                                    currentControl.IsNew = false;
3607
                                    currentControl = null;
3608
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3609
                                }
3610
                                else
3611
                                {
3612
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3613
                                    //{
3614
                                    currentControl = new ArrowTextControl()
3615
                                    {
3616
                                        ControlType = ControlType.ArrowTransTextControl
3617
                                    };
3618
                                    currentControl.CommentID = Commons.shortGuid();
3619
                                    currentControl.IsNew = true;
3620
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3621
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3622
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3623
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3624
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3625
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3626
                                    (currentControl as ArrowTextControl).isFixed = true;
3627
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3628

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

    
3632
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3633
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3634
                                    (currentControl as ArrowTextControl).isTrans = true;
3635
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3636
                                }
3637
                            }
3638
                        }
3639
                        break;
3640
                    case ControlType.ArrowTextBorderControl:
3641
                         {
3642
                            if (e.LeftButton == MouseButtonState.Pressed)
3643
                            {
3644
                                if (currentControl is ArrowTextControl)
3645
                                {
3646
                                    //20180906 LJY TEST IsRotationDrawingEnable
3647
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3648
                                    {
3649
                                        return;
3650
                                    }
3651

    
3652
                                    CreateCommand.Instance.Execute(currentControl);
3653
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3654
                                    currentControl.IsNew = false;
3655
                                    currentControl = null;
3656
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3657
                                }
3658
                                else
3659
                                {
3660
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3661
                                    //{
3662
                                        currentControl = new ArrowTextControl()
3663
                                        {
3664
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3665
                                        };
3666
                                        currentControl.CommentID = Commons.shortGuid();
3667
                                        currentControl.IsNew = true;
3668
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3669
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3670

    
3671
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3672

    
3673
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3674

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

    
3705
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3706
                                }
3707
                                else
3708
                                {
3709
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3710
                                    //{
3711
                                    
3712

    
3713
                                    currentControl = new ArrowTextControl()
3714
                                    {
3715
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3716
                                        ControlType = ControlType.ArrowTransTextBorderControl
3717

    
3718
                                    };
3719
                                        currentControl.CommentID = Commons.shortGuid();
3720
                                        currentControl.IsNew = true;
3721
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3722
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3723

    
3724
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3725

    
3726
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3727
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3728
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3729
                                        (currentControl as ArrowTextControl).isFixed = true;
3730
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3731
                                     
3732
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3733
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3734
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3735
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3736
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3737
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3738
                                    
3739
                                    //20180911 LJY
3740
                                        (currentControl as ArrowTextControl).isTrans = true;
3741
                                    
3742

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

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

    
3821
                                        };
3822
                                        currentControl.CommentID = Commons.shortGuid();
3823
                                        currentControl.IsNew = true; 
3824
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3825
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3826
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3827

    
3828
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3829
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3830
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3831
                                        (currentControl as ArrowTextControl).isFixed = true;
3832
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3833

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

    
3857
                                if (_sign == null)
3858
                                    {
3859
                                        txtBatch.Visibility = Visibility.Collapsed;
3860
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3861
                                        controlType = ControlType.None;
3862

    
3863
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3864
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3865
                                        return;
3866
                                    }
3867

    
3868
                                    if (currentControl is SignControl)
3869
                                    {
3870
                                        //20180906 LJY TEST IsRotationDrawingEnable
3871
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3872
                                        {
3873
                                            return;
3874
                                        }
3875

    
3876
                                        CreateCommand.Instance.Execute(currentControl);
3877
                                        currentControl = null;
3878
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3879
                                        {
3880
                                            txtBatch.Text = "Place Date";
3881
                                            controlType = ControlType.Date;
3882
                                        }
3883
                                    }
3884
                                    else
3885
                                    {
3886
                                        currentControl = new SignControl
3887
                                        {
3888
                                            Background = new SolidColorBrush(Colors.Black),
3889
                                            UserNumber = App.ViewInfo.UserID,
3890
                                            ProjectNO = App.ViewInfo.ProjectNO,
3891
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3892
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3893
                                            ControlType = ControlType.Sign
3894
                                        };
3895

    
3896
                                        currentControl.CommentID = Commons.shortGuid();
3897
                                        currentControl.IsNew = true;
3898
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3899
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3900

    
3901
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3902
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3903
                                }
3904
                                //}
3905
                            }
3906
                        }
3907
                        break;
3908
                    case ControlType.Mark:
3909
                        {
3910
                            if (e.LeftButton == MouseButtonState.Pressed)
3911
                            {
3912
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3913
                                //{
3914
                                    if (currentControl is RectangleControl)
3915
                                    {
3916
                                        //20180906 LJY TEST IsRotationDrawingEnable
3917
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3918
                                        {
3919
                                            return;
3920
                                        }
3921

    
3922
                                        CreateCommand.Instance.Execute(currentControl);
3923
                                        (currentControl as RectangleControl).ApplyOverViewData();
3924
                                        currentControl = null;
3925
                                    
3926
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3927

    
3928
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3929
                                        {
3930
                                            txtBatch.Text = "Place Signature";
3931
                                            controlType = ControlType.Sign;
3932
                                        }
3933
                                    }
3934
                                    else
3935
                                    {
3936
                                        currentControl = new RectangleControl
3937
                                        {
3938
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3939
                                            Background = new SolidColorBrush(Colors.Black),
3940
                                            ControlType = ControlType.Mark ,
3941
                                            Paint = PaintSet.Fill
3942
                                        };
3943

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

    
3980
                                    currentControl.IsNew = true;
3981
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3982
                                    currentControl.CommentID = Commons.shortGuid();
3983
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3984

    
3985
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3986
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3987
                                }
3988
                                //}
3989
                            }
3990
                        }
3991
                        break;
3992
                    case ControlType.Stamp:
3993
                        {
3994
                            if (e.LeftButton == MouseButtonState.Pressed)
3995
                            {
3996
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3997
                                //{
3998
                                    if (currentControl is SymControlN)
3999
                                    {
4000
                                        //20180906 LJY TEST IsRotationDrawingEnable
4001
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4002
                                        {
4003
                                            return;
4004
                                        }
4005

    
4006
                                        CreateCommand.Instance.Execute(currentControl);
4007
                                        currentControl = null;
4008
                                   
4009

    
4010
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4011
                                    }
4012
                                    else
4013
                                    {
4014
                                        currentControl = new SymControlN
4015
                                        {
4016
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4017
                                            Background = new SolidColorBrush(Colors.Black),
4018
                                            STAMP = App.SystemInfo.STAMP,                                            
4019
                                            ControlType = ControlType.Stamp
4020
                                        };
4021

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

    
4060
                if (currentControl != null)
4061
                {
4062
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4063
                }
4064
            }
4065
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4066
            {
4067
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4068
                {
4069
                    bool mouseOff = false;
4070
                    foreach (var item in SelectLayer.Children)
4071
                    {
4072
                        if (item is AdornerFinal)
4073
                        {
4074

    
4075
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4076
                            if (over != null)
4077
                            {
4078
                                mouseOff = true;
4079
                            }
4080
                        }
4081
                    }
4082

    
4083
                    if (!mouseOff)
4084
                    {
4085
                        SelectionSet.Instance.UnSelect(this);
4086
                    }
4087
                }
4088
                zoomAndPanControl.CaptureMouse();
4089
                e.Handled = true;
4090
            }
4091
          
4092
        }
4093

    
4094
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4095
        {
4096
            ///mouseButtonDown = e.ChangedButton;
4097
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4098
        }
4099

    
4100
        private void RemoveLineStroke(Point P)
4101
        {
4102
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4103
            if (control != null)
4104
            {
4105
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4106
            }
4107
        }
4108

    
4109
        private void RemovePointStroke(Point P)
4110
        {
4111
            foreach (Stroke hits in inkBoard.Strokes)
4112
            {
4113
                foreach (StylusPoint sty in hits.StylusPoints)
4114
                {
4115

    
4116
                }
4117
                if (hits.HitTest(P))
4118
                {
4119
                    inkBoard.Strokes.Remove(hits);
4120
                    return;
4121
                }
4122
            }
4123
        }
4124

    
4125
        private void StartNewStroke(Point P)
4126
        {
4127
            strokePoints = new StylusPointCollection();
4128
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4129
            strokePoints.Add(segment1Start);
4130
            stroke = new Stroke(strokePoints);
4131

    
4132
            stroke.DrawingAttributes.Color = Colors.Red;
4133
            stroke.DrawingAttributes.Width = 4;
4134
            stroke.DrawingAttributes.Height = 4;
4135

    
4136
            inkBoard.Strokes.Add(stroke);
4137
        }
4138

    
4139
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4140
        {
4141
            ConsolidationMethod();
4142
        }
4143

    
4144
        /// <summary>
4145
        /// execute TeamConsolidationCommand
4146
        /// </summary>
4147
        public void TeamConsolidationMethod()
4148
        {
4149
            this.UpdateMyMarkupList();
4150
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4151
            {
4152
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4153
            }
4154
            else
4155
            {
4156

    
4157
                ViewerDataModel.Instance.IsConsolidate = true;
4158
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4159

    
4160
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4161
                {
4162
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4163
                    {
4164
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4165
                        return;
4166
                    }                    
4167
                }
4168
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4169
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4170
                {
4171
                    MarkupInfoList.Add(item);
4172
                }
4173
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4174
            }
4175
        }
4176

    
4177
        public void ConsolidationMethod()
4178
        {
4179
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4180
            {
4181
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4182
            }
4183
            else
4184
            {
4185
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4186
                foreach (var item in this.gridViewMarkup.SelectedItems)
4187
                {
4188
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4189
                }
4190
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4191
                
4192
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4193
            }
4194
        }
4195

    
4196
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4197
        {
4198
            if (App.ViewInfo != null)
4199
            {
4200
                btnConsolidate = (sender as RadRibbonButton);
4201
                if (!App.ViewInfo.NewCommentPermission)
4202
                {
4203
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4204
                }
4205
            }
4206
        }
4207

    
4208
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4209
        {
4210
            TeamConsolidationMethod();
4211
        }
4212

    
4213
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4214
        {
4215
            btnTeamConsolidate = sender as RadRibbonButton;
4216
            if (App.ViewInfo != null)
4217
            {
4218
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4219
                {
4220
                    if (btnConsolidate != null)
4221
                    {
4222
                        btnConsolidate.Visibility = Visibility.Collapsed;
4223
                    }
4224

    
4225
                    if (!App.ViewInfo.NewCommentPermission)
4226
                    {
4227
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4228
                    }
4229
                }
4230
                else
4231
                {
4232
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4233
                }
4234
            }
4235
        }
4236

    
4237
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4238
        {
4239
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4240
            if(item != null)
4241
            {
4242
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4243
                {
4244
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4245
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4246
                }
4247
                else
4248
                {
4249
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4250
                }
4251
            }else{
4252
                //Consolidate 가 없는 경우
4253
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4254
            }
4255
            
4256
        }
4257

    
4258
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4259
        {
4260
            btnFinalPDF = sender as RadRibbonButton;
4261
            if (App.ViewInfo != null)
4262
            {
4263
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4264
                {
4265
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4266
                    if (btnConsolidate != null)
4267
                    {
4268
                        btnConsolidate.Visibility = Visibility.Collapsed;
4269
                    }
4270
                }
4271
            }
4272
        }
4273

    
4274
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4275
        {
4276
            UpdateMyMarkupList();
4277

    
4278
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4279
            {
4280
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4281
            }
4282
            else
4283
            {
4284
                ViewerDataModel.Instance.IsConsolidate = true;
4285
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4286
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4287

    
4288
                string project_no = App.ViewInfo.ProjectNO;
4289
                string doc_id = _DocInfo.ID;
4290
                string user_id = App.ViewInfo.UserID;
4291
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4292
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4293
                {
4294
                    markupInfoItems.Add(item);
4295
                }
4296
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4297
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4298
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4299
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4300

    
4301
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4302
                if (item2 != null)
4303
                {
4304
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4305

    
4306
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4307
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4308
                }
4309
                else
4310
                {
4311
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4312
                }
4313
            }
4314
        }
4315

    
4316
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4317
        {
4318
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4319

    
4320
            if (App.ViewInfo != null)
4321
            {
4322
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4323
                {
4324
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4325
                }
4326
            }
4327
        }
4328

    
4329
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4330
        {
4331
            SetCompareRect();
4332
        }
4333

    
4334
        private void Sync_Click(object sender, RoutedEventArgs e)
4335
        {
4336
            if (Sync.IsChecked)
4337
            {
4338
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4339
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4340
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4341
            }
4342
        }
4343

    
4344
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4345
        {
4346
            if (UserList.IsChecked)
4347
            {
4348
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4349
            }
4350
            else
4351
            {
4352
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4353
            }
4354
        }
4355

    
4356
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4357
        {
4358

    
4359
            if (BalanceMode.IsChecked)
4360
            {
4361
                ViewerDataModel.Instance.PageBalanceMode = true;
4362
            }
4363
            else
4364
            {
4365
                ViewerDataModel.Instance.PageBalanceMode = false;
4366
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4367
            }
4368
        }
4369

    
4370
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4371
        {
4372
            //초기화
4373
            testPanel2.IsHidden = true;
4374
            ViewerDataModel.Instance.PageBalanceMode = false;
4375
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4376
            ViewerDataModel.Instance.PageNumber = 0;
4377
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4378
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4379
            UserList.IsChecked = false;
4380
            BalanceMode.IsChecked = false;
4381
        }
4382

    
4383
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4384
        {
4385
            if ((sender as System.Windows.Controls.Control).Tag != null)
4386
            {
4387
                //Compare 초기화
4388
                CompareMode.IsChecked = false;
4389
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4390

    
4391
                if (ViewerDataModel.Instance.PageNumber == 0)
4392
                {
4393
                    ViewerDataModel.Instance.PageNumber = 1;
4394
                }
4395

    
4396
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4397
                {
4398
                }
4399
                else
4400
                {
4401
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4402
                }
4403

    
4404

    
4405

    
4406
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4407
                {
4408

    
4409
                }
4410
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4411
                {
4412
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4413
                }
4414

    
4415
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4416

    
4417
                if (!testPanel2.IsHidden)
4418
                {
4419
                    if (IsSyncPDFMode)
4420
                    {
4421
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4422
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4423

    
4424
                        if (pdfpath.IsDownloading)
4425
                        {
4426
                            pdfpath.DownloadCompleted += (ex, arg) =>
4427
                            {
4428
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4429
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4430
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4431
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4432
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4433
                            };
4434
                        }
4435
                        else
4436
                        {
4437
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4438
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4439
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4440

    
4441
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4442
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4443
                        }
4444

    
4445
                    }
4446
                    else
4447
                    {
4448
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4449

    
4450
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4451

    
4452
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4453
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4454
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4455

    
4456
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4457
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4458

    
4459
                        if (defaultBitmapImage_Compare.IsDownloading)
4460
                        {
4461
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4462
                            {
4463
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4464
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4465
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4466

    
4467
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4468
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4469
                            };
4470
                        }
4471
                    }
4472

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

    
4477
                    foreach (var item in gridSelectionRevItem)
4478
                    {
4479
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4480
                        {
4481
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4482
                        });
4483
                    }
4484

    
4485
                    //강인구 추가
4486
                    zoomAndPanControl2.ZoomTo(new Rect
4487
                    {
4488
                        X = 0,
4489
                        Y = 0,
4490
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4491
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4492
                    });
4493

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

    
4496
                }
4497
            }
4498
        }
4499

    
4500
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4501
        {
4502
            if (MarkupMode.IsChecked)
4503
            {
4504
                IsSyncPDFMode = true;
4505

    
4506
                var uri = CurrentRev.TO_VENDOR;
4507

    
4508
                if (ViewerDataModel.Instance.PageNumber == 0)
4509
                {
4510
                    ViewerDataModel.Instance.PageNumber = 1;
4511
                }
4512

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

    
4517
                if (pdfpath.IsDownloading)
4518
                {
4519
                    pdfpath.DownloadCompleted += (ex, arg) =>
4520
                    {
4521
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4522
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4523
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4524
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4525
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4526
                    };
4527
                }
4528
                else
4529
                {
4530
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4531
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4532
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4533

    
4534
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4535
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4536
                }
4537
            }
4538
            else
4539
            {
4540
                IsSyncPDFMode = false;
4541
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4542

    
4543
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4544

    
4545
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4546
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4547
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4548

    
4549
                if (defaultBitmapImage_Compare.IsDownloading)
4550
                {
4551
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4552
                    {
4553
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4554
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4555
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4556
                    };
4557
                }
4558
                zoomAndPanControl2.ApplyTemplate();
4559
                zoomAndPanControl2.UpdateLayout();
4560
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4561
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4562
            }
4563
        }
4564

    
4565
        /// <summary>
4566
        /// Compare된 영역을 초기화
4567
        /// </summary>
4568
        private void ClearCompareRect()
4569
        {
4570
            da.From = 1;
4571
            da.To = 1;
4572
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4573
            da.AutoReverse = false;
4574
            canvas_compareBorder.Children.Clear();
4575
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4576
        }
4577

    
4578
        /// <summary>
4579
        /// 문서 Comprare 
4580
        /// </summary>
4581
        private void SetCompareRect()
4582
        {
4583
            if (CompareMode.IsChecked)
4584
            {
4585
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4586
                {
4587
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4588
                }
4589
                if (ViewerDataModel.Instance.PageNumber == 0)
4590
                {
4591
                    ViewerDataModel.Instance.PageNumber = 1;
4592
                }
4593

    
4594
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4595
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4596
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4597

    
4598
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4599
            }
4600
            else
4601
            {
4602
                ClearCompareRect();
4603
            }
4604
        }
4605

    
4606
        private void RadButton_Click(object sender, RoutedEventArgs e)
4607
        {
4608
            gridViewHistory_Busy.IsBusy = true;
4609

    
4610
            RadButton instance = sender as RadButton;
4611
            if (instance.CommandParameter != null)
4612
            {
4613
                CurrentRev = instance.CommandParameter as VPRevision;
4614
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4615

    
4616
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4617
                {
4618
                    if (ea.Error == null && ea.Result != null)
4619
                    {
4620
                        testPanel2.IsHidden = false;
4621

    
4622
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4623
                        foreach(var info in ea.Result)
4624
                        {
4625
                            if(info.UserID == App.ViewInfo.UserID)
4626
                            {
4627
                                info.userDelete = true;
4628
                                info.DisplayColor = "FFFF0000";
4629
                            }
4630
                            else
4631
                            {
4632
                                info.userDelete = false;
4633
                            }
4634
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4635
                        }
4636
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4637

    
4638
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4639

    
4640
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4641

    
4642
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4643
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4644
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4645
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4646
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4647
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4648

    
4649
                        zoomAndPanControl2.ApplyTemplate();
4650
                        zoomAndPanControl2.UpdateLayout();
4651
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4652
                        {
4653
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4654
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4655
                        }
4656

    
4657
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4658
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4659
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4660

    
4661
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4662
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4663
                        gridViewHistory_Busy.IsBusy = false;
4664
                    }
4665

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

    
4668
                    if (GetSyncMarkupInfoItemshandler != null)
4669
                    {
4670
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4671
                    }
4672

    
4673
                    ClearCompareRect();
4674
                    SetCompareRect();
4675
                };
4676

    
4677
                /// 중복 실행이 발생하여 수정함.
4678
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4679
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4680

    
4681
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4682
            }
4683
        }
4684

    
4685
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4686
        {
4687
            try
4688
            {
4689
                if (sender is RadButton)
4690
                {
4691
                    if ((sender as RadButton).Tag != null)
4692
                    {
4693
                        var url = (sender as RadButton).Tag.ToString();
4694
                        System.Diagnostics.Process.Start(url);
4695
                    }
4696
                    else
4697
                    {
4698
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4699
                    }
4700
                }
4701
            }
4702
            catch (Exception ex)
4703
            {
4704
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4705
            }
4706
        }
4707

    
4708
        public void Sync_Event(VPRevision Currnet_Rev)
4709
        {
4710
            CurrentRev = Currnet_Rev;
4711

    
4712
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4713
            {
4714
                if (ea.Error == null && ea.Result != null)
4715
                {
4716
                    testPanel2.IsHidden = false;
4717

    
4718
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4719
                    foreach(var info in ea.Result)
4720
                    {
4721
                        if(info.UserID == App.ViewInfo.UserID)
4722
                        {
4723
                            info.userDelete = true;
4724
                            info.DisplayColor = "FFFF0000";
4725
                        }
4726
                        else
4727
                        {
4728
                            info.userDelete = false;
4729
                        }
4730
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4731
                    }
4732
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4733

    
4734
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4735

    
4736
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4737

    
4738
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4739

    
4740
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4741
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4742
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4743

    
4744
                    if (defaultBitmapImage_Compare.IsDownloading)
4745
                    {
4746
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4747
                        {
4748
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4749
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4750
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4751
                        };
4752
                    }
4753

    
4754

    
4755
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4756
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4757
                    zoomAndPanControl2.ApplyTemplate();
4758
                    zoomAndPanControl2.UpdateLayout();
4759

    
4760
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4761
                    {
4762
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4763
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4764
                    }
4765
                    //}
4766

    
4767
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4768
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4769
                    gridViewHistory_Busy.IsBusy = false;
4770
                }
4771
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4772

    
4773
            };
4774
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4775
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4776
        }
4777

    
4778
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4779
        {
4780
            if (sender is Image)
4781
            {
4782
                if ((sender as Image).Tag != null)
4783
                {
4784
                    var pdfUrl = (sender as Image).Tag.ToString();
4785
                    System.Diagnostics.Process.Start(pdfUrl);
4786
                }
4787
                else
4788
                {
4789
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4790
                }
4791
            }
4792
        }
4793

    
4794
        private void Create_Symbol(object sender, RoutedEventArgs e)
4795
        {
4796
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4797

    
4798
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4799
            {
4800
                DialogMessage_Alert("Please Select Controls", "Alert");
4801
            }
4802
            else //선택된 것이 있으면
4803
            {
4804
                string MarkupData = "";
4805
                adorner_ = new AdornerFinal();
4806

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

    
4835
        }
4836
        public int symbolselectindex = 0;
4837
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4838
        {
4839
            //Save save = new Save();
4840
            try
4841
            {
4842
                string svgfilename = null;
4843
                if (symbolname != null)
4844
                {
4845
                    if (symbolpng == true || symbolsvg == true)
4846
                    {
4847
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4848
                        string guid = Commons.shortGuid();
4849

    
4850
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4851
                        //Check_Uri.UriCheck();
4852
                        fileUploader.RunCompleted += (ex, arg) =>
4853
                        {
4854
                            filename = arg.Result;
4855
                            if (symbolpng == true)
4856
                            {
4857
                                if (filename != null)
4858
                                { 
4859
                                    if (symbolselectindex == 0)
4860
                                    {
4861
                                        SymbolSave(symbolname, filename, data);
4862
                                    }
4863
                                    else
4864
                                    {
4865
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4866
                                    }
4867
                                    DataBind();
4868
                                }                                
4869
                            }
4870

    
4871
                            if (symbolsvg == true)
4872
                            {
4873
                                try
4874
                                {
4875
                                    var defaultBitmapImage = new BitmapImage();
4876
                                    defaultBitmapImage.BeginInit();
4877
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4878
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4879
                                    Check_Uri.UriCheck(filename);
4880
                                    defaultBitmapImage.UriSource = new Uri(filename);
4881
                                    defaultBitmapImage.EndInit();
4882

    
4883
                                    System.Drawing.Bitmap image;
4884

    
4885
                                    if (defaultBitmapImage.IsDownloading)
4886
                                    {
4887
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4888
                                        {
4889
                                            defaultBitmapImage.Freeze();
4890
                                            image = GetBitmap(defaultBitmapImage);
4891
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4892
                                            Process potrace = new Process
4893
                                            {
4894
                                                StartInfo = new ProcessStartInfo
4895
                                                {
4896
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4897
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4898
                                                    RedirectStandardInput = true,
4899
                                                    RedirectStandardOutput = true,
4900
                                                    RedirectStandardError = true,
4901
                                                    UseShellExecute = false,
4902
                                                    CreateNoWindow = true,
4903
                                                    WindowStyle = ProcessWindowStyle.Hidden
4904
                                                },
4905
                                            };
4906

    
4907
                                            StringBuilder svgBuilder = new StringBuilder();
4908
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4909
                                            {
4910
                                                svgBuilder.AppendLine(e2.Data);
4911
                                            };
4912

    
4913
                                            potrace.EnableRaisingEvents = true;
4914
                                            potrace.Start();
4915
                                            potrace.Exited += (sender, e) =>
4916
                                            {
4917
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4918
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4919
                                                Check_Uri.UriCheck(svgfilename);
4920
                                                if (symbolselectindex == 0)
4921
                                                {
4922
                                                    SymbolSave(symbolname, svgfilename, data);
4923
                                                }
4924
                                                else
4925
                                                {
4926
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4927
                                                }
4928

    
4929
                                                DataBind();
4930
                                            };
4931
                                            potrace.WaitForExit();
4932
                                        };
4933
                                    }
4934
                                    else
4935
                                    {
4936
                                        //GC.Collect();
4937
                                    }
4938
                                }
4939
                                catch(Exception ee)
4940
                                {
4941
                                    DialogMessage_Alert("" + ee, "Alert");
4942
                                }
4943
                            }
4944
                        };                                             
4945
                    }
4946
                }
4947
            }
4948
            catch (Exception e)
4949
            {
4950
                //DialogMessage_Alert(e + "", "Alert");
4951
            }            
4952
        }
4953

    
4954
        public void SymbolSave(string Name, string Url, string Data)
4955
        {
4956
            try
4957
            {
4958
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4959
                {
4960
                    ID = Commons.shortGuid(),
4961
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4962
                    NAME = Name,
4963
                    IMAGE_URL = Url,
4964
                    DATA = Data
4965
                };
4966

    
4967
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4968
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4969
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4970
            }
4971
            catch (Exception)
4972
            {
4973
                throw;
4974
            }
4975
        }
4976

    
4977
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4978
        {
4979
            try
4980
            {
4981
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4982
                {
4983
                    ID = Commons.shortGuid(),
4984
                    DEPARTMENT = Department,
4985
                    NAME = Name,
4986
                    IMAGE_URL = Url,
4987
                    DATA = Data
4988
                };
4989
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4990
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4991
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4992
            }
4993
            catch (Exception)
4994
            {
4995
                throw;
4996
            }
4997
        }
4998

    
4999
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5000
        {           
5001
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5002
            DataBind();
5003
        }
5004

    
5005
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5006
        {
5007
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5008
            DataBind();
5009
        }
5010
        private void DataBind()
5011
        {
5012
            try
5013
            {
5014
                Symbol_Custom Custom = new Symbol_Custom();
5015
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5016
                
5017
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5018
                foreach (var item in symbol_Private)
5019
                {
5020
                    Custom.Name = item.NAME;
5021
                    Custom.ImageUri = item.IMAGE_URL;
5022
                    Custom.ID = item.ID;
5023
                    Custom_List.Add(Custom);
5024
                    Custom = new Symbol_Custom();
5025
                }
5026
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5027
                
5028
                Custom = new Symbol_Custom();
5029
                Custom_List = new List<Symbol_Custom>();
5030

    
5031
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5032

    
5033
                List<SYMBOL_PUBLIC> symbol_Public;
5034

    
5035
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5036
                {
5037
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5038
                }
5039
                else
5040
                {
5041
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5042
                }
5043
                foreach (var item in symbol_Public)
5044
                {
5045
                    Custom.Name = item.NAME;
5046
                    Custom.ImageUri = item.IMAGE_URL;
5047
                    Custom.ID = item.ID;
5048
                    Custom_List.Add(Custom);
5049
                    Custom = new Symbol_Custom();
5050
                }
5051
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5052
                BaseClient.Close();                
5053
            }
5054
            catch(Exception e)
5055
            {
5056
                //DialogMessage_Alert("DataBind", "Alert");
5057
            }
5058
            
5059
        }
5060
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5061
        {
5062
            try
5063
            {
5064
                if (args.PromptResult != null)
5065
                {
5066
                    if (args.DialogResult.Value)
5067
                    {
5068
                        PngBitmapEncoder _Encoder = symImage(data);
5069

    
5070
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5071
                        _Encoder.Save(fs);
5072
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5073

    
5074
                        byte[] Img_byte = fs.ToArray();
5075

    
5076
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5077
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5078
                        Check_Uri.UriCheck(filename);
5079
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5080
                        {
5081
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5082
                        }
5083
                        else
5084
                        {
5085
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5086
                        }
5087
                        DataBind();
5088
                    }
5089
                }
5090
            }
5091
            catch(Exception ex)
5092
            {
5093
                DialogMessage_Alert("" + ex, "Alert");
5094
            }
5095
        }
5096

    
5097
        public PngBitmapEncoder symImage(string data)
5098
        {
5099

    
5100
            Canvas _canvas = new Canvas();
5101
            _canvas.Background = Brushes.White;
5102
            _canvas.Width = adorner_.BorderSize.Width;
5103
            _canvas.Height = adorner_.BorderSize.Height;
5104
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5105

    
5106
            BitmapEncoder encoder = new PngBitmapEncoder();
5107

    
5108

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

    
5111
            DrawingVisual dv = new DrawingVisual();
5112

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

    
5116
            using (DrawingContext ctx = dv.RenderOpen())
5117
            {
5118
                VisualBrush vb = new VisualBrush(_canvas);
5119
                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)));
5120
            }
5121

    
5122
            try
5123
            {
5124
                renderBitmap.Render(dv);
5125

    
5126
                //GC.Collect();
5127
                GC.WaitForPendingFinalizers();
5128
                //GC.Collect();
5129
                // encode png data
5130
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5131
                // puch rendered bitmap into it
5132
                pngEncoder.Interlace = PngInterlaceOption.Off;
5133
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5134
                return pngEncoder;
5135

    
5136
            }
5137
            catch //(Exception ex)
5138
            {
5139
                return null;
5140
            }
5141

    
5142
        }
5143

    
5144
        public void DialogMessage_Alert(string content, string header)
5145
        {
5146
            DialogParameters parameters = new DialogParameters()
5147
            {
5148
                Owner = this.ParentOfType<MainWindow>(),
5149
                Content = new TextBlock()
5150
                { 
5151
                    MinWidth = 400,
5152
                    FontSize = 11,
5153
                    Text = content,
5154
                    TextWrapping = System.Windows.TextWrapping.Wrap
5155
                },
5156
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5157
                Header = header,
5158
                Theme = new VisualStudio2013Theme(),
5159
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5160
            };            
5161
            RadWindow.Alert(parameters);
5162
        }
5163

    
5164
        #region 캡쳐 기능
5165

    
5166
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5167
        {
5168
            if (x < 0)
5169
            {
5170
                width += x;
5171
                x = 0;
5172
            }
5173
            if (y < 0)
5174
            {
5175
                height += y;
5176
                y = 0;
5177

    
5178
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5179
            }
5180
            if (x + width > zoomAndPanCanvas.ActualWidth)
5181
            {
5182
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5183
            }
5184
            if (y + height > zoomAndPanCanvas.ActualHeight)
5185
            {
5186
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5187
            }
5188

    
5189
            byte[] pixels = CopyPixels(x, y, width, height);
5190

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

    
5193
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5194
        }
5195

    
5196
        public byte[] CopyPixels(int x, int y, int width, int height)
5197
        {
5198
            byte[] pixels = new byte[width * height * 4];
5199
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5200

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

    
5204
            return pixels;
5205
        }
5206

    
5207
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5208
        {
5209
            DrawingVisual drawingVisual = new DrawingVisual();
5210
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5211

    
5212
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5213
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5214
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5215
            drawingContext.Close();
5216

    
5217
            // 비트맵으로 변환합니다.
5218
            RenderTargetBitmap target =
5219
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5220
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5221

    
5222
            target.Render(drawingVisual);
5223
            return target;
5224
        }
5225

    
5226
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5227
        {
5228
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5229
            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);
5230
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5231
            bmp.UnlockBits(data);
5232
            return bmp;
5233
        }
5234
        public string symbolname = null;
5235
        public bool symbolsvg = true;
5236
        public bool symbolpng = true;
5237

    
5238
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5239
        {
5240
            System.Drawing.Bitmap image = GetBitmap(source);
5241
            //흰색 제거
5242
            //image.MakeTransparent(System.Drawing.Color.White);
5243

    
5244
            var imageStream = new System.IO.MemoryStream();
5245
            byte[] imageBytes = null;
5246
            using (imageStream)
5247
            {
5248
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5249
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5250
                imageStream.Position = 0;
5251
                imageBytes = imageStream.ToArray();
5252
            }
5253

    
5254
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5255

    
5256
            RadWindow CheckPop = new RadWindow();
5257
            //Alert check = new Alert(Msg);
5258

    
5259
            CheckPop = new RadWindow
5260
            {
5261
                MinWidth = 400,
5262
                MinHeight = 100,
5263
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5264
                Header = "Alert",
5265
                Content = symbolPrompt,
5266
                //DialogResult = 
5267
                ResizeMode = System.Windows.ResizeMode.NoResize,
5268
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5269
                IsTopmost = true,
5270
            };
5271
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5272
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5273
            CheckPop.ShowDialog();
5274

    
5275
            /*
5276
            DialogParameters parameters = new DialogParameters()
5277
            {
5278
                Owner = Application.Current.MainWindow,
5279
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5280
                DefaultPromptResultValue = "Custom State",
5281
                Content = "Name :",
5282
                Header = "Insert Custom Symbol Name",
5283
                Theme = new VisualStudio2013Theme(),
5284
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5285
            };            
5286
            RadWindow.Prompt(parameters);
5287
            */
5288
        }
5289

    
5290
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5291
        {
5292
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5293
            KCOMDataModel.DataModel.CHECK_LIST check_;
5294
            string Result = streamToBase64.ImageToBase64(source);
5295
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5296
            string projectno = App.ViewInfo.ProjectNO;
5297
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5298

    
5299
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5300
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5301
            if (Item != null)
5302
            {
5303
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5304
            }
5305
            else
5306
            {
5307
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5308
            }
5309

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

    
5342
        }
5343

    
5344
        public void Set_Capture()
5345
        {
5346
            double x = CanvasDrawingMouseDownPoint.X;
5347
            double y = CanvasDrawingMouseDownPoint.Y;
5348
            double width = dragCaptureBorder.Width;
5349
            double height = dragCaptureBorder.Height;
5350

    
5351
            if (width > 5 || height > 5)
5352
            {
5353
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5354
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5355
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5356
            }
5357
        }
5358
        #endregion
5359

    
5360
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5361
        {
5362
            multi_Undo_Data = new Multi_Undo_data();
5363

    
5364
            multi_Undo_Data.Markup = control;
5365

    
5366
            if ((control as IShapeControl) != null)
5367
            {
5368
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5369
            }
5370
            if ((control as IDashControl) != null)
5371
            {
5372
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5373
            }
5374
            if ((control as IPath) != null)
5375
            {
5376
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5377
            }
5378
            if ((control as UIElement) != null)
5379
            {
5380
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5381
            }
5382

    
5383
            return multi_Undo_Data;
5384
        }
5385

    
5386
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5387
        {
5388
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5389
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5390
            {
5391
                if (items.UserID == Select_ID)
5392
                {
5393
                    foreach (var item in items.MarkupList)
5394
                    {
5395
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5396
                        {
5397
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5398
                                items.MarkupInfoID, Commons.shortGuid());
5399
                        }
5400
                    }
5401
                }
5402
            }
5403
        }
5404

    
5405
        /// <summary>
5406
        /// convert inkcontrol to polygoncontrol
5407
        /// </summary>
5408
        public void ConvertInkControlToPolygon()
5409
        {
5410
            if (inkBoard.Strokes.Count > 0)
5411
            {
5412
                inkBoard.Strokes.ToList().ForEach(stroke =>
5413
                {
5414
                    InkToPath ip = new InkToPath();
5415

    
5416
                    List<Point> inkPointSet = new List<Point>();
5417
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5418

    
5419
                    PolygonControl pc = new PolygonControl()
5420
                    {
5421
                        CommentAngle = 0,
5422
                        PointSet = inkPointSet,
5423
                        ControlType = ControlType.Ink
5424
                    };
5425
                    pc.StartPoint = inkPointSet[0];
5426
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5427
                    pc.LineSize = 3;
5428
                    pc.CommentID = Commons.shortGuid();
5429
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5430

    
5431
                    if (pc.PointSet.Count > 0)
5432
                    {
5433
                        CreateCommand.Instance.Execute(pc);
5434
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5435
                    }
5436
                });
5437
                inkBoard.Strokes.Clear();
5438
            }
5439
        }
5440

    
5441
        /// <summary>
5442
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5443
        /// </summary>
5444
        /// <author>ingu</author>
5445
        /// <date>2018.06.05</date>
5446
        /// <param name="getPoint"></param>
5447
        /// <returns></returns>
5448
        private bool IsGetoutpoint(Point getPoint)
5449
        {
5450
            if (getPoint == new Point())
5451
            {
5452
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5453
                currentControl = null;
5454
                return true;
5455
            }
5456

    
5457
            return false;
5458
        }
5459

    
5460
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5461
        {
5462
            e.Effects = DragDropEffects.Copy;
5463
        }
5464

    
5465
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5466
        {
5467
            e.Effects = DragDropEffects.Copy;
5468
        }
5469

    
5470
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5471
        {
5472
            e.Effects = DragDropEffects.None;
5473
        }
5474

    
5475
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5476
        {
5477
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5478
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5479

    
5480
            ScaleImage(pageWidth, pageHeight);
5481
        }
5482

    
5483
        /// <summary>
5484
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5485
        /// </summary>
5486
        /// <param name="pageWidth">원본 사이즈</param>
5487
        /// <param name="pageHeight">원본 사이즈</param>
5488
        /// <returns></returns>
5489
        private void ScaleImage(double pageWidth,double pageHeight)
5490
        {
5491
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5492
        }
5493

    
5494
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5495
        {
5496
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5497
        }
5498

    
5499

    
5500
        /*
5501
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5502
        {
5503
            try
5504
            {
5505
                if (e.Data.GetDataPresent(typeof(string)))
5506
                {
5507
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5508
                    string dragData = e.Data.GetData(typeof(string)) as string;
5509
                    Move_Symbol(sender, dragData);
5510
                }
5511
            }
5512
            catch (Exception ex)
5513
            {
5514
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5515
            }            
5516
        }
5517
        */
5518
    }
5519

    
5520
    public class testItem
5521
    {
5522
        public string Title { get; set; }
5523
    }
5524
}
클립보드 이미지 추가 (최대 크기: 500 MB)