프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
                }
190
            }
191
        }
192

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

    
217
        public bool IsSyncPDFMode { get; set; }
218

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

    
243
        #endregion
244

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

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

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

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

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

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

    
289
            return uri;
290
        }
291

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

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

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

    
333
            return false;
334
        }
335

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

    
359
            return false;
360
        }
361

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
495
        }
496

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

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

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

    
516
                    await task;
517

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

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

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

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

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

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

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

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

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

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

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

    
619
        DispatcherTimer renderTesttimer;
620

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

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

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

    
647
            #endregion
648

    
649
            ViewerDataModel.Instance.PageNumber = BalancePoint;
650

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

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

    
658
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
659
            try
660
            {
661
                System.Diagnostics.Debug.WriteLine(pageUri);
662
                ViewerDataModel.Instance.ImageViewPath = null;
663

    
664
                new System.Net.Http.HttpClient().CancelPendingRequests();
665
                 //await Task.Delay(300);
666

    
667
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
668
            }
669
            catch (Exception ex)
670
            {
671
                ViewerDataModel.Instance.ImageViewPath = null;
672
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
673
                DialogMessage_Alert(imgfailedmsg, "Warning");
674
                App.FileLogger.Fatal(ex);
675
            }
676
            ScaleImage(pageWidth, pageHeight);
677

    
678
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
679
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
680

    
681
            zoomAndPanCanvas.Width = pageWidth;
682
            zoomAndPanCanvas.Height = pageHeight;
683

    
684
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
685
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
686

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

    
690
            #endregion
691

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

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

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

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

    
740
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
741

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

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

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

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

    
781
            SearchFocusBorder.Visibility = Visibility.Collapsed;
782

    
783
            this.pageNavigator.ChangePage(e.PageNumber);
784
        }
785

    
786
        /// <summary>
787
        /// called after page is changed
788
        /// </summary>
789
        /// <param name="sender"></param>
790
        /// <param name="e"></param>
791
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
792
        {
793
            //if (zoomAndPanCanvas.Width.IsNaN())
794
            //{
795
            
796
            await zoomAndPanControl.Dispatcher.InvokeAsync(()=>
797
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
798
                );
799
            //}
800

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

    
826
            /// fire selection event
827
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
828
            this.gridViewMarkup.UnselectAll();
829
            this.gridViewMarkup.Select(gridSelectionItem);
830

    
831
            if (!testPanel2.IsHidden)
832
            {
833
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
834
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
835
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
836

    
837
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
838
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
839

    
840

    
841
                foreach (var item in gridSelectionRevItem)
842
                {
843
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
844
                    {
845
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
846
                    });
847
                }
848
            }
849

    
850
            var instanceMain = this.ParentOfType<MainWindow>();
851
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
852
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
853

    
854
            instanceMain.dzTopMenu.rotateOffSet = 0;
855
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
856
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
857
            
858
            SetCommentPages(true);
859
        }
860

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

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

    
914
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
915
        {
916
            var instance = ViewerDataModel.Instance;
917

    
918
            if(instance.IsWheelPageChanage)
919
            {
920
                return;
921
            }
922

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

    
961
                //if (changePage != 0)
962
                //{
963
                //    await Task.Factory.StartNew(() =>
964
                //    {
965
                //        double beforeScale = instance.ContentScale;
966

    
967
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
968

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

    
978
                //        pageNavigator.PageChanged += handler;
979

    
980
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
981
                //    });
982
                    
983

    
984
                //}
985
            }
986
            else
987
            {
988
                e.Handled = true;
989
                if (e.Delta > 0)
990
                {
991
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
992
                    ZoomIn(currentContentMousePoint);
993
                }
994
                else
995
                {
996
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
997
                    ZoomOut(currentContentMousePoint);
998
                }
999
            }
1000
        }
1001

    
1002
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1003
        {
1004
            e.Handled = true;
1005
            if (e.Delta > 0)
1006
            {
1007
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1008
                ZoomIn_Sync(currentContentMousePoint);
1009
            }
1010
            else
1011
            {
1012
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1013
                ZoomOut_Sync(currentContentMousePoint);
1014
            }
1015
        }
1016

    
1017
        #region ZoomIn & ZoomOut
1018

    
1019
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1020
        {
1021
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1022
                zoomAndPanControl.ContentZoomFocusY));
1023
        }
1024

    
1025
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1026
        {
1027
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1028
                zoomAndPanControl.ContentZoomFocusY));
1029
        }
1030

    
1031

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

    
1045
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1046
            {
1047
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1048
            }
1049
        }
1050

    
1051
        private void ZoomIn(Point contentZoomCenter)
1052
        {
1053
            if (zoomAndPanControl.ContentScale > 0.19)
1054
            {
1055
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1056
            }
1057
            else
1058
            {
1059
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1060
            }
1061

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

    
1067
        }
1068

    
1069
        private void ZoomOut_Sync(Point contentZoomCenter)
1070
        {
1071
            if (zoomAndPanControl2.ContentScale > 0.39)
1072
            {
1073
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1074
            }
1075
            else
1076
            {
1077
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1078
            }
1079

    
1080
            if (Sync.IsChecked)
1081
            {
1082
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1083
            }
1084
        }
1085

    
1086
        private void ZoomIn_Sync(Point contentZoomCenter)
1087
        {
1088
            if (zoomAndPanControl2.ContentScale > 0.19)
1089
            {
1090
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1091
            }
1092
            else
1093
            {
1094
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1095
            }
1096

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

    
1103
        private void ZoomOut()
1104
        {
1105
            zoomAndPanControl.ContentScale -= 0.1;
1106
            //if (zoomAndPanControl2 != null)
1107
            //{
1108
            //    zoomAndPanControl2.ContentScale -= 0.1;
1109
            //}
1110
        }
1111

    
1112
        private void ZoomIn()
1113
        {
1114
            zoomAndPanControl.ContentScale += 0.1;
1115
            //if (zoomAndPanControl2 != null)
1116
            //{
1117
            //    zoomAndPanControl2.ContentScale += 0.1;
1118
            //}
1119
        }
1120

    
1121
        #endregion
1122

    
1123
        private void init()
1124
        {
1125
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1126
            {
1127

    
1128
                ControlList.Clear();
1129
                listBox.Items.Clear();
1130
                selected_item.Clear();
1131

    
1132
                (item as IMarkupCommonData).IsSelected = false;
1133
            }
1134

    
1135
        }
1136

    
1137
        private HitTestResultBehavior MyCallback(HitTestResult result)
1138
        {
1139
            //this.cursor = Cursors.UpArrow;
1140
            var element = result.VisualHit;
1141
            while (element != null && !(element is CommentUserInfo))
1142
                element = VisualTreeHelper.GetParent(element);
1143

    
1144
            if (element == null)
1145
            {
1146
                return HitTestResultBehavior.Stop;
1147
            }
1148
            else
1149
            {
1150
                if (element is CommentUserInfo)
1151
                {
1152
                    if (!hitList.Contains(element))
1153
                    {
1154
                        hitList.Add((CommentUserInfo)element);
1155
                    }
1156
                    else
1157
                    {
1158
                        return HitTestResultBehavior.Stop;
1159
                    }
1160
                }
1161
            }
1162
            return HitTestResultBehavior.Continue;
1163
        }
1164

    
1165
        public void ReleaseSelectPath()
1166
        {
1167
            if (SelectionPath == null)
1168
            {
1169
                SelectionPath = new Path();
1170
                SelectionPath.Name = "";
1171
            }
1172
            if (SelectionPath.Name != "")
1173
            {
1174
                SelectionPath.Name = "None";
1175
            }
1176
            SelectionPath.Opacity = 0.01;
1177
            SelectionPath.RenderTransform = null;
1178
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1179
        }
1180

    
1181
        #region 컨트롤 초기화 
1182
        public void Control_Init(object control)
1183
        {
1184
            if (L_Size != 0 && (control as IPath) != null)
1185
            {
1186
                (control as IPath).LineSize = L_Size;
1187
                L_Size = 0;
1188
            }
1189

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

    
1276
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1277
        {
1278
            //Control_Init(e.Source);
1279
        }
1280
        //private Window _dragdropWindow = null;
1281

    
1282
        [DllImport("user32.dll")]
1283
        [return: MarshalAs(UnmanagedType.Bool)]
1284
        internal static extern bool GetCursorPos(ref Win32Point pt);
1285

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

    
1303

    
1304
               if (this._dragdropWindow != null)
1305
               {
1306
                   this._dragdropWindow.Close();
1307
                   this._dragdropWindow = null;
1308
               }
1309

    
1310
               symbol_id = id;
1311
               symbol_group_id = group_id;
1312
               symbol_SelectedIndex = SelectedIndex;
1313
               symbol_Data = Data_;
1314
               symbol_img = img;
1315

    
1316

    
1317
               CreateDragDropWindow2(img);
1318
              
1319
    }
1320

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

    
1341
            Win32Point w32Mouse = new Win32Point();
1342
            GetCursorPos(ref w32Mouse);
1343

    
1344
            //w32Mouse.X = getCurrentPoint.X;
1345
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1346
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1347
            this._dragdropWindow.Show();
1348
        }
1349

    
1350
        
1351

    
1352
         */
1353

    
1354
        public void MoveZoomAndPanControl(Vector dragOffset)
1355
        {
1356
   
1357
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1358
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1359

    
1360
            if (Sync.IsChecked)
1361
            {
1362
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1363
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1364
            }
1365
        }
1366

    
1367
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1368
        {
1369
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1370
            {
1371
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1372

    
1373
                Point currentPos = e.GetPosition(rect);
1374

    
1375
                floatingTip.HorizontalOffset = currentPos.X + 20;
1376
                floatingTip.VerticalOffset = currentPos.Y;
1377
            }
1378

    
1379
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1380
            
1381
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1382
            {
1383
                SetCursor();
1384
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1385
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1386

    
1387
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1388

    
1389
                MoveZoomAndPanControl(dragOffset);
1390
            }
1391

    
1392
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1393
            {
1394
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1395
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1396
                SetCursor();
1397

    
1398
                if (currentControl != null)
1399
                {
1400
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1401
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1402
                    //강인구 추가
1403
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1404

    
1405
                    if ((currentControl as IPath) != null)
1406
                    {
1407
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1408
                    }
1409
                    if ((currentControl as LineControl) != null)
1410
                    {
1411
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1412
                    }
1413

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

    
1457

    
1458
                    #region // 모든 컨트롤의 공통기능 제어
1459
                    if (controlType != ControlType.PenControl)
1460
                    {
1461
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1462
                    }
1463

    
1464

    
1465
                    #endregion
1466

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

    
1469
                    switch (controlType)
1470
                    {
1471
                        case (ControlType.Coordinate):
1472
                            {
1473
                                var control = currentControl as CoordinateControl;
1474
                                if (control != null)
1475
                                {
1476
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1477
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1478
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1479
                                }
1480
                            }
1481
                            break;
1482
                        case (ControlType.InsideWhite):
1483
                            {
1484
                                var control = currentControl as InsideWhiteControl;
1485
                                if (control != null)
1486
                                {
1487
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1488
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1489
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1490
                                    control.Paint = PaintSet.Fill;
1491
                                }
1492
                            }
1493
                            break;
1494
                        case ControlType.OverlapWhite:
1495
                            {
1496
                                var control = currentControl as OverlapWhiteControl;
1497
                                if (control != null)
1498
                                {
1499
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1500
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1501
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1502
                                    control.Paint = PaintSet.Fill;
1503
                                }
1504
                            }
1505
                            break;
1506
                        case ControlType.ClipWhite:
1507
                            {
1508
                                var control = currentControl as ClipWhiteControl;
1509
                                if (control != null)
1510
                                {
1511
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1512
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1513
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1514
                                    control.Paint = PaintSet.Fill;
1515
                                }
1516
                            }
1517
                            break;
1518
                        case ControlType.RectCloud:
1519
                            {
1520
                                var control = currentControl as RectCloudControl;
1521
                                if (control != null)
1522
                                {
1523
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1524
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1525
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1526
                                }
1527
                            }
1528
                            break;
1529
                        case ControlType.SingleLine:
1530
                        case ControlType.CancelLine:
1531
                        case ControlType.ArrowLine:
1532
                        case ControlType.TwinLine:
1533
                        case ControlType.DimLine:
1534
                            {
1535
                                var control = currentControl as LineControl;
1536
                                if (control != null)
1537
                                {
1538
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1539
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1540
                                }
1541

    
1542
                            }
1543
                            break;
1544

    
1545
                        case ControlType.ArcLine:
1546
                            {
1547
                                var control = currentControl as ArcControl;
1548
                                if (control != null)
1549
                                {
1550
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1551
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1552
                                }
1553
                            }
1554
                            break;
1555

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

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

    
1578
                        case ControlType.Circle:
1579
                            {
1580
                                var control = currentControl as CircleControl;
1581

    
1582
                                if (control != null)
1583
                                {
1584
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1585
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1586
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1587
                                }
1588
                            }
1589
                            break;
1590

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

    
1603
                        case ControlType.Triangle:
1604
                            {
1605
                                var control = currentControl as TriControl;
1606
                                if (control != null)
1607
                                {
1608
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1609
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1610
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1611
                                }
1612
                            }
1613
                            break;
1614

    
1615
                        case ControlType.ImgControl:
1616
                            {
1617
                                var control = currentControl as ImgControl;
1618
                                if (control != null)
1619
                                {
1620
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1621
                                }
1622
                            }
1623
                            break;
1624

    
1625
                        case ControlType.Date:
1626
                            {
1627
                                var control = currentControl as DateControl;
1628
                                if (control != null)
1629
                                {
1630
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1631
                                }
1632
                            }
1633
                            break;
1634

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

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

    
1750
                                //inkBoard.Strokes.Add(stroke);
1751
                            }
1752
                            break;
1753
                    }
1754
                    return;
1755
                }
1756
            }
1757
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1758
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1759
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1760
            {
1761
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1762

    
1763
                if (isDraggingSelectionRect)
1764
                {
1765
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1766
                    e.Handled = true;
1767
                }
1768
                else if (isLeftMouseButtonDownOnWindow)
1769
                {
1770
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1771
                    double dragDistance = Math.Abs(dragDelta.Length);
1772

    
1773
                    if (dragDistance > DragThreshold)
1774
                    {
1775
                        isDraggingSelectionRect = true;
1776
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1777
                    }
1778

    
1779
                    e.Handled = true;
1780
                }
1781

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

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

    
1823
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1824
        {
1825
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1826
            {
1827
                SetCursor();
1828
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1829
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1830

    
1831
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1832

    
1833
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1834
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1835

    
1836
                if (Sync.IsChecked)
1837
                {
1838
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1839
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1840
                }
1841
            }
1842
        }
1843

    
1844
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1845

    
1846
        private EllipseGeometry hitArea = new EllipseGeometry();
1847

    
1848
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1849
        {
1850
            IsDrawing = false;
1851
    
1852
            if (mouseHandlingMode != MouseHandlingMode.None)
1853
            {
1854
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1855
                {
1856
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1857

    
1858
                    SetCursor();
1859

    
1860
                    switch (controlType)
1861
                    {
1862
                        case ControlType.None:
1863
                            break;
1864
                        case ControlType.Rectangle:
1865
                            {
1866

    
1867
                            }
1868
                            break;
1869
                        case ControlType.PenControl:
1870
                            {
1871

    
1872
                            }
1873
                            break;
1874
                        default:
1875
                            break;
1876
                    }                    
1877
                }
1878
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1879
                {
1880
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1881

    
1882
                    if (isLeftMouseButtonDownOnWindow)
1883
                    {
1884
                        bool wasDragSelectionApplied = false;
1885

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

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

    
1921
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1922

    
1923
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1924
                            }
1925

    
1926
                            isDraggingSelectionRect = false;
1927
                            e.Handled = true;
1928
                            wasDragSelectionApplied = true;
1929
                        }
1930

    
1931
                        if (isLeftMouseButtonDownOnWindow)
1932
                        {
1933
                            isLeftMouseButtonDownOnWindow = false;
1934
                            this.ReleaseMouseCapture();
1935
                            e.Handled = true;
1936
                        }
1937

    
1938
                        if (!wasDragSelectionApplied)
1939
                        {
1940
                            init();
1941
                        }
1942
                    }
1943
                }
1944
                else if (e.RightButton == MouseButtonState.Pressed)
1945
                {
1946
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1947
                    SetCursor();
1948
                }
1949

    
1950
                zoomAndPanControl.ReleaseMouseCapture();
1951

    
1952

    
1953
                e.Handled = true;
1954
            }
1955
            else
1956
            {
1957
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1958
                SetCursor();
1959
            }
1960

    
1961
            ///mouseButtonDown = MouseButton.Left;
1962
            //controlType = ControlType.SingleLine;
1963
        }
1964

    
1965
        public void Set_Symbol_Capture(Point endPoint)
1966
        {       
1967
            double x = CanvasDrawingMouseDownPoint.X;
1968
            double y = CanvasDrawingMouseDownPoint.Y;
1969
            if(x > endPoint.X)
1970
            {
1971
                x = endPoint.X;
1972
                y = endPoint.Y;
1973
            }
1974

    
1975
            double width = dragCaptureBorder.Width;
1976
            double height = dragCaptureBorder.Height;
1977

    
1978
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1979

    
1980
            if (x < 0)
1981
            {
1982
                width += x;
1983
                x = 0;
1984
            }
1985
            if (y < 0)
1986
            {
1987
                height += y;
1988
                y = 0;
1989

    
1990
                width = (int)canvasImage.PixelWidth - x;
1991
            }
1992
            if (x + width > canvasImage.PixelWidth)
1993
            {
1994
                width = (int)canvasImage.PixelWidth - x;
1995
            }
1996
            if (y + height > canvasImage.PixelHeight)
1997
            {
1998
                height = (int)canvasImage.PixelHeight - y;
1999
            }
2000
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2001

    
2002
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2003
            var defaultBitmapImage = new BitmapImage();
2004
            defaultBitmapImage.BeginInit();
2005
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2006
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2007
            defaultBitmapImage.UriSource = new Uri(uri);
2008
            defaultBitmapImage.EndInit();
2009

    
2010
            //GC.Collect();
2011

    
2012
            if (defaultBitmapImage.IsDownloading)
2013
            {
2014
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2015
                {
2016
                    defaultBitmapImage.Freeze();
2017
                    //GC.Collect();
2018
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2019
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2020
                };
2021
            }
2022
        }
2023

    
2024
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2025
        {
2026
            ///mouseButtonDown = MouseButton.Left;
2027
        }
2028

    
2029
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2030
        {
2031
            ///mouseButtonDown = MouseButton.Left;
2032
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2033
        }
2034

    
2035
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2036
        {
2037

    
2038
        }
2039

    
2040
        /// <summary>
2041
        /// select items by dragging
2042
        /// </summary>
2043
        private void ApplyDragSelectionRect()
2044
        {
2045
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2046

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

    
2055
            Rect dragRect = new Rect(x, y, width, height);
2056
            ///dragRect.Inflate(width / 10, height / 10);
2057

    
2058
            foreach (var item in Items)
2059
            {
2060
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2061

    
2062
                if (Flag)
2063
                {
2064
                    adornerSet.Add(item);
2065
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2066
                    Control_Style(item);
2067
                }
2068
            }
2069
            if (adornerSet.Count > 0)
2070
            {
2071
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2072
                SelectLayer.Children.Add(final);
2073
            }
2074
        }
2075

    
2076
        private void InitDragSelectionRect(Point pt1, Point pt2)
2077
        {
2078
            //캡쳐 중
2079
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2080
            {
2081
                dragCaptureBorder.Visibility = Visibility.Visible;
2082
            }
2083
            //선택 중
2084
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2085
            {
2086

    
2087
                dragSelectionBorder.Visibility = Visibility.Visible;
2088
            }
2089
            else
2090
            {
2091
                dragZoomBorder.Visibility = Visibility.Visible;
2092
            }
2093
            UpdateDragSelectionRect(pt1, pt2);
2094
        }
2095

    
2096
        /// <summary>
2097
        /// Update the position and size of the rectangle used for drag selection.
2098
        /// </summary>
2099
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2100
        {
2101
            double x, y, width, height;
2102

    
2103
            //
2104
            // Determine x,y,width and height of the rect inverting the points if necessary.
2105
            // 
2106

    
2107
            if (pt2.X < pt1.X)
2108
            {
2109
                x = pt2.X;
2110
                width = pt1.X - pt2.X;
2111
            }
2112
            else
2113
            {
2114
                x = pt1.X;
2115
                width = pt2.X - pt1.X;
2116
            }
2117

    
2118
            if (pt2.Y < pt1.Y)
2119
            {
2120
                y = pt2.Y;
2121
                height = pt1.Y - pt2.Y;
2122
            }
2123
            else
2124
            {
2125
                y = pt1.Y;
2126
                height = pt2.Y - pt1.Y;
2127
            }
2128

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

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

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

    
2190
            zoomAndPanControl.RotationAngle = rotate.Angle;
2191

    
2192

    
2193
            if (!testPanel2.IsHidden)
2194
            {
2195
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2196
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2197
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2198
            }
2199

    
2200
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2201
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2202
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2203
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2204
            ViewerDataModel.Instance.Angle = rotate.Angle;
2205
        }
2206

    
2207
        private void syncPannelRotate(double angle)
2208
        {
2209
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2210
            rotate.Angle = angle;
2211
            var rotationNum = Math.Abs((rotate.Angle / 90));
2212

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

    
2240
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2241
        }
2242

    
2243
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2244
        {
2245
            string Data_ = "";
2246

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

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

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

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

    
2320
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2321
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2322
                    UndoData.Markup_List.Add(multi_Undo_Data);
2323
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2324

    
2325
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2326
                    currentControl.CommentID = Commons.shortGuid();
2327
                    currentControl.SymbolID = id;
2328
                    currentControl.GroupID = group_id;
2329
                    currentControl.ApplyTemplate();
2330
                    currentControl.SetImage();
2331

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

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

    
2353
            ConvertInkControlToPolygon();
2354

    
2355
            ///TODO:
2356
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2357
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2358

    
2359
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2360
            {
2361
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2362
            }
2363
            /// up to here
2364

    
2365
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2366
            {
2367
                if (item as ArrowTextControl != null)
2368
                {
2369
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2370
                }
2371
                else if (item as TextControl != null)
2372
                {
2373
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2374
                }
2375
            }
2376

    
2377
            //if (currentControl != null)
2378
            {
2379
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2380
                if (text_item_ != null)
2381
                {
2382
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2383
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2384
                    (text_item_ as TextControl).IsEditingMode = false;                    
2385
                    currentControl = null;
2386
                }
2387

    
2388
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2389
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2390
                {
2391
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2392
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2393
                    currentControl = null;
2394
                }
2395
            }
2396

    
2397
            double Ang = 0;                                          
2398
            if (rotate.Angle != 0)
2399
            {
2400
                Ang = 360 - rotate.Angle;
2401
            }
2402

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

    
2417
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2418
            {
2419
                if (this._dragdropWindow != null)
2420
                {
2421
                    this._dragdropWindow.Close();
2422
                    this._dragdropWindow = null;
2423
                    symbol_id = null;
2424
                }
2425
            }
2426
            */
2427

    
2428
            if (e.LeftButton == MouseButtonState.Pressed)
2429
            {
2430
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2431
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2432

    
2433
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2434
                SetCursor();
2435

    
2436
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2437
            }
2438

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

    
2458
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2459

    
2460
            }
2461
            else if (e.XButton2 == MouseButtonState.Pressed)
2462
            {
2463
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2464
                {
2465
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2466
                }
2467
            }
2468

    
2469
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2470
            {
2471
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2472
                {
2473
                    if (SelectLayer.Children.Count == 0)
2474
                    {
2475
                        isLeftMouseButtonDownOnWindow = true;
2476
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2477
                    }
2478

    
2479
                    if (controlType == ControlType.None)
2480
                    {
2481
                        isLeftMouseButtonDownOnWindow = true;
2482
                    }
2483
                }
2484

    
2485
                /// 캡쳐 모드 설정
2486
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2487
                {
2488
                    dragCaptureBorder.Visibility = Visibility.Visible;
2489
                    isLeftMouseButtonDownOnWindow = true;
2490
                }
2491

    
2492
                /// 줌 모드 설정
2493
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2494
                {
2495
                    isLeftMouseButtonDownOnWindow = true;
2496
                }
2497

    
2498
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2499
                if (control != null)
2500
                {
2501
                    AdornerFinal final = null;
2502

    
2503
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2504
                    {
2505
                        /// 기존 selection 해제
2506
                        SelectionSet.Instance.UnSelect(this);
2507

    
2508
                        final = new AdornerFinal(control);
2509

    
2510
                        this.Control_Style(control);
2511

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

    
2537
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2538

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

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

    
2620
                        Control_Style(control);
2621

    
2622
                        final = new AdornerFinal(comment);
2623
                    }
2624

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

    
2668
                switch (controlType)
2669
                {
2670
                    case ControlType.Coordinate:
2671
                        {
2672
                            if (e.LeftButton == MouseButtonState.Pressed)
2673
                            {
2674
                                if (currentControl is CoordinateControl)
2675
                                {
2676
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2677
                                    {
2678
                                        return;
2679
                                    }
2680

    
2681
                                    CreateCommand.Instance.Execute(currentControl);
2682

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

    
2706
                                        currentControl.CommentID = Commons.shortGuid();
2707
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2708
                                        currentControl.IsNew = true;
2709

    
2710
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2711

    
2712
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2713
                                    }
2714
                                }
2715
                            }
2716
                        }
2717
                        break;
2718
                    case ControlType.InsideWhite:
2719
                        {
2720
                            if (e.LeftButton == MouseButtonState.Pressed)
2721
                            {
2722
                                if (currentControl is InsideWhiteControl)
2723
                                {
2724
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2725
                                    {
2726
                                        return;
2727
                                    }
2728

    
2729
                                    CreateCommand.Instance.Execute(currentControl);
2730

    
2731
                                    currentControl = null;
2732
                                    this.cursor = Cursors.Arrow;
2733
                                }
2734
                                else
2735
                                {
2736
                                    currentControl = new InsideWhiteControl
2737
                                    {
2738
                                        Background = new SolidColorBrush(Colors.Black),
2739
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2740
                                        ControlType = ControlType.InsideWhite
2741
                                    };
2742

    
2743
                                    currentControl.CommentID = Commons.shortGuid();
2744
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2745
                                    currentControl.IsNew = true;
2746
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2747

    
2748
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2749
                                }
2750
                            }
2751
                        }
2752
                        break;
2753
                    case ControlType.OverlapWhite:
2754
                        {
2755
                            if (e.LeftButton == MouseButtonState.Pressed)
2756
                            {
2757
                                if (currentControl is OverlapWhiteControl)
2758
                                {
2759
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2760
                                    {
2761
                                        return;
2762
                                    }
2763

    
2764
                                    CreateCommand.Instance.Execute(currentControl);
2765

    
2766
                                    currentControl = null;
2767
                                    this.cursor = Cursors.Arrow;
2768
                                }
2769
                                else
2770
                                {
2771
                                    currentControl = new OverlapWhiteControl
2772
                                    {
2773
                                        Background = new SolidColorBrush(Colors.Black),
2774
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2775
                                        ControlType = ControlType.OverlapWhite
2776
                                    };
2777

    
2778
                                    currentControl.CommentID = Commons.shortGuid();
2779
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2780
                                    currentControl.IsNew = true;
2781
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2782

    
2783
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2784
                                }
2785
                            }
2786
                        }
2787
                        break;
2788
                    case ControlType.ClipWhite:
2789
                        {
2790
                            if (e.LeftButton == MouseButtonState.Pressed)
2791
                            {
2792
                                if (currentControl is ClipWhiteControl)
2793
                                {
2794
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2795
                                    {
2796
                                        return;
2797
                                    }
2798

    
2799
                                    CreateCommand.Instance.Execute(currentControl);
2800

    
2801
                                    currentControl = null;
2802
                                    this.cursor = Cursors.Arrow;
2803
                                }
2804
                                else
2805
                                {
2806
                                    currentControl = new ClipWhiteControl
2807
                                    {
2808
                                        Background = new SolidColorBrush(Colors.Black),
2809
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2810
                                        ControlType = ControlType.ClipWhite
2811
                                    };
2812

    
2813
                                    currentControl.CommentID = Commons.shortGuid();
2814
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2815
                                    currentControl.IsNew = true;
2816
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2817

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

    
2835
                                    CreateCommand.Instance.Execute(currentControl);
2836
                                    currentControl = null;
2837
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2838
                                }
2839
                                else
2840
                                {
2841
                                    currentControl = new RectangleControl
2842
                                    {
2843
                                        Background = new SolidColorBrush(Colors.Black),
2844
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2845
                                        ControlType = ControlType.Rectangle
2846
                                    };
2847

    
2848
                                    currentControl.CommentID = Commons.shortGuid();
2849
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2850
                                    currentControl.IsNew = true;
2851
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2852

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

    
2870
                                    CreateCommand.Instance.Execute(currentControl);
2871

    
2872
                                    currentControl = null;
2873
                                
2874
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2875
                                }
2876
                                else
2877
                                {
2878
                                    currentControl = new RectCloudControl
2879
                                    {
2880
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2881
                                        ControlType = ControlType.RectCloud,
2882
                                        Background = new SolidColorBrush(Colors.Black)
2883
                                    };
2884

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

    
2905
                                    CreateCommand.Instance.Execute(currentControl);
2906

    
2907
                                    currentControl = null;
2908
                                }
2909
                                else
2910
                                {
2911
                                    currentControl = new CircleControl
2912
                                    {
2913
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2914
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2915
                                        Background = new SolidColorBrush(Colors.Black)
2916
                                    };
2917

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

    
2945
                                        CreateCommand.Instance.Execute(currentControl);
2946

    
2947
                                        currentControl = null;
2948
                                    }
2949
                                }
2950
                                else
2951
                                {
2952
                                    currentControl = new TriControl
2953
                                    {
2954
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2955
                                        Background = new SolidColorBrush(Colors.Black),
2956
                                    };
2957

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

    
2982
                                    CreateCommand.Instance.Execute(currentControl);
2983
                                    currentControl = null;
2984
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2985
                                }
2986
                                else
2987
                                {
2988
                                    currentControl = new LineControl
2989
                                    {
2990
                                        ControlType = this.controlType,
2991
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2992
                                        Background = new SolidColorBrush(Colors.Black)
2993
                                    };
2994

    
2995
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2996
                                    currentControl.CommentID = Commons.shortGuid();
2997
                                    currentControl.IsNew = true;
2998
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2999
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3000
                                }
3001
                            }
3002
                        }
3003
                        break;
3004
                    case ControlType.PolygonControl:
3005
                        {
3006
                            if (currentControl is PolygonControl)
3007
                            {
3008
                                var control = currentControl as PolygonControl;
3009

    
3010
                                if (e.RightButton == MouseButtonState.Pressed)
3011
                                {
3012
                                    control.IsCompleted = true;
3013
                                }
3014

    
3015
                                if (!control.IsCompleted)
3016
                                {
3017
                                    control.PointSet.Add(control.EndPoint);
3018
                                }
3019
                                else
3020
                                {
3021
                                    //20180906 LJY TEST IsRotationDrawingEnable
3022
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3023
                                    {
3024
                                        return;
3025
                                    }
3026

    
3027
                                    var firstPoint = control.PointSet.First();
3028
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3029
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3030
                                    control.PointSet.Add(firstPoint);
3031

    
3032
                                    control.ApplyOverViewData();
3033

    
3034
                                    CreateCommand.Instance.Execute(currentControl);
3035
                                    control.UpdateControl();
3036
                                    currentControl = null;
3037
                                }
3038
                            }
3039
                            else
3040
                            {
3041
                                if (e.LeftButton == MouseButtonState.Pressed)
3042
                                {
3043
                                    currentControl = new PolygonControl
3044
                                    {
3045
                                        PointSet = new List<Point>(),
3046
                                    };
3047

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

    
3069
                                if (e.RightButton == MouseButtonState.Pressed)
3070
                                {
3071
                                    //20180906 LJY TEST IsRotationDrawingEnable
3072
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3073
                                    {
3074
                                        return;
3075
                                    }
3076

    
3077
                                    CreateCommand.Instance.Execute(currentControl);
3078

    
3079
                                    currentControl = null;
3080
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3081
                                    return;
3082
                                }
3083

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

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

    
3134
                                    CreateCommand.Instance.Execute(currentControl);
3135

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

    
3177
                                    CreateCommand.Instance.Execute(currentControl);
3178

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

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

    
3237
                                            CreateCommand.Instance.Execute(currentControl);
3238

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

    
3270
                                if (!control.IsCompleted)
3271
                                {
3272
                                    control.PointSet.Add(control.EndPoint);
3273
                                }
3274
                                else
3275
                                {
3276
                                    //20180906 LJY TEST IsRotationDrawingEnable
3277
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3278
                                    {
3279
                                        return;
3280
                                    }
3281

    
3282
                                    CreateCommand.Instance.Execute(currentControl);
3283

    
3284
                                    control.isTransOn = true;
3285
                                    var firstPoint = control.PointSet.First();
3286

    
3287
                                    control.PointSet.Add(firstPoint);
3288
                                    control.DrawingCloud();
3289
                                    control.ApplyOverViewData();
3290

    
3291
                                    currentControl = null;
3292
                                }
3293
                            }
3294
                            else
3295
                            {
3296
                                if (e.LeftButton == MouseButtonState.Pressed)
3297
                                {
3298
                                    currentControl = new CloudControl
3299
                                    {
3300
                                        PointSet = new List<Point>(),
3301
                                        PointC = new StylusPointSet()
3302
                                    };
3303

    
3304
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3305
                                    //{
3306
                                        var polygonControl = (currentControl as CloudControl);
3307
                                        currentControl.CommentID = Commons.shortGuid();
3308
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3309
                                        currentControl.IsNew = true;
3310
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3311

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

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

    
3362
                                            currentControl = new ImgControl
3363
                                            {
3364
                                                    Background = new SolidColorBrush(Colors.Black),
3365
                                                    PointSet = new List<Point>(),
3366
                                                    FilePath = filename,
3367
                                                    ImageData = img.Source,
3368
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3369
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3370
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3371
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3372
                                                    ControlType = ControlType.ImgControl
3373
                                                };
3374

    
3375
                                        
3376
                                                currentControl.CommentID = Commons.shortGuid();                                            
3377
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3378
                                                currentControl.IsNew = true;
3379
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3380

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

    
3403
                                    CreateCommand.Instance.Execute(currentControl);
3404
                                    currentControl = null;
3405

    
3406
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3407
                                    {
3408
                                        controlType = ControlType.None;
3409
                                        IsSwingMode = false;
3410
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3411
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3412
                                        mouseHandlingMode = MouseHandlingMode.None;
3413
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3414
                                        txtBatch.Visibility = Visibility.Collapsed;
3415

    
3416
                                    }
3417
                                }
3418
                                else
3419
                                {
3420
                                    currentControl = new DateControl
3421
                                    {
3422
                                        StartPoint = CanvasDrawingMouseDownPoint,
3423
                                        Background = new SolidColorBrush(Colors.Black)
3424
                                    };
3425
                                    currentControl.CommentID = Commons.shortGuid();
3426
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3427
                                    currentControl.IsNew = true;
3428
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3429

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

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

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

    
3513
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3514
                                    currentControl.CommentID = Commons.shortGuid();
3515
                                    currentControl.IsNew = true;
3516
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3517
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3518

    
3519
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3520
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3521
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3522

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

    
3547
                                    CreateCommand.Instance.Execute(currentControl);
3548

    
3549
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3550
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3551
                                    (currentControl as ArrowTextControl).IsNew = false;
3552
                                    currentControl = null;
3553
                                }
3554
                                else
3555
                                {
3556
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3557
                                    //{
3558
                                        currentControl = new ArrowTextControl();
3559
                                        currentControl.CommentID = Commons.shortGuid();
3560
                                        currentControl.IsNew = true;
3561
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3562
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3563

    
3564
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3565
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3566
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3567
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3568
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3569

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

    
3573
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3574
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3575
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3576
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3577

    
3578
                                    
3579
                                    //}
3580
                                }
3581
                            }
3582
                        }
3583
                        break;
3584
                    case ControlType.ArrowTransTextControl:
3585
                        {
3586
                            if (e.LeftButton == MouseButtonState.Pressed)
3587
                            {
3588
                                if (currentControl is ArrowTextControl)
3589
                                {
3590
                                    //20180906 LJY TEST IsRotationDrawingEnable
3591
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3592
                                    {
3593
                                        return;
3594
                                    }
3595

    
3596
                                    CreateCommand.Instance.Execute(currentControl);
3597

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

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

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

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

    
3665
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3666

    
3667
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3668

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

    
3699
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3700
                                }
3701
                                else
3702
                                {
3703
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3704
                                    //{
3705
                                    
3706

    
3707
                                    currentControl = new ArrowTextControl()
3708
                                    {
3709
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3710
                                        ControlType = ControlType.ArrowTransTextBorderControl
3711

    
3712
                                    };
3713
                                        currentControl.CommentID = Commons.shortGuid();
3714
                                        currentControl.IsNew = true;
3715
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3716
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3717

    
3718
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3719

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

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

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

    
3815
                                        };
3816
                                        currentControl.CommentID = Commons.shortGuid();
3817
                                        currentControl.IsNew = true; 
3818
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3819
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3820
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3821

    
3822
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3823
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3824
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3825
                                        (currentControl as ArrowTextControl).isFixed = true;
3826
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3827

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

    
3851
                                    if (_sign == null)
3852
                                    {
3853
                                        txtBatch.Visibility = Visibility.Collapsed;
3854
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3855
                                        controlType = ControlType.None;
3856

    
3857
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3858
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3859
                                        return;
3860
                                    }
3861

    
3862
                                    if (currentControl is SignControl)
3863
                                    {
3864
                                        //20180906 LJY TEST IsRotationDrawingEnable
3865
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3866
                                        {
3867
                                            return;
3868
                                        }
3869

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

    
3890
                                        currentControl.CommentID = Commons.shortGuid();
3891
                                        currentControl.IsNew = true;
3892
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3893
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3894

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

    
3916
                                        CreateCommand.Instance.Execute(currentControl);
3917
                                        (currentControl as RectangleControl).ApplyOverViewData();
3918
                                        currentControl = null;
3919
                                    
3920
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3921

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

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

    
3974
                                    currentControl.IsNew = true;
3975
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3976
                                    currentControl.CommentID = Commons.shortGuid();
3977
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3978

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

    
4000
                                        CreateCommand.Instance.Execute(currentControl);
4001
                                        currentControl = null;
4002
                                   
4003

    
4004
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4005
                                    }
4006
                                    else
4007
                                    {
4008
                                        currentControl = new SymControlN
4009
                                        {
4010
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4011
                                            Background = new SolidColorBrush(Colors.Black),
4012
                                            STAMP = App.SystemInfo.STAMP,                                            
4013
                                            ControlType = ControlType.Stamp
4014
                                        };
4015

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

    
4054
                if (currentControl != null)
4055
                {
4056
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4057
                }
4058
            }
4059
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4060
            {
4061
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4062
                {
4063
                    bool mouseOff = false;
4064
                    foreach (var item in SelectLayer.Children)
4065
                    {
4066
                        if (item is AdornerFinal)
4067
                        {
4068

    
4069
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4070
                            if (over != null)
4071
                            {
4072
                                mouseOff = true;
4073
                            }
4074
                        }
4075
                    }
4076

    
4077
                    if (!mouseOff)
4078
                    {
4079
                        SelectionSet.Instance.UnSelect(this);
4080
                    }
4081
                }
4082
                zoomAndPanControl.CaptureMouse();
4083
                e.Handled = true;
4084
            }
4085
          
4086
        }
4087

    
4088
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4089
        {
4090
            ///mouseButtonDown = e.ChangedButton;
4091
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4092
        }
4093

    
4094
        private void RemoveLineStroke(Point P)
4095
        {
4096
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4097
            if (control != null)
4098
            {
4099
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4100
            }
4101
        }
4102

    
4103
        private void RemovePointStroke(Point P)
4104
        {
4105
            foreach (Stroke hits in inkBoard.Strokes)
4106
            {
4107
                foreach (StylusPoint sty in hits.StylusPoints)
4108
                {
4109

    
4110
                }
4111
                if (hits.HitTest(P))
4112
                {
4113
                    inkBoard.Strokes.Remove(hits);
4114
                    return;
4115
                }
4116
            }
4117
        }
4118

    
4119
        private void StartNewStroke(Point P)
4120
        {
4121
            strokePoints = new StylusPointCollection();
4122
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4123
            strokePoints.Add(segment1Start);
4124
            stroke = new Stroke(strokePoints);
4125

    
4126
            stroke.DrawingAttributes.Color = Colors.Red;
4127
            stroke.DrawingAttributes.Width = 4;
4128
            stroke.DrawingAttributes.Height = 4;
4129

    
4130
            inkBoard.Strokes.Add(stroke);
4131
        }
4132

    
4133
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4134
        {
4135
            ConsolidationMethod();
4136
        }
4137

    
4138
        /// <summary>
4139
        /// execute TeamConsolidationCommand
4140
        /// </summary>
4141
        public void TeamConsolidationMethod()
4142
        {
4143
            this.UpdateMyMarkupList();
4144
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4145
            {
4146
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4147
            }
4148
            else
4149
            {
4150

    
4151
                ViewerDataModel.Instance.IsConsolidate = true;
4152
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4153

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

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

    
4190
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4191
        {
4192
            if (App.ViewInfo != null)
4193
            {
4194
                btnConsolidate = (sender as RadRibbonButton);
4195
                if (!App.ViewInfo.NewCommentPermission)
4196
                {
4197
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4198
                }
4199
            }
4200
        }
4201

    
4202
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4203
        {
4204
            TeamConsolidationMethod();
4205
        }
4206

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

    
4219
                    if (!App.ViewInfo.NewCommentPermission)
4220
                    {
4221
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4222
                    }
4223
                }
4224
                else
4225
                {
4226
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4227
                }
4228
            }
4229
        }
4230

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

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

    
4268
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4269
        {
4270
            UpdateMyMarkupList();
4271

    
4272
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4273
            {
4274
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4275
            }
4276
            else
4277
            {
4278
                ViewerDataModel.Instance.IsConsolidate = true;
4279
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4280
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4281

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

    
4295
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4296
                if (item2 != null)
4297
                {
4298
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4299

    
4300
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4301
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4302
                }
4303
                else
4304
                {
4305
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4306
                }
4307
            }
4308
        }
4309

    
4310
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4311
        {
4312
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4313

    
4314
            if (App.ViewInfo != null)
4315
            {
4316
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4317
                {
4318
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4319
                }
4320
            }
4321
        }
4322

    
4323
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4324
        {
4325
            SetCompareRect();
4326
        }
4327

    
4328
        private void Sync_Click(object sender, RoutedEventArgs e)
4329
        {
4330
            if (Sync.IsChecked)
4331
            {
4332
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4333
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4334
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4335
            }
4336
        }
4337

    
4338
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4339
        {
4340
            if (UserList.IsChecked)
4341
            {
4342
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4343
            }
4344
            else
4345
            {
4346
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4347
            }
4348
        }
4349

    
4350
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4351
        {
4352

    
4353
            if (BalanceMode.IsChecked)
4354
            {
4355
                ViewerDataModel.Instance.PageBalanceMode = true;
4356
            }
4357
            else
4358
            {
4359
                ViewerDataModel.Instance.PageBalanceMode = false;
4360
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4361
            }
4362
        }
4363

    
4364
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4365
        {
4366
            //초기화
4367
            testPanel2.IsHidden = true;
4368
            ViewerDataModel.Instance.PageBalanceMode = false;
4369
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4370
            ViewerDataModel.Instance.PageNumber = 0;
4371
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4372
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4373
            UserList.IsChecked = false;
4374
            BalanceMode.IsChecked = false;
4375
        }
4376

    
4377
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4378
        {
4379
            if ((sender as System.Windows.Controls.Control).Tag != null)
4380
            {
4381
                //Compare 초기화
4382
                CompareMode.IsChecked = false;
4383
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4384

    
4385
                if (ViewerDataModel.Instance.PageNumber == 0)
4386
                {
4387
                    ViewerDataModel.Instance.PageNumber = 1;
4388
                }
4389

    
4390
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4391
                {
4392
                }
4393
                else
4394
                {
4395
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4396
                }
4397

    
4398

    
4399

    
4400
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4401
                {
4402

    
4403
                }
4404
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4405
                {
4406
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4407
                }
4408

    
4409
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4410

    
4411
                if (!testPanel2.IsHidden)
4412
                {
4413
                    if (IsSyncPDFMode)
4414
                    {
4415
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4416
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4417

    
4418
                        if (pdfpath.IsDownloading)
4419
                        {
4420
                            pdfpath.DownloadCompleted += (ex, arg) =>
4421
                            {
4422
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4423
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4424
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4425
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4426
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4427
                            };
4428
                        }
4429
                        else
4430
                        {
4431
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4432
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4433
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4434

    
4435
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4436
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4437
                        }
4438

    
4439
                    }
4440
                    else
4441
                    {
4442
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4443

    
4444
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4445

    
4446
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4447
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4448
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4449

    
4450
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4451
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4452

    
4453
                        if (defaultBitmapImage_Compare.IsDownloading)
4454
                        {
4455
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4456
                            {
4457
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4458
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4459
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4460

    
4461
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4462
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4463
                            };
4464
                        }
4465
                    }
4466

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

    
4471
                    foreach (var item in gridSelectionRevItem)
4472
                    {
4473
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4474
                        {
4475
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4476
                        });
4477
                    }
4478

    
4479
                    //강인구 추가
4480
                    zoomAndPanControl2.ZoomTo(new Rect
4481
                    {
4482
                        X = 0,
4483
                        Y = 0,
4484
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4485
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4486
                    });
4487

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

    
4490
                }
4491
            }
4492
        }
4493

    
4494
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4495
        {
4496
            if (MarkupMode.IsChecked)
4497
            {
4498
                IsSyncPDFMode = true;
4499

    
4500
                var uri = CurrentRev.TO_VENDOR;
4501

    
4502
                if (ViewerDataModel.Instance.PageNumber == 0)
4503
                {
4504
                    ViewerDataModel.Instance.PageNumber = 1;
4505
                }
4506

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

    
4511
                if (pdfpath.IsDownloading)
4512
                {
4513
                    pdfpath.DownloadCompleted += (ex, arg) =>
4514
                    {
4515
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4516
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4517
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4518
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4519
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4520
                    };
4521
                }
4522
                else
4523
                {
4524
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4525
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4526
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4527

    
4528
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4529
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4530
                }
4531
            }
4532
            else
4533
            {
4534
                IsSyncPDFMode = false;
4535
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4536

    
4537
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4538

    
4539
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4540
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4541
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4542

    
4543
                if (defaultBitmapImage_Compare.IsDownloading)
4544
                {
4545
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4546
                    {
4547
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4548
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4549
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4550
                    };
4551
                }
4552
                zoomAndPanControl2.ApplyTemplate();
4553
                zoomAndPanControl2.UpdateLayout();
4554
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4555
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4556
            }
4557
        }
4558

    
4559
        /// <summary>
4560
        /// Compare된 영역을 초기화
4561
        /// </summary>
4562
        private void ClearCompareRect()
4563
        {
4564
            da.From = 1;
4565
            da.To = 1;
4566
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4567
            da.AutoReverse = false;
4568
            canvas_compareBorder.Children.Clear();
4569
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4570
        }
4571

    
4572
        /// <summary>
4573
        /// 문서 Comprare 
4574
        /// </summary>
4575
        private void SetCompareRect()
4576
        {
4577
            if (CompareMode.IsChecked)
4578
            {
4579
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4580
                {
4581
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4582
                }
4583
                if (ViewerDataModel.Instance.PageNumber == 0)
4584
                {
4585
                    ViewerDataModel.Instance.PageNumber = 1;
4586
                }
4587

    
4588
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4589
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4590
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4591

    
4592
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4593
            }
4594
            else
4595
            {
4596
                ClearCompareRect();
4597
            }
4598
        }
4599

    
4600
        private void RadButton_Click(object sender, RoutedEventArgs e)
4601
        {
4602
            gridViewHistory_Busy.IsBusy = true;
4603

    
4604
            RadButton instance = sender as RadButton;
4605
            if (instance.CommandParameter != null)
4606
            {
4607
                CurrentRev = instance.CommandParameter as VPRevision;
4608
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4609

    
4610
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4611
                {
4612
                    if (ea.Error == null && ea.Result != null)
4613
                    {
4614
                        testPanel2.IsHidden = false;
4615

    
4616
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4617
                        foreach(var info in ea.Result)
4618
                        {
4619
                            if(info.UserID == App.ViewInfo.UserID)
4620
                            {
4621
                                info.userDelete = true;
4622
                                info.DisplayColor = "FFFF0000";
4623
                            }
4624
                            else
4625
                            {
4626
                                info.userDelete = false;
4627
                            }
4628
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4629
                        }
4630
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4631

    
4632
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4633

    
4634
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4635

    
4636
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4637
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4638
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4639
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4640
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4641
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4642

    
4643
                        zoomAndPanControl2.ApplyTemplate();
4644
                        zoomAndPanControl2.UpdateLayout();
4645
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4646
                        {
4647
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4648
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4649
                        }
4650

    
4651
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4652
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4653
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4654

    
4655
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4656
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4657
                        gridViewHistory_Busy.IsBusy = false;
4658
                    }
4659

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

    
4662
                    if (GetSyncMarkupInfoItemshandler != null)
4663
                    {
4664
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4665
                    }
4666

    
4667
                    ClearCompareRect();
4668
                    SetCompareRect();
4669
                };
4670

    
4671
                /// 중복 실행이 발생하여 수정함.
4672
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4673
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4674

    
4675
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4676
            }
4677
        }
4678

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

    
4702
        public void Sync_Event(VPRevision Currnet_Rev)
4703
        {
4704
            CurrentRev = Currnet_Rev;
4705

    
4706
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4707
            {
4708
                if (ea.Error == null && ea.Result != null)
4709
                {
4710
                    testPanel2.IsHidden = false;
4711

    
4712
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4713
                    foreach(var info in ea.Result)
4714
                    {
4715
                        if(info.UserID == App.ViewInfo.UserID)
4716
                        {
4717
                            info.userDelete = true;
4718
                            info.DisplayColor = "FFFF0000";
4719
                        }
4720
                        else
4721
                        {
4722
                            info.userDelete = false;
4723
                        }
4724
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4725
                    }
4726
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4727

    
4728
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4729

    
4730
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4731

    
4732
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4733

    
4734
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4735
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4736
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4737

    
4738
                    if (defaultBitmapImage_Compare.IsDownloading)
4739
                    {
4740
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4741
                        {
4742
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4743
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4744
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4745
                        };
4746
                    }
4747

    
4748

    
4749
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4750
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4751
                    zoomAndPanControl2.ApplyTemplate();
4752
                    zoomAndPanControl2.UpdateLayout();
4753

    
4754
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4755
                    {
4756
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4757
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4758
                    }
4759
                    //}
4760

    
4761
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4762
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4763
                    gridViewHistory_Busy.IsBusy = false;
4764
                }
4765
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4766

    
4767
            };
4768
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4769
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4770
        }
4771

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

    
4788
        private void Create_Symbol(object sender, RoutedEventArgs e)
4789
        {
4790
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4791

    
4792
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4793
            {
4794
                DialogMessage_Alert("Please Select Controls", "Alert");
4795
            }
4796
            else //선택된 것이 있으면
4797
            {
4798
                string MarkupData = "";
4799
                adorner_ = new AdornerFinal();
4800

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

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

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

    
4865
                            if (symbolsvg == true)
4866
                            {
4867
                                try
4868
                                {
4869
                                    var defaultBitmapImage = new BitmapImage();
4870
                                    defaultBitmapImage.BeginInit();
4871
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4872
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4873
                                    Check_Uri.UriCheck(filename);
4874
                                    defaultBitmapImage.UriSource = new Uri(filename);
4875
                                    defaultBitmapImage.EndInit();
4876

    
4877
                                    System.Drawing.Bitmap image;
4878

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

    
4901
                                            StringBuilder svgBuilder = new StringBuilder();
4902
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4903
                                            {
4904
                                                svgBuilder.AppendLine(e2.Data);
4905
                                            };
4906

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

    
4923
                                                DataBind();
4924
                                            };
4925
                                            potrace.WaitForExit();
4926
                                        };
4927
                                    }
4928
                                    else
4929
                                    {
4930
                                        //GC.Collect();
4931
                                    }
4932
                                }
4933
                                catch(Exception ee)
4934
                                {
4935
                                    DialogMessage_Alert("" + ee, "Alert");
4936
                                }
4937
                            }
4938
                        };                                             
4939
                    }
4940
                }
4941
            }
4942
            catch (Exception e)
4943
            {
4944
                //DialogMessage_Alert(e + "", "Alert");
4945
            }            
4946
        }
4947

    
4948
        public void SymbolSave(string Name, string Url, string Data)
4949
        {
4950
            try
4951
            {
4952
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4953
                {
4954
                    ID = Commons.shortGuid(),
4955
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4956
                    NAME = Name,
4957
                    IMAGE_URL = Url,
4958
                    DATA = Data
4959
                };
4960

    
4961
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4962
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4963
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4964
            }
4965
            catch (Exception)
4966
            {
4967
                throw;
4968
            }
4969
        }
4970

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

    
4993
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4994
        {           
4995
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4996
            DataBind();
4997
        }
4998

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

    
5025
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5026

    
5027
                List<SYMBOL_PUBLIC> symbol_Public;
5028

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

    
5064
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5065
                        _Encoder.Save(fs);
5066
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5067

    
5068
                        byte[] Img_byte = fs.ToArray();
5069

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

    
5091
        public PngBitmapEncoder symImage(string data)
5092
        {
5093

    
5094
            Canvas _canvas = new Canvas();
5095
            _canvas.Background = Brushes.White;
5096
            _canvas.Width = adorner_.BorderSize.Width;
5097
            _canvas.Height = adorner_.BorderSize.Height;
5098
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5099

    
5100
            BitmapEncoder encoder = new PngBitmapEncoder();
5101

    
5102

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

    
5105
            DrawingVisual dv = new DrawingVisual();
5106

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

    
5110
            using (DrawingContext ctx = dv.RenderOpen())
5111
            {
5112
                VisualBrush vb = new VisualBrush(_canvas);
5113
                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)));
5114
            }
5115

    
5116
            try
5117
            {
5118
                renderBitmap.Render(dv);
5119

    
5120
                //GC.Collect();
5121
                GC.WaitForPendingFinalizers();
5122
                //GC.Collect();
5123
                // encode png data
5124
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5125
                // puch rendered bitmap into it
5126
                pngEncoder.Interlace = PngInterlaceOption.Off;
5127
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5128
                return pngEncoder;
5129

    
5130
            }
5131
            catch //(Exception ex)
5132
            {
5133
                return null;
5134
            }
5135

    
5136
        }
5137

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

    
5158
        #region 캡쳐 기능
5159

    
5160
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5161
        {
5162
            if (x < 0)
5163
            {
5164
                width += x;
5165
                x = 0;
5166
            }
5167
            if (y < 0)
5168
            {
5169
                height += y;
5170
                y = 0;
5171

    
5172
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5173
            }
5174
            if (x + width > zoomAndPanCanvas.ActualWidth)
5175
            {
5176
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5177
            }
5178
            if (y + height > zoomAndPanCanvas.ActualHeight)
5179
            {
5180
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5181
            }
5182

    
5183
            byte[] pixels = CopyPixels(x, y, width, height);
5184

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

    
5187
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5188
        }
5189

    
5190
        public byte[] CopyPixels(int x, int y, int width, int height)
5191
        {
5192
            byte[] pixels = new byte[width * height * 4];
5193
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5194

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

    
5198
            return pixels;
5199
        }
5200

    
5201
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5202
        {
5203
            DrawingVisual drawingVisual = new DrawingVisual();
5204
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5205

    
5206
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5207
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5208
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5209
            drawingContext.Close();
5210

    
5211
            // 비트맵으로 변환합니다.
5212
            RenderTargetBitmap target =
5213
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5214
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5215

    
5216
            target.Render(drawingVisual);
5217
            return target;
5218
        }
5219

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

    
5232
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5233
        {
5234
            System.Drawing.Bitmap image = GetBitmap(source);
5235
            //흰색 제거
5236
            //image.MakeTransparent(System.Drawing.Color.White);
5237

    
5238
            var imageStream = new System.IO.MemoryStream();
5239
            byte[] imageBytes = null;
5240
            using (imageStream)
5241
            {
5242
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5243
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5244
                imageStream.Position = 0;
5245
                imageBytes = imageStream.ToArray();
5246
            }
5247

    
5248
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5249

    
5250
            RadWindow CheckPop = new RadWindow();
5251
            //Alert check = new Alert(Msg);
5252

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

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

    
5284
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5285
        {
5286
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5287
            KCOMDataModel.DataModel.CHECK_LIST check_;
5288
            string Result = streamToBase64.ImageToBase64(source);
5289
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5290
            string projectno = App.ViewInfo.ProjectNO;
5291
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5292

    
5293
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5294
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5295
            if (Item != null)
5296
            {
5297
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5298
            }
5299
            else
5300
            {
5301
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5302
            }
5303

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

    
5336
        }
5337

    
5338
        public void Set_Capture()
5339
        {
5340
            double x = CanvasDrawingMouseDownPoint.X;
5341
            double y = CanvasDrawingMouseDownPoint.Y;
5342
            double width = dragCaptureBorder.Width;
5343
            double height = dragCaptureBorder.Height;
5344

    
5345
            if (width > 5 || height > 5)
5346
            {
5347
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5348
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5349
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5350
            }
5351
        }
5352
        #endregion
5353

    
5354
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5355
        {
5356
            multi_Undo_Data = new Multi_Undo_data();
5357

    
5358
            multi_Undo_Data.Markup = control;
5359

    
5360
            if ((control as IShapeControl) != null)
5361
            {
5362
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5363
            }
5364
            if ((control as IDashControl) != null)
5365
            {
5366
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5367
            }
5368
            if ((control as IPath) != null)
5369
            {
5370
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5371
            }
5372
            if ((control as UIElement) != null)
5373
            {
5374
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5375
            }
5376

    
5377
            return multi_Undo_Data;
5378
        }
5379

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

    
5399
        /// <summary>
5400
        /// convert inkcontrol to polygoncontrol
5401
        /// </summary>
5402
        public void ConvertInkControlToPolygon()
5403
        {
5404
            if (inkBoard.Strokes.Count > 0)
5405
            {
5406
                inkBoard.Strokes.ToList().ForEach(stroke =>
5407
                {
5408
                    InkToPath ip = new InkToPath();
5409

    
5410
                    List<Point> inkPointSet = new List<Point>();
5411
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5412

    
5413
                    PolygonControl pc = new PolygonControl()
5414
                    {
5415
                        CommentAngle = 0,
5416
                        PointSet = inkPointSet,
5417
                        ControlType = ControlType.Ink
5418
                    };
5419
                    pc.StartPoint = inkPointSet[0];
5420
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5421
                    pc.LineSize = 3;
5422
                    pc.CommentID = Commons.shortGuid();
5423
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5424

    
5425
                    if (pc.PointSet.Count > 0)
5426
                    {
5427
                        CreateCommand.Instance.Execute(pc);
5428
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5429
                    }
5430
                });
5431
                inkBoard.Strokes.Clear();
5432
            }
5433
        }
5434

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

    
5451
            return false;
5452
        }
5453

    
5454
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5455
        {
5456
            e.Effects = DragDropEffects.Copy;
5457
        }
5458

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

    
5464
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5465
        {
5466
            e.Effects = DragDropEffects.None;
5467
        }
5468

    
5469
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5470
        {
5471
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5472
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5473

    
5474
            ScaleImage(pageWidth, pageHeight);
5475
        }
5476

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

    
5488
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5489
        {
5490
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5491
        }
5492

    
5493

    
5494
        /*
5495
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5496
        {
5497
            try
5498
            {
5499
                if (e.Data.GetDataPresent(typeof(string)))
5500
                {
5501
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5502
                    string dragData = e.Data.GetData(typeof(string)) as string;
5503
                    Move_Symbol(sender, dragData);
5504
                }
5505
            }
5506
            catch (Exception ex)
5507
            {
5508
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5509
            }            
5510
        }
5511
        */
5512
    }
5513
}
클립보드 이미지 추가 (최대 크기: 500 MB)