프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 0cda2a88

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
                }
190
            }
191
        }
192

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

    
217
        public bool IsSyncPDFMode { get; set; }
218

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

    
243
        #endregion
244

    
245
        public MainMenu()
246
        {
247
            //App.splashString(ISplashMessage.MAINMENU_0);            
248
           InitializeComponent();
249

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

    
258
            lstSymbolPrivate.ItemsSource = testItems;
259

    
260
            this.Loaded += MainMenu_Loaded;
261
        }
262

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

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

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

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

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

    
300
            return uri;
301
        }
302

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

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

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

    
344
            return false;
345
        }
346

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

    
370
            return false;
371
        }
372

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
507
        }
508

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

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

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

    
528
                    await task;
529

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

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

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

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

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

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

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

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

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

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

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

    
631
        DispatcherTimer renderTesttimer;
632

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

    
644
            await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
645

    
646
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
647
        }
648

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

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

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

    
668
            #endregion
669

    
670
            ViewerDataModel.Instance.PageNumber = BalancePoint;
671

    
672
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
673
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
674
            var pageUri = pageNavigator.CurrentPage.PageUri;
675
            var contentScale = zoomAndPanControl.ContentScale;
676

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

    
679
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(pageNavigator.CurrentPage.PageNumber);
680
       
681
            ScaleImage(pageWidth, pageHeight);
682

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

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

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

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

    
695
            #endregion
696

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

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

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

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

    
745
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
746

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

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

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

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

    
786
            SearchFocusBorder.Visibility = Visibility.Collapsed;
787

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

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

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

    
806

    
807
            var instanceMain = ViewerDataModel.Instance.SystemMain;
808

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

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

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

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

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

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

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

    
862

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

    
874
        }
875

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

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

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

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

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

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

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

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

    
993
                //        pageNavigator.PageChanged += handler;
994

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

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

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

    
1032
        #region ZoomIn & ZoomOut
1033

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

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

    
1046

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

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

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

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

    
1082
        }
1083

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

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

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

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

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

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

    
1136
        #endregion
1137

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

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

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

    
1150
        }
1151

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

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

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

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

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

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

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

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

    
1318

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

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

    
1331

    
1332
               CreateDragDropWindow2(img);
1333
              
1334
    }
1335

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

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

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

    
1365
        
1366

    
1367
         */
1368

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

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

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

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

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

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

    
1402
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1403

    
1404
                MoveZoomAndPanControl(dragOffset);
1405
            }
1406

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

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

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

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

    
1472

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

    
1479

    
1480
                    #endregion
1481

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

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

    
1557
                            }
1558
                            break;
1559

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1794
                    e.Handled = true;
1795
                }
1796

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

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

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

    
1846
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1847

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

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

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

    
1861
        private EllipseGeometry hitArea = new EllipseGeometry();
1862

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

    
1873
                    SetCursor();
1874

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

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

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

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

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

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

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

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

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

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

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

    
1965
                zoomAndPanControl.ReleaseMouseCapture();
1966

    
1967

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

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

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

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

    
1993
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1994

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

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

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

    
2025
            //GC.Collect();
2026

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

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

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

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

    
2053
        }
2054

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2205
            zoomAndPanControl.RotationAngle = rotate.Angle;
2206

    
2207

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2368
            ConvertInkControlToPolygon();
2369

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2523
                        final = new AdornerFinal(control);
2524

    
2525
                        this.Control_Style(control);
2526

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

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

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

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

    
2635
                        Control_Style(control);
2636

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

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

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

    
2697
                                    CreateCommand.Instance.Execute(currentControl);
2698

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

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

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

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

    
2745
                                    CreateCommand.Instance.Execute(currentControl);
2746

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

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

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

    
2780
                                    CreateCommand.Instance.Execute(currentControl);
2781

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

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

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

    
2815
                                    CreateCommand.Instance.Execute(currentControl);
2816

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

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

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

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

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

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

    
2886
                                    CreateCommand.Instance.Execute(currentControl);
2887

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

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

    
2921
                                    CreateCommand.Instance.Execute(currentControl);
2922

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

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

    
2961
                                        CreateCommand.Instance.Execute(currentControl);
2962

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

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

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

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

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

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

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

    
3048
                                    control.ApplyOverViewData();
3049

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

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

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

    
3093
                                    CreateCommand.Instance.Execute(currentControl);
3094

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

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

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

    
3150
                                    CreateCommand.Instance.Execute(currentControl);
3151

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

    
3193
                                    CreateCommand.Instance.Execute(currentControl);
3194

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

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

    
3253
                                            CreateCommand.Instance.Execute(currentControl);
3254

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

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

    
3298
                                    CreateCommand.Instance.Execute(currentControl);
3299

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3563
                                    CreateCommand.Instance.Execute(currentControl);
3564

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

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

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

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

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

    
3612
                                    CreateCommand.Instance.Execute(currentControl);
3613

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4414

    
4415

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4506
                }
4507
            }
4508
        }
4509

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

    
4516
                var uri = CurrentRev.TO_VENDOR;
4517

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4764

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

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

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

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

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

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

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

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

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

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

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

    
4893
                                    System.Drawing.Bitmap image;
4894

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

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

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

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

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

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

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

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

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

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

    
5043
                List<SYMBOL_PUBLIC> symbol_Public;
5044

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

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

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

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

    
5107
        public PngBitmapEncoder symImage(string data)
5108
        {
5109

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

    
5116
            BitmapEncoder encoder = new PngBitmapEncoder();
5117

    
5118

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

    
5121
            DrawingVisual dv = new DrawingVisual();
5122

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

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

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

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

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

    
5152
        }
5153

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

    
5174
        #region 캡쳐 기능
5175

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

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

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

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

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

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

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

    
5214
            return pixels;
5215
        }
5216

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

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

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

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

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

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

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

    
5264
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5265

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

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

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

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

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

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

    
5352
        }
5353

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

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

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

    
5374
            multi_Undo_Data.Markup = control;
5375

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

    
5393
            return multi_Undo_Data;
5394
        }
5395

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

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

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

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

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

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

    
5467
            return false;
5468
        }
5469

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

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

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

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

    
5490
            ScaleImage(pageWidth, pageHeight);
5491
        }
5492

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

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

    
5509

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

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