프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 315ae55e

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
180
                }
181
            }
182
        }
183

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

    
208
        public bool IsSyncPDFMode { get; set; }
209

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

    
234
        #endregion
235

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

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

    
249
            //lstSymbolPrivate.ItemsSource = testItems;
250

    
251
            this.Loaded += MainMenu_Loaded;
252
        }
253

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

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

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

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

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

    
291
            return uri;
292
        }
293

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

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

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

    
335
            return false;
336
        }
337

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

    
361
            return false;
362
        }
363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
499
        }
500

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

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

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

    
520
                    await task;
521

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

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

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

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

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

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

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

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

    
599
                foreach (var markup in deleted)
600
                {
601
                    ViewerDataModel.Instance.MyMarkupList.Remove(markup);
602
                }
603
            }
604
            else
605
            {
606
                System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
607
            }
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(10);
643

    
644
            // 마크업 로드
645
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
646
            await MarkupLoadAsync(e.PageNumber);
647

    
648
            // 페이지 이미지 변경
649
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
650
        }
651

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

    
659
            if (BalancePoint < 1)
660
            {
661
                BalancePoint = 1;
662
                ViewerDataModel.Instance.PageBalanceNumber = 0;
663
            }
664

    
665
            if (pageNavigator.PageCount < BalancePoint)
666
            {
667
                BalancePoint = pageNavigator.PageCount;
668
                ViewerDataModel.Instance.PageBalanceNumber = 0;
669
            }
670

    
671
            #endregion
672

    
673
            ViewerDataModel.Instance.PageNumber = BalancePoint;
674

    
675
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
676
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
677
            var contentScale = zoomAndPanControl.ContentScale;
678

    
679
            #region 페이지 이미지 로딩 수정
680

    
681
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(changePageNumber);
682
       
683
            ScaleImage(pageWidth, pageHeight);
684

    
685
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
686
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
687

    
688
            zoomAndPanCanvas.Width = pageWidth;
689
            zoomAndPanCanvas.Height = pageHeight;
690

    
691
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
692
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
693

    
694
            inkBoard.Width = pageWidth;
695
            inkBoard.Height = pageHeight;
696

    
697
            #endregion
698

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

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

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

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

    
747
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
748

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

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

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

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

    
788
            SearchFocusBorder.Visibility = Visibility.Collapsed;
789

    
790
            this.pageNavigator.ChangePage(changePageNumber);
791
        }
792

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

    
803
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
804
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
805
                );
806
            //}
807
            
808
            var instanceMain = ViewerDataModel.Instance.SystemMain;
809

    
810
            instanceMain.dzMainMenu.CanvasDrawingMouseDownPoint = new Point(ViewerDataModel.Instance.ImageViewWidth / 2, ViewerDataModel.Instance.ImageViewHeight / 2);
811

    
812
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
813
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
814

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

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

    
824
        private async Task MarkupLoadAsync(int pageNumber)
825
        {
826
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
827
            stopwatch.Start();
828

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

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

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

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

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

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

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

    
873

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

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

    
885
            SetCommentPages();
886
        }
887

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

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

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

    
945
            if(instance.IsWheelPageChanage)
946
            {
947
                return;
948
            }
949

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

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

    
994
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
995

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

    
1005
                //        pageNavigator.PageChanged += handler;
1006

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

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

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

    
1044
        #region ZoomIn & ZoomOut
1045

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

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

    
1058

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

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

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

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

    
1094
        }
1095

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

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

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

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

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

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

    
1148
        #endregion
1149

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

    
1155
                ControlList.Clear();
1156
                listBox.Items.Clear();
1157
                selected_item.Clear();
1158

    
1159
                (item as IMarkupCommonData).IsSelected = false;
1160
            }
1161

    
1162
        }
1163

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

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

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

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

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

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

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

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

    
1330

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

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

    
1343

    
1344
               CreateDragDropWindow2(img);
1345
              
1346
    }
1347

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

    
1368
            Win32Point w32Mouse = new Win32Point();
1369
            GetCursorPos(ref w32Mouse);
1370

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

    
1377
        
1378

    
1379
         */
1380

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

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

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

    
1400
                Point currentPos = e.GetPosition(rect);
1401

    
1402
                floatingTip.HorizontalOffset = currentPos.X + 20;
1403
                floatingTip.VerticalOffset = currentPos.Y;
1404
            }
1405

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

    
1414
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1415

    
1416
                MoveZoomAndPanControl(dragOffset);
1417
            }
1418

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

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

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

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

    
1484

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

    
1491

    
1492
                    #endregion
1493

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

    
1496
                    switch (controlType)
1497
                    {
1498
                        case (ControlType.Coordinate):
1499
                            {
1500
                                var control = currentControl as CoordinateControl;
1501
                                if (control != null)
1502
                                {
1503
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1504
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1505
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1506
                                }
1507
                            }
1508
                            break;
1509
                        case (ControlType.InsideWhite):
1510
                            {
1511
                                var control = currentControl as InsideWhiteControl;
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.OverlapWhite:
1522
                            {
1523
                                var control = currentControl as OverlapWhiteControl;
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.ClipWhite:
1534
                            {
1535
                                var control = currentControl as ClipWhiteControl;
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
                                    control.Paint = PaintSet.Fill;
1542
                                }
1543
                            }
1544
                            break;
1545
                        case ControlType.RectCloud:
1546
                            {
1547
                                var control = currentControl as RectCloudControl;
1548
                                if (control != null)
1549
                                {
1550
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1551
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1552
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1553
                                }
1554
                            }
1555
                            break;
1556
                        case ControlType.SingleLine:
1557
                        case ControlType.CancelLine:
1558
                        case ControlType.ArrowLine:
1559
                        case ControlType.TwinLine:
1560
                        case ControlType.DimLine:
1561
                            {
1562
                                var control = currentControl as LineControl;
1563
                                if (control != null)
1564
                                {
1565
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1566
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1567
                                }
1568

    
1569
                            }
1570
                            break;
1571

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

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

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

    
1605
                        case ControlType.Circle:
1606
                            {
1607
                                var control = currentControl as CircleControl;
1608

    
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.PolygonCloud:
1619
                            {
1620
                                var control = currentControl as CloudControl;
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.Triangle:
1631
                            {
1632
                                var control = currentControl as TriControl;
1633
                                if (control != null)
1634
                                {
1635
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1636
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1637
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1638
                                }
1639
                            }
1640
                            break;
1641

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

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

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

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

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

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

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

    
1806
                    e.Handled = true;
1807
                }
1808

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

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

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

    
1858
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1859

    
1860
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1861
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1862

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

    
1871
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1872

    
1873
        private EllipseGeometry hitArea = new EllipseGeometry();
1874

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

    
1885
                    SetCursor();
1886

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

    
1894
                            }
1895
                            break;
1896
                        case ControlType.PenControl:
1897
                            {
1898

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

    
1909
                    if (isLeftMouseButtonDownOnWindow)
1910
                    {
1911
                        bool wasDragSelectionApplied = false;
1912

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

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

    
1948
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1949

    
1950
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1951
                            }
1952

    
1953
                            isDraggingSelectionRect = false;
1954
                            e.Handled = true;
1955
                            wasDragSelectionApplied = true;
1956
                        }
1957

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

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

    
1977
                zoomAndPanControl.ReleaseMouseCapture();
1978

    
1979

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

    
1988
            ///mouseButtonDown = MouseButton.Left;
1989
            //controlType = ControlType.SingleLine;
1990
        }
1991

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

    
2002
            double width = dragCaptureBorder.Width;
2003
            double height = dragCaptureBorder.Height;
2004

    
2005
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2006

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

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

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

    
2037
            //GC.Collect();
2038

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

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

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

    
2062
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2063
        {
2064

    
2065
        }
2066

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2217
            zoomAndPanControl.RotationAngle = rotate.Angle;
2218

    
2219

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

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

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

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

    
2267
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2268
        }
2269

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

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

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

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

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

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

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

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

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

    
2380
            ConvertInkControlToPolygon();
2381

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

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

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

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

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

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

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

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

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

    
2460
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2461
                SetCursor();
2462

    
2463
                if (!ViewerDataModel.Instance.IsPressCtrl)
2464
                {
2465
                    SelectionSet.Instance.UnSelect(this);
2466
                }
2467
            }
2468

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

    
2488
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2489

    
2490
            }
2491
            else if (e.XButton2 == MouseButtonState.Pressed)
2492
            {
2493
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2494
                {
2495
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2496
                }
2497
            }
2498

    
2499
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2500
            {
2501
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2502
                {
2503
                    if (SelectLayer.Children.Count == 0)
2504
                    {
2505
                        isLeftMouseButtonDownOnWindow = true;
2506
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2507
                    }
2508

    
2509
                    if (controlType == ControlType.None)
2510
                    {
2511
                        isLeftMouseButtonDownOnWindow = true;
2512
                    }
2513
                }
2514

    
2515
                /// 캡쳐 모드 설정
2516
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2517
                {
2518
                    dragCaptureBorder.Visibility = Visibility.Visible;
2519
                    isLeftMouseButtonDownOnWindow = true;
2520
                }
2521

    
2522
                /// 줌 모드 설정
2523
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2524
                {
2525
                    isLeftMouseButtonDownOnWindow = true;
2526
                }
2527

    
2528
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2529
                if (control != null)
2530
                {
2531
                    AdornerFinal final = null;
2532

    
2533
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2534
                    {
2535
                        /// 기존 selection 해제
2536
                        SelectionSet.Instance.UnSelect(this);
2537

    
2538
                        final = new AdornerFinal(control);
2539

    
2540
                        this.Control_Style(control);
2541

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

    
2567
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2568

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

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

    
2650
                        Control_Style(control);
2651

    
2652
                        final = new AdornerFinal(comment);
2653
                    }
2654

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

    
2699
                switch (controlType)
2700
                {
2701
                    case ControlType.Coordinate:
2702
                        {
2703
                            if (e.LeftButton == MouseButtonState.Pressed)
2704
                            {
2705
                                if (currentControl is CoordinateControl)
2706
                                {
2707
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2708
                                    {
2709
                                        return;
2710
                                    }
2711

    
2712
                                    CreateCommand.Instance.Execute(currentControl);
2713

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

    
2737
                                        currentControl.CommentID = Commons.shortGuid();
2738
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2739
                                        currentControl.IsNew = true;
2740

    
2741
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2742

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

    
2760
                                    CreateCommand.Instance.Execute(currentControl);
2761

    
2762
                                    currentControl = null;
2763
                                    this.cursor = Cursors.Arrow;
2764
                                }
2765
                                else
2766
                                {
2767
                                    currentControl = new InsideWhiteControl
2768
                                    {
2769
                                        Background = new SolidColorBrush(Colors.Black),
2770
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2771
                                        ControlType = ControlType.InsideWhite
2772
                                    };
2773

    
2774
                                    currentControl.CommentID = Commons.shortGuid();
2775
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2776
                                    currentControl.IsNew = true;
2777
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2778

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

    
2795
                                    CreateCommand.Instance.Execute(currentControl);
2796

    
2797
                                    currentControl = null;
2798
                                    this.cursor = Cursors.Arrow;
2799
                                }
2800
                                else
2801
                                {
2802
                                    currentControl = new OverlapWhiteControl
2803
                                    {
2804
                                        Background = new SolidColorBrush(Colors.Black),
2805
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2806
                                        ControlType = ControlType.OverlapWhite
2807
                                    };
2808

    
2809
                                    currentControl.CommentID = Commons.shortGuid();
2810
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2811
                                    currentControl.IsNew = true;
2812
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2813

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

    
2830
                                    CreateCommand.Instance.Execute(currentControl);
2831

    
2832
                                    currentControl = null;
2833
                                    this.cursor = Cursors.Arrow;
2834
                                }
2835
                                else
2836
                                {
2837
                                    currentControl = new ClipWhiteControl
2838
                                    {
2839
                                        Background = new SolidColorBrush(Colors.Black),
2840
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2841
                                        ControlType = ControlType.ClipWhite
2842
                                    };
2843

    
2844
                                    currentControl.CommentID = Commons.shortGuid();
2845
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2846
                                    currentControl.IsNew = true;
2847
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2848

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

    
2866
                                    CreateCommand.Instance.Execute(currentControl);
2867
                                    currentControl = null;
2868
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2869
                                }
2870
                                else
2871
                                {
2872
                                    currentControl = new RectangleControl
2873
                                    {
2874
                                        Background = new SolidColorBrush(Colors.Black),
2875
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2876
                                        ControlType = ControlType.Rectangle
2877
                                    };
2878

    
2879
                                    currentControl.CommentID = Commons.shortGuid();
2880
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2881
                                    currentControl.IsNew = true;
2882
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2883

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

    
2901
                                    CreateCommand.Instance.Execute(currentControl);
2902

    
2903
                                    currentControl = null;
2904
                                
2905
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2906
                                }
2907
                                else
2908
                                {
2909
                                    currentControl = new RectCloudControl
2910
                                    {
2911
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2912
                                        ControlType = ControlType.RectCloud,
2913
                                        Background = new SolidColorBrush(Colors.Black)
2914
                                    };
2915

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

    
2936
                                    CreateCommand.Instance.Execute(currentControl);
2937

    
2938
                                    currentControl = null;
2939
                                }
2940
                                else
2941
                                {
2942
                                    currentControl = new CircleControl
2943
                                    {
2944
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2945
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2946
                                        Background = new SolidColorBrush(Colors.Black)
2947
                                    };
2948

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

    
2976
                                        CreateCommand.Instance.Execute(currentControl);
2977

    
2978
                                        currentControl = null;
2979
                                    }
2980
                                }
2981
                                else
2982
                                {
2983
                                    currentControl = new TriControl
2984
                                    {
2985
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2986
                                        Background = new SolidColorBrush(Colors.Black),
2987
                                    };
2988

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

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

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

    
3041
                                if (e.RightButton == MouseButtonState.Pressed)
3042
                                {
3043
                                    control.IsCompleted = true;
3044
                                }
3045

    
3046
                                if (!control.IsCompleted)
3047
                                {
3048
                                    control.PointSet.Add(control.EndPoint);
3049
                                }
3050
                                else
3051
                                {
3052
                                    //20180906 LJY TEST IsRotationDrawingEnable
3053
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3054
                                    {
3055
                                        return;
3056
                                    }
3057

    
3058
                                    var firstPoint = control.PointSet.First();
3059
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3060
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3061
                                    control.PointSet.Add(firstPoint);
3062

    
3063
                                    control.ApplyOverViewData();
3064

    
3065
                                    CreateCommand.Instance.Execute(currentControl);
3066
                                    control.UpdateControl();
3067
                                    currentControl = null;
3068
                                }
3069
                            }
3070
                            else
3071
                            {
3072
                                if (e.LeftButton == MouseButtonState.Pressed)
3073
                                {
3074
                                    currentControl = new PolygonControl
3075
                                    {
3076
                                        PointSet = new List<Point>(),
3077
                                    };
3078

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

    
3100
                                if (e.RightButton == MouseButtonState.Pressed)
3101
                                {
3102
                                    //20180906 LJY TEST IsRotationDrawingEnable
3103
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3104
                                    {
3105
                                        return;
3106
                                    }
3107

    
3108
                                    CreateCommand.Instance.Execute(currentControl);
3109

    
3110
                                    currentControl = null;
3111
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3112
                                    return;
3113
                                }
3114

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

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

    
3165
                                    CreateCommand.Instance.Execute(currentControl);
3166

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

    
3208
                                    CreateCommand.Instance.Execute(currentControl);
3209

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

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

    
3268
                                            CreateCommand.Instance.Execute(currentControl);
3269

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

    
3301
                                if (!control.IsCompleted)
3302
                                {
3303
                                    control.PointSet.Add(control.EndPoint);
3304
                                }
3305
                                else
3306
                                {
3307
                                    //20180906 LJY TEST IsRotationDrawingEnable
3308
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3309
                                    {
3310
                                        return;
3311
                                    }
3312

    
3313
                                    CreateCommand.Instance.Execute(currentControl);
3314

    
3315
                                    control.isTransOn = true;
3316
                                    var firstPoint = control.PointSet.First();
3317

    
3318
                                    control.PointSet.Add(firstPoint);
3319
                                    control.DrawingCloud();
3320
                                    control.ApplyOverViewData();
3321

    
3322
                                    currentControl = null;
3323
                                }
3324
                            }
3325
                            else
3326
                            {
3327
                                if (e.LeftButton == MouseButtonState.Pressed)
3328
                                {
3329
                                    currentControl = new CloudControl
3330
                                    {
3331
                                        PointSet = new List<Point>(),
3332
                                        PointC = new StylusPointSet()
3333
                                    };
3334

    
3335
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3336
                                    //{
3337
                                        var polygonControl = (currentControl as CloudControl);
3338
                                        currentControl.CommentID = Commons.shortGuid();
3339
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3340
                                        currentControl.IsNew = true;
3341
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3342

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

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

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

    
3406
                                        
3407
                                                currentControl.CommentID = Commons.shortGuid();                                            
3408
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3409
                                                currentControl.IsNew = true;
3410
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3411

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

    
3434
                                    CreateCommand.Instance.Execute(currentControl);
3435
                                    currentControl = null;
3436

    
3437
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3438
                                    {
3439
                                        controlType = ControlType.None;
3440
                                        IsSwingMode = false;
3441
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3442
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3443
                                        mouseHandlingMode = MouseHandlingMode.None;
3444
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3445
                                        txtBatch.Visibility = Visibility.Collapsed;
3446

    
3447
                                    }
3448
                                }
3449
                                else
3450
                                {
3451
                                    currentControl = new DateControl
3452
                                    {
3453
                                        StartPoint = CanvasDrawingMouseDownPoint,
3454
                                        Background = new SolidColorBrush(Colors.Black)
3455
                                    };
3456
                                    currentControl.CommentID = Commons.shortGuid();
3457
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3458
                                    currentControl.IsNew = true;
3459
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3460

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

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

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

    
3544
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3545
                                    currentControl.CommentID = Commons.shortGuid();
3546
                                    currentControl.IsNew = true;
3547
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3548
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3549

    
3550
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3551
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3552
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3553

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

    
3578
                                    CreateCommand.Instance.Execute(currentControl);
3579

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

    
3595
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3596
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3597
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3598
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3599
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3600

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

    
3604
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3605
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3606
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3607
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3608

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

    
3627
                                    CreateCommand.Instance.Execute(currentControl);
3628

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

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

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

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

    
3696
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3697

    
3698
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3699

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

    
3730
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3731
                                }
3732
                                else
3733
                                {
3734
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3735
                                    //{
3736
                                    
3737

    
3738
                                    currentControl = new ArrowTextControl()
3739
                                    {
3740
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3741
                                        ControlType = ControlType.ArrowTransTextBorderControl
3742

    
3743
                                    };
3744
                                        currentControl.CommentID = Commons.shortGuid();
3745
                                        currentControl.IsNew = true;
3746
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3747
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3748

    
3749
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3750

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

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

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

    
3846
                                        };
3847
                                        currentControl.CommentID = Commons.shortGuid();
3848
                                        currentControl.IsNew = true; 
3849
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3850
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3851
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3852

    
3853
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3854
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3855
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3856
                                        (currentControl as ArrowTextControl).isFixed = true;
3857
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3858

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

    
3882
                                if (_sign == null)
3883
                                    {
3884
                                        txtBatch.Visibility = Visibility.Collapsed;
3885
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3886
                                        controlType = ControlType.None;
3887

    
3888
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3889
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3890
                                        return;
3891
                                    }
3892

    
3893
                                    if (currentControl is SignControl)
3894
                                    {
3895
                                        //20180906 LJY TEST IsRotationDrawingEnable
3896
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3897
                                        {
3898
                                            return;
3899
                                        }
3900

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

    
3921
                                        currentControl.CommentID = Commons.shortGuid();
3922
                                        currentControl.IsNew = true;
3923
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3924
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3925

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

    
3947
                                        CreateCommand.Instance.Execute(currentControl);
3948
                                        (currentControl as RectangleControl).ApplyOverViewData();
3949
                                        currentControl = null;
3950
                                    
3951
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3952

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

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

    
4005
                                    currentControl.IsNew = true;
4006
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4007
                                    currentControl.CommentID = Commons.shortGuid();
4008
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4009

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

    
4031
                                        CreateCommand.Instance.Execute(currentControl);
4032
                                        currentControl = null;
4033
                                   
4034

    
4035
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4036
                                    }
4037
                                    else
4038
                                    {
4039
                                        currentControl = new SymControlN
4040
                                        {
4041
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4042
                                            Background = new SolidColorBrush(Colors.Black),
4043
                                            STAMP = App.SystemInfo.STAMP,                                            
4044
                                            ControlType = ControlType.Stamp
4045
                                        };
4046

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

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

    
4100
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4101
                            if (over != null)
4102
                            {
4103
                                mouseOff = true;
4104
                            }
4105
                        }
4106
                    }
4107

    
4108
                    if (!mouseOff)
4109
                    {
4110
                        SelectionSet.Instance.UnSelect(this);
4111
                    }
4112
                }
4113
                zoomAndPanControl.CaptureMouse();
4114
                e.Handled = true;
4115
            }
4116
          
4117
        }
4118

    
4119
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4120
        {
4121
            ///mouseButtonDown = e.ChangedButton;
4122
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4123
        }
4124

    
4125
        private void RemoveLineStroke(Point P)
4126
        {
4127
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4128
            if (control != null)
4129
            {
4130
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4131
            }
4132
        }
4133

    
4134
        private void RemovePointStroke(Point P)
4135
        {
4136
            foreach (Stroke hits in inkBoard.Strokes)
4137
            {
4138
                foreach (StylusPoint sty in hits.StylusPoints)
4139
                {
4140

    
4141
                }
4142
                if (hits.HitTest(P))
4143
                {
4144
                    inkBoard.Strokes.Remove(hits);
4145
                    return;
4146
                }
4147
            }
4148
        }
4149

    
4150
        private void StartNewStroke(Point P)
4151
        {
4152
            strokePoints = new StylusPointCollection();
4153
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4154
            strokePoints.Add(segment1Start);
4155
            stroke = new Stroke(strokePoints);
4156

    
4157
            stroke.DrawingAttributes.Color = Colors.Red;
4158
            stroke.DrawingAttributes.Width = 4;
4159
            stroke.DrawingAttributes.Height = 4;
4160

    
4161
            inkBoard.Strokes.Add(stroke);
4162
        }
4163

    
4164
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4165
        {
4166
            ConsolidationMethod();
4167
        }
4168

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

    
4182
                ViewerDataModel.Instance.IsConsolidate = true;
4183
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4184

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

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

    
4221
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4222
        {
4223
            if (App.ViewInfo != null)
4224
            {
4225
                btnConsolidate = (sender as RadRibbonButton);
4226
                if (!App.ViewInfo.NewCommentPermission)
4227
                {
4228
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4229
                }
4230
            }
4231
        }
4232

    
4233
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4234
        {
4235
            TeamConsolidationMethod();
4236
        }
4237

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

    
4250
                    if (!App.ViewInfo.NewCommentPermission)
4251
                    {
4252
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4253
                    }
4254
                }
4255
                else
4256
                {
4257
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4258
                }
4259
            }
4260
        }
4261

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

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

    
4299
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4300
        {
4301
            UpdateMyMarkupList();
4302

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

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

    
4326
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4327
                if (item2 != null)
4328
                {
4329
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4330

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

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

    
4357
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4358
        {
4359
            SetCompareRect();
4360
        }
4361

    
4362
        private void Sync_Click(object sender, RoutedEventArgs e)
4363
        {
4364
            if (Sync.IsChecked)
4365
            {
4366
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4367
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4368
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4369
            }
4370
        }
4371

    
4372
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4373
        {
4374
            if (UserList.IsChecked)
4375
            {
4376
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4377
            }
4378
            else
4379
            {
4380
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4381
            }
4382
        }
4383

    
4384
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4385
        {
4386

    
4387
            if (BalanceMode.IsChecked)
4388
            {
4389
                ViewerDataModel.Instance.PageBalanceMode = true;
4390
            }
4391
            else
4392
            {
4393
                ViewerDataModel.Instance.PageBalanceMode = false;
4394
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4395
            }
4396
        }
4397

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

    
4411
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4412
        {
4413
            if ((sender as System.Windows.Controls.Control).Tag != null)
4414
            {
4415
                //Compare 초기화
4416
                CompareMode.IsChecked = false;
4417
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4418

    
4419
                if (ViewerDataModel.Instance.PageNumber == 0)
4420
                {
4421
                    ViewerDataModel.Instance.PageNumber = 1;
4422
                }
4423

    
4424
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4425
                {
4426
                }
4427
                else
4428
                {
4429
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4430
                }
4431

    
4432

    
4433

    
4434
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4435
                {
4436

    
4437
                }
4438
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4439
                {
4440
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4441
                }
4442

    
4443
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4444

    
4445
                if (!testPanel2.IsHidden)
4446
                {
4447
                    if (IsSyncPDFMode)
4448
                    {
4449
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4450
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4451

    
4452
                        if (pdfpath.IsDownloading)
4453
                        {
4454
                            pdfpath.DownloadCompleted += (ex, arg) =>
4455
                            {
4456
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4457
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4458
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4459
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4460
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4461
                            };
4462
                        }
4463
                        else
4464
                        {
4465
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4466
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4467
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4468

    
4469
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4470
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4471
                        }
4472

    
4473
                    }
4474
                    else
4475
                    {
4476
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4477

    
4478
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4479

    
4480
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4481
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4482
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4483

    
4484
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4485
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4486

    
4487
                        if (defaultBitmapImage_Compare.IsDownloading)
4488
                        {
4489
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4490
                            {
4491
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4492
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4493
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4494

    
4495
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4496
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4497
                            };
4498
                        }
4499
                    }
4500

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

    
4505
                    foreach (var item in gridSelectionRevItem)
4506
                    {
4507
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4508
                        foreach (var markupitem in markupitems)
4509
                        {
4510
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4511
                        }
4512
                    }
4513

    
4514
                    //강인구 추가
4515
                    zoomAndPanControl2.ZoomTo(new Rect
4516
                    {
4517
                        X = 0,
4518
                        Y = 0,
4519
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4520
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4521
                    });
4522

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

    
4525
                }
4526
            }
4527
        }
4528

    
4529
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4530
        {
4531
            if (MarkupMode.IsChecked)
4532
            {
4533
                IsSyncPDFMode = true;
4534

    
4535
                var uri = CurrentRev.TO_VENDOR;
4536

    
4537
                if (ViewerDataModel.Instance.PageNumber == 0)
4538
                {
4539
                    ViewerDataModel.Instance.PageNumber = 1;
4540
                }
4541

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

    
4546
                if (pdfpath.IsDownloading)
4547
                {
4548
                    pdfpath.DownloadCompleted += (ex, arg) =>
4549
                    {
4550
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4551
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4552
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4553
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4554
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4555
                    };
4556
                }
4557
                else
4558
                {
4559
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4560
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4561
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4562

    
4563
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4564
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4565
                }
4566
            }
4567
            else
4568
            {
4569
                IsSyncPDFMode = false;
4570
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4571

    
4572
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4573

    
4574
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4575
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4576
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4577

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

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

    
4607
        /// <summary>
4608
        /// 문서 Comprare 
4609
        /// </summary>
4610
        private void SetCompareRect()
4611
        {
4612
            if (CompareMode.IsChecked)
4613
            {
4614
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4615
                {
4616
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4617
                }
4618
                if (ViewerDataModel.Instance.PageNumber == 0)
4619
                {
4620
                    ViewerDataModel.Instance.PageNumber = 1;
4621
                }
4622

    
4623
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4624
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4625
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4626

    
4627
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4628
            }
4629
            else
4630
            {
4631
                ClearCompareRect();
4632
            }
4633
        }
4634

    
4635
        private void RadButton_Click(object sender, RoutedEventArgs e)
4636
        {
4637
            gridViewHistory_Busy.IsBusy = true;
4638

    
4639
            RadButton instance = sender as RadButton;
4640
            if (instance.CommandParameter != null)
4641
            {
4642
                CurrentRev = instance.CommandParameter as VPRevision;
4643
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4644

    
4645
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4646
                {
4647
                    if (ea.Error == null && ea.Result != null)
4648
                    {
4649
                        testPanel2.IsHidden = false;
4650

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

    
4667
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4668

    
4669
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4670

    
4671
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4672
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4673
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4674
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4675
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4676
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4677

    
4678
                        zoomAndPanControl2.ApplyTemplate();
4679
                        zoomAndPanControl2.UpdateLayout();
4680
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4681
                        {
4682
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4683
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4684
                        }
4685

    
4686
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4687
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4688
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4689

    
4690
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4691
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4692
                        gridViewHistory_Busy.IsBusy = false;
4693
                    }
4694

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

    
4697
                    if (GetSyncMarkupInfoItemshandler != null)
4698
                    {
4699
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4700
                    }
4701

    
4702
                    ClearCompareRect();
4703
                    SetCompareRect();
4704
                };
4705

    
4706
                /// 중복 실행이 발생하여 수정함.
4707
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4708
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4709

    
4710
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4711
            }
4712
        }
4713

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

    
4737
        public void Sync_Event(VPRevision Currnet_Rev)
4738
        {
4739
            CurrentRev = Currnet_Rev;
4740

    
4741
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4742
            {
4743
                if (ea.Error == null && ea.Result != null)
4744
                {
4745
                    testPanel2.IsHidden = false;
4746

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

    
4763
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4764

    
4765
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4766

    
4767
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4768

    
4769
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4770
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4771
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4772

    
4773
                    if (defaultBitmapImage_Compare.IsDownloading)
4774
                    {
4775
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4776
                        {
4777
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4778
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4779
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4780
                        };
4781
                    }
4782

    
4783

    
4784
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4785
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4786
                    zoomAndPanControl2.ApplyTemplate();
4787
                    zoomAndPanControl2.UpdateLayout();
4788

    
4789
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4790
                    {
4791
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4792
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4793
                    }
4794
                    //}
4795

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

    
4802
            };
4803
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4804
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4805
        }
4806

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

    
4823
        private void Create_Symbol(object sender, RoutedEventArgs e)
4824
        {
4825
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4826

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

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

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

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

    
4900
                            if (symbolsvg == true)
4901
                            {
4902
                                try
4903
                                {
4904
                                    var defaultBitmapImage = new BitmapImage();
4905
                                    defaultBitmapImage.BeginInit();
4906
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4907
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4908
                                    Check_Uri.UriCheck(filename);
4909
                                    defaultBitmapImage.UriSource = new Uri(filename);
4910
                                    defaultBitmapImage.EndInit();
4911

    
4912
                                    System.Drawing.Bitmap image;
4913

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

    
4936
                                            StringBuilder svgBuilder = new StringBuilder();
4937
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4938
                                            {
4939
                                                svgBuilder.AppendLine(e2.Data);
4940
                                            };
4941

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

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

    
4983
        public void SymbolSave(string Name, string Url, string Data)
4984
        {
4985
            try
4986
            {
4987
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4988
                {
4989
                    ID = Commons.shortGuid(),
4990
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4991
                    NAME = Name,
4992
                    IMAGE_URL = Url,
4993
                    DATA = Data
4994
                };
4995

    
4996
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4997
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4998
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4999
            }
5000
            catch (Exception)
5001
            {
5002
                throw;
5003
            }
5004
        }
5005

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

    
5028
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5029
        {           
5030
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5031
            DataBind();
5032
        }
5033

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

    
5060
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5061

    
5062
                List<SYMBOL_PUBLIC> symbol_Public;
5063

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

    
5099
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5100
                        _Encoder.Save(fs);
5101
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5102

    
5103
                        byte[] Img_byte = fs.ToArray();
5104

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

    
5126
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5127
        {
5128

    
5129
            Canvas _canvas = new Canvas();
5130
            _canvas.Background = Brushes.White;
5131
            _canvas.Width = adorner_.BorderSize.Width;
5132
            _canvas.Height = adorner_.BorderSize.Height;
5133
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5134

    
5135
            BitmapEncoder encoder = new PngBitmapEncoder();
5136

    
5137

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

    
5140
            DrawingVisual dv = new DrawingVisual();
5141

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

    
5145
            using (DrawingContext ctx = dv.RenderOpen())
5146
            {
5147
                VisualBrush vb = new VisualBrush(_canvas);
5148
                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)));
5149
            }
5150

    
5151
            try
5152
            {
5153
                renderBitmap.Render(dv);
5154

    
5155
                //GC.Collect();
5156
                GC.WaitForPendingFinalizers();
5157
                //GC.Collect();
5158
                // encode png data
5159
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5160
                // puch rendered bitmap into it
5161
                pngEncoder.Interlace = PngInterlaceOption.Off;
5162
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5163
                return pngEncoder;
5164

    
5165
            }
5166
            catch //(Exception ex)
5167
            {
5168
                return null;
5169
            }
5170

    
5171
        }
5172

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

    
5193
#region 캡쳐 기능
5194

    
5195
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5196
        {
5197
            if (x < 0)
5198
            {
5199
                width += x;
5200
                x = 0;
5201
            }
5202
            if (y < 0)
5203
            {
5204
                height += y;
5205
                y = 0;
5206

    
5207
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5208
            }
5209
            if (x + width > zoomAndPanCanvas.ActualWidth)
5210
            {
5211
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5212
            }
5213
            if (y + height > zoomAndPanCanvas.ActualHeight)
5214
            {
5215
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5216
            }
5217

    
5218
            byte[] pixels = CopyPixels(x, y, width, height);
5219

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

    
5222
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5223
        }
5224

    
5225
        public byte[] CopyPixels(int x, int y, int width, int height)
5226
        {
5227
            byte[] pixels = new byte[width * height * 4];
5228
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5229

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

    
5233
            return pixels;
5234
        }
5235

    
5236
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5237
        {
5238
            DrawingVisual drawingVisual = new DrawingVisual();
5239
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5240

    
5241
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5242
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5243
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5244
            drawingContext.Close();
5245

    
5246
            // 비트맵으로 변환합니다.
5247
            RenderTargetBitmap target =
5248
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5249
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5250

    
5251
            target.Render(drawingVisual);
5252
            return target;
5253
        }
5254

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

    
5267
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5268
        {
5269
            System.Drawing.Bitmap image = GetBitmap(source);
5270
            //흰색 제거
5271
            //image.MakeTransparent(System.Drawing.Color.White);
5272

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

    
5283
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5284

    
5285
            RadWindow CheckPop = new RadWindow();
5286
            //Alert check = new Alert(Msg);
5287

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

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

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

    
5328
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5329
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5330
            if (Item != null)
5331
            {
5332
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5333
            }
5334
            else
5335
            {
5336
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5337
            }
5338

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

    
5371
        }
5372

    
5373
        public void Set_Capture()
5374
        {
5375
            double x = CanvasDrawingMouseDownPoint.X;
5376
            double y = CanvasDrawingMouseDownPoint.Y;
5377
            double width = dragCaptureBorder.Width;
5378
            double height = dragCaptureBorder.Height;
5379

    
5380
            if (width > 5 || height > 5)
5381
            {
5382
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5383
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5384
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5385
            }
5386
        }
5387
#endregion
5388

    
5389
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5390
        {
5391
            multi_Undo_Data = new Multi_Undo_data();
5392

    
5393
            multi_Undo_Data.Markup = control;
5394

    
5395
            if ((control as IShapeControl) != null)
5396
            {
5397
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5398
            }
5399
            if ((control as IDashControl) != null)
5400
            {
5401
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5402
            }
5403
            if ((control as IPath) != null)
5404
            {
5405
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5406
            }
5407
            if ((control as UIElement) != null)
5408
            {
5409
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5410
            }
5411

    
5412
            return multi_Undo_Data;
5413
        }
5414

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

    
5434
        /// <summary>
5435
        /// convert inkcontrol to polygoncontrol
5436
        /// </summary>
5437
        public void ConvertInkControlToPolygon()
5438
        {
5439
            if (inkBoard.Strokes.Count > 0)
5440
            {
5441
                inkBoard.Strokes.ToList().ForEach(stroke =>
5442
                {
5443
                    InkToPath ip = new InkToPath();
5444

    
5445
                    List<Point> inkPointSet = new List<Point>();
5446
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5447

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

    
5460
                    if (pc.PointSet.Count > 0)
5461
                    {
5462
                        CreateCommand.Instance.Execute(pc);
5463
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5464
                    }
5465
                });
5466
                inkBoard.Strokes.Clear();
5467
            }
5468
        }
5469

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

    
5486
            return false;
5487
        }
5488

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

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

    
5499
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5500
        {
5501
            e.Effects = DragDropEffects.None;
5502
        }
5503

    
5504
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5505
        {
5506
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5507
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5508

    
5509
            ScaleImage(pageWidth, pageHeight);
5510
        }
5511

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

    
5523
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5524
        {
5525
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5526
        }
5527

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

    
5548
    public class testItem
5549
    {
5550
        public string Title { get; set; }
5551
    }
5552
}
클립보드 이미지 추가 (최대 크기: 500 MB)