프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 6af42ff0

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

1

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

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

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

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

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

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

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

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

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

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

    
122
    /// <summary>
123
    /// MainMenu.xaml에 대한 상호 작용 논리
124
    /// </summary>
125
    public partial class MainMenu : UserControl
126
    {
127
        #region 프로퍼티
128
        public CommentUserInfo currentControl { get; set; }
129
        public ControlType controlType { get; set; }
130
        private Move move = new Move();
131
        private double[] rotateValue = { 0, 90, 180, 270 };
132
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
133
        private static readonly double DragThreshold = 5;
134
        private System.Windows.Input.Cursor cursor { get; set; }
135
        private Point canvasDrawingMouseDownPoint;
136
        public string filename { get; set; }
137
        private Point canvasZoomPanningMouseDownPoint;
138
        public Point getCurrentPoint;
139
        private Point canvasZoommovingMouseDownPoint;
140
        List<object> ControlList = new List<object>();
141
        private ListBox listBox = new ListBox();
142
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
143
        private bool isDraggingSelectionRect = false;
144
        DrawingAttributes inkDA = new DrawingAttributes();
145
        private VPRevision CurrentRev { get; set; }
146
        public RadRibbonButton btnConsolidate { get; set; }
147
        public RadRibbonButton btnFinalPDF { get; set; }
148
        public RadRibbonButton btnTeamConsolidate { get; set; }
149
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
150

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

    
161
        public InkPresenter _InkBoard = null;
162
        Stroke stroke;
163
        Boolean IsDrawing = false;
164
        StylusPointCollection strokePoints;
165
        //StylusPointCollection erasePoints;
166
        RenderTargetBitmap canvasImage;
167
        Point Sync_Offset_Point;
168

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

    
184
                }
185
            }
186
        }
187

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

    
212
        public bool IsSyncPDFMode { get; set; }
213

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

    
238
        #endregion
239

    
240
        public MainMenu()
241
        {
242
            App.splashString(ISplashMessage.MAINMENU_0);            
243
            //InitializeComponent();    
244
            this.Loaded += MainMenu_Loaded;
245
        }
246

    
247
        public class TempDt
248
        {
249
            public int PageNumber { get; set; }
250
            public string CommentID { get; set; }
251
            public string ConvertData { get; set; }
252
            public int DATA_TYPE { get; set; }
253
            public string MarkupInfoID { get; set; }
254
            public int IsUpdate { get; set; }
255
        }
256

    
257
        List<TempDt> tempDtList = new List<TempDt>();
258

    
259
        private void SetCursor()
260
        {
261
            this.Cursor = cursor;
262
        }
263

    
264
        /// <summary>
265
        /// get image url
266
        /// </summary>
267
        /// <author>humkyung</author>
268
        /// <param name="sDocumentID"></param>
269
        /// <returns></returns>
270
        public string GetImageURL(string sDocumentID, int iPageNo)
271
        {
272
            string uri = string.Empty;
273

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

    
284
            return uri;
285
        }
286

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

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

    
318
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
319
        {
320
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
321
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
322
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
323
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
324
            {
325
                return true;
326
            }
327

    
328
            return false;
329
        }
330

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

    
354
            return false;
355
        }
356

    
357
        public void DeleteItem(MarkupInfoItem item)
358
        {
359
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
360
            {
361
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
362

    
363
            
364
            ViewerDataModel.Instance._markupInfoList.Remove(item);
365

    
366
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
367
            {
368
                ViewerDataModel.Instance.MarkupControls.Remove(a);
369
            });
370

    
371
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
372
            {
373
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
374
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
375
                null, Event_Type.Delete, a.CommentID, null);
376
            });
377

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

    
385
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
386

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

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

    
447
                        Button content = (sender as Button);
448
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
449

    
450
                        DeleteItem(item);
451
                    }
452
                }
453
            };
454
            RadWindow.Confirm(parameters);
455
        }
456

    
457
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
458

    
459
        private static Timer timer;
460
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
461
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
462
        {
463
            InitializeComponent();            
464
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
465

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

    
479
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
480
                {
481
                    this.SymbolPane.Visibility = Visibility.Collapsed;
482
                    this.FavoritePane.Visibility = Visibility.Collapsed;
483
                    this.drawingRotateCanvas.IsHitTestVisible = false;
484
                }
485
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
486
            }
487

    
488
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
489

    
490
        }
491

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

    
504
                    client.DownloadProgressChanged += (snd, evt) =>
505
                    {
506
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
507

    
508
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
509
                    };
510

    
511
                    await task;
512

    
513
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
514
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
515
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
516
                }
517
            }
518
            catch (Exception ex)
519
            {
520
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
521
            }
522
        }
523

    
524
        private void timercallback(Object o)
525
        {
526
            Stopwatch sw = new Stopwatch();
527
            sw.Start();
528
            TempFile.TempFileAdd();
529
            sw.Stop();
530

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

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

    
551
            /// add or update markup list
552
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
553
            {
554
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
555

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

    
580
            /// delete markup list
581
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
582
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
583
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
584
                          select markup).ToList();
585
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
586
            /// up to here
587

    
588
            //if (modified)
589
            //{
590
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
591
            //    {
592
            //        ComingNewBieEnd = true;
593
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
594
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
595
            //        gridViewMarkup.ItemsSource = null;
596
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
597
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
598

    
599
            //        GroupDescriptor descriptor = new GroupDescriptor();
600
            //        descriptor.Member = "Depatment";
601
            //        descriptor.DisplayContent = "DEPT";
602
            //        descriptor.SortDirection = ListSortDirection.Ascending;
603
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
604
            //    }
605
            //}
606
        }
607

    
608
        DispatcherTimer renderTesttimer;
609

    
610
        /// <summary>
611
        /// start page changing
612
        ///  - save controls if page is modified
613
        ///  - starting download page image
614
        /// </summary>
615
        /// <param name="sender"></param>
616
        /// <param name="e"></param>
617
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
618
        {
619
            CompareMode.IsChecked = false;
620
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
621

    
622
            #region 페이지가 벗어난 경우
623

    
624
            if (BalancePoint < 1)
625
            {
626
                BalancePoint = 1;
627
                ViewerDataModel.Instance.PageBalanceNumber = 0;
628
            }
629

    
630
            if (pageNavigator.PageCount < BalancePoint)
631
            {
632
                BalancePoint = pageNavigator.PageCount;
633
                ViewerDataModel.Instance.PageBalanceNumber = 0;
634
            }
635

    
636
            #endregion
637

    
638
            ViewerDataModel.Instance.PageNumber = BalancePoint;
639

    
640
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
641
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
642
            var pageUri = pageNavigator.CurrentPage.PageUri;
643
            var contentScale = zoomAndPanControl.ContentScale;
644

    
645
            #region 페이지 이미지 로딩 수정
646

    
647
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
648
            try
649
            {
650
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
651
                
652
            }
653
            catch (Exception ex)
654
            {
655
                ViewerDataModel.Instance.ImageViewPath = null;
656
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
657
                DialogMessage_Alert(imgfailedmsg, "Warning");
658
                App.FileLogger.Fatal(ex);
659
            }
660
            ScaleImage(pageWidth, pageHeight);
661

    
662
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
663
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
664

    
665
            zoomAndPanCanvas.Width = pageWidth;
666
            zoomAndPanCanvas.Height = pageHeight;
667

    
668
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
669
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
670

    
671
            inkBoard.Width = pageWidth;
672
            inkBoard.Height = pageHeight;
673

    
674
            #endregion
675

    
676
            if (!testPanel2.IsHidden)
677
            {
678
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
679
                //PDF모드일때 잠시 대기(강인구)
680
                if (IsSyncPDFMode)
681
                {
682
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
683
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
684

    
685
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
686
                    if (pdfpath.IsDownloading)
687
                    {
688
                        pdfpath.DownloadCompleted += (ex, arg) =>
689
                        {
690
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
691
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
692
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
693
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
694
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
695
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
696
                        };
697
                    }
698
                    else
699
                    {
700
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
701
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
702
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
703
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
704

    
705
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
706
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
707
                    }
708
                }
709
                else
710
                {
711
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
712
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
713

    
714
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
715
                    var defaultBitmapImage_Compare = new BitmapImage();
716
                    defaultBitmapImage_Compare.BeginInit();
717
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
718
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
719
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
720
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
721
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
722
                    defaultBitmapImage_Compare.EndInit();
723

    
724
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
725

    
726
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
727
                    zoomAndPanControl.ZoomTo(new Rect
728
                    {
729
                        X = 0,
730
                        Y = 0,
731
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
732
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
733
                    });
734

    
735
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
736
                    if (defaultBitmapImage_Compare.IsDownloading)
737
                    {
738
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
739
                        {
740
                            defaultBitmapImage_Compare.Freeze();
741
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
742
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
743
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
744
                            ComparePanel.UpdateLayout();
745
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
746
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
747

    
748
                            zoomAndPanControl.ZoomTo(new Rect
749
                            {
750
                                X = 0,
751
                                Y = 0,
752
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
753
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
754
                            });
755

    
756
                            //defaultBitmapImage_Compare dispose
757
                            defaultBitmapImage_Compare = null;
758
                            GC.Collect();
759
                        };
760
                    }
761
                }
762
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
763
            }
764

    
765
            this.pageNavigator.ChangePage(e.PageNumber);
766
        }
767

    
768
        /// <summary>
769
        /// called after page is changed
770
        /// </summary>
771
        /// <param name="sender"></param>
772
        /// <param name="e"></param>
773
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
774
        {
775
            if (zoomAndPanCanvas2.Width.IsNaN())
776
            {
777
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
778
            }
779

    
780
            /// 컨트롤을 새로 생성한다.
781
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
782
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
783
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
784
            { 
785
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
786
                if (info != null)
787
                {
788
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
789
                    if (info.UserID == App.ViewInfo.UserID)
790
                    {
791
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
792
                                        markup.MarkupInfoID, markup.ID);
793
                        control.Visibility = Visibility.Hidden;
794
                    }
795
                    else
796
                    {
797
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
798
                                                                markup.MarkupInfoID, markup.ID);
799
                        control.Visibility = Visibility.Hidden;
800
                    }
801
                }
802
            };
803
            /// up to here
804

    
805
            /// fire selection event
806
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
807
            this.gridViewMarkup.UnselectAll();
808
            this.gridViewMarkup.Select(gridSelectionItem);
809

    
810
            if (!testPanel2.IsHidden)
811
            {
812
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
813
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
814
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
815

    
816
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
817
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
818

    
819

    
820
                foreach (var item in gridSelectionRevItem)
821
                {
822
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
823
                    {
824
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
825
                    });
826
                }
827
            }
828

    
829
            var instanceMain = this.ParentOfType<MainWindow>();
830
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
831
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
832

    
833
            instanceMain.dzTopMenu.rotateOffSet = 0;
834
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
835
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
836
            
837
            SetCommentPages(true);
838
        }
839

    
840
        public void SetCommentPages(bool onlyMe = false)
841
        {
842
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
843
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
844
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
845
            {
846
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
847
                if(item.MarkupList != null)
848
                {
849
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
850
                    instance.UserName = item.UserName;
851
                    instance.Depart = item.Depatment;
852
                    instance.MarkupInfoID = item.MarkupInfoID;
853
                    instance.IsSelected = true;
854
                    instance.isConSolidation = item.Consolidate;
855
                    instance.SetColor = item.DisplayColor;
856
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
857
                    {
858
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
859
                    }
860
                    else
861
                    {
862
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
863
                    }
864
                    _pages.Add(instance);
865
                }                   
866
            }
867
            
868
            this.pageNavigator.SetCommentList(_pages.ToList());
869
        }
870

    
871
        public void MarkupitemViewUpdate(string markupinfo_id)
872
        {
873
            //db에 업데이트 한 list 를 view 에 업데이트
874
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
875
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
876
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
877
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
878
            if (dbinfo.MarkupList.Count > 0)
879
            {
880
                if (viewinfo.MarkupList != null)
881
                {
882
                    viewinfo.MarkupList.Clear();
883
                    viewinfo.MarkupList = null;
884
                }
885
                viewinfo.MarkupList = new List<MarkupItem>();
886
                foreach (var item in dbinfo.MarkupList)
887
                {
888
                    viewinfo.MarkupList.Add(item);
889
                }
890
            }
891
        }
892

    
893
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
894
        {
895
            if (e.MiddleButton == MouseButtonState.Pressed)
896
            {
897

    
898
            }
899
            e.Handled = true;
900
            if (e.Delta > 0)
901
            {
902
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
903
                ZoomIn(currentContentMousePoint);
904
            }
905
            else
906
            {
907
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
908
                ZoomOut(currentContentMousePoint);
909
            }
910
        }
911

    
912
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
913
        {
914
            e.Handled = true;
915
            if (e.Delta > 0)
916
            {
917
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
918
                ZoomIn_Sync(currentContentMousePoint);
919
            }
920
            else
921
            {
922
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
923
                ZoomOut_Sync(currentContentMousePoint);
924
            }
925
        }
926

    
927
        #region ZoomIn & ZoomOut
928

    
929
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
930
        {
931
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
932
                zoomAndPanControl.ContentZoomFocusY));
933
        }
934

    
935
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
936
        {
937
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
938
                zoomAndPanControl.ContentZoomFocusY));
939
        }
940

    
941

    
942
        //강인구 추가 (줌 인아웃 수치 변경)
943
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
944
        private void ZoomOut(Point contentZoomCenter)
945
        {
946
            if (zoomAndPanControl.ContentScale > 0.39)
947
            {
948
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
949
            }
950
            else
951
            {
952
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
953
            }
954

    
955
            if (zoomAndPanControl2 != null && Sync.IsChecked)
956
            {
957
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
958
            }
959
        }
960

    
961
        private void ZoomIn(Point contentZoomCenter)
962
        {
963
            if (zoomAndPanControl.ContentScale > 0.19)
964
            {
965
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
966
            }
967
            else
968
            {
969
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
970
            }
971

    
972
            if (zoomAndPanControl2 != null && Sync.IsChecked)
973
            {
974
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
975
            }
976

    
977
        }
978

    
979
        private void ZoomOut_Sync(Point contentZoomCenter)
980
        {
981
            if (zoomAndPanControl2.ContentScale > 0.39)
982
            {
983
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
984
            }
985
            else
986
            {
987
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
988
            }
989

    
990
            if (Sync.IsChecked)
991
            {
992
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
993
            }
994
        }
995

    
996
        private void ZoomIn_Sync(Point contentZoomCenter)
997
        {
998
            if (zoomAndPanControl2.ContentScale > 0.19)
999
            {
1000
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1001
            }
1002
            else
1003
            {
1004
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1005
            }
1006

    
1007
            if (Sync.IsChecked)
1008
            {
1009
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1010
            }
1011
        }
1012

    
1013
        private void ZoomOut()
1014
        {
1015
            zoomAndPanControl.ContentScale -= 0.1;
1016
            //if (zoomAndPanControl2 != null)
1017
            //{
1018
            //    zoomAndPanControl2.ContentScale -= 0.1;
1019
            //}
1020
        }
1021

    
1022
        private void ZoomIn()
1023
        {
1024
            zoomAndPanControl.ContentScale += 0.1;
1025
            //if (zoomAndPanControl2 != null)
1026
            //{
1027
            //    zoomAndPanControl2.ContentScale += 0.1;
1028
            //}
1029
        }
1030

    
1031
        #endregion
1032

    
1033
        private void init()
1034
        {
1035
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1036
            {
1037

    
1038
                ControlList.Clear();
1039
                listBox.Items.Clear();
1040
                selected_item.Clear();
1041

    
1042
                (item as IMarkupCommonData).IsSelected = false;
1043
            }
1044

    
1045
        }
1046

    
1047
        private HitTestResultBehavior MyCallback(HitTestResult result)
1048
        {
1049
            //this.cursor = Cursors.UpArrow;
1050
            var element = result.VisualHit;
1051
            while (element != null && !(element is CommentUserInfo))
1052
                element = VisualTreeHelper.GetParent(element);
1053

    
1054
            if (element == null)
1055
            {
1056
                return HitTestResultBehavior.Stop;
1057
            }
1058
            else
1059
            {
1060
                if (element is CommentUserInfo)
1061
                {
1062
                    if (!hitList.Contains(element))
1063
                    {
1064
                        hitList.Add((CommentUserInfo)element);
1065
                    }
1066
                    else
1067
                    {
1068
                        return HitTestResultBehavior.Stop;
1069
                    }
1070
                }
1071
            }
1072
            return HitTestResultBehavior.Continue;
1073
        }
1074

    
1075
        public void ReleaseSelectPath()
1076
        {
1077
            if (SelectionPath == null)
1078
            {
1079
                SelectionPath = new Path();
1080
                SelectionPath.Name = "";
1081
            }
1082
            if (SelectionPath.Name != "")
1083
            {
1084
                SelectionPath.Name = "None";
1085
            }
1086
            SelectionPath.Opacity = 0.01;
1087
            SelectionPath.RenderTransform = null;
1088
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1089
        }
1090

    
1091
        #region 컨트롤 초기화 
1092
        public void Control_Init(object control)
1093
        {
1094
            if (L_Size != 0 && (control as IPath) != null)
1095
            {
1096
                (control as IPath).LineSize = L_Size;
1097
                L_Size = 0;
1098
            }
1099

    
1100
            switch (control.GetType().Name)
1101
            {
1102
                case "RectangleControl":
1103
                    {
1104
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1105
                    }
1106
                    break;
1107
                case "CircleControl":
1108
                    {
1109
                        (control as CircleControl).StrokeColor = Brushes.Red;
1110
                    }
1111
                    break;
1112
                case "TriControl":
1113
                    {
1114
                        (control as TriControl).StrokeColor = Brushes.Red;
1115
                    }
1116
                    break;
1117
                case "RectCloudControl":
1118
                    {
1119
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1120
                    }
1121
                    break;
1122
                case "CloudControl":
1123
                    {
1124
                        (control as CloudControl).StrokeColor = Brushes.Red;
1125
                    }
1126
                    break;
1127
                case "PolygonControl":
1128
                    {
1129
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1130
                    }
1131
                    break;
1132
                case "ArcControl":
1133
                    {
1134
                        (control as ArcControl).StrokeColor = Brushes.Red;
1135
                    }
1136
                    break;
1137
                case "ArrowArcControl":
1138
                    {
1139
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1140
                    }
1141
                    break;
1142
                case "LineControl":
1143
                    {
1144
                        (control as LineControl).StrokeColor = Brushes.Red;
1145
                    }
1146
                    break;
1147
                case "ArrowControl_Multi":
1148
                    {
1149
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1150
                    }
1151
                    break;
1152
                case "TextControl":
1153
                    {
1154
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1155
                    }
1156
                    break;
1157
                case "ArrowTextControl":
1158
                    {
1159
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1160
                    }
1161
                    break;
1162
                case "InsideWhiteControl":
1163
                    {
1164
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1165
                    }
1166
                    break;
1167
                case "OverlapWhiteControl":
1168
                    {
1169
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1170
                    }
1171
                    break;
1172
                case "ClipWhiteControl":
1173
                    {
1174
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1175
                    }
1176
                    break;
1177
                case "CoordinateControl":
1178
                    {
1179
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1180
                    }
1181
                    break;
1182
            }
1183
        }
1184
        #endregion
1185

    
1186
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1187
        {
1188
            //Control_Init(e.Source);
1189
        }
1190
        //private Window _dragdropWindow = null;
1191

    
1192
        [DllImport("user32.dll")]
1193
        [return: MarshalAs(UnmanagedType.Bool)]
1194
        internal static extern bool GetCursorPos(ref Win32Point pt);
1195

    
1196
        [StructLayout(LayoutKind.Sequential)]
1197
        internal struct Win32Point
1198
        {
1199
            public Int32 X;
1200
            public Int32 Y;
1201
        };
1202
        /*
1203
       public string symbol_id = null;
1204
       public long symbol_group_id;
1205
       public int symbol_SelectedIndex;
1206
       public ImageSource symbol_img;
1207
       public string symbol_Data = null;
1208
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1209
       {
1210
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1211
               zoomAndPanCanvas.ActualHeight / 2));
1212

    
1213

    
1214
               if (this._dragdropWindow != null)
1215
               {
1216
                   this._dragdropWindow.Close();
1217
                   this._dragdropWindow = null;
1218
               }
1219

    
1220
               symbol_id = id;
1221
               symbol_group_id = group_id;
1222
               symbol_SelectedIndex = SelectedIndex;
1223
               symbol_Data = Data_;
1224
               symbol_img = img;
1225

    
1226

    
1227
               CreateDragDropWindow2(img);
1228
              
1229
    }
1230

    
1231
    private void CreateDragDropWindow2(ImageSource image)
1232
        {
1233
            this._dragdropWindow = new Window();
1234
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1235
            _dragdropWindow.WindowStyle = WindowStyle.None;
1236
            _dragdropWindow.AllowsTransparency = true;           
1237
            _dragdropWindow.AllowDrop = false;
1238
            _dragdropWindow.Background = null;
1239
            _dragdropWindow.IsHitTestVisible = false;
1240
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1241
            _dragdropWindow.Topmost = true;
1242
            _dragdropWindow.ShowInTaskbar = false;
1243
            
1244
            Rectangle r = new Rectangle();
1245
            r.Width = image.Width;
1246
            r.Height = image.Height;
1247
            r.Opacity = 0.5;            
1248
            r.Fill = new ImageBrush(image);
1249
            this._dragdropWindow.Content = r;
1250

    
1251
            Win32Point w32Mouse = new Win32Point();
1252
            GetCursorPos(ref w32Mouse);
1253

    
1254
            //w32Mouse.X = getCurrentPoint.X;
1255
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1256
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1257
            this._dragdropWindow.Show();
1258
        }
1259
         */
1260
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1261
        {
1262
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1263
            {
1264
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1265

    
1266
                Point currentPos = e.GetPosition(rect);
1267

    
1268
                floatingTip.HorizontalOffset = currentPos.X + 20;
1269
                floatingTip.VerticalOffset = currentPos.Y;
1270
            }
1271

    
1272
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1273
            
1274
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1275
            {
1276
                SetCursor();
1277
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1278
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1279

    
1280
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1281
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1282
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1283

    
1284
                if (Sync.IsChecked)
1285
                {
1286
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1287
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1288
                }
1289
            }
1290

    
1291
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1292
            {
1293
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1294
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1295
                SetCursor();
1296

    
1297
                if (currentControl != null)
1298
                {
1299
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1300
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1301
                    //강인구 추가
1302
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1303

    
1304
                    if ((currentControl as IPath) != null)
1305
                    {
1306
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1307
                    }
1308
                    if ((currentControl as LineControl) != null)
1309
                    {
1310
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1311
                    }
1312

    
1313
                    if ((currentControl as IShapeControl) != null)
1314
                    {
1315
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1316
                    }
1317
                    if ((currentControl as TextControl) != null)
1318
                    {
1319
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1320
                        {
1321
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1322
                        }
1323
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1324
                        {
1325
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1326
                        }
1327
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1328
                        {
1329
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1330
                        }
1331
                    }
1332
                    else if ((currentControl as ArrowTextControl) != null)
1333
                    {
1334
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1335
                        {
1336
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1337
                        }
1338
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1339
                        {
1340
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1341
                        }
1342
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1343
                        {
1344
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1345
                        }
1346
                    }
1347
                    else if ((currentControl as RectCloudControl) != null)
1348
                    {
1349
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1350
                    }
1351
                    else if ((currentControl as CloudControl) != null)
1352
                    {
1353
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1354
                    }
1355

    
1356
                    switch (controlType)
1357
                    {
1358
                        case (ControlType.Coordinate):
1359
                            {
1360
                                var control = currentControl as CoordinateControl;
1361
                                if (control != null)
1362
                                {
1363
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1364
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1365
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1366
                                }
1367
                            }
1368
                            break;
1369
                        case (ControlType.InsideWhite):
1370
                            {
1371
                                var control = currentControl as InsideWhiteControl;
1372
                                if (control != null)
1373
                                {
1374
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1375
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1376
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1377
                                    control.Paint = PaintSet.Fill;
1378
                                }
1379
                            }
1380
                            break;
1381
                        case ControlType.OverlapWhite:
1382
                            {
1383
                                var control = currentControl as OverlapWhiteControl;
1384
                                if (control != null)
1385
                                {
1386
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1387
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1388
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1389
                                    control.Paint = PaintSet.Fill;
1390
                                }
1391
                            }
1392
                            break;
1393
                        case ControlType.ClipWhite:
1394
                            {
1395
                                var control = currentControl as ClipWhiteControl;
1396
                                if (control != null)
1397
                                {
1398
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1399
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1400
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1401
                                    control.Paint = PaintSet.Fill;
1402
                                }
1403
                            }
1404
                            break;
1405
                        case ControlType.RectCloud:
1406
                            {
1407
                                var control = currentControl as RectCloudControl;
1408
                                if (control != null)
1409
                                {
1410
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1411
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1412
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1413
                                }
1414
                            }
1415
                            break;
1416
                        case ControlType.SingleLine:
1417
                        case ControlType.CancelLine:
1418
                        case ControlType.ArrowLine:
1419
                        case ControlType.TwinLine:
1420
                        case ControlType.DimLine:
1421
                            {
1422
                                var control = currentControl as LineControl;
1423
                                if (control != null)
1424
                                {
1425
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1426
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1427
                                }
1428
                            }
1429
                            break;
1430

    
1431
                        case ControlType.ArcLine:
1432
                            {
1433
                                var control = currentControl as ArcControl;
1434
                                if (control != null)
1435
                                {
1436
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1437
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1438
                                }
1439
                            }
1440
                            break;
1441

    
1442
                        case ControlType.ArcArrow:
1443
                            {
1444
                                var control = currentControl as ArrowArcControl;
1445
                                if (control != null)
1446
                                {
1447
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1448
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1449
                                }
1450
                            }
1451
                            break;
1452

    
1453
                        case ControlType.ArrowMultiLine:
1454
                            {
1455
                                var control = currentControl as ArrowControl_Multi;
1456
                                if (control != null)
1457
                                {
1458
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1459
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1460
                                }
1461
                            }
1462
                            break;
1463

    
1464
                        case ControlType.Circle:
1465
                            {
1466
                                if (currentControl != null)
1467
                                {
1468
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1469
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1470
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1471
                                }
1472
                            }
1473
                            break;
1474

    
1475
                        case ControlType.PolygonCloud:
1476
                            {
1477
                                var control = currentControl as CloudControl;
1478
                                if (control != null)
1479
                                {
1480
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1481
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1482
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1483
                                }
1484
                            }
1485
                            break;
1486

    
1487
                        case ControlType.Triangle:
1488
                            {
1489
                                var control = currentControl as TriControl;
1490
                                if (control != null)
1491
                                {
1492
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1493
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1494
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1495
                                }
1496
                            }
1497
                            break;
1498

    
1499
                        case ControlType.ImgControl:
1500
                            {
1501
                                var control = currentControl as ImgControl;
1502
                                if (control != null)
1503
                                {
1504
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1505
                                }
1506
                            }
1507
                            break;
1508

    
1509
                        case ControlType.Date:
1510
                            {
1511
                                var control = currentControl as DateControl;
1512
                                if (control != null)
1513
                                {
1514
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1515
                                }
1516
                            }
1517
                            break;
1518

    
1519
                        case ControlType.ArrowTextControl:
1520
                        case ControlType.ArrowTransTextControl:
1521
                        case ControlType.ArrowTextBorderControl:
1522
                        case ControlType.ArrowTransTextBorderControl:
1523
                        case ControlType.ArrowTextCloudControl:
1524
                        case ControlType.ArrowTransTextCloudControl:
1525
                            {
1526
                                var control = currentControl as ArrowTextControl;
1527
                                if (control != null)
1528
                                {
1529
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1530
                                }
1531
                            }
1532
                            break;
1533
                        case ControlType.PolygonControl:
1534
                        case ControlType.ChainLine:
1535
                            {
1536
                                var control = currentControl as PolygonControl;
1537
                                if (control != null)
1538
                                {
1539
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1540
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1541
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1542
                                }
1543
                            }
1544
                            break;
1545
                        case ControlType.Sign:
1546
                            {
1547
                                var control = currentControl as SignControl;
1548
                                if (control != null)
1549
                                {
1550
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1551
                                }
1552
                            }
1553
                            break;
1554
                        case ControlType.Symbol:
1555
                            {
1556
                                var control = currentControl as SymControl;
1557
                                if (control != null)
1558
                                {
1559
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1560
                                }
1561
                            }
1562
                            break;
1563
                        case ControlType.Stamp:
1564
                            {
1565
                                var control = currentControl as SymControlN;
1566
                                if (control != null)
1567
                                {
1568
                                    if (control.STAMP != null)
1569
                                    {
1570
                                        control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1571
                                    }
1572
                                    else
1573
                                    {
1574
                                        currentControl = null;
1575
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1576
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1577
                                    }
1578
                                }                                    
1579
                            }
1580
                            break;
1581
                        case ControlType.Rectangle:
1582
                        case ControlType.Mark:
1583
                            {
1584
                                var control = currentControl as RectangleControl;
1585
                                if (control != null)
1586
                                {
1587
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1588
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1589
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1590
                                }
1591
                            }
1592
                            break;
1593
                        case ControlType.PenControl:
1594
                            {
1595
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1596
                                //inkBoard.Strokes.Add(stroke);
1597
                            }
1598
                            break;
1599
                        default:
1600
                            break;
1601
                    }
1602
                }
1603
            }
1604
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1605
            {
1606
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1607
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1608
                SetCursor();
1609
                if (currentControl == null)
1610
                {
1611
                    switch (controlType)
1612
                    {
1613
                        case ControlType.PenControl:
1614
                            {
1615
                                if (inkBoard.Tag.ToString() == "Ink")
1616
                                {
1617
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1618
                                }
1619
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1620
                                {
1621
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1622
                                }
1623
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1624
                                {
1625
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1626
                                }
1627

    
1628
                                //inkBoard.Strokes.Add(stroke);
1629
                            }
1630
                            break;
1631
                    }
1632
                    return;
1633
                }
1634
            }
1635
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1636
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1637
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1638
            {
1639
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1640

    
1641
                if (isDraggingSelectionRect)
1642
                {
1643
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1644
                    e.Handled = true;
1645
                }
1646
                else if (isLeftMouseButtonDownOnWindow)
1647
                {
1648
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1649
                    double dragDistance = Math.Abs(dragDelta.Length);
1650

    
1651
                    if (dragDistance > DragThreshold)
1652
                    {
1653
                        isDraggingSelectionRect = true;
1654
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1655
                    }
1656

    
1657
                    e.Handled = true;
1658
                }
1659

    
1660
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1661
                {
1662
                }
1663
                else
1664
                {
1665
                    e.Handled = true;
1666
                }
1667
            }
1668
            /*
1669
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1670
            { //symbol      
1671
                if(_dragdropWindow != null)
1672
                {
1673
                    Win32Point w32Mouse = new Win32Point();
1674
                    GetCursorPos(ref w32Mouse);
1675

    
1676
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1677
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1678
                }                
1679
            }
1680
            */
1681
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1682
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1683
            {
1684
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1685
                if(control != null)
1686
                {
1687
                    this.cursor = Cursors.Hand;
1688
                    SetCursor();
1689
                }
1690
                else
1691
                {
1692
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1693
                    SetCursor();
1694
                }
1695
            }
1696
            else
1697
            {
1698
            }
1699
        }
1700

    
1701
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1702
        {
1703
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1704
            {
1705
                SetCursor();
1706
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1707
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1708

    
1709
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1710

    
1711
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1712
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1713

    
1714
                if (Sync.IsChecked)
1715
                {
1716
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1717
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1718
                }
1719
            }
1720
        }
1721

    
1722
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1723

    
1724
        private EllipseGeometry hitArea = new EllipseGeometry();
1725

    
1726
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1727
        {
1728
            IsDrawing = false;
1729

    
1730
            if (mouseHandlingMode != MouseHandlingMode.None)
1731
            {
1732
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1733
                {
1734
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1735

    
1736
                    SetCursor();
1737

    
1738
                    switch (controlType)
1739
                    {
1740
                        case ControlType.None:
1741
                            break;
1742
                        case ControlType.Rectangle:
1743
                            {
1744

    
1745
                            }
1746
                            break;
1747
                        case ControlType.PenControl:
1748
                            {
1749

    
1750
                            }
1751
                            break;
1752
                        default:
1753
                            break;
1754
                    }                    
1755
                }
1756
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1757
                {
1758
                    if (isLeftMouseButtonDownOnWindow)
1759
                    {
1760
                        bool wasDragSelectionApplied = false;
1761

    
1762
                        if (isDraggingSelectionRect)
1763
                        {
1764
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1765
                            {
1766
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1767
                                mouseHandlingMode = MouseHandlingMode.None;
1768
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1769
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1770
                                Set_Symbol_Capture(endPoint);
1771
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1772
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1773
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1774
                            }
1775
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1776
                            {
1777
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1778
                                mouseHandlingMode = MouseHandlingMode.None;
1779
                                Set_Capture();
1780

    
1781
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1782
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1783
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1784
                            }
1785
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1786
                            {
1787
                                ApplyDragSelectionRect();
1788
                            }
1789
                            else
1790
                            {
1791
                                double x = Canvas.GetLeft(dragZoomBorder);
1792
                                double y = Canvas.GetTop(dragZoomBorder);
1793
                                double width = dragZoomBorder.Width;
1794
                                double height = dragZoomBorder.Height;
1795
                                Rect dragRect = new Rect(x, y, width, height);
1796

    
1797
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1798

    
1799
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1800
                            }
1801

    
1802
                            isDraggingSelectionRect = false;
1803
                            e.Handled = true;
1804
                            wasDragSelectionApplied = true;
1805
                        }
1806

    
1807
                        if (isLeftMouseButtonDownOnWindow)
1808
                        {
1809
                            isLeftMouseButtonDownOnWindow = false;
1810
                            this.ReleaseMouseCapture();
1811
                            e.Handled = true;
1812
                        }
1813

    
1814
                        if (!wasDragSelectionApplied)
1815
                        {
1816
                            init();
1817
                        }
1818
                    }
1819
                }
1820
                else if (e.RightButton == MouseButtonState.Pressed)
1821
                {
1822
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1823
                    SetCursor();
1824
                }
1825

    
1826
                zoomAndPanControl.ReleaseMouseCapture();
1827

    
1828

    
1829
                e.Handled = true;
1830
            }
1831
            else
1832
            {
1833
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1834
                SetCursor();
1835
            }
1836

    
1837
            ///mouseButtonDown = MouseButton.Left;
1838
            //controlType = ControlType.SingleLine;
1839
        }
1840

    
1841
        public void Set_Symbol_Capture(Point endPoint)
1842
        {       
1843
            double x = canvasDrawingMouseDownPoint.X;
1844
            double y = canvasDrawingMouseDownPoint.Y;
1845
            if(x > endPoint.X)
1846
            {
1847
                x = endPoint.X;
1848
                y = endPoint.Y;
1849
            }
1850

    
1851
            double width = dragCaptureBorder.Width;
1852
            double height = dragCaptureBorder.Height;
1853

    
1854
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1855

    
1856
            if (x < 0)
1857
            {
1858
                width += x;
1859
                x = 0;
1860
            }
1861
            if (y < 0)
1862
            {
1863
                height += y;
1864
                y = 0;
1865

    
1866
                width = (int)canvasImage.PixelWidth - x;
1867
            }
1868
            if (x + width > canvasImage.PixelWidth)
1869
            {
1870
                width = (int)canvasImage.PixelWidth - x;
1871
            }
1872
            if (y + height > canvasImage.PixelHeight)
1873
            {
1874
                height = (int)canvasImage.PixelHeight - y;
1875
            }
1876
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1877

    
1878
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1879
            var defaultBitmapImage = new BitmapImage();
1880
            defaultBitmapImage.BeginInit();
1881
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1882
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1883
            defaultBitmapImage.UriSource = new Uri(uri);
1884
            defaultBitmapImage.EndInit();
1885

    
1886
            //GC.Collect();
1887

    
1888
            if (defaultBitmapImage.IsDownloading)
1889
            {
1890
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1891
                {
1892
                    defaultBitmapImage.Freeze();
1893
                    //GC.Collect();
1894
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1895
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1896
                };
1897
            }
1898
        }
1899

    
1900
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1901
        {
1902
            ///mouseButtonDown = MouseButton.Left;
1903
        }
1904

    
1905
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1906
        {
1907
            ///mouseButtonDown = MouseButton.Left;
1908
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1909
        }
1910

    
1911
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1912
        {
1913

    
1914
        }
1915

    
1916
        /// <summary>
1917
        /// select items by dragging
1918
        /// </summary>
1919
        private void ApplyDragSelectionRect()
1920
        {
1921
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1922

    
1923
            double x = Canvas.GetLeft(dragSelectionBorder);
1924
            double y = Canvas.GetTop(dragSelectionBorder);
1925
            double width = dragSelectionBorder.Width;
1926
            double height = dragSelectionBorder.Height;
1927
            Boolean Flag = false;
1928
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1929
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1930

    
1931
            Rect dragRect = new Rect(x, y, width, height);
1932
            ///dragRect.Inflate(width / 10, height / 10);
1933

    
1934
            foreach (var item in Items)
1935
            {
1936
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1937

    
1938
                if (Flag)
1939
                {
1940
                    adornerSet.Add(item);
1941
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1942
                    Control_Style(item);
1943
                }
1944
            }
1945
            if (adornerSet.Count > 0)
1946
            {
1947
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1948
                SelectLayer.Children.Add(final);
1949
            }
1950
        }
1951

    
1952
        private void InitDragSelectionRect(Point pt1, Point pt2)
1953
        {
1954
            //캡쳐 중
1955
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1956
            {
1957
                dragCaptureBorder.Visibility = Visibility.Visible;
1958
            }
1959
            //선택 중
1960
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1961
            {
1962

    
1963
                dragSelectionBorder.Visibility = Visibility.Visible;
1964
            }
1965
            else
1966
            {
1967
                dragZoomBorder.Visibility = Visibility.Visible;
1968
            }
1969
            UpdateDragSelectionRect(pt1, pt2);
1970
        }
1971

    
1972
        /// <summary>
1973
        /// Update the position and size of the rectangle used for drag selection.
1974
        /// </summary>
1975
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1976
        {
1977
            double x, y, width, height;
1978

    
1979
            //
1980
            // Determine x,y,width and height of the rect inverting the points if necessary.
1981
            // 
1982

    
1983
            if (pt2.X < pt1.X)
1984
            {
1985
                x = pt2.X;
1986
                width = pt1.X - pt2.X;
1987
            }
1988
            else
1989
            {
1990
                x = pt1.X;
1991
                width = pt2.X - pt1.X;
1992
            }
1993

    
1994
            if (pt2.Y < pt1.Y)
1995
            {
1996
                y = pt2.Y;
1997
                height = pt1.Y - pt2.Y;
1998
            }
1999
            else
2000
            {
2001
                y = pt1.Y;
2002
                height = pt2.Y - pt1.Y;
2003
            }
2004

    
2005
            //
2006
            // Update the coordinates of the rectangle used for drag selection.
2007
            //
2008
            //캡쳐 중
2009
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2010
            {
2011
                Canvas.SetLeft(dragCaptureBorder, x);
2012
                Canvas.SetTop(dragCaptureBorder, y);
2013
                dragCaptureBorder.Width = width;
2014
                dragCaptureBorder.Height = height;
2015
            }
2016
            //선택 중
2017
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2018
            {
2019
                Canvas.SetLeft(dragSelectionBorder, x);
2020
                Canvas.SetTop(dragSelectionBorder, y);
2021
                dragSelectionBorder.Width = width;
2022
                dragSelectionBorder.Height = height;
2023
            }
2024
            else
2025
            {
2026
                Canvas.SetLeft(dragZoomBorder, x);
2027
                Canvas.SetTop(dragZoomBorder, y);
2028
                dragZoomBorder.Width = width;
2029
                dragZoomBorder.Height = height;
2030
            }
2031
        }
2032

    
2033
        private void drawingPannelRotate(double angle)
2034
        {
2035
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2036
            rotate.Angle = angle;
2037
            var rotationNum = Math.Abs((rotate.Angle / 90));
2038

    
2039
            if (angle == 90 || angle == 270)
2040
            {
2041
                double emptySize = zoomAndPanCanvas.Width;
2042
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2043
                zoomAndPanCanvas.Height = emptySize;
2044
            }
2045
            if (angle == 0)
2046
            {
2047
                translate.X = 0;
2048
                translate.Y = 0;
2049
            }
2050
            else if (angle == 90)
2051
            {
2052
                translate.X = zoomAndPanCanvas.Width;
2053
                translate.Y = 0;
2054
            }
2055
            else if (angle == 180)
2056
            {
2057
                translate.X = zoomAndPanCanvas.Width;
2058
                translate.Y = zoomAndPanCanvas.Height;
2059
            }
2060
            else
2061
            {
2062
                translate.X = 0;
2063
                translate.Y = zoomAndPanCanvas.Height;
2064
            }
2065

    
2066
            zoomAndPanControl.RotationAngle = rotate.Angle;
2067

    
2068

    
2069
            if (!testPanel2.IsHidden)
2070
            {
2071
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2072
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2073
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2074
            }
2075

    
2076
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2077
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2078
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2079
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2080
            ViewerDataModel.Instance.Angle = rotate.Angle;
2081
        }
2082

    
2083
        private void syncPannelRotate(double angle)
2084
        {
2085
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2086
            rotate.Angle = angle;
2087
            var rotationNum = Math.Abs((rotate.Angle / 90));
2088

    
2089
            if (angle == 90 || angle == 270)
2090
            {
2091
                double emptySize = zoomAndPanCanvas2.Width;
2092
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2093
                zoomAndPanCanvas2.Height = emptySize;
2094
            }
2095
            if (angle == 0)
2096
            {
2097
                translate2.X = 0;
2098
                translate2.Y = 0;
2099
            }
2100
            else if (angle == 90)
2101
            {
2102
                translate2.X = zoomAndPanCanvas2.Width;
2103
                translate2.Y = 0;
2104
            }
2105
            else if (angle == 180)
2106
            {
2107
                translate2.X = zoomAndPanCanvas2.Width;
2108
                translate2.Y = zoomAndPanCanvas2.Height;
2109
            }
2110
            else
2111
            {
2112
                translate2.X = 0;
2113
                translate2.Y = zoomAndPanCanvas2.Height;
2114
            }
2115

    
2116
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2117
        }
2118

    
2119
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2120
        {
2121
            string Data_ = "";
2122

    
2123
            try
2124
            {
2125
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2126
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2127
                if (Data_ != null || Data_ != "")
2128
                {
2129
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2130
                }
2131
                else
2132
                {
2133
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2134
                }
2135

    
2136
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2137
                //{
2138
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2139
                //    STATE = 0,
2140
                //};
2141
                if (Data_ != null)
2142
                {
2143
                    Image img = new Image();
2144
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2145
                    if (Data_.Contains(".svg"))
2146
                    {
2147
                        byte[] imageData = null;
2148
                        DrawingImage image = null;
2149
                        using (System.Net.WebClient web = new System.Net.WebClient())
2150
                        {
2151
                            imageData = web.DownloadData(new Uri(Data_));
2152
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2153
                            image = SvgReader.Load(stream);
2154
                        }
2155
                        img.Source = image;
2156
                    }
2157
                    else
2158
                    {
2159
                        img.Source = new BitmapImage(new Uri(Data_));
2160
                    }
2161

    
2162
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2163
                    {
2164
                        PointSet = new List<Point>(),
2165
                        FilePath = Data_,
2166
                        ImageData = img.Source,
2167
                        StartPoint = canvasZoomPanningMouseDownPoint,
2168
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2169
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2170
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2171
                        canvasZoomPanningMouseDownPoint.Y),
2172
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2173
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2174
                    };
2175

    
2176
                    currentControl.PointSet = new List<Point>
2177
                                        {
2178
                                            currentControl.StartPoint,
2179
                                            currentControl.LeftBottomPoint,
2180
                                            currentControl.EndPoint,
2181
                                            currentControl.TopRightPoint,
2182
                                        };
2183
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2184
                    UndoData = new Undo_data()
2185
                    {
2186
                        IsUndo = false,
2187
                        Event = Event_Type.Create,
2188
                        EventTime = DateTime.Now,
2189
                        Markup_List = new List<Multi_Undo_data>()
2190
                    };
2191
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2192
                    {
2193
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2194
                    });
2195

    
2196
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2197
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2198
                    UndoData.Markup_List.Add(multi_Undo_Data);
2199
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2200

    
2201
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2202
                    currentControl.CommentID = Commons.shortGuid();
2203
                    currentControl.SymbolID = id;
2204
                    currentControl.GroupID = group_id;
2205
                    currentControl.ApplyTemplate();
2206
                    currentControl.SetImage();
2207

    
2208
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2209
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2210
                    SelectLayer.Children.Add(final);
2211
                }
2212
            }
2213
            catch (Exception ex)
2214
            {
2215
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2216
            }
2217
        }
2218

    
2219
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2220
        {            
2221
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2222
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2223
            {
2224
                set_option.Value = double.Parse(set_option.ContentText);
2225
                //set_option.Focusable = false;
2226
                zoomAndPanControl.Focus();
2227
            }
2228

    
2229
            ConvertInkControlToPolygon();
2230

    
2231
            ///TODO:
2232
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2233
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2234

    
2235
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2236
            {
2237
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2238
            }
2239
            /// up to here
2240

    
2241
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2242
            {
2243
                if (item as ArrowTextControl != null)
2244
                {
2245
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2246
                }
2247
                else if (item as TextControl != null)
2248
                {
2249
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2250
                }
2251
            }
2252

    
2253
            //if (currentControl != null)
2254
            {
2255
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2256
                if (text_item_ != null)
2257
                {
2258
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2259
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2260
                    (text_item_ as TextControl).IsEditingMode = false;                    
2261
                    currentControl = null;
2262
                }
2263

    
2264
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2265
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2266
                {
2267
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2268
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2269
                    currentControl = null;
2270
                }
2271
            }
2272

    
2273
            double Ang = 0;                                          
2274
            if (rotate.Angle != 0)
2275
            {
2276
                Ang = 360 - rotate.Angle;
2277
            }
2278

    
2279
            if (e.OriginalSource is System.Windows.Controls.Image)
2280
            {
2281
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2282
            }
2283
            /*
2284
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2285
            {                
2286
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2287
                if(symbol_id != null)
2288
                {
2289
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2290
                }                
2291
            }
2292

    
2293
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2294
            {
2295
                if (this._dragdropWindow != null)
2296
                {
2297
                    this._dragdropWindow.Close();
2298
                    this._dragdropWindow = null;
2299
                    symbol_id = null;
2300
                }
2301
            }
2302
            */
2303

    
2304
            if (e.LeftButton == MouseButtonState.Pressed)
2305
            {
2306
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2307
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2308

    
2309
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2310
                SetCursor();
2311

    
2312
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2313
            }
2314

    
2315
            if (e.MiddleButton == MouseButtonState.Pressed)
2316
            {
2317
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2318
                cursor = Cursors.SizeAll;
2319
                SetCursor();
2320
            }
2321
            if (e.RightButton == MouseButtonState.Pressed)
2322
            {
2323
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2324
                cursor = Cursors.SizeAll;
2325
                SetCursor();
2326
            }
2327
            else if (e.XButton1 == MouseButtonState.Pressed)
2328
            {
2329
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2330
                {
2331
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2332
                }
2333

    
2334
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2335

    
2336
            }
2337
            else if (e.XButton2 == MouseButtonState.Pressed)
2338
            {
2339
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2340
                {
2341
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2342
                }
2343
            }
2344

    
2345
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2346
            {
2347
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2348
                {
2349
                    if (SelectLayer.Children.Count == 0)
2350
                    {
2351
                        isLeftMouseButtonDownOnWindow = true;
2352
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2353
                    }
2354

    
2355
                    if (controlType == ControlType.None)
2356
                    {
2357
                        isLeftMouseButtonDownOnWindow = true;
2358
                    }
2359
                }
2360

    
2361
                /// 캡쳐 모드 설정
2362
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2363
                {
2364
                    dragCaptureBorder.Visibility = Visibility.Visible;
2365
                    isLeftMouseButtonDownOnWindow = true;
2366
                }
2367

    
2368
                /// 줌 모드 설정
2369
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2370
                {
2371
                    isLeftMouseButtonDownOnWindow = true;
2372
                }
2373

    
2374
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2375
                if (control != null)
2376
                {
2377
                    AdornerFinal final = null;
2378

    
2379
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2380
                    {
2381
                        /// 기존 selection 해제
2382
                        SelectionSet.Instance.UnSelect(this);
2383

    
2384
                        final = new AdornerFinal(control);
2385

    
2386
                        this.Control_Style(control);
2387

    
2388
                        if ((control as IPath) != null)
2389
                        {
2390
                            if ((control as IPath).LineSize != 0)
2391
                            {
2392
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2393
                            }
2394
                        }
2395
                        if ((control as IShapeControl) != null)
2396
                        {
2397
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2398
                            {
2399
                                ViewerDataModel.Instance.checkHatchShape = true;
2400
                            }
2401
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2402
                            {
2403
                                ViewerDataModel.Instance.checkFillShape = true;
2404
                            }
2405
                            else
2406
                            {
2407
                                ViewerDataModel.Instance.checkHatchShape = false;
2408
                                ViewerDataModel.Instance.checkFillShape = false;
2409
                            }
2410
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2411
                        }
2412

    
2413
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2414

    
2415
                        if ((control as TextControl) != null)
2416
                        {
2417
                            if(!((control as TextControl).EnableEditing)) {
2418
                                (control as TextControl).EnableEditing = true;
2419
                            }
2420
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2421
                            {
2422
                                ViewerDataModel.Instance.checkTextStyle = true;
2423
                            }
2424
                            else
2425
                            {
2426
                                ViewerDataModel.Instance.checkTextStyle = false;
2427
                            }
2428
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2429
                            {
2430
                                ViewerDataModel.Instance.checkTextWeight = true;
2431
                            }
2432
                            else
2433
                            {
2434
                                ViewerDataModel.Instance.checkTextWeight = false;
2435
                            }
2436
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2437
                            {
2438
                                ViewerDataModel.Instance.checkUnderLine = true;
2439
                            }
2440
                            else
2441
                            {
2442
                                ViewerDataModel.Instance.checkUnderLine = false;
2443
                            }
2444
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2445
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2446

    
2447
                        }
2448
                        else if ((control as ArrowTextControl) != null)
2449
                        {
2450
                            if (!((control as ArrowTextControl).EnableEditing))
2451
                            {
2452
                                (control as ArrowTextControl).EnableEditing = true;
2453
                            }
2454
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2455
                            {
2456
                                ViewerDataModel.Instance.checkTextStyle = true;
2457
                            }
2458
                            else
2459
                            {
2460
                                ViewerDataModel.Instance.checkTextStyle = false;
2461
                            }
2462
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2463
                            {
2464
                                ViewerDataModel.Instance.checkTextWeight = true;
2465
                            }
2466
                            else
2467
                            {
2468
                                ViewerDataModel.Instance.checkTextWeight = false;
2469
                            }
2470
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2471
                            {
2472
                                ViewerDataModel.Instance.checkUnderLine = true;
2473
                            }
2474
                            else
2475
                            {
2476
                                ViewerDataModel.Instance.checkUnderLine = false;
2477
                            }
2478
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2479
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2480
                        }
2481
                        else if ((control as RectCloudControl) != null)
2482
                        {
2483
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2484
                        }
2485
                        else if ((control as CloudControl) != null)
2486
                        {
2487
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2488
                        }
2489
                    }
2490
                    else
2491
                    {
2492
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2493
                        SelectionSet.Instance.UnSelect(this);
2494
                        comment.Add(control);
2495

    
2496
                        Control_Style(control);
2497

    
2498
                        final = new AdornerFinal(comment);
2499
                    }
2500

    
2501
                    if (final != null)
2502
                    {
2503
                        this.SelectLayer.Children.Add(final);
2504
                    }
2505
                }              
2506
            }
2507
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2508
            {               
2509
                init();
2510
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2511
                if (cursor != Cursors.SizeAll)
2512
                {
2513
                    cursor = Cursors.Cross;
2514
                    SetCursor();
2515
                }
2516
                bool init_user = false;
2517
                foreach (var user in gridViewMarkup.Items)
2518
                {
2519
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2520
                    {
2521
                        init_user = true;
2522
                    }
2523
                }
2524
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2525
                {
2526
                    RadWindow.Alert(new DialogParameters
2527
                    {
2528
                        Owner = Application.Current.MainWindow,
2529
                        Theme = new VisualStudio2013Theme(),
2530
                        Header = "안내",
2531
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2532
                    });
2533
                    return;
2534
                }
2535
                else
2536
                {
2537
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2538
                    if (item != null)
2539
                    {
2540
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2541
                    }
2542
                }
2543

    
2544
                switch (controlType)
2545
                {
2546
                    case ControlType.Coordinate:
2547
                        {
2548
                            if (e.LeftButton == MouseButtonState.Pressed)
2549
                            {
2550
                                if (currentControl is CoordinateControl)
2551
                                {
2552
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2553
                                    {
2554
                                        return;
2555
                                    }
2556

    
2557
                                    CreateCommand.Instance.Execute(currentControl);
2558

    
2559
                                    currentControl = null;
2560
                                    this.cursor = Cursors.Arrow;
2561
                                }
2562
                                else
2563
                                {
2564
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2565
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2566
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2567
                                    {
2568
                                        currentControl = null;
2569
                                        this.cursor = Cursors.Arrow;
2570
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2571
                                        return;
2572
                                    }
2573
                                    else
2574
                                    {
2575
                                        currentControl = new CoordinateControl
2576
                                        {
2577
                                            Background = new SolidColorBrush(Colors.Black),
2578
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2579
                                            ControlType = ControlType.Coordinate
2580
                                        };
2581

    
2582
                                        currentControl.CommentID = Commons.shortGuid();
2583
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2584
                                        currentControl.IsNew = true;
2585

    
2586
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2587

    
2588
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2589
                                    }
2590
                                }
2591
                            }
2592
                        }
2593
                        break;
2594
                    case ControlType.InsideWhite:
2595
                        {
2596
                            if (e.LeftButton == MouseButtonState.Pressed)
2597
                            {
2598
                                if (currentControl is InsideWhiteControl)
2599
                                {
2600
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2601
                                    {
2602
                                        return;
2603
                                    }
2604

    
2605
                                    CreateCommand.Instance.Execute(currentControl);
2606

    
2607
                                    currentControl = null;
2608
                                    this.cursor = Cursors.Arrow;
2609
                                }
2610
                                else
2611
                                {
2612
                                    currentControl = new InsideWhiteControl
2613
                                    {
2614
                                        Background = new SolidColorBrush(Colors.Black),
2615
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2616
                                        ControlType = ControlType.InsideWhite
2617
                                    };
2618

    
2619
                                    currentControl.CommentID = Commons.shortGuid();
2620
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2621
                                    currentControl.IsNew = true;
2622
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2623

    
2624
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2625
                                }
2626
                            }
2627
                        }
2628
                        break;
2629
                    case ControlType.OverlapWhite:
2630
                        {
2631
                            if (e.LeftButton == MouseButtonState.Pressed)
2632
                            {
2633
                                if (currentControl is OverlapWhiteControl)
2634
                                {
2635
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2636
                                    {
2637
                                        return;
2638
                                    }
2639

    
2640
                                    CreateCommand.Instance.Execute(currentControl);
2641

    
2642
                                    currentControl = null;
2643
                                    this.cursor = Cursors.Arrow;
2644
                                }
2645
                                else
2646
                                {
2647
                                    currentControl = new OverlapWhiteControl
2648
                                    {
2649
                                        Background = new SolidColorBrush(Colors.Black),
2650
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2651
                                        ControlType = ControlType.OverlapWhite
2652
                                    };
2653

    
2654
                                    currentControl.CommentID = Commons.shortGuid();
2655
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2656
                                    currentControl.IsNew = true;
2657
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2658

    
2659
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2660
                                }
2661
                            }
2662
                        }
2663
                        break;
2664
                    case ControlType.ClipWhite:
2665
                        {
2666
                            if (e.LeftButton == MouseButtonState.Pressed)
2667
                            {
2668
                                if (currentControl is ClipWhiteControl)
2669
                                {
2670
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2671
                                    {
2672
                                        return;
2673
                                    }
2674

    
2675
                                    CreateCommand.Instance.Execute(currentControl);
2676

    
2677
                                    currentControl = null;
2678
                                    this.cursor = Cursors.Arrow;
2679
                                }
2680
                                else
2681
                                {
2682
                                    currentControl = new ClipWhiteControl
2683
                                    {
2684
                                        Background = new SolidColorBrush(Colors.Black),
2685
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2686
                                        ControlType = ControlType.ClipWhite
2687
                                    };
2688

    
2689
                                    currentControl.CommentID = Commons.shortGuid();
2690
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2691
                                    currentControl.IsNew = true;
2692
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2693

    
2694
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2695
                                }
2696
                            }
2697
                        }
2698
                        break;
2699
                    case ControlType.Rectangle:
2700
                        {
2701
                            if (e.LeftButton == MouseButtonState.Pressed)
2702
                            {
2703
                                if (currentControl is RectangleControl)
2704
                                {
2705
                                    //20180906 LJY TEST IsRotationDrawingEnable
2706
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2707
                                    {
2708
                                        return;
2709
                                    }
2710

    
2711
                                    CreateCommand.Instance.Execute(currentControl);
2712
                                    currentControl = null;
2713
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2714
                                }
2715
                                else
2716
                                {
2717
                                    currentControl = new RectangleControl
2718
                                    {
2719
                                        Background = new SolidColorBrush(Colors.Black),
2720
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2721
                                        ControlType = ControlType.Rectangle
2722
                                    };
2723

    
2724
                                    currentControl.CommentID = Commons.shortGuid();
2725
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2726
                                    currentControl.IsNew = true;
2727
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2728

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

    
2746
                                    CreateCommand.Instance.Execute(currentControl);
2747

    
2748
                                    currentControl = null;
2749
                                
2750
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2751
                                }
2752
                                else
2753
                                {
2754
                                    currentControl = new RectCloudControl
2755
                                    {
2756
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2757
                                        ControlType = ControlType.RectCloud,
2758
                                        Background = new SolidColorBrush(Colors.Black)
2759
                                    };
2760

    
2761
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2762
                                    currentControl.CommentID = Commons.shortGuid();
2763
                                    currentControl.IsNew = true;
2764
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2765
                                }
2766
                            }
2767
                        }
2768
                        break;
2769
                    case ControlType.Circle:
2770
                        {
2771
                            if (e.LeftButton == MouseButtonState.Pressed)
2772
                            {
2773
                                if (currentControl is CircleControl)
2774
                                {
2775
                                    //20180906 LJY TEST IsRotationDrawingEnable
2776
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2777
                                    {
2778
                                        return;
2779
                                    }
2780

    
2781
                                    CreateCommand.Instance.Execute(currentControl);
2782

    
2783
                                    currentControl = null;
2784
                                }
2785
                                else
2786
                                {
2787
                                    currentControl = new CircleControl
2788
                                    {
2789
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2790
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2791
                                        Background = new SolidColorBrush(Colors.Black)
2792
                                    };
2793

    
2794
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2795
                                    currentControl.CommentID = Commons.shortGuid();
2796
                                    currentControl.IsNew = true;
2797
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2798
                                }
2799
                            }
2800
                        }
2801
                        break;
2802
                    case ControlType.Triangle:
2803
                        {
2804
                            if (e.LeftButton == MouseButtonState.Pressed)
2805
                            {
2806
                                if (currentControl is TriControl)
2807
                                {
2808
                                    var content = currentControl as TriControl;
2809
                                    if (content.MidPoint == new Point(0, 0))
2810
                                    {
2811
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2812
                                    }
2813
                                    else
2814
                                    {
2815
                                        //20180906 LJY TEST IsRotationDrawingEnable
2816
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2817
                                        {
2818
                                            return;
2819
                                        }
2820

    
2821
                                        CreateCommand.Instance.Execute(currentControl);
2822

    
2823
                                        currentControl = null;
2824
                                    }
2825
                                }
2826
                                else
2827
                                {
2828
                                    currentControl = new TriControl
2829
                                    {
2830
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2831
                                        Background = new SolidColorBrush(Colors.Black),
2832
                                    };
2833

    
2834
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2835
                                    currentControl.CommentID = Commons.shortGuid();
2836
                                    currentControl.IsNew = true;
2837
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2838
                                }
2839
                            }
2840
                        }
2841
                        break;
2842
                    case ControlType.CancelLine:
2843
                    case ControlType.SingleLine:
2844
                    case ControlType.ArrowLine:
2845
                    case ControlType.TwinLine:
2846
                    case ControlType.DimLine:
2847
                        {
2848
                            if (e.LeftButton == MouseButtonState.Pressed)
2849
                            {
2850
                                if (currentControl is LineControl)
2851
                                {
2852
                                    //20180906 LJY TEST IsRotationDrawingEnable
2853
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2854
                                    {
2855
                                        return;
2856
                                    }
2857

    
2858
                                    CreateCommand.Instance.Execute(currentControl);
2859
                                    currentControl = null;
2860
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2861
                                }
2862
                                else
2863
                                {
2864
                                    currentControl = new LineControl
2865
                                    {
2866
                                        ControlType = this.controlType,
2867
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2868
                                        Background = new SolidColorBrush(Colors.Black)
2869
                                    };
2870

    
2871
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2872
                                    currentControl.CommentID = Commons.shortGuid();
2873
                                    currentControl.IsNew = true;
2874
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2875
                                    this.MainAngle.Visibility = Visibility.Visible;
2876
                                }
2877
                            }
2878
                        }
2879
                        break;
2880
                    case ControlType.PolygonControl:
2881
                        {
2882
                            if (currentControl is PolygonControl)
2883
                            {
2884
                                var control = currentControl as PolygonControl;
2885

    
2886
                                if (e.RightButton == MouseButtonState.Pressed)
2887
                                {
2888
                                    control.IsCompleted = true;
2889
                                }
2890

    
2891
                                if (!control.IsCompleted)
2892
                                {
2893
                                    control.PointSet.Add(control.EndPoint);
2894
                                }
2895
                                else
2896
                                {
2897
                                    //20180906 LJY TEST IsRotationDrawingEnable
2898
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2899
                                    {
2900
                                        return;
2901
                                    }
2902

    
2903
                                    var firstPoint = control.PointSet.First();
2904
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2905
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2906
                                    control.PointSet.Add(firstPoint);
2907

    
2908
                                    control.ApplyOverViewData();
2909

    
2910
                                    CreateCommand.Instance.Execute(currentControl);
2911
                                    control.UpdateControl();
2912
                                    currentControl = null;
2913
                                }
2914
                            }
2915
                            else
2916
                            {
2917
                                if (e.LeftButton == MouseButtonState.Pressed)
2918
                                {
2919
                                    currentControl = new PolygonControl
2920
                                    {
2921
                                        PointSet = new List<Point>(),
2922
                                    };
2923

    
2924
                                    var polygonControl = (currentControl as PolygonControl);
2925
                                    currentControl.CommentID = Commons.shortGuid();
2926
                                    currentControl.IsNew = true;
2927
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2928
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2929
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2930
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2931
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2932
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2933
                                    polygonControl.ApplyTemplate();
2934
                                    polygonControl.Visibility = Visibility.Visible;
2935
                                }
2936
                            }
2937
                        }
2938
                        break;
2939
                    case ControlType.ChainLine:
2940
                        {
2941
                            if (currentControl is PolygonControl)
2942
                            {
2943
                                var control = currentControl as PolygonControl;
2944

    
2945
                                if (e.RightButton == MouseButtonState.Pressed)
2946
                                {
2947
                                    //20180906 LJY TEST IsRotationDrawingEnable
2948
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2949
                                    {
2950
                                        return;
2951
                                    }
2952

    
2953
                                    CreateCommand.Instance.Execute(currentControl);
2954

    
2955
                                    currentControl = null;
2956
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2957
                                    return;
2958
                                }
2959

    
2960
                                if (!control.IsCompleted)
2961
                                {
2962
                                    control.PointSet.Add(control.EndPoint);
2963
                                    this.MainAngle.Visibility = Visibility.Visible;
2964
                                }
2965
                            }
2966
                            else
2967
                            {
2968
                                if (e.LeftButton == MouseButtonState.Pressed)
2969
                                {
2970
                                    MainAngle.Visibility = Visibility.Visible;
2971
                                    currentControl = new PolygonControl
2972
                                    {
2973
                                        PointSet = new List<Point>(),
2974
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2975
                                        ControlType = ControlType.ChainLine,
2976
                                        DashSize = ViewerDataModel.Instance.DashSize,
2977
                                        LineSize = ViewerDataModel.Instance.LineSize,
2978
                                        //PointC = new StylusPointSet()
2979
                                    };
2980

    
2981
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2982
                                    //{
2983
                                        var polygonControl = (currentControl as PolygonControl);
2984
                                        currentControl.CommentID = Commons.shortGuid();
2985
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2986
                                        currentControl.IsNew = true;
2987
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2988
                                        //currentControl.OnApplyTemplate();
2989
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2990
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2991
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2992
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2993
                                    //}
2994
                                }
2995
                            }
2996
                        }
2997
                        break;
2998
                    case ControlType.ArcLine:
2999
                        {
3000
                            if (e.LeftButton == MouseButtonState.Pressed)
3001
                            {
3002
                                if (currentControl is ArcControl)
3003
                                {
3004
                                    //20180906 LJY TEST IsRotationDrawingEnable
3005
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3006
                                    {
3007
                                        return;
3008
                                    }
3009

    
3010
                                    CreateCommand.Instance.Execute(currentControl);
3011

    
3012
                                    currentControl = null;
3013
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3014
                                }
3015
                                else
3016
                                {
3017
                                    currentControl = new ArcControl
3018
                                    {
3019
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3020
                                        Background = new SolidColorBrush(Colors.Black)
3021
                                    };
3022
                                    currentControl.CommentID = Commons.shortGuid();
3023
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3024
                                    currentControl.IsNew = true;
3025
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3026
                                    this.MainAngle.Visibility = Visibility.Visible;
3027
                                }
3028
                            }
3029
                            else if (e.RightButton == MouseButtonState.Pressed)
3030
                            {
3031
                                if (currentControl != null)
3032
                                {
3033
                                    (currentControl as ArcControl).setClock();
3034
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3035
                                }
3036
                            }
3037
                        }
3038
                        break;
3039
                    case ControlType.ArcArrow:
3040
                        {
3041
                            if (e.LeftButton == MouseButtonState.Pressed)
3042
                            {
3043
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3044
                                //{
3045
                                if (currentControl is ArrowArcControl)
3046
                                {
3047
                                    //20180906 LJY TEST IsRotationDrawingEnable
3048
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3049
                                    {
3050
                                        return;
3051
                                    }
3052

    
3053
                                    CreateCommand.Instance.Execute(currentControl);
3054

    
3055
                                    currentControl = null;
3056
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3057
                                }
3058
                                else
3059
                                {
3060
                                    currentControl = new ArrowArcControl
3061
                                    {
3062
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3063
                                        Background = new SolidColorBrush(Colors.Black)
3064
                                    };
3065
                                    currentControl.CommentID = Commons.shortGuid();
3066
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3067
                                    currentControl.IsNew = true;
3068
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3069
                                    this.MainAngle.Visibility = Visibility.Visible;
3070
                                }
3071
                                //}
3072
                            }
3073
                            else if (e.RightButton == MouseButtonState.Pressed)
3074
                            {
3075
                                if (currentControl != null)
3076
                                {
3077
                                    (currentControl as ArrowArcControl).setClock();
3078
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3079
                                    //(currentControl as ArcControl).ApplyTemplate();
3080
                                }
3081
                            }
3082
                        }
3083
                        break;
3084
                    case ControlType.ArrowMultiLine:
3085
                        {
3086
                            if (e.LeftButton == MouseButtonState.Pressed)
3087
                            {
3088
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3089
                                //{
3090

    
3091
                                    if (currentControl is ArrowControl_Multi)
3092
                                    {
3093
                                        var content = currentControl as ArrowControl_Multi;
3094
                                        if (content.MiddlePoint == new Point(0, 0))
3095
                                        {
3096
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3097
                                            {
3098
                                                content.MiddlePoint = content.EndPoint;
3099
                                            }
3100
                                            else
3101
                                            {
3102
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3103
                                            }
3104
                                        }
3105
                                        else
3106
                                        {
3107
                                            //20180906 LJY TEST IsRotationDrawingEnable
3108
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3109
                                            {
3110
                                                return;
3111
                                            }
3112

    
3113
                                            CreateCommand.Instance.Execute(currentControl);
3114

    
3115
                                            currentControl = null;
3116
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3117
                                        }
3118
                                    }
3119
                                    else
3120
                                    {
3121
                                        currentControl = new ArrowControl_Multi
3122
                                        {
3123
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3124
                                            Background = new SolidColorBrush(Colors.Black)
3125
                                        };
3126
                                        currentControl.CommentID = Commons.shortGuid();
3127
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3128
                                        currentControl.IsNew = true;
3129
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3130
                                        this.MainAngle.Visibility = Visibility.Visible;
3131
                                    }
3132
                                //}
3133
                            }
3134
                        }
3135
                        break;
3136
                    case ControlType.PolygonCloud:
3137
                        {
3138
                            if (currentControl is CloudControl)
3139
                            {
3140
                                var control = currentControl as CloudControl;
3141
                                if (e.RightButton == MouseButtonState.Pressed)
3142
                                {
3143
                                    control.IsCompleted = true;
3144
                                }
3145

    
3146
                                if (!control.IsCompleted)
3147
                                {
3148
                                    control.PointSet.Add(control.EndPoint);
3149
                                }
3150
                                else
3151
                                {
3152
                                    //20180906 LJY TEST IsRotationDrawingEnable
3153
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3154
                                    {
3155
                                        return;
3156
                                    }
3157

    
3158
                                    CreateCommand.Instance.Execute(currentControl);
3159

    
3160
                                    control.isTransOn = true;
3161
                                    var firstPoint = control.PointSet.First();
3162

    
3163
                                    control.PointSet.Add(firstPoint);
3164
                                    control.DrawingCloud();
3165
                                    control.ApplyOverViewData();
3166

    
3167
                                    currentControl = null;
3168
                                }
3169
                            }
3170
                            else
3171
                            {
3172
                                if (e.LeftButton == MouseButtonState.Pressed)
3173
                                {
3174
                                    currentControl = new CloudControl
3175
                                    {
3176
                                        PointSet = new List<Point>(),
3177
                                        PointC = new StylusPointSet()
3178
                                    };
3179

    
3180
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3181
                                    //{
3182
                                        var polygonControl = (currentControl as CloudControl);
3183
                                        currentControl.CommentID = Commons.shortGuid();
3184
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3185
                                        currentControl.IsNew = true;
3186
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3187

    
3188
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3189
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3190
                                    
3191
                                    //}
3192
                                }
3193
                            }
3194
                        }
3195
                        break;
3196
                    case ControlType.ImgControl:
3197
                        {
3198
                            if (e.LeftButton == MouseButtonState.Pressed)
3199
                            {
3200
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3201
                                //{
3202
                                    if (currentControl is ImgControl)
3203
                                    {
3204
                                        //20180906 LJY TEST IsRotationDrawingEnable
3205
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3206
                                        {
3207
                                            return;
3208
                                        }
3209

    
3210
                                        CreateCommand.Instance.Execute(currentControl);
3211
                                        controlType = ControlType.ImgControl;
3212
                                        currentControl = null;
3213
                                    }
3214
                                    else
3215
                                    {
3216
                                        
3217
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3218
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3219
                                        {
3220
                                            Image img = new Image();
3221
                                            if (filename.Contains(".svg"))
3222
                                            {
3223
                                                byte[] imageData = null;
3224
                                                DrawingImage image = null;
3225
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3226
                                                {
3227
                                                    imageData = web.DownloadData(new Uri(filename));
3228
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3229
                                                    image = SvgReader.Load(stream);
3230
                                                }
3231
                                                img.Source = image;
3232
                                            }
3233
                                            else
3234
                                            {
3235
                                                img.Source = new BitmapImage(new Uri(filename));
3236
                                            }
3237

    
3238
                                            currentControl = new ImgControl
3239
                                            {
3240
                                                    Background = new SolidColorBrush(Colors.Black),
3241
                                                    PointSet = new List<Point>(),
3242
                                                    FilePath = filename,
3243
                                                    ImageData = img.Source,
3244
                                                    StartPoint = canvasDrawingMouseDownPoint,
3245
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3246
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3247
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3248
                                                    ControlType = ControlType.ImgControl
3249
                                                };
3250

    
3251
                                        
3252
                                                currentControl.CommentID = Commons.shortGuid();                                            
3253
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3254
                                                currentControl.IsNew = true;
3255
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3256

    
3257
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3258
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3259
                                        }
3260
                                    }
3261
                                //}
3262
                            }
3263
                        }
3264
                        break;
3265
                    case ControlType.Date:
3266
                        {
3267
                            if (e.LeftButton == MouseButtonState.Pressed)
3268
                            {
3269
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3270
                                //{
3271
                                    if (currentControl is DateControl)
3272
                                    {
3273
                                        //20180906 LJY TEST IsRotationDrawingEnable
3274
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3275
                                        {
3276
                                            return;
3277
                                        }
3278

    
3279
                                        CreateCommand.Instance.Execute(currentControl);
3280
                                        currentControl = null;
3281

    
3282
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3283
                                        {
3284
                                            controlType = ControlType.None;
3285
                                            IsSwingMode = false;
3286
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3287
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3288
                                            mouseHandlingMode = MouseHandlingMode.None;
3289
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3290
                                            txtBatch.Visibility = Visibility.Collapsed;
3291

    
3292
                                        }
3293
                                    }
3294
                                    else
3295
                                    {
3296
                                        currentControl = new DateControl
3297
                                        {
3298
                                            StartPoint = canvasDrawingMouseDownPoint,
3299
                                            Background = new SolidColorBrush(Colors.Black)
3300
                                        };
3301
                                        currentControl.CommentID = Commons.shortGuid();
3302
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3303
                                        currentControl.IsNew = true;
3304
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3305

    
3306
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3307
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3308
                                }
3309
                                //}
3310
                            }
3311
                        }
3312
                        break;
3313
                    case ControlType.TextControl:
3314
                        {
3315
                            if (e.LeftButton == MouseButtonState.Pressed)
3316
                            {
3317
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3318
                                {
3319
                                    currentControl = new TextControl
3320
                                    {
3321
                                        ControlType = controlType
3322
                                    };
3323
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3324
                                    currentControl.CommentID = Commons.shortGuid();
3325
                                    currentControl.IsNew = true;
3326
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3327
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3328
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3329

    
3330
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3331
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3332
                                    
3333
                                    (currentControl as TextControl).ControlType_No = 0;
3334
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3335
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3336
                                    (currentControl as TextControl).ApplyTemplate();
3337
                                    (currentControl as TextControl).Base_TextBox.Focus();
3338
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3339
                                    CreateCommand.Instance.Execute(currentControl);
3340
                                }
3341
                            }
3342
                        }
3343
                        break;
3344
                    case ControlType.TextBorder:
3345
                        {
3346
                            if (e.LeftButton == MouseButtonState.Pressed)
3347
                            {
3348
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3349
                                {
3350
                                    currentControl = new TextControl
3351
                                    {
3352
                                        ControlType = controlType
3353
                                    };
3354

    
3355
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3356
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3357
                                    currentControl.CommentID = Commons.shortGuid();
3358
                                    currentControl.IsNew = true;
3359
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3360
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3361
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3362
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3363
                                    
3364
                                    (currentControl as TextControl).ControlType_No = 1;
3365
                                    (currentControl as TextControl).Angle = Ang;
3366
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3367
                                    (currentControl as TextControl).ApplyTemplate();
3368
                                    (currentControl as TextControl).Base_TextBox.Focus();
3369
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3370
                                    CreateCommand.Instance.Execute(currentControl);
3371
                                }
3372
                            }
3373
                        }
3374
                        break;
3375
                    case ControlType.TextCloud:
3376
                        {
3377
                            if (e.LeftButton == MouseButtonState.Pressed)
3378
                            {
3379
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3380
                                {
3381
                                    currentControl = new TextControl
3382
                                    {
3383
                                        ControlType = controlType
3384
                                    };
3385

    
3386
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3387
                                    currentControl.CommentID = Commons.shortGuid();
3388
                                    currentControl.IsNew = true;
3389
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3390
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3391

    
3392
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3393
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3394
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3395

    
3396
                                    (currentControl as TextControl).Angle = Ang;
3397
                                    (currentControl as TextControl).ControlType_No = 2;
3398
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3399
                                    (currentControl as TextControl).ApplyTemplate();
3400
                                    (currentControl as TextControl).Base_TextBox.Focus();
3401
                                    CreateCommand.Instance.Execute(currentControl);
3402
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3403
                                    //currentControl = null;
3404
                                }
3405
                            }
3406
                        }
3407
                        break;
3408
                    case ControlType.ArrowTextControl:
3409
                         {
3410
                            if (e.LeftButton == MouseButtonState.Pressed)
3411
                            {
3412
                                if (currentControl is ArrowTextControl)
3413
                                {
3414
                                    //20180906 LJY TEST IsRotationDrawingEnable
3415
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3416
                                    {
3417
                                        return;
3418
                                    }
3419

    
3420
                                    CreateCommand.Instance.Execute(currentControl);
3421

    
3422
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3423
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3424
                                    (currentControl as ArrowTextControl).IsNew = false;
3425
                                    currentControl = null;
3426
                                }
3427
                                else
3428
                                {
3429
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3430
                                    //{
3431
                                        currentControl = new ArrowTextControl();
3432
                                        currentControl.CommentID = Commons.shortGuid();
3433
                                        currentControl.IsNew = true;
3434
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3435
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3436

    
3437
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3438
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3439
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3440
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3441
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3442

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

    
3446
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3447
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3448
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3449
                                        this.MainAngle.Visibility = Visibility.Visible;
3450

    
3451
                                    
3452
                                    //}
3453
                                }
3454
                            }
3455
                        }
3456
                        break;
3457
                    case ControlType.ArrowTransTextControl:
3458
                        {
3459
                            if (e.LeftButton == MouseButtonState.Pressed)
3460
                            {
3461
                                if (currentControl is ArrowTextControl)
3462
                                {
3463
                                    //20180906 LJY TEST IsRotationDrawingEnable
3464
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3465
                                    {
3466
                                        return;
3467
                                    }
3468

    
3469
                                    CreateCommand.Instance.Execute(currentControl);
3470

    
3471
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3472
                                    
3473
                                    currentControl.IsNew = false;
3474
                                    currentControl = null;
3475
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3476
                                }
3477
                                else
3478
                                {
3479
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3480
                                    //{
3481
                                    currentControl = new ArrowTextControl()
3482
                                    {
3483
                                        ControlType = ControlType.ArrowTransTextControl
3484
                                    };
3485
                                    currentControl.CommentID = Commons.shortGuid();
3486
                                    currentControl.IsNew = true;
3487
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3488
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3489
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3490
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3491
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3492
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3493
                                    (currentControl as ArrowTextControl).isFixed = true;
3494
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3495

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

    
3499
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3500
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3501
                                    (currentControl as ArrowTextControl).isTrans = true;
3502
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3503
                                }
3504
                            }
3505
                        }
3506
                        break;
3507
                    case ControlType.ArrowTextBorderControl:
3508
                         {
3509
                            if (e.LeftButton == MouseButtonState.Pressed)
3510
                            {
3511
                                if (currentControl is ArrowTextControl)
3512
                                {
3513
                                    //20180906 LJY TEST IsRotationDrawingEnable
3514
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3515
                                    {
3516
                                        return;
3517
                                    }
3518

    
3519
                                    CreateCommand.Instance.Execute(currentControl);
3520
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3521
                                    currentControl.IsNew = false;
3522
                                    currentControl = null;
3523
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3524
                                }
3525
                                else
3526
                                {
3527
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3528
                                    //{
3529
                                        currentControl = new ArrowTextControl()
3530
                                        {
3531
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3532
                                        };
3533
                                        currentControl.CommentID = Commons.shortGuid();
3534
                                        currentControl.IsNew = true;
3535
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3536
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3537

    
3538
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3539

    
3540
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3541

    
3542
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3543
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3544
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3545
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3546
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3547
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3548
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3549
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3550
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3551
                                    //}
3552
                                }
3553
                            }
3554
                        }
3555
                        break;
3556
                    case ControlType.ArrowTransTextBorderControl:
3557
                        {
3558
                            if (e.LeftButton == MouseButtonState.Pressed)
3559
                            {
3560
                                if (currentControl is ArrowTextControl)
3561
                                {
3562
                                    //20180906 LJY TEST IsRotationDrawingEnable
3563
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3564
                                    {
3565
                                        return;
3566
                                    }
3567
                                    CreateCommand.Instance.Execute(currentControl);
3568
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3569
                                    currentControl.IsNew = false;
3570
                                    currentControl = null;
3571

    
3572
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3573
                                }
3574
                                else
3575
                                {
3576
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3577
                                    //{
3578
                                    
3579

    
3580
                                    currentControl = new ArrowTextControl()
3581
                                    {
3582
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3583
                                        ControlType = ControlType.ArrowTransTextBorderControl
3584

    
3585
                                    };
3586
                                        currentControl.CommentID = Commons.shortGuid();
3587
                                        currentControl.IsNew = true;
3588
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3589
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3590

    
3591
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3592

    
3593
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3594
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3595
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3596
                                        (currentControl as ArrowTextControl).isFixed = true;
3597
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3598
                                     
3599
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3600
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3601
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3602
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3603
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3604
                                        this.MainAngle.Visibility = Visibility.Visible;
3605
                                    
3606
                                    //20180911 LJY
3607
                                        (currentControl as ArrowTextControl).isTrans = true;
3608
                                    
3609

    
3610
                                    //}
3611
                                }
3612
                            }
3613
                        }
3614
                        break;
3615
                    case ControlType.ArrowTextCloudControl:
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
                                    CreateCommand.Instance.Execute(currentControl);
3627
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3628
                                    currentControl.IsNew = false;
3629
                                    currentControl = null;
3630
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3631
                                }
3632
                                else
3633
                                {
3634
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3635
                                    //{
3636
                                        currentControl = new ArrowTextControl()
3637
                                        {
3638
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3639
                                        };
3640
                                        currentControl.CommentID = Commons.shortGuid();
3641
                                        currentControl.IsNew = true;
3642
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3643
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3644

    
3645
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3646
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3647
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3648
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3649
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3650
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3651
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3652
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3653
                                    
3654
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3655
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3656
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3657
                                    //}
3658
                                }
3659
                            }
3660
                        }
3661
                        break;
3662
                    case ControlType.ArrowTransTextCloudControl:
3663
                        {
3664
                            if (e.LeftButton == MouseButtonState.Pressed)
3665
                            {
3666
                                if (currentControl is ArrowTextControl)
3667
                                {
3668
                                    //20180906 LJY TEST IsRotationDrawingEnable
3669
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3670
                                    {
3671
                                        return;
3672
                                    }
3673
                                    CreateCommand.Instance.Execute(currentControl);
3674
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3675
                                    currentControl.IsNew = false;
3676
                                    currentControl = null;
3677
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3678
                                }
3679
                                else
3680
                                {
3681
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3682
                                    //{
3683
                                        currentControl = new ArrowTextControl()
3684
                                        {
3685
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3686
                                            ControlType = ControlType.ArrowTransTextCloudControl
3687

    
3688
                                        };
3689
                                        currentControl.CommentID = Commons.shortGuid();
3690
                                        currentControl.IsNew = true; 
3691
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3692
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3693
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3694

    
3695
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3696
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3697
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3698
                                        (currentControl as ArrowTextControl).isFixed = true;
3699
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3700

    
3701
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3702
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3703
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3704
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3705
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3706
                                        this.MainAngle.Visibility = Visibility.Visible;  
3707
                                    
3708
                                    //20180911 LJY
3709
                                        (currentControl as ArrowTextControl).isTrans = true;
3710
                                    //}
3711
                                }
3712
                            }
3713
                        }
3714
                        break;
3715
                    //강인구 추가
3716
                    case ControlType.Sign:
3717
                        {
3718
                            if (e.LeftButton == MouseButtonState.Pressed)
3719
                            {
3720
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3721
                                //{
3722
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3723

    
3724
                                    if (_sign == null)
3725
                                    {
3726
                                        txtBatch.Visibility = Visibility.Collapsed;
3727
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3728
                                        controlType = ControlType.None;
3729

    
3730
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3731
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3732
                                        return;
3733
                                    }
3734

    
3735
                                    if (currentControl is SignControl)
3736
                                    {
3737
                                        //20180906 LJY TEST IsRotationDrawingEnable
3738
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3739
                                        {
3740
                                            return;
3741
                                        }
3742

    
3743
                                        CreateCommand.Instance.Execute(currentControl);
3744
                                        currentControl = null;
3745
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3746
                                        {
3747
                                            txtBatch.Text = "Place Date";
3748
                                            controlType = ControlType.Date;
3749
                                        }
3750
                                    }
3751
                                    else
3752
                                    {
3753
                                        currentControl = new SignControl
3754
                                        {
3755
                                            Background = new SolidColorBrush(Colors.Black),
3756
                                            UserNumber = App.ViewInfo.UserID,
3757
                                            ProjectNO = App.ViewInfo.ProjectNO,
3758
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3759
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3760
                                            ControlType = ControlType.Sign
3761
                                        };
3762

    
3763
                                        currentControl.CommentID = Commons.shortGuid();
3764
                                        currentControl.IsNew = true;
3765
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3766
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3767

    
3768
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3769
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3770
                                }
3771
                                //}
3772
                            }
3773
                        }
3774
                        break;
3775
                    case ControlType.Mark:
3776
                        {
3777
                            if (e.LeftButton == MouseButtonState.Pressed)
3778
                            {
3779
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3780
                                //{
3781
                                    if (currentControl is RectangleControl)
3782
                                    {
3783
                                        //20180906 LJY TEST IsRotationDrawingEnable
3784
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3785
                                        {
3786
                                            return;
3787
                                        }
3788

    
3789
                                        CreateCommand.Instance.Execute(currentControl);
3790
                                        (currentControl as RectangleControl).ApplyOverViewData();
3791
                                        currentControl = null;
3792
                                    
3793
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3794

    
3795
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3796
                                        {
3797
                                            txtBatch.Text = "Place Signature";
3798
                                            controlType = ControlType.Sign;
3799
                                        }
3800
                                    }
3801
                                    else
3802
                                    {
3803
                                        currentControl = new RectangleControl
3804
                                        {
3805
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3806
                                            Background = new SolidColorBrush(Colors.Black),
3807
                                            ControlType = ControlType.Mark ,
3808
                                            Paint = PaintSet.Fill
3809
                                        };
3810

    
3811
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3812
                                        currentControl.CommentID = Commons.shortGuid();
3813
                                        currentControl.IsNew = true;
3814
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3815
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3816
                                    }
3817
                                //}
3818
                            }
3819
                        }
3820
                        break;
3821
                    case ControlType.Symbol:
3822
                        {
3823
                            if (e.LeftButton == MouseButtonState.Pressed)
3824
                            {
3825
                                if (currentControl is SymControl)
3826
                                {
3827
                                    //20180906 LJY TEST IsRotationDrawingEnable
3828
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3829
                                    {
3830
                                        return;
3831
                                    }
3832
                                    CreateCommand.Instance.Execute(currentControl);
3833
                                    currentControl = null;
3834
                                
3835
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3836
                                }
3837
                                else
3838
                                {
3839
                                    currentControl = new SymControl
3840
                                    {
3841
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3842
                                        Background = new SolidColorBrush(Colors.Black),
3843
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3844
                                        ControlType = ControlType.Symbol
3845
                                    };
3846

    
3847
                                    currentControl.IsNew = true;
3848
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3849
                                    currentControl.CommentID = Commons.shortGuid();
3850
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3851

    
3852
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3853
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3854
                                }
3855
                                //}
3856
                            }
3857
                        }
3858
                        break;
3859
                    case ControlType.Stamp:
3860
                        {
3861
                            if (e.LeftButton == MouseButtonState.Pressed)
3862
                            {
3863
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3864
                                //{
3865
                                    if (currentControl is SymControlN)
3866
                                    {
3867
                                        //20180906 LJY TEST IsRotationDrawingEnable
3868
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3869
                                        {
3870
                                            return;
3871
                                        }
3872

    
3873
                                        CreateCommand.Instance.Execute(currentControl);
3874
                                        currentControl = null;
3875
                                   
3876

    
3877
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3878
                                    }
3879
                                    else
3880
                                    {
3881
                                        currentControl = new SymControlN
3882
                                        {
3883
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3884
                                            Background = new SolidColorBrush(Colors.Black),
3885
                                            STAMP = App.SystemInfo.STAMP,                                            
3886
                                            ControlType = ControlType.Stamp
3887
                                        };
3888

    
3889
                                        currentControl.IsNew = true;
3890
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3891
                                        currentControl.CommentID = Commons.shortGuid();
3892
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3893
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3894
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3895
                                }                                    
3896
                                //}
3897
                            }
3898
                        }
3899
                        break;
3900
                    case ControlType.PenControl:
3901
                        {
3902
                            if (inkBoard.Tag.ToString() == "Ink")
3903
                            {
3904
                                inkBoard.IsEnabled = true;
3905
                                StartNewStroke(canvasDrawingMouseDownPoint);
3906
                            }
3907
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3908
                            {
3909
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3910
                            }
3911
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3912
                            {
3913
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3914
                            }
3915
                            IsDrawing = true;
3916
                            return;
3917
                        }
3918
                    default:
3919
                        if (currentControl != null)
3920
                        {
3921
                            currentControl.CommentID = null;
3922
                            currentControl.IsNew = false;
3923
                        }
3924
                        break;
3925
                }
3926
            }
3927
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3928
            {
3929
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3930
                {
3931
                    bool mouseOff = false;
3932
                    foreach (var item in SelectLayer.Children)
3933
                    {
3934
                        if (item is AdornerFinal)
3935
                        {
3936

    
3937
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3938
                            if (over != null)
3939
                            {
3940
                                mouseOff = true;
3941
                            }
3942
                        }
3943
                    }
3944

    
3945
                    if (!mouseOff)
3946
                    {
3947
                        SelectionSet.Instance.UnSelect(this);
3948
                    }
3949
                }
3950
                zoomAndPanControl.CaptureMouse();
3951
                e.Handled = true;
3952
            }
3953
          
3954
        }
3955

    
3956
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3957
        {
3958
            ///mouseButtonDown = e.ChangedButton;
3959
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3960
        }
3961

    
3962
        private void RemoveLineStroke(Point P)
3963
        {
3964
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3965
            if (control != null)
3966
            {
3967
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3968
            }
3969
        }
3970

    
3971
        private void RemovePointStroke(Point P)
3972
        {
3973
            foreach (Stroke hits in inkBoard.Strokes)
3974
            {
3975
                foreach (StylusPoint sty in hits.StylusPoints)
3976
                {
3977

    
3978
                }
3979
                if (hits.HitTest(P))
3980
                {
3981
                    inkBoard.Strokes.Remove(hits);
3982
                    return;
3983
                }
3984
            }
3985
        }
3986

    
3987
        private void StartNewStroke(Point P)
3988
        {
3989
            strokePoints = new StylusPointCollection();
3990
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3991
            strokePoints.Add(segment1Start);
3992
            stroke = new Stroke(strokePoints);
3993

    
3994
            stroke.DrawingAttributes.Color = Colors.Red;
3995
            stroke.DrawingAttributes.Width = 4;
3996
            stroke.DrawingAttributes.Height = 4;
3997

    
3998
            inkBoard.Strokes.Add(stroke);
3999
        }
4000

    
4001
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4002
        {
4003
            ConsolidationMethod();
4004
        }
4005

    
4006
        /// <summary>
4007
        /// execute TeamConsolidationCommand
4008
        /// </summary>
4009
        public void TeamConsolidationMethod()
4010
        {
4011
            this.UpdateMyMarkupList();
4012
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4013
            {
4014
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4015
            }
4016
            else
4017
            {
4018

    
4019
                ViewerDataModel.Instance.IsConsolidate = true;
4020
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4021

    
4022
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4023
                {
4024
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4025
                    {
4026
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4027
                        return;
4028
                    }                    
4029
                }
4030
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4031
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4032
                {
4033
                    MarkupInfoList.Add(item);
4034
                }
4035
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4036
            }
4037
        }
4038

    
4039
        public void ConsolidationMethod()
4040
        {
4041
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4042
            {
4043
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4044
            }
4045
            else
4046
            {
4047
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4048
                foreach (var item in this.gridViewMarkup.SelectedItems)
4049
                {
4050
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4051
                }
4052
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4053
                
4054
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4055
            }
4056
        }
4057

    
4058
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4059
        {
4060
            if (App.ViewInfo != null)
4061
            {
4062
                btnConsolidate = (sender as RadRibbonButton);
4063
                if (!App.ViewInfo.NewCommentPermission)
4064
                {
4065
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4066
                }
4067
            }
4068
        }
4069

    
4070
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4071
        {
4072
            TeamConsolidationMethod();
4073
        }
4074

    
4075
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4076
        {
4077
            btnTeamConsolidate = sender as RadRibbonButton;
4078
            if (App.ViewInfo != null)
4079
            {
4080
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4081
                {
4082
                    if (btnConsolidate != null)
4083
                    {
4084
                        btnConsolidate.Visibility = Visibility.Collapsed;
4085
                    }
4086

    
4087
                    if (!App.ViewInfo.NewCommentPermission)
4088
                    {
4089
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4090
                    }
4091
                }
4092
                else
4093
                {
4094
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4095
                }
4096
            }
4097
        }
4098

    
4099
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4100
        {
4101
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4102
            if(item != null)
4103
            {
4104
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4105
                {
4106
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4107
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4108
                }
4109
                else
4110
                {
4111
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4112
                }
4113
            }else{
4114
                //Consolidate 가 없는 경우
4115
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4116
            }
4117
            
4118
        }
4119

    
4120
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4121
        {
4122
            btnFinalPDF = sender as RadRibbonButton;
4123
            if (App.ViewInfo != null)
4124
            {
4125
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4126
                {
4127
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4128
                    if (btnConsolidate != null)
4129
                    {
4130
                        btnConsolidate.Visibility = Visibility.Collapsed;
4131
                    }
4132
                }
4133
            }
4134
        }
4135

    
4136
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4137
        {
4138
            UpdateMyMarkupList();
4139

    
4140
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4141
            {
4142
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4143
            }
4144
            else
4145
            {
4146
                ViewerDataModel.Instance.IsConsolidate = true;
4147
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4148
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4149

    
4150
                string project_no = App.ViewInfo.ProjectNO;
4151
                string doc_id = _DocInfo.ID;
4152
                string user_id = App.ViewInfo.UserID;
4153
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4154
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4155
                {
4156
                    markupInfoItems.Add(item);
4157
                }
4158
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4159
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4160
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4161
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4162

    
4163
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4164
                if (item2 != null)
4165
                {
4166
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4167

    
4168
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4169
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4170
                }
4171
                else
4172
                {
4173
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4174
                }
4175
            }
4176
        }
4177

    
4178
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4179
        {
4180
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4181

    
4182
            if (App.ViewInfo != null)
4183
            {
4184
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4185
                {
4186
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4187
                }
4188
            }
4189
        }
4190

    
4191
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4192
        {
4193
            SetCompareRect();
4194
        }
4195

    
4196
        private void Sync_Click(object sender, RoutedEventArgs e)
4197
        {
4198
            if (Sync.IsChecked)
4199
            {
4200
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4201
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4202
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4203
            }
4204
        }
4205

    
4206
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4207
        {
4208
            if (UserList.IsChecked)
4209
            {
4210
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4211
            }
4212
            else
4213
            {
4214
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4215
            }
4216
        }
4217

    
4218
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4219
        {
4220

    
4221
            if (BalanceMode.IsChecked)
4222
            {
4223
                ViewerDataModel.Instance.PageBalanceMode = true;
4224
            }
4225
            else
4226
            {
4227
                ViewerDataModel.Instance.PageBalanceMode = false;
4228
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4229
            }
4230
        }
4231

    
4232
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4233
        {
4234
            //초기화
4235
            testPanel2.IsHidden = true;
4236
            ViewerDataModel.Instance.PageBalanceMode = false;
4237
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4238
            ViewerDataModel.Instance.PageNumber = 0;
4239
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4240
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4241
            UserList.IsChecked = false;
4242
            BalanceMode.IsChecked = false;
4243
        }
4244

    
4245
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4246
        {
4247
            if ((sender as System.Windows.Controls.Control).Tag != null)
4248
            {
4249
                //Compare 초기화
4250
                CompareMode.IsChecked = false;
4251
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4252

    
4253
                if (ViewerDataModel.Instance.PageNumber == 0)
4254
                {
4255
                    ViewerDataModel.Instance.PageNumber = 1;
4256
                }
4257

    
4258
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4259
                {
4260
                }
4261
                else
4262
                {
4263
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4264
                }
4265

    
4266
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4267
                {
4268

    
4269
                }
4270
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4271
                {
4272
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4273
                }
4274

    
4275
                if (!testPanel2.IsHidden)
4276
                {
4277
                    if (IsSyncPDFMode)
4278
                    {
4279
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4280
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4281

    
4282
                        if (pdfpath.IsDownloading)
4283
                        {
4284
                            pdfpath.DownloadCompleted += (ex, arg) =>
4285
                            {
4286
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4287
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4288
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4289
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4290
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4291
                            };
4292
                        }
4293
                        else
4294
                        {
4295
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4296
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4297
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4298

    
4299
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4300
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4301
                        }
4302

    
4303
                    }
4304
                    else
4305
                    {
4306
                        string uri = this.GetImageURL(_ViewInfo.ProjectNO, ViewerDataModel.Instance.PageNumber);
4307

    
4308
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4309

    
4310
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4311
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4312
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4313

    
4314
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4315
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4316

    
4317
                        if (defaultBitmapImage_Compare.IsDownloading)
4318
                        {
4319
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4320
                            {
4321
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4322
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4323
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4324

    
4325
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4326
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4327
                            };
4328
                        }
4329
                    }
4330

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

    
4335
                    foreach (var item in gridSelectionRevItem)
4336
                    {
4337
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4338
                        {
4339
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4340
                        });
4341
                    }
4342

    
4343
                    //강인구 추가
4344
                    zoomAndPanControl2.ZoomTo(new Rect
4345
                    {
4346
                        X = 0,
4347
                        Y = 0,
4348
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4349
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4350
                    });
4351

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

    
4354
                }
4355
            }
4356
        }
4357

    
4358
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4359
        {
4360
            if (MarkupMode.IsChecked)
4361
            {
4362
                IsSyncPDFMode = true;
4363

    
4364
                var uri = CurrentRev.TO_VENDOR;
4365

    
4366
                if (ViewerDataModel.Instance.PageNumber == 0)
4367
                {
4368
                    ViewerDataModel.Instance.PageNumber = 1;
4369
                }
4370

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

    
4375
                if (pdfpath.IsDownloading)
4376
                {
4377
                    pdfpath.DownloadCompleted += (ex, arg) =>
4378
                    {
4379
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4380
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4381
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4382
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4383
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4384
                    };
4385
                }
4386
                else
4387
                {
4388
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4389
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4390
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4391

    
4392
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4393
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4394
                }
4395
            }
4396
            else
4397
            {
4398
                IsSyncPDFMode = false;
4399
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4400

    
4401
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4402

    
4403
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4404
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4405
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4406

    
4407
                if (defaultBitmapImage_Compare.IsDownloading)
4408
                {
4409
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4410
                    {
4411
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4412
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4413
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4414
                    };
4415
                }
4416
                zoomAndPanControl2.ApplyTemplate();
4417
                zoomAndPanControl2.UpdateLayout();
4418
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4419
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4420
            }
4421
        }
4422

    
4423
        /// <summary>
4424
        /// Compare된 영역을 초기화
4425
        /// </summary>
4426
        private void ClearCompareRect()
4427
        {
4428
            da.From = 1;
4429
            da.To = 1;
4430
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4431
            da.AutoReverse = false;
4432
            canvas_compareBorder.Children.Clear();
4433
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4434
        }
4435

    
4436
        /// <summary>
4437
        /// 문서 Comprare 
4438
        /// </summary>
4439
        private void SetCompareRect()
4440
        {
4441
            if (CompareMode.IsChecked)
4442
            {
4443
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4444
                {
4445
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4446
                }
4447
                if (ViewerDataModel.Instance.PageNumber == 0)
4448
                {
4449
                    ViewerDataModel.Instance.PageNumber = 1;
4450
                }
4451

    
4452
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4453
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4454
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4455

    
4456
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4457
            }
4458
            else
4459
            {
4460
                ClearCompareRect();
4461
            }
4462
        }
4463

    
4464
        private void RadButton_Click(object sender, RoutedEventArgs e)
4465
        {
4466
            gridViewHistory_Busy.IsBusy = true;
4467

    
4468
            RadButton instance = sender as RadButton;
4469
            if (instance.CommandParameter != null)
4470
            {
4471
                CurrentRev = instance.CommandParameter as VPRevision;
4472
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4473

    
4474
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4475
                {
4476
                    if (ea.Error == null && ea.Result != null)
4477
                    {
4478
                        testPanel2.IsHidden = false;
4479

    
4480
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4481
                        foreach(var info in ea.Result)
4482
                        {
4483
                            if(info.UserID == App.ViewInfo.UserID)
4484
                            {
4485
                                info.userDelete = true;
4486
                                info.DisplayColor = "FFFF0000";
4487
                            }
4488
                            else
4489
                            {
4490
                                info.userDelete = false;
4491
                            }
4492
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4493
                        }
4494
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4495

    
4496
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4497

    
4498
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4499

    
4500
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4501
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4502
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4503
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4504
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4505
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4506

    
4507
                        zoomAndPanControl2.ApplyTemplate();
4508
                        zoomAndPanControl2.UpdateLayout();
4509
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4510
                        {
4511
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4512
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4513
                        }
4514

    
4515
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4516
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4517
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4518

    
4519
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4520
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4521
                        gridViewHistory_Busy.IsBusy = false;
4522
                    }
4523

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

    
4526
                    if (GetSyncMarkupInfoItemshandler != null)
4527
                    {
4528
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4529
                    }
4530

    
4531
                    ClearCompareRect();
4532
                    SetCompareRect();
4533
                };
4534

    
4535
                /// 중복 실행이 발생하여 수정함.
4536
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4537
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4538

    
4539
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4540
            }
4541
        }
4542

    
4543
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4544
        {
4545
            try
4546
            {
4547
                if (sender is RadButton)
4548
                {
4549
                    if ((sender as RadButton).Tag != null)
4550
                    {
4551
                        var url = (sender as RadButton).Tag.ToString();
4552
                        System.Diagnostics.Process.Start(url);
4553
                    }
4554
                    else
4555
                    {
4556
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4557
                    }
4558
                }
4559
            }
4560
            catch (Exception ex)
4561
            {
4562
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4563
            }
4564
        }
4565

    
4566
        public void Sync_Event(VPRevision Currnet_Rev)
4567
        {
4568
            CurrentRev = Currnet_Rev;
4569

    
4570
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4571
            {
4572
                if (ea.Error == null && ea.Result != null)
4573
                {
4574
                    testPanel2.IsHidden = false;
4575

    
4576
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4577
                    foreach(var info in ea.Result)
4578
                    {
4579
                        if(info.UserID == App.ViewInfo.UserID)
4580
                        {
4581
                            info.userDelete = true;
4582
                            info.DisplayColor = "FFFF0000";
4583
                        }
4584
                        else
4585
                        {
4586
                            info.userDelete = false;
4587
                        }
4588
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4589
                    }
4590
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4591

    
4592
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4593

    
4594
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4595

    
4596
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4597

    
4598
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4599
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4600
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4601

    
4602
                    if (defaultBitmapImage_Compare.IsDownloading)
4603
                    {
4604
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4605
                        {
4606
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4607
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4608
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4609
                        };
4610
                    }
4611

    
4612

    
4613
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4614
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4615
                    zoomAndPanControl2.ApplyTemplate();
4616
                    zoomAndPanControl2.UpdateLayout();
4617

    
4618
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4619
                    {
4620
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4621
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4622
                    }
4623
                    //}
4624

    
4625
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4626
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4627
                    gridViewHistory_Busy.IsBusy = false;
4628
                }
4629
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4630

    
4631
            };
4632
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4633
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4634
        }
4635

    
4636
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4637
        {
4638
            if (sender is Image)
4639
            {
4640
                if ((sender as Image).Tag != null)
4641
                {
4642
                    var pdfUrl = (sender as Image).Tag.ToString();
4643
                    System.Diagnostics.Process.Start(pdfUrl);
4644
                }
4645
                else
4646
                {
4647
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4648
                }
4649
            }
4650
        }
4651

    
4652
        private void Create_Symbol(object sender, RoutedEventArgs e)
4653
        {
4654
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4655

    
4656
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4657
            {
4658
                DialogMessage_Alert("Please Select Controls", "Alert");
4659
            }
4660
            else //선택된 것이 있으면
4661
            {
4662
                string MarkupData = "";
4663
                adorner_ = new AdornerFinal();
4664

    
4665
                foreach (var item in SelectLayer.Children)
4666
                {
4667
                    if (item.GetType().Name == "AdornerFinal")
4668
                    {
4669
                        adorner_ = (item as Controls.AdornerFinal);
4670
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4671
                        {
4672
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4673
                            {
4674
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4675
                                MarkupData += markupReturn.ConvertData;
4676
                            }
4677
                        }
4678
                    }
4679
                }
4680
                DialogParameters parameters = new DialogParameters()
4681
                {
4682
                    Owner = Application.Current.MainWindow,
4683
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4684
                    DefaultPromptResultValue = "Custom State",
4685
                    Content = "Name :",
4686
                    Header = "Insert Custom Symbol Name",
4687
                    Theme = new VisualStudio2013Theme(),
4688
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4689
                };
4690
                RadWindow.Prompt(parameters);
4691
            }
4692

    
4693
        }
4694
        public int symbolselectindex = 0;
4695
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4696
        {
4697
            //Save save = new Save();
4698
            try
4699
            {
4700
                string svgfilename = null;
4701
                if (symbolname != null)
4702
                {
4703
                    if (symbolpng == true || symbolsvg == true)
4704
                    {
4705
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4706
                        string guid = Commons.shortGuid();
4707

    
4708
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4709
                        //Check_Uri.UriCheck();
4710
                        fileUploader.RunCompleted += (ex, arg) =>
4711
                        {
4712
                            filename = arg.Result;
4713
                            if (symbolpng == true)
4714
                            {
4715
                                if (filename != null)
4716
                                { 
4717
                                    if (symbolselectindex == 0)
4718
                                    {
4719
                                        SymbolSave(symbolname, filename, data);
4720
                                    }
4721
                                    else
4722
                                    {
4723
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4724
                                    }
4725
                                    DataBind();
4726
                                }                                
4727
                            }
4728

    
4729
                            if (symbolsvg == true)
4730
                            {
4731
                                try
4732
                                {
4733
                                    var defaultBitmapImage = new BitmapImage();
4734
                                    defaultBitmapImage.BeginInit();
4735
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4736
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4737
                                    Check_Uri.UriCheck(filename);
4738
                                    defaultBitmapImage.UriSource = new Uri(filename);
4739
                                    defaultBitmapImage.EndInit();
4740

    
4741
                                    System.Drawing.Bitmap image;
4742

    
4743
                                    if (defaultBitmapImage.IsDownloading)
4744
                                    {
4745
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4746
                                        {
4747
                                            defaultBitmapImage.Freeze();
4748
                                            image = GetBitmap(defaultBitmapImage);
4749
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4750
                                            Process potrace = new Process
4751
                                            {
4752
                                                StartInfo = new ProcessStartInfo
4753
                                                {
4754
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4755
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4756
                                                    RedirectStandardInput = true,
4757
                                                    RedirectStandardOutput = true,
4758
                                                    RedirectStandardError = true,
4759
                                                    UseShellExecute = false,
4760
                                                    CreateNoWindow = true,
4761
                                                    WindowStyle = ProcessWindowStyle.Hidden
4762
                                                },
4763
                                            };
4764

    
4765
                                            StringBuilder svgBuilder = new StringBuilder();
4766
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4767
                                            {
4768
                                                svgBuilder.AppendLine(e2.Data);
4769
                                            };
4770

    
4771
                                            potrace.EnableRaisingEvents = true;
4772
                                            potrace.Start();
4773
                                            potrace.Exited += (sender, e) =>
4774
                                            {
4775
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4776
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4777
                                                Check_Uri.UriCheck(svgfilename);
4778
                                                if (symbolselectindex == 0)
4779
                                                {
4780
                                                    SymbolSave(symbolname, svgfilename, data);
4781
                                                }
4782
                                                else
4783
                                                {
4784
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4785
                                                }
4786

    
4787
                                                DataBind();
4788
                                            };
4789
                                            potrace.WaitForExit();
4790
                                        };
4791
                                    }
4792
                                    else
4793
                                    {
4794
                                        //GC.Collect();
4795
                                    }
4796
                                }
4797
                                catch(Exception ee)
4798
                                {
4799
                                    DialogMessage_Alert("" + ee, "Alert");
4800
                                }
4801
                            }
4802
                        };                                             
4803
                    }
4804
                }
4805
            }
4806
            catch (Exception e)
4807
            {
4808
                //DialogMessage_Alert(e + "", "Alert");
4809
            }            
4810
        }
4811

    
4812
        public void SymbolSave(string Name, string Url, string Data)
4813
        {
4814
            try
4815
            {
4816
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4817
                {
4818
                    ID = Commons.shortGuid(),
4819
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4820
                    NAME = Name,
4821
                    IMAGE_URL = Url,
4822
                    DATA = Data
4823
                };
4824

    
4825
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4826
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4827
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4828
            }
4829
            catch (Exception)
4830
            {
4831
                throw;
4832
            }
4833
        }
4834

    
4835
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4836
        {
4837
            try
4838
            {
4839
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4840
                {
4841
                    ID = Commons.shortGuid(),
4842
                    DEPARTMENT = Department,
4843
                    NAME = Name,
4844
                    IMAGE_URL = Url,
4845
                    DATA = Data
4846
                };
4847
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4848
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4849
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4850
            }
4851
            catch (Exception)
4852
            {
4853
                throw;
4854
            }
4855
        }
4856

    
4857
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4858
        {           
4859
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4860
            DataBind();
4861
        }
4862

    
4863
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4864
        {
4865
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4866
            DataBind();
4867
        }
4868
        private void DataBind()
4869
        {
4870
            try
4871
            {
4872
                Symbol_Custom Custom = new Symbol_Custom();
4873
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4874
                
4875
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4876
                foreach (var item in symbol_Private)
4877
                {
4878
                    Custom.Name = item.NAME;
4879
                    Custom.ImageUri = item.IMAGE_URL;
4880
                    Custom.ID = item.ID;
4881
                    Custom_List.Add(Custom);
4882
                    Custom = new Symbol_Custom();
4883
                }
4884
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4885
                
4886
                Custom = new Symbol_Custom();
4887
                Custom_List = new List<Symbol_Custom>();
4888

    
4889
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4890

    
4891
                List<SYMBOL_PUBLIC> symbol_Public;
4892

    
4893
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4894
                {
4895
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4896
                }
4897
                else
4898
                {
4899
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4900
                }
4901
                foreach (var item in symbol_Public)
4902
                {
4903
                    Custom.Name = item.NAME;
4904
                    Custom.ImageUri = item.IMAGE_URL;
4905
                    Custom.ID = item.ID;
4906
                    Custom_List.Add(Custom);
4907
                    Custom = new Symbol_Custom();
4908
                }
4909
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4910
                BaseClient.Close();                
4911
            }
4912
            catch(Exception e)
4913
            {
4914
                //DialogMessage_Alert("DataBind", "Alert");
4915
            }
4916
            
4917
        }
4918
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4919
        {
4920
            try
4921
            {
4922
                if (args.PromptResult != null)
4923
                {
4924
                    if (args.DialogResult.Value)
4925
                    {
4926
                        PngBitmapEncoder _Encoder = symImage(data);
4927

    
4928
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4929
                        _Encoder.Save(fs);
4930
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4931

    
4932
                        byte[] Img_byte = fs.ToArray();
4933

    
4934
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4935
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4936
                        Check_Uri.UriCheck(filename);
4937
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4938
                        {
4939
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4940
                        }
4941
                        else
4942
                        {
4943
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4944
                        }
4945
                        DataBind();
4946
                    }
4947
                }
4948
            }
4949
            catch(Exception ex)
4950
            {
4951
                DialogMessage_Alert("" + ex, "Alert");
4952
            }
4953
        }
4954

    
4955
        public PngBitmapEncoder symImage(string data)
4956
        {
4957

    
4958
            Canvas _canvas = new Canvas();
4959
            _canvas.Background = Brushes.White;
4960
            _canvas.Width = adorner_.BorderSize.Width;
4961
            _canvas.Height = adorner_.BorderSize.Height;
4962
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4963

    
4964
            BitmapEncoder encoder = new PngBitmapEncoder();
4965

    
4966

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

    
4969
            DrawingVisual dv = new DrawingVisual();
4970

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

    
4974
            using (DrawingContext ctx = dv.RenderOpen())
4975
            {
4976
                VisualBrush vb = new VisualBrush(_canvas);
4977
                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)));
4978
            }
4979

    
4980
            try
4981
            {
4982
                renderBitmap.Render(dv);
4983

    
4984
                //GC.Collect();
4985
                GC.WaitForPendingFinalizers();
4986
                //GC.Collect();
4987
                // encode png data
4988
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4989
                // puch rendered bitmap into it
4990
                pngEncoder.Interlace = PngInterlaceOption.Off;
4991
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4992
                return pngEncoder;
4993

    
4994
            }
4995
            catch //(Exception ex)
4996
            {
4997
                return null;
4998
            }
4999

    
5000
        }
5001

    
5002
        public void DialogMessage_Alert(string content, string header)
5003
        {
5004
            DialogParameters parameters = new DialogParameters()
5005
            {
5006
                Owner = this.ParentOfType<MainWindow>(),
5007
                Content = new TextBlock()
5008
                { 
5009
                    MinWidth = 400,
5010
                    FontSize = 11,
5011
                    Text = content,
5012
                    TextWrapping = System.Windows.TextWrapping.Wrap
5013
                },
5014
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5015
                Header = header,
5016
                Theme = new VisualStudio2013Theme(),
5017
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5018
            };            
5019
            RadWindow.Alert(parameters);
5020
        }
5021

    
5022
        #region 캡쳐 기능
5023

    
5024
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5025
        {
5026
            if (x < 0)
5027
            {
5028
                width += x;
5029
                x = 0;
5030
            }
5031
            if (y < 0)
5032
            {
5033
                height += y;
5034
                y = 0;
5035

    
5036
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5037
            }
5038
            if (x + width > zoomAndPanCanvas.ActualWidth)
5039
            {
5040
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5041
            }
5042
            if (y + height > zoomAndPanCanvas.ActualHeight)
5043
            {
5044
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5045
            }
5046

    
5047
            byte[] pixels = CopyPixels(x, y, width, height);
5048

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

    
5051
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5052
        }
5053

    
5054
        public byte[] CopyPixels(int x, int y, int width, int height)
5055
        {
5056
            byte[] pixels = new byte[width * height * 4];
5057
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5058

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

    
5062
            return pixels;
5063
        }
5064

    
5065
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5066
        {
5067
            DrawingVisual drawingVisual = new DrawingVisual();
5068
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5069

    
5070
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5071
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5072
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5073
            drawingContext.Close();
5074

    
5075
            // 비트맵으로 변환합니다.
5076
            RenderTargetBitmap target =
5077
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5078
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5079

    
5080
            target.Render(drawingVisual);
5081
            return target;
5082
        }
5083

    
5084
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5085
        {
5086
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5087
            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);
5088
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5089
            bmp.UnlockBits(data);
5090
            return bmp;
5091
        }
5092
        public string symbolname = null;
5093
        public bool symbolsvg = true;
5094
        public bool symbolpng = true;
5095

    
5096
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5097
        {
5098
            System.Drawing.Bitmap image = GetBitmap(source);
5099
            //흰색 제거
5100
            //image.MakeTransparent(System.Drawing.Color.White);
5101

    
5102
            var imageStream = new System.IO.MemoryStream();
5103
            byte[] imageBytes = null;
5104
            using (imageStream)
5105
            {
5106
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5107
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5108
                imageStream.Position = 0;
5109
                imageBytes = imageStream.ToArray();
5110
            }
5111

    
5112
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5113

    
5114
            RadWindow CheckPop = new RadWindow();
5115
            //Alert check = new Alert(Msg);
5116

    
5117
            CheckPop = new RadWindow
5118
            {
5119
                MinWidth = 400,
5120
                MinHeight = 100,
5121
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5122
                Header = "Alert",
5123
                Content = symbolPrompt,
5124
                //DialogResult = 
5125
                ResizeMode = System.Windows.ResizeMode.NoResize,
5126
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5127
                IsTopmost = true,
5128
            };
5129
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5130
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5131
            CheckPop.ShowDialog();
5132

    
5133
            /*
5134
            DialogParameters parameters = new DialogParameters()
5135
            {
5136
                Owner = Application.Current.MainWindow,
5137
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5138
                DefaultPromptResultValue = "Custom State",
5139
                Content = "Name :",
5140
                Header = "Insert Custom Symbol Name",
5141
                Theme = new VisualStudio2013Theme(),
5142
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5143
            };            
5144
            RadWindow.Prompt(parameters);
5145
            */
5146
        }
5147

    
5148
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5149
        {
5150
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5151
            KCOMDataModel.DataModel.CHECK_LIST check_;
5152
            string Result = streamToBase64.ImageToBase64(source);
5153
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5154
            string projectno = App.ViewInfo.ProjectNO;
5155
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5156

    
5157
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5158
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5159
            if (Item != null)
5160
            {
5161
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5162
            }
5163
            else
5164
            {
5165
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5166
            }
5167

    
5168
            if (Item == null)
5169
            {
5170
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5171
                {
5172
                    ID = Commons.shortGuid(),
5173
                    USER_ID = App.ViewInfo.UserID,
5174
                    IMAGE_URL = Result,
5175
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5176
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5177
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5178
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5179
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5180
                    STATUS = "False",
5181
                    CREATE_TIME = DateTime.Now,
5182
                    UPDATE_TIME = DateTime.Now,
5183
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5184
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5185
                };
5186
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5187
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5188
                //this.BaseClient.AddCheckList(projectno, check_);
5189
            }
5190
            else
5191
            {
5192
                Item.IMAGE_URL = Result;
5193
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5194
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5195
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5196
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5197
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5198
            }
5199

    
5200
        }
5201

    
5202
        public void Set_Capture()
5203
        {
5204
            double x = canvasDrawingMouseDownPoint.X;
5205
            double y = canvasDrawingMouseDownPoint.Y;
5206
            double width = dragCaptureBorder.Width;
5207
            double height = dragCaptureBorder.Height;
5208

    
5209
            if (width > 5 || height > 5)
5210
            {
5211
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5212
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5213
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5214
            }
5215
        }
5216
        #endregion
5217

    
5218
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5219
        {
5220
            multi_Undo_Data = new Multi_Undo_data();
5221

    
5222
            multi_Undo_Data.Markup = control;
5223

    
5224
            if ((control as IShapeControl) != null)
5225
            {
5226
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5227
            }
5228
            if ((control as IDashControl) != null)
5229
            {
5230
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5231
            }
5232
            if ((control as IPath) != null)
5233
            {
5234
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5235
            }
5236
            if ((control as UIElement) != null)
5237
            {
5238
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5239
            }
5240

    
5241
            return multi_Undo_Data;
5242
        }
5243

    
5244
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5245
        {
5246
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5247
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5248
            {
5249
                if (items.UserID == Select_ID)
5250
                {
5251
                    foreach (var item in items.MarkupList)
5252
                    {
5253
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5254
                        {
5255
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5256
                                items.MarkupInfoID, Commons.shortGuid());
5257
                        }
5258
                    }
5259
                }
5260
            }
5261
        }
5262

    
5263
        /// <summary>
5264
        /// convert inkcontrol to polygoncontrol
5265
        /// </summary>
5266
        public void ConvertInkControlToPolygon()
5267
        {
5268
            if (inkBoard.Strokes.Count > 0)
5269
            {
5270
                inkBoard.Strokes.ToList().ForEach(stroke =>
5271
                {
5272
                    InkToPath ip = new InkToPath();
5273

    
5274
                    List<Point> inkPointSet = new List<Point>();
5275
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5276

    
5277
                    PolygonControl pc = new PolygonControl()
5278
                    {
5279
                        Angle = 0,
5280
                        PointSet = inkPointSet,
5281
                        ControlType = ControlType.Ink
5282
                    };
5283
                    pc.StartPoint = inkPointSet[0];
5284
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5285
                    pc.LineSize = 3;
5286
                    pc.CommentID = Commons.shortGuid();
5287
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5288

    
5289
                    if (pc.PointSet.Count > 0)
5290
                    {
5291
                        CreateCommand.Instance.Execute(pc);
5292
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5293
                    }
5294
                });
5295
                inkBoard.Strokes.Clear();
5296
            }
5297
        }
5298

    
5299
        /// <summary>
5300
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5301
        /// </summary>
5302
        /// <author>ingu</author>
5303
        /// <date>2018.06.05</date>
5304
        /// <param name="getPoint"></param>
5305
        /// <returns></returns>
5306
        private bool IsGetoutpoint(Point getPoint)
5307
        {
5308
            if (getPoint == new Point())
5309
            {
5310
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5311
                currentControl = null;
5312
                return true;
5313
            }
5314

    
5315
            return false;
5316
        }
5317

    
5318
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5319
        {
5320
            e.Effects = DragDropEffects.Copy;
5321
        }
5322

    
5323
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5324
        {
5325
            e.Effects = DragDropEffects.Copy;
5326
        }
5327

    
5328
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5329
        {
5330
            e.Effects = DragDropEffects.None;
5331
        }
5332

    
5333
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5334
        {
5335
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5336
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5337

    
5338
            ScaleImage(pageWidth, pageHeight);
5339
        }
5340

    
5341
        /// <summary>
5342
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5343
        /// </summary>
5344
        /// <param name="pageWidth">원본 사이즈</param>
5345
        /// <param name="pageHeight">원본 사이즈</param>
5346
        /// <returns></returns>
5347
        private void ScaleImage(double pageWidth,double pageHeight)
5348
        {
5349
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5350
        }
5351

    
5352
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5353
        {
5354
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5355
        }
5356

    
5357

    
5358
        /*
5359
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5360
        {
5361
            try
5362
            {
5363
                if (e.Data.GetDataPresent(typeof(string)))
5364
                {
5365
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5366
                    string dragData = e.Data.GetData(typeof(string)) as string;
5367
                    Move_Symbol(sender, dragData);
5368
                }
5369
            }
5370
            catch (Exception ex)
5371
            {
5372
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5373
            }            
5374
        }
5375
        */
5376
    }
5377
}
클립보드 이미지 추가 (최대 크기: 500 MB)