프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (245 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

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

    
54
            T instance = Activator.CreateInstance<T>();
55

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

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

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

    
92
        public TextBox Gui { get; private set; }
93

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

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

    
115
            Gui.Text += line + Environment.NewLine;
116
        }
117
    }
118

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

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

    
237
        public MainMenu()
238
        {
239
            App.splashString(ISplashMessage.MAINMENU_0);
240
            //InitializeComponent();    
241
            this.Loaded += MainMenu_Loaded;
242
        }
243

    
244
        public class TempDt
245
        {
246
            public int PageNumber { get; set; }
247
            public string CommentID { get; set; }
248
            public string ConvertData { get; set; }
249
            public int DATA_TYPE { get; set; }
250
            public string MarkupInfoID { get; set; }
251
            public int IsUpdate { get; set; }
252
        }
253

    
254
        List<TempDt> tempDtList = new List<TempDt>();
255

    
256
        private void SetCursor()
257
        {
258
            this.Cursor = cursor;
259
        }
260

    
261
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
262
        {
263
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
264
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
265
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
266
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
267
            {
268
                return true;
269
            }
270

    
271
            return false;
272
        }
273

    
274
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
275
        {
276
            if (rotate.Angle == 90 || rotate.Angle == 270)
277
            {
278
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
279
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
280
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
281
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
282
                {
283
                    return true;
284
                }
285
            }
286
            else
287
            {
288
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
289
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
290
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
291
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
292
                {
293
                    return true;
294
                }
295
            }
296

    
297
            return false;
298
        }
299

    
300

    
301
        public void DeleteItem(MarkupInfoItem item)
302
        {
303
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
304
            {
305
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
306
            }
307

    
308
            ViewerDataModel.Instance._markupInfoList.Remove(item);
309

    
310
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
311
            {
312
                ViewerDataModel.Instance.MarkupControls.Remove(a);
313
            });
314

    
315
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
316
            {
317
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
318
            });
319

    
320
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
321
            {
322
                ComingNewBieEnd = false;
323
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
324
                //임시파일에서도 삭제
325
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
326
            });
327

    
328
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
329

    
330
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
331
            {
332
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
333
                {
334
                    var infoId = Commons.shortGuid();
335
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
336
                    {
337
                        CreateTime = DateTime.Now,
338
                        Depatment = userData.DEPARTMENT,
339
                        UpdateTime = DateTime.Now,
340
                        DisplayColor = "#FFFF0000",
341
                        UserID = userData.ID,
342
                        UserName = userData.NAME,
343
                        PageCount = 1,
344
                        Description = "",
345
                        MarkupInfoID = infoId,
346
                        MarkupList = null,
347
                        MarkupVersionID = Commons.shortGuid(),
348
                        Consolidate = 0,
349
                        PartConsolidate = 0,
350
                        userDelete = true,
351
                        AvoidConsolidate = 0,
352
                        IsPreviewUser = true
353
                    };
354
                    App.Custom_ViewInfoId = infoId;
355
                }
356
            }
357
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
358
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
359
        }
360

    
361
        /// <summary>
362
        /// delete selected comments
363
        /// </summary>
364
        /// <param name="sender"></param>
365
        /// <param name="e"></param>
366
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
367
        {
368
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
369
            SelectionSet.Instance.UnSelect(this);
370

    
371
            Button content = (sender as Button);
372
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
373

    
374
            DeleteItem(item);
375
        }
376

    
377
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
378

    
379
        private static Timer timer;
380
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
381
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
382
        {
383
            InitializeComponent();
384
            
385
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
386

    
387
            if (App.ParameterMode)
388
            {
389
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
390
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
391
                imageViewer_Compare = new Image();
392
                ViewerDataModel.Instance.Capture_Opacity = 0;
393
                da.From = 0.8;
394
                da.To = 0;
395
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
396
                da.AutoReverse = true;
397
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
398

    
399
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
400
                {
401
                    this.SymbolPane.Visibility = Visibility.Collapsed;
402
                    this.FavoritePane.Visibility = Visibility.Collapsed;
403
                    this.drawingRotateCanvas.IsHitTestVisible = false;
404
                }
405
            }
406
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
407
        }
408

    
409
        
410

    
411
        private void timercallback(Object o)
412
        {
413
            Stopwatch sw = new Stopwatch();
414
            sw.Start();
415
            TempFile.TempFileAdd();
416
            sw.Stop();
417

    
418
            Dispatcher.InvokeAsync(new Action(delegate
419
            {
420
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
421
                {
422
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
423
                }
424
            }));
425

    
426
            ////GC.Collect();
427
        }
428
        
429
        /// <summary>
430
        /// update my markuplist
431
        ///  - update existing markup data if already exist
432
        ///  - add new markup data if control is new
433
        /// </summary>
434
        public void UpdateMyMarkupList()
435
        {
436
            App.splashString(ISplashMessage.MAINMENU_3);
437
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
438
            bool isComingNewBie = false;
439

    
440
            /// add or update markup list
441
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
442
            {
443
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
444

    
445
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
446
                if (exist != null) //신규 추가 된 코멘트
447
                {
448
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
449
                    {
450
                        exist.Data = root.ConvertData;
451
                        exist.IsUpdate = true;
452
                        ComingNewBieEnd = false;
453
                    }
454
                }
455
                else if (root.CommentID != null)
456
                {
457
                    isComingNewBie = true;
458
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
459
                    {
460
                        ID = control.CommentID,
461
                        Data = root.ConvertData,
462
                        Data_Type = root.DATA_TYPE,
463
                        MarkupInfoID = App.Custom_ViewInfoId,
464
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
465
                        Symbol_ID = control.SymbolID,
466
                        //Group_ID = control.GroupID,
467
                    });
468
                    ComingNewBieEnd = false;
469
                }
470
            }
471

    
472
            /// delete markup list
473
            int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
474
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
475
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
476
                          select markup).ToList();
477
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
478
            /// up to here
479

    
480
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
481
            {
482
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
483
                {
484
                    ComingNewBieEnd = true;
485
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
486
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
487
                    gridViewMarkup.ItemsSource = null;
488
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
489
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
490

    
491
                    GroupDescriptor descriptor = new GroupDescriptor();
492
                    descriptor.Member = "Depatment";
493
                    descriptor.DisplayContent = "DEPT";
494
                    descriptor.SortDirection = ListSortDirection.Ascending;
495
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
496
                }
497
            }
498
        }
499

    
500
        bool ComingNewBieEnd = false;
501

    
502
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
503
        {
504
            if (zoomAndPanCanvas2.Width.IsNaN())
505
            {
506
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
507
            }
508

    
509
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
510
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
511

    
512
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
513
            foreach (var info in gridSelectionItem)
514
            {
515
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
516
            }
517
            /// fire selection event
518
            this.gridViewMarkup.UnselectAll();
519
            this.gridViewMarkup.Select(gridSelectionItem);
520

    
521
            if (!testPanel2.IsHidden)
522
            {
523
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
524
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
525
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
526

    
527
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
528
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
529

    
530

    
531
                foreach (var item in gridSelectionRevItem)
532
                {
533
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
534
                    {
535
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
536
                    });
537
                }
538
            }
539

    
540
            var instanceMain = this.ParentOfType<MainWindow>();
541
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
542
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
543

    
544
            instanceMain.dzTopMenu.rotateOffSet = 0;
545
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
546
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
547

    
548
            //}
549
            SetCommentPages(true);
550
        }
551
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
552
        {
553
            App.splashString(ISplashMessage.MAINMENU_1);
554
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
555
            {            
556
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
557
            }
558
            
559
            ViewerDataModel.Instance.UndoDataList.Clear();
560

    
561
            ConvertInkControlToPolygon();
562

    
563
            SelectionSet.Instance.UnSelect(this);
564
            UpdateMyMarkupList();
565

    
566
            CompareMode.IsChecked = false;
567
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
568

    
569

    
570
            #region 페이지가 벗어난 경우
571

    
572
            if (BalancePoint < 1)
573
            {
574
                BalancePoint = 1;
575
                ViewerDataModel.Instance.PageBalanceNumber = 0;
576
            }
577

    
578
            if (pageNavigator.PageCount < BalancePoint)
579
            {
580
                BalancePoint = pageNavigator.PageCount;
581
                ViewerDataModel.Instance.PageBalanceNumber = 0;
582
            }
583

    
584
            #endregion
585

    
586
            ViewerDataModel.Instance.PageNumber = BalancePoint;
587

    
588
            string uri = "";
589
            if (userData.COMPANY != "EXT")
590
            {
591
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
592
            }
593
            else
594
            {
595
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
596
            }
597

    
598
            var defaultBitmapImage = new BitmapImage();
599
            defaultBitmapImage.BeginInit();
600
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
601
            defaultBitmapImage.UriSource = new Uri(uri);
602
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
603
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
604
            defaultBitmapImage.EndInit();
605

    
606
            ViewerDataModel.Instance.ImageViewPath = null;
607

    
608
            App.splashString(ISplashMessage.MAINMENU_2);
609
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
610
            if (defaultBitmapImage.IsDownloading)
611
            {
612
                App.splashString(ISplashMessage.MAINMENU_4);
613
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
614
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
615
                {                   
616
                    defaultBitmapImage.Freeze();                                        
617
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
618
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
619
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
620
                    mainPanel.UpdateLayout();
621
                    this.pageNavigator.SetNextPage(); 
622
                    
623
                    //image dispose
624
                    defaultBitmapImage = null;
625
                    GC.Collect();
626
                };
627
            }
628

    
629
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
630
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
631

    
632

    
633
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
634
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
635
            inkBoard.Width = zoomAndPanCanvas.Width;
636
            inkBoard.Height = zoomAndPanCanvas.Height;
637

    
638

    
639

    
640
            if (!testPanel2.IsHidden)
641
            {
642
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
643
                //PDF모드일때 잠시 대기(강인구)
644
                if (IsSyncPDFMode)
645
                {
646
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
647
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
648

    
649
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
650
                    if (pdfpath.IsDownloading)
651
                    {
652
                        pdfpath.DownloadCompleted += (ex, arg) =>
653
                        {
654
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
655
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
656
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
657
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
658
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
659
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
660
                        };
661
                    }
662
                    else
663
                    {
664
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
665
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
666
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
667
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
668

    
669
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
670
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
671
                    }
672
                }
673
                else
674
                {
675
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
676
                    string uri2 = "";
677
                    if (userData.COMPANY != "EXT")
678
                    {
679
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
680
                    }
681
                    else
682
                    {
683
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
684
                    }
685

    
686
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
687
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
688
                    defaultBitmapImage_Compare.BeginInit();
689
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
690
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
691
                    defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
692
                    defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
693
                    defaultBitmapImage_Compare.EndInit();
694

    
695
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
696

    
697
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
698
                    zoomAndPanControl.ZoomTo(new Rect
699
                    {
700
                        X = 0,
701
                        Y = 0,
702
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
703
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
704
                    });
705

    
706
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
707
                    if (defaultBitmapImage_Compare.IsDownloading)
708
                    {
709
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
710
                        {
711
                            defaultBitmapImage_Compare.Freeze();
712
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
713
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
714
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
715
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
716
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
717

    
718
                            zoomAndPanControl.ZoomTo(new Rect
719
                            {
720
                                X = 0,
721
                                Y = 0,
722
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
723
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
724
                            });
725

    
726
                            //defaultBitmapImage_Compare dispose
727
                            defaultBitmapImage_Compare = null;
728
                            GC.Collect();
729
                        };
730
                    }
731
                }
732
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
733
            }
734

    
735
        }
736

    
737

    
738
        
739

    
740
        private void SetCommentPages(bool onlyMe = false)
741
        {
742
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
743
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
744
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
745
            {
746
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
747
                instance.UserName = item.UserName;
748
                instance.Depart = item.Depatment;
749
                instance.MarkupInfoID = item.MarkupInfoID;
750
                instance.IsSelected = true;
751
                instance.isConSolidation = item.Consolidate;
752
                instance.SetColor = item.DisplayColor;
753
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
754
                {
755
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
756
                }
757
                else
758
                {
759
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
760
                }
761
                _pages.Add(instance);
762
            }
763
            this.pageNavigator.SetCommentList(_pages.ToList());
764
        }
765

    
766
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
767
        {
768
            if (e.MiddleButton == MouseButtonState.Pressed)
769
            {
770

    
771
            }
772
            e.Handled = true;
773
            if (e.Delta > 0)
774
            {
775
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
776
                ZoomIn(currentContentMousePoint);
777
            }
778
            else
779
            {
780
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
781
                ZoomOut(currentContentMousePoint);
782
            }
783
        }
784

    
785
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
786
        {
787
            e.Handled = true;
788
            if (e.Delta > 0)
789
            {
790
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
791
                ZoomIn_Sync(currentContentMousePoint);
792
            }
793
            else
794
            {
795
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
796
                ZoomOut_Sync(currentContentMousePoint);
797
            }
798
        }
799

    
800
        #region ZoomIn & ZoomOut
801

    
802
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
803
        {
804
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
805
                zoomAndPanControl.ContentZoomFocusY));
806
        }
807

    
808
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
809
        {
810
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
811
                zoomAndPanControl.ContentZoomFocusY));
812
        }
813

    
814

    
815
        //강인구 추가 (줌 인아웃 수치 변경)
816
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
817
        private void ZoomOut(Point contentZoomCenter)
818
        {
819
            if (zoomAndPanControl.ContentScale > 0.39)
820
            {
821
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
822
            }
823
            else
824
            {
825
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
826
            }
827

    
828
            if (zoomAndPanControl2 != null && Sync.IsChecked)
829
            {
830
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
831
            }
832
        }
833

    
834
        private void ZoomIn(Point contentZoomCenter)
835
        {
836
            if (zoomAndPanControl.ContentScale > 0.19)
837
            {
838
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
839
            }
840
            else
841
            {
842
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
843
            }
844

    
845
            if (zoomAndPanControl2 != null && Sync.IsChecked)
846
            {
847
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
848
            }
849

    
850
        }
851

    
852
        private void ZoomOut_Sync(Point contentZoomCenter)
853
        {
854
            if (zoomAndPanControl2.ContentScale > 0.39)
855
            {
856
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
857
            }
858
            else
859
            {
860
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
861
            }
862

    
863
            if (Sync.IsChecked)
864
            {
865
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
866
            }
867
        }
868

    
869
        private void ZoomIn_Sync(Point contentZoomCenter)
870
        {
871
            if (zoomAndPanControl2.ContentScale > 0.19)
872
            {
873
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
874
            }
875
            else
876
            {
877
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
878
            }
879

    
880
            if (Sync.IsChecked)
881
            {
882
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
883
            }
884
        }
885

    
886
        private void ZoomOut()
887
        {
888
            zoomAndPanControl.ContentScale -= 0.1;
889
            //if (zoomAndPanControl2 != null)
890
            //{
891
            //    zoomAndPanControl2.ContentScale -= 0.1;
892
            //}
893
        }
894

    
895
        private void ZoomIn()
896
        {
897
            zoomAndPanControl.ContentScale += 0.1;
898
            //if (zoomAndPanControl2 != null)
899
            //{
900
            //    zoomAndPanControl2.ContentScale += 0.1;
901
            //}
902
        }
903

    
904
        #endregion
905

    
906
        private void init()
907
        {
908
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
909
            {
910

    
911
                ControlList.Clear();
912
                listBox.Items.Clear();
913
                selected_item.Clear();
914

    
915
                (item as IMarkupCommonData).IsSelected = false;
916
            }
917

    
918
        }
919

    
920
        private HitTestResultBehavior MyCallback(HitTestResult result)
921
        {
922
            //this.cursor = Cursors.UpArrow;
923
            var element = result.VisualHit;
924
            while (element != null && !(element is CommentUserInfo))
925
                element = VisualTreeHelper.GetParent(element);
926

    
927
            if (element == null)
928
            {
929
                return HitTestResultBehavior.Stop;
930
            }
931
            else
932
            {
933
                if (element is CommentUserInfo)
934
                {
935
                    if (!hitList.Contains(element))
936
                    {
937
                        hitList.Add((CommentUserInfo)element);
938
                    }
939
                    else
940
                    {
941
                        return HitTestResultBehavior.Stop;
942
                    }
943
                }
944
            }
945
            return HitTestResultBehavior.Continue;
946
        }
947

    
948
        public void ReleaseSelectPath()
949
        {
950
            if (SelectionPath == null)
951
            {
952
                SelectionPath = new Path();
953
                SelectionPath.Name = "";
954
            }
955
            if (SelectionPath.Name != "")
956
            {
957
                SelectionPath.Name = "None";
958
            }
959
            SelectionPath.Opacity = 0.01;
960
            SelectionPath.RenderTransform = null;
961
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
962
        }
963

    
964
        #region 컨트롤 초기화 
965
        public void Control_Init(object control)
966
        {
967
            if (L_Size != 0 && (control as IPath) != null)
968
            {
969
                (control as IPath).LineSize = L_Size;
970
                L_Size = 0;
971
            }
972

    
973
            switch (control.GetType().Name)
974
            {
975
                case "RectangleControl":
976
                    {
977
                        (control as RectangleControl).StrokeColor = Brushes.Red;
978
                    }
979
                    break;
980
                case "CircleControl":
981
                    {
982
                        (control as CircleControl).StrokeColor = Brushes.Red;
983
                    }
984
                    break;
985
                case "TriControl":
986
                    {
987
                        (control as TriControl).StrokeColor = Brushes.Red;
988
                    }
989
                    break;
990
                case "RectCloudControl":
991
                    {
992
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
993
                    }
994
                    break;
995
                case "CloudControl":
996
                    {
997
                        (control as CloudControl).StrokeColor = Brushes.Red;
998
                    }
999
                    break;
1000
                case "PolygonControl":
1001
                    {
1002
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1003
                    }
1004
                    break;
1005
                case "ArcControl":
1006
                    {
1007
                        (control as ArcControl).StrokeColor = Brushes.Red;
1008
                    }
1009
                    break;
1010
                case "ArrowArcControl":
1011
                    {
1012
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1013
                    }
1014
                    break;
1015
                case "LineControl":
1016
                    {
1017
                        (control as LineControl).StrokeColor = Brushes.Red;
1018
                    }
1019
                    break;
1020
                case "ArrowControl_Multi":
1021
                    {
1022
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1023
                    }
1024
                    break;
1025
                case "TextControl":
1026
                    {
1027
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1028
                    }
1029
                    break;
1030
                case "ArrowTextControl":
1031
                    {
1032
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1033
                    }
1034
                    break;
1035
                case "InsideWhiteControl":
1036
                    {
1037
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1038
                    }
1039
                    break;
1040
                case "OverlapWhiteControl":
1041
                    {
1042
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1043
                    }
1044
                    break;
1045
                case "ClipWhiteControl":
1046
                    {
1047
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1048
                    }
1049
                    break;
1050
                case "CoordinateControl":
1051
                    {
1052
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1053
                    }
1054
                    break;
1055
            }
1056
        }
1057
        #endregion
1058

    
1059
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1060
        {
1061
            //Control_Init(e.Source);
1062
        }
1063
        private Window _dragdropWindow = null;
1064

    
1065
        [DllImport("user32.dll")]
1066
        [return: MarshalAs(UnmanagedType.Bool)]
1067
        internal static extern bool GetCursorPos(ref Win32Point pt);
1068

    
1069
        [StructLayout(LayoutKind.Sequential)]
1070
        internal struct Win32Point
1071
        {
1072
            public Int32 X;
1073
            public Int32 Y;
1074
        };
1075
        public string symbol_id = null;
1076
        public long symbol_group_id;
1077
        public int symbol_SelectedIndex;
1078
        public ImageSource symbol_img;
1079
        public string symbol_Data = null;
1080
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1081
        {
1082
            if (this._dragdropWindow != null)
1083
            {
1084
                this._dragdropWindow.Close();
1085
                this._dragdropWindow = null;
1086
            }
1087

    
1088
            symbol_id = id;
1089
            symbol_group_id = group_id;
1090
            symbol_SelectedIndex = SelectedIndex;
1091
            symbol_Data = Data_;
1092
            symbol_img = img;
1093

    
1094
      
1095
            CreateDragDropWindow2(img);
1096
        }
1097

    
1098
        private void CreateDragDropWindow2(ImageSource image)
1099
        {
1100
            this._dragdropWindow = new Window();
1101
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1102
            _dragdropWindow.WindowStyle = WindowStyle.None;
1103
            _dragdropWindow.AllowsTransparency = true;           
1104
            _dragdropWindow.AllowDrop = false;
1105
            _dragdropWindow.Background = null;
1106
            _dragdropWindow.IsHitTestVisible = false;
1107
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1108
            _dragdropWindow.Topmost = true;
1109
            _dragdropWindow.ShowInTaskbar = false;
1110
            
1111
            Rectangle r = new Rectangle();
1112
            r.Width = image.Width;
1113
            r.Height = image.Height;
1114
            r.Opacity = 0.5;            
1115
            r.Fill = new ImageBrush(image);
1116
            this._dragdropWindow.Content = r;
1117

    
1118
            Win32Point w32Mouse = new Win32Point();
1119
            GetCursorPos(ref w32Mouse);
1120

    
1121
            //w32Mouse.X = getCurrentPoint.X;
1122
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1123
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1124
            this._dragdropWindow.Show();
1125
        }
1126

    
1127
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1128
        {
1129
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1130
            {
1131
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1132

    
1133
                Point currentPos = e.GetPosition(rect);
1134

    
1135
                floatingTip.HorizontalOffset = currentPos.X + 20;
1136
                floatingTip.VerticalOffset = currentPos.Y;
1137
            }
1138

    
1139
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1140
            
1141
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1142
            {
1143
                SetCursor();
1144
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1145
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1146

    
1147
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1148
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1149
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1150

    
1151
                if (Sync.IsChecked)
1152
                {
1153
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1154
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1155
                }
1156
            }
1157

    
1158
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1159
            {
1160
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1161
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1162
                SetCursor();
1163

    
1164
                if (currentControl != null)
1165
                {
1166
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1167
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1168
                    //강인구 추가
1169
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1170

    
1171
                    if ((currentControl as IPath) != null)
1172
                    {
1173
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1174
                    }
1175
                    if ((currentControl as LineControl) != null)
1176
                    {
1177
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1178
                    }
1179

    
1180
                    if ((currentControl as IShapeControl) != null)
1181
                    {
1182
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1183
                    }
1184
                    if ((currentControl as TextControl) != null)
1185
                    {
1186
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1187
                        {
1188
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1189
                        }
1190
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1191
                        {
1192
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1193
                        }
1194
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1195
                        {
1196
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1197
                        }
1198
                    }
1199
                    else if ((currentControl as ArrowTextControl) != null)
1200
                    {
1201
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1202
                        {
1203
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1204
                        }
1205
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1206
                        {
1207
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1208
                        }
1209
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1210
                        {
1211
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1212
                        }
1213
                    }
1214
                    else if ((currentControl as RectCloudControl) != null)
1215
                    {
1216
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1217
                    }
1218
                    else if ((currentControl as CloudControl) != null)
1219
                    {
1220
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1221
                    }
1222

    
1223
                    switch (controlType)
1224
                    {
1225
                        case (ControlType.Coordinate):
1226
                            {
1227
                                var control = currentControl as CoordinateControl;
1228
                                if (control != null)
1229
                                {
1230
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1231
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1232
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1233
                                }
1234
                            }
1235
                            break;
1236
                        case (ControlType.InsideWhite):
1237
                            {
1238
                                var control = currentControl as InsideWhiteControl;
1239
                                if (control != null)
1240
                                {
1241
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1242
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1243
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1244
                                    control.Paint = PaintSet.Fill;
1245
                                }
1246
                            }
1247
                            break;
1248
                        case ControlType.OverlapWhite:
1249
                            {
1250
                                var control = currentControl as OverlapWhiteControl;
1251
                                if (control != null)
1252
                                {
1253
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1254
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1255
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1256
                                    control.Paint = PaintSet.Fill;
1257
                                }
1258
                            }
1259
                            break;
1260
                        case ControlType.ClipWhite:
1261
                            {
1262
                                var control = currentControl as ClipWhiteControl;
1263
                                if (control != null)
1264
                                {
1265
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1266
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1267
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1268
                                    control.Paint = PaintSet.Fill;
1269
                                }
1270
                            }
1271
                            break;
1272
                        case ControlType.RectCloud:
1273
                            {
1274
                                var control = currentControl as RectCloudControl;
1275
                                if (control != null)
1276
                                {
1277
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1278
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1279
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1280
                                }
1281
                            }
1282
                            break;
1283
                        case ControlType.SingleLine:
1284
                        case ControlType.CancelLine:
1285
                        case ControlType.ArrowLine:
1286
                        case ControlType.TwinLine:
1287
                        case ControlType.DimLine:
1288
                            {
1289
                                var control = currentControl as LineControl;
1290
                                if (control != null)
1291
                                {
1292
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1293
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1294
                                }
1295
                            }
1296
                            break;
1297

    
1298
                        case ControlType.ArcLine:
1299
                            {
1300
                                var control = currentControl as ArcControl;
1301
                                if (control != null)
1302
                                {
1303
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1304
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1305
                                }
1306
                            }
1307
                            break;
1308

    
1309
                        case ControlType.ArcArrow:
1310
                            {
1311
                                var control = currentControl as ArrowArcControl;
1312
                                if (control != null)
1313
                                {
1314
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1315
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1316
                                }
1317
                            }
1318
                            break;
1319

    
1320
                        case ControlType.ArrowMultiLine:
1321
                            {
1322
                                var control = currentControl as ArrowControl_Multi;
1323
                                if (control != null)
1324
                                {
1325
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1326
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1327
                                }
1328
                            }
1329
                            break;
1330

    
1331
                        case ControlType.Circle:
1332
                            {
1333
                                if (currentControl != null)
1334
                                {
1335
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1336
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1337
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1338
                                }
1339
                            }
1340
                            break;
1341

    
1342
                        case ControlType.PolygonCloud:
1343
                            {
1344
                                var control = currentControl as CloudControl;
1345
                                if (control != null)
1346
                                {
1347
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1348
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1349
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1350
                                }
1351
                            }
1352
                            break;
1353

    
1354
                        case ControlType.Triangle:
1355
                            {
1356
                                var control = currentControl as TriControl;
1357
                                if (control != null)
1358
                                {
1359
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1360
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1361
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1362
                                }
1363
                            }
1364
                            break;
1365

    
1366
                        case ControlType.ImgControl:
1367
                            {
1368
                                var control = currentControl as ImgControl;
1369
                                if (control != null)
1370
                                {
1371
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1372
                                }
1373
                            }
1374
                            break;
1375

    
1376
                        case ControlType.Date:
1377
                            {
1378
                                var control = currentControl as DateControl;
1379
                                if (control != null)
1380
                                {
1381
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1382
                                }
1383
                            }
1384
                            break;
1385

    
1386
                        case ControlType.ArrowTextControl:
1387
                        case ControlType.ArrowTransTextControl:
1388
                        case ControlType.ArrowTextBorderControl:
1389
                        case ControlType.ArrowTransTextBorderControl:
1390
                        case ControlType.ArrowTextCloudControl:
1391
                        case ControlType.ArrowTransTextCloudControl:
1392
                            {
1393
                                var control = currentControl as ArrowTextControl;
1394
                                if (control != null)
1395
                                {
1396
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1397
                                }
1398
                            }
1399
                            break;
1400
                        case ControlType.PolygonControl:
1401
                        case ControlType.ChainLine:
1402
                            {
1403
                                var control = currentControl as PolygonControl;
1404
                                if (control != null)
1405
                                {
1406
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1407
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1408
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1409
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1410
                                }
1411
                            }
1412
                            break;
1413
                        case ControlType.Sign:
1414
                            {
1415
                                var control = currentControl as SignControl;
1416
                                if (control != null)
1417
                                {
1418
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1419
                                }
1420
                            }
1421
                            break;
1422
                        case ControlType.Symbol:
1423
                            {
1424
                                var control = currentControl as SymControl;
1425
                                if (control != null)
1426
                                {
1427
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1428
                                }
1429
                            }
1430
                            break;
1431
                        case ControlType.Stamp:
1432
                            {
1433
                                var control = currentControl as SymControlN;
1434
                                if (control != null)
1435
                                {
1436
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1437
                                }
1438
                            }
1439
                            break;
1440
                        case ControlType.Rectangle:
1441
                        case ControlType.Mark:
1442
                            {
1443
                                var control = currentControl as RectangleControl;
1444
                                if (control != null)
1445
                                {
1446
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1447
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1448
                                }
1449
                            }
1450
                            break;
1451
                        case ControlType.PenControl:
1452
                            {
1453
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1454
                                //inkBoard.Strokes.Add(stroke);
1455
                            }
1456
                            break;
1457
                        default:
1458
                            break;
1459
                    }
1460
                }
1461
            }
1462
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1463
            {
1464
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1465
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1466
                SetCursor();
1467
                if (currentControl == null)
1468
                {
1469
                    switch (controlType)
1470
                    {
1471
                        case ControlType.PenControl:
1472
                            {
1473
                                if (inkBoard.Tag.ToString() == "Ink")
1474
                                {
1475
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1476
                                }
1477
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1478
                                {
1479
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1480
                                }
1481
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1482
                                {
1483
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1484
                                }
1485

    
1486
                                //inkBoard.Strokes.Add(stroke);
1487
                            }
1488
                            break;
1489
                    }
1490
                    return;
1491
                }
1492
            }
1493
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1494
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1495
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1496
            {
1497
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1498

    
1499
                if (isDraggingSelectionRect)
1500
                {
1501
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1502
                    e.Handled = true;
1503
                }
1504
                else if (isLeftMouseButtonDownOnWindow)
1505
                {
1506
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1507
                    double dragDistance = Math.Abs(dragDelta.Length);
1508

    
1509
                    if (dragDistance > DragThreshold)
1510
                    {
1511
                        isDraggingSelectionRect = true;
1512
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1513
                    }
1514

    
1515
                    e.Handled = true;
1516
                }
1517

    
1518
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1519
                {
1520
                }
1521
                else
1522
                {
1523
                    e.Handled = true;
1524
                }
1525
            }
1526
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1527
            { //symbol      
1528
                if(_dragdropWindow != null)
1529
                {
1530
                    Win32Point w32Mouse = new Win32Point();
1531
                    GetCursorPos(ref w32Mouse);
1532

    
1533
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1534
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1535
                }                
1536
            }
1537
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1538
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1539
            {
1540
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1541
                if(control != null)
1542
                {
1543
                    this.cursor = Cursors.Hand;
1544
                    SetCursor();
1545
                }
1546
                else
1547
                {
1548
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1549
                    SetCursor();
1550
                }
1551
            }
1552
            else
1553
            {
1554
            }
1555
        }
1556

    
1557
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1558
        {
1559
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1560
            {
1561
                SetCursor();
1562
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1563
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1564

    
1565
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1566

    
1567
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1568
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1569

    
1570
                if (Sync.IsChecked)
1571
                {
1572
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1573
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1574
                }
1575
            }
1576
        }
1577

    
1578
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1579

    
1580
        private EllipseGeometry hitArea = new EllipseGeometry();
1581

    
1582
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1583
        {
1584
            IsDrawing = false;
1585

    
1586
            if (mouseHandlingMode != MouseHandlingMode.None)
1587
            {
1588
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1589
                {
1590
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1591

    
1592
                    SetCursor();
1593

    
1594
                    switch (controlType)
1595
                    {
1596
                        case ControlType.None:
1597
                            break;
1598
                        case ControlType.Rectangle:
1599
                            {
1600

    
1601
                            }
1602
                            break;
1603
                        case ControlType.PenControl:
1604
                            {
1605

    
1606
                            }
1607
                            break;
1608
                        default:
1609
                            break;
1610
                    }
1611
                }
1612
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1613
                {
1614
                    if (isLeftMouseButtonDownOnWindow)
1615
                    {
1616
                        bool wasDragSelectionApplied = false;
1617

    
1618
                        if (isDraggingSelectionRect)
1619
                        {
1620
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1621
                            {
1622
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1623
                                mouseHandlingMode = MouseHandlingMode.None;
1624
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1625
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1626
                                Set_Symbol_Capture(endPoint);
1627
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1628
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1629
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1630
                            }
1631
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1632
                            {
1633
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1634
                                mouseHandlingMode = MouseHandlingMode.None;
1635
                                Set_Capture();
1636

    
1637
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1638
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1639
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1640
                            }
1641
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1642
                            {
1643
                                ApplyDragSelectionRect();
1644
                            }
1645
                            else
1646
                            {
1647
                                double x = Canvas.GetLeft(dragZoomBorder);
1648
                                double y = Canvas.GetTop(dragZoomBorder);
1649
                                double width = dragZoomBorder.Width;
1650
                                double height = dragZoomBorder.Height;
1651
                                Rect dragRect = new Rect(x, y, width, height);
1652

    
1653
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1654

    
1655
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1656
                            }
1657

    
1658
                            isDraggingSelectionRect = false;
1659
                            e.Handled = true;
1660
                            wasDragSelectionApplied = true;
1661
                        }
1662

    
1663
                        if (isLeftMouseButtonDownOnWindow)
1664
                        {
1665
                            isLeftMouseButtonDownOnWindow = false;
1666
                            this.ReleaseMouseCapture();
1667
                            e.Handled = true;
1668
                        }
1669

    
1670
                        if (!wasDragSelectionApplied)
1671
                        {
1672
                            init();
1673
                        }
1674
                    }
1675
                }
1676
                else if (e.RightButton == MouseButtonState.Pressed)
1677
                {
1678
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1679
                    SetCursor();
1680
                }
1681

    
1682
                zoomAndPanControl.ReleaseMouseCapture();
1683

    
1684

    
1685
                e.Handled = true;
1686
            }
1687
            else
1688
            {
1689
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1690
                SetCursor();
1691
            }
1692

    
1693
            ///mouseButtonDown = MouseButton.Left;
1694
            //controlType = ControlType.SingleLine;
1695
        }
1696

    
1697
        public void Set_Symbol_Capture(Point endPoint)
1698
        {       
1699
            double x = canvasDrawingMouseDownPoint.X;
1700
            double y = canvasDrawingMouseDownPoint.Y;
1701
            if(x > endPoint.X)
1702
            {
1703
                x = endPoint.X;
1704
                y = endPoint.Y;
1705
            }
1706

    
1707
            double width = dragCaptureBorder.Width;
1708
            double height = dragCaptureBorder.Height;
1709

    
1710
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1711

    
1712
            if (x < 0)
1713
            {
1714
                width += x;
1715
                x = 0;
1716
            }
1717
            if (y < 0)
1718
            {
1719
                height += y;
1720
                y = 0;
1721

    
1722
                width = (int)canvasImage.PixelWidth - x;
1723
            }
1724
            if (x + width > canvasImage.PixelWidth)
1725
            {
1726
                width = (int)canvasImage.PixelWidth - x;
1727
            }
1728
            if (y + height > canvasImage.PixelHeight)
1729
            {
1730
                height = (int)canvasImage.PixelHeight - y;
1731
            }
1732
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1733

    
1734
            string uri = "";
1735
            if (userData.COMPANY != "EXT")
1736
            {
1737
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1738
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1739
            }
1740
            else
1741
            {
1742
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1743
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1744
            }
1745

    
1746
            var defaultBitmapImage = new BitmapImage();
1747
            defaultBitmapImage.BeginInit();
1748
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1749
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1750
            defaultBitmapImage.UriSource = new Uri(uri);
1751
            defaultBitmapImage.EndInit();
1752

    
1753
            //GC.Collect();
1754

    
1755
            if (defaultBitmapImage.IsDownloading)
1756
            {
1757
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1758
                {
1759
                    defaultBitmapImage.Freeze();
1760
                    //GC.Collect();
1761
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1762
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1763
                };
1764
            }
1765
        }
1766

    
1767
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1768
        {
1769
            ///mouseButtonDown = MouseButton.Left;
1770
        }
1771

    
1772
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1773
        {
1774
            ///mouseButtonDown = MouseButton.Left;
1775
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1776
        }
1777

    
1778
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1779
        {
1780

    
1781
        }
1782

    
1783
        /// <summary>
1784
        /// select items by dragging
1785
        /// </summary>
1786
        private void ApplyDragSelectionRect()
1787
        {
1788
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1789

    
1790
            double x = Canvas.GetLeft(dragSelectionBorder);
1791
            double y = Canvas.GetTop(dragSelectionBorder);
1792
            double width = dragSelectionBorder.Width;
1793
            double height = dragSelectionBorder.Height;
1794
            Boolean Flag = false;
1795
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1796
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1797

    
1798
            Rect dragRect = new Rect(x, y, width, height);
1799
            ///dragRect.Inflate(width / 10, height / 10);
1800

    
1801
            foreach (var item in Items)
1802
            {
1803
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1804

    
1805
                if (Flag)
1806
                {
1807
                    adornerSet.Add(item);
1808
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1809
                    Control_Style(item);
1810
                }
1811
            }
1812
            if (adornerSet.Count > 0)
1813
            {
1814
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1815
                SelectLayer.Children.Add(final);
1816
            }
1817
        }
1818

    
1819
        private void InitDragSelectionRect(Point pt1, Point pt2)
1820
        {
1821
            //캡쳐 중
1822
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1823
            {
1824
                dragCaptureBorder.Visibility = Visibility.Visible;
1825
            }
1826
            //선택 중
1827
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1828
            {
1829

    
1830
                dragSelectionBorder.Visibility = Visibility.Visible;
1831
            }
1832
            else
1833
            {
1834
                dragZoomBorder.Visibility = Visibility.Visible;
1835
            }
1836
            UpdateDragSelectionRect(pt1, pt2);
1837
        }
1838

    
1839
        /// <summary>
1840
        /// Update the position and size of the rectangle used for drag selection.
1841
        /// </summary>
1842
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1843
        {
1844
            double x, y, width, height;
1845

    
1846
            //
1847
            // Determine x,y,width and height of the rect inverting the points if necessary.
1848
            // 
1849

    
1850
            if (pt2.X < pt1.X)
1851
            {
1852
                x = pt2.X;
1853
                width = pt1.X - pt2.X;
1854
            }
1855
            else
1856
            {
1857
                x = pt1.X;
1858
                width = pt2.X - pt1.X;
1859
            }
1860

    
1861
            if (pt2.Y < pt1.Y)
1862
            {
1863
                y = pt2.Y;
1864
                height = pt1.Y - pt2.Y;
1865
            }
1866
            else
1867
            {
1868
                y = pt1.Y;
1869
                height = pt2.Y - pt1.Y;
1870
            }
1871

    
1872
            //
1873
            // Update the coordinates of the rectangle used for drag selection.
1874
            //
1875
            //캡쳐 중
1876
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1877
            {
1878
                Canvas.SetLeft(dragCaptureBorder, x);
1879
                Canvas.SetTop(dragCaptureBorder, y);
1880
                dragCaptureBorder.Width = width;
1881
                dragCaptureBorder.Height = height;
1882
            }
1883
            //선택 중
1884
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1885
            {
1886
                Canvas.SetLeft(dragSelectionBorder, x);
1887
                Canvas.SetTop(dragSelectionBorder, y);
1888
                dragSelectionBorder.Width = width;
1889
                dragSelectionBorder.Height = height;
1890
            }
1891
            else
1892
            {
1893
                Canvas.SetLeft(dragZoomBorder, x);
1894
                Canvas.SetTop(dragZoomBorder, y);
1895
                dragZoomBorder.Width = width;
1896
                dragZoomBorder.Height = height;
1897
            }
1898
        }
1899

    
1900
        private void drawingPannelRotate(double angle)
1901
        {
1902
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1903
            rotate.Angle = angle;
1904
            var rotationNum = Math.Abs((rotate.Angle / 90));
1905

    
1906
            if (angle == 90 || angle == 270)
1907
            {
1908
                double emptySize = zoomAndPanCanvas.Width;
1909
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1910
                zoomAndPanCanvas.Height = emptySize;
1911
            }
1912
            if (angle == 0)
1913
            {
1914
                translate.X = 0;
1915
                translate.Y = 0;
1916
            }
1917
            else if (angle == 90)
1918
            {
1919
                translate.X = zoomAndPanCanvas.Width;
1920
                translate.Y = 0;
1921
            }
1922
            else if (angle == 180)
1923
            {
1924
                translate.X = zoomAndPanCanvas.Width;
1925
                translate.Y = zoomAndPanCanvas.Height;
1926
            }
1927
            else
1928
            {
1929
                translate.X = 0;
1930
                translate.Y = zoomAndPanCanvas.Height;
1931
            }
1932

    
1933
            zoomAndPanControl.RotationAngle = rotate.Angle;
1934

    
1935

    
1936
            if (!testPanel2.IsHidden)
1937
            {
1938
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1939
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1940
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1941
            }
1942

    
1943
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1944
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1945
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1946
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1947
            ViewerDataModel.Instance.Angle = rotate.Angle;
1948
        }
1949

    
1950
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1951
        {
1952
            string Data_ = "";
1953

    
1954
            try
1955
            {
1956
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1957
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1958
                if (Data_ != null || Data_ != "")
1959
                {
1960
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1961
                }
1962
                else
1963
                {
1964
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1965
                }
1966

    
1967
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1968
                //{
1969
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1970
                //    STATE = 0,
1971
                //};
1972
                if (Data_ != null)
1973
                {
1974
                    Image img = new Image();
1975
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1976
                    if (Data_.Contains(".svg"))
1977
                    {
1978
                        byte[] imageData = null;
1979
                        DrawingImage image = null;
1980
                        using (System.Net.WebClient web = new System.Net.WebClient())
1981
                        {
1982
                            imageData = web.DownloadData(new Uri(Data_));
1983
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1984
                            image = SvgReader.Load(stream);
1985
                        }
1986
                        img.Source = image;
1987
                    }
1988
                    else
1989
                    {
1990
                        img.Source = new BitmapImage(new Uri(Data_));
1991
                    }
1992

    
1993
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1994
                    {
1995
                        PointSet = new List<Point>(),
1996
                        FilePath = Data_,
1997
                        ImageData = img.Source,
1998
                        StartPoint = canvasZoomPanningMouseDownPoint,
1999
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2000
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2001
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2002
                        canvasZoomPanningMouseDownPoint.Y),
2003
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2004
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2005
                    };
2006

    
2007
                    currentControl.PointSet = new List<Point>
2008
                                        {
2009
                                            currentControl.StartPoint,
2010
                                            currentControl.LeftBottomPoint,
2011
                                            currentControl.EndPoint,
2012
                                            currentControl.TopRightPoint,
2013
                                        };
2014
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2015
                    UndoData = new Undo_data()
2016
                    {
2017
                        IsUndo = false,
2018
                        Event = Event_Type.Create,
2019
                        EventTime = DateTime.Now,
2020
                        Markup_List = new List<Multi_Undo_data>()
2021
                    };
2022
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2023
                    {
2024
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2025
                    });
2026

    
2027
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2028
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2029
                    UndoData.Markup_List.Add(multi_Undo_Data);
2030
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2031

    
2032
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2033
                    currentControl.CommentID = Commons.shortGuid();
2034
                    currentControl.SymbolID = id;
2035
                    currentControl.GroupID = group_id;
2036
                    currentControl.ApplyTemplate();
2037
                    currentControl.SetImage();
2038

    
2039
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2040
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2041
                    SelectLayer.Children.Add(final);
2042
                }
2043
            }
2044
            catch (Exception ex)
2045
            {
2046
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2047
            }
2048
        }
2049

    
2050
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2051
        {            
2052
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2053
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2054
            {
2055
                set_option.Value = double.Parse(set_option.ContentText);
2056
            }
2057

    
2058
            ConvertInkControlToPolygon();
2059

    
2060
            ///TODO:
2061
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2062
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2063

    
2064
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2065
            {
2066
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2067
            }
2068
            /// up to here
2069

    
2070
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2071
            {
2072
                if (arrow_text as ArrowTextControl != null)
2073
                {
2074
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2075
                }
2076
            }
2077

    
2078
            //if (currentControl != null)
2079
            {
2080
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2081
                if (text_item_ != null)
2082
                {
2083
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2084
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2085
                    (text_item_ as TextControl).EnableEditing = false;
2086
                    currentControl = null;
2087
                }
2088

    
2089
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2090
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2091
                {
2092
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2093
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2094
                    currentControl = null;
2095
                }
2096
            }
2097

    
2098
            double Ang = 0;                                          
2099
            if (rotate.Angle != 0)
2100
            {
2101
                Ang = 360 - rotate.Angle;
2102
            }
2103

    
2104
            if (e.OriginalSource is System.Windows.Controls.Image)
2105
            {
2106
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2107
            }
2108

    
2109
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2110
            {                
2111
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2112
                if(symbol_id != null)
2113
                {
2114
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2115
                }                
2116
            }
2117

    
2118
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2119
            {
2120
                if (this._dragdropWindow != null)
2121
                {
2122
                    this._dragdropWindow.Close();
2123
                    this._dragdropWindow = null;
2124
                    symbol_id = null;
2125
                }
2126
            }
2127

    
2128
            if (e.LeftButton == MouseButtonState.Pressed)
2129
            {
2130
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2131
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2132

    
2133
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2134
                SetCursor();
2135

    
2136
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2137
            }
2138

    
2139
            if (e.MiddleButton == MouseButtonState.Pressed)
2140
            {
2141
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2142
                cursor = Cursors.SizeAll;
2143
                SetCursor();
2144
            }
2145
            if (e.RightButton == MouseButtonState.Pressed)
2146
            {
2147
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2148
                cursor = Cursors.SizeAll;
2149
                SetCursor();
2150
            }
2151
            else if (e.XButton1 == MouseButtonState.Pressed)
2152
            {
2153
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2154
                {
2155
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2156
                }
2157

    
2158
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2159

    
2160
            }
2161
            else if (e.XButton2 == MouseButtonState.Pressed)
2162
            {
2163
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2164
                {
2165
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2166
                }
2167
            }
2168

    
2169
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2170
            {
2171
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2172
                {
2173
                    if (SelectLayer.Children.Count == 0)
2174
                    {
2175
                        isLeftMouseButtonDownOnWindow = true;
2176
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2177
                    }
2178

    
2179
                    if (controlType == ControlType.None)
2180
                    {
2181
                        isLeftMouseButtonDownOnWindow = true;
2182
                    }
2183
                }
2184

    
2185
                /// 캡쳐 모드 설정
2186
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2187
                {
2188
                    dragCaptureBorder.Visibility = Visibility.Visible;
2189
                    isLeftMouseButtonDownOnWindow = true;
2190
                }
2191

    
2192
                /// 줌 모드 설정
2193
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2194
                {
2195
                    isLeftMouseButtonDownOnWindow = true;
2196
                }
2197

    
2198
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2199
                if (control != null)
2200
                {
2201
                    AdornerFinal final = null;
2202

    
2203
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2204
                    {
2205
                        /// 기존 selection 해제
2206
                        SelectionSet.Instance.UnSelect(this);
2207

    
2208
                        final = new AdornerFinal(control);
2209

    
2210
                        this.Control_Style(control);
2211

    
2212
                        if ((control as IPath) != null)
2213
                        {
2214
                            if ((control as IPath).LineSize != 0)
2215
                            {
2216
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2217
                            }
2218
                        }
2219
                        if ((control as IShapeControl) != null)
2220
                        {
2221
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2222
                            {
2223
                                ViewerDataModel.Instance.checkHatchShape = true;
2224
                            }
2225
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2226
                            {
2227
                                ViewerDataModel.Instance.checkFillShape = true;
2228
                            }
2229
                            else
2230
                            {
2231
                                ViewerDataModel.Instance.checkHatchShape = false;
2232
                                ViewerDataModel.Instance.checkFillShape = false;
2233
                            }
2234
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2235
                        }
2236

    
2237
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2238

    
2239
                        if ((control as TextControl) != null)
2240
                        {
2241
                            if(!((control as TextControl).EnableEditing)) {
2242
                                (control as TextControl).EnableEditing = true;
2243
                            }
2244

    
2245
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2246
                            {
2247
                                ViewerDataModel.Instance.checkTextStyle = true;
2248
                            }
2249
                            else
2250
                            {
2251
                                ViewerDataModel.Instance.checkTextStyle = false;
2252
                            }
2253

    
2254
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2255
                            {
2256
                                ViewerDataModel.Instance.checkTextStyle = true;
2257
                            }
2258
                            else
2259
                            {
2260
                                ViewerDataModel.Instance.checkTextStyle = false;
2261
                            }
2262
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2263
                            {
2264
                                ViewerDataModel.Instance.checkTextWeight = true;
2265
                            }
2266
                            else
2267
                            {
2268
                                ViewerDataModel.Instance.checkTextWeight = false;
2269
                            }
2270
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2271
                            {
2272
                                ViewerDataModel.Instance.checkUnderLine = true;
2273
                            }
2274
                            else
2275
                            {
2276
                                ViewerDataModel.Instance.checkUnderLine = false;
2277
                            }
2278
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2279
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2280

    
2281
                        }
2282
                        else if ((control as ArrowTextControl) != null)
2283
                        {
2284
                            if (!((control as ArrowTextControl).EnableEditing))
2285
                            {
2286
                                (control as ArrowTextControl).EnableEditing = true;
2287
                            }
2288
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2289
                            {
2290
                                ViewerDataModel.Instance.checkTextStyle = true;
2291
                            }
2292
                            else
2293
                            {
2294
                                ViewerDataModel.Instance.checkTextStyle = false;
2295
                            }
2296

    
2297
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2298
                            {
2299
                                ViewerDataModel.Instance.checkTextStyle = true;
2300
                            }
2301
                            else
2302
                            {
2303
                                ViewerDataModel.Instance.checkTextStyle = false;
2304
                            }
2305
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2306
                            {
2307
                                ViewerDataModel.Instance.checkTextWeight = true;
2308
                            }
2309
                            else
2310
                            {
2311
                                ViewerDataModel.Instance.checkTextWeight = false;
2312
                            }
2313
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2314
                            {
2315
                                ViewerDataModel.Instance.checkUnderLine = true;
2316
                            }
2317
                            else
2318
                            {
2319
                                ViewerDataModel.Instance.checkUnderLine = false;
2320
                            }
2321
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2322
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2323
                        }
2324
                        else if ((control as RectCloudControl) != null)
2325
                        {
2326
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2327
                        }
2328
                        else if ((control as CloudControl) != null)
2329
                        {
2330
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2331
                        }
2332
                    }
2333
                    else
2334
                    {
2335
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2336
                        SelectionSet.Instance.UnSelect(this);
2337
                        comment.Add(control);
2338

    
2339
                        Control_Style(control);
2340

    
2341
                        final = new AdornerFinal(comment);
2342
                    }
2343

    
2344
                    if (final != null)
2345
                    {
2346
                        this.SelectLayer.Children.Add(final);
2347
                    }
2348
                }              
2349
            }
2350
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2351
            {               
2352
                init();
2353
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2354
                if (cursor != Cursors.SizeAll)
2355
                {
2356
                    cursor = Cursors.Cross;
2357
                    SetCursor();
2358
                }
2359
                bool init_user = false;
2360
                foreach (var user in gridViewMarkup.Items)
2361
                {
2362
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2363
                    {
2364
                        init_user = true;
2365
                    }
2366
                }
2367
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2368
                {
2369
                    RadWindow.Alert(new DialogParameters
2370
                    {
2371
                        Owner = Application.Current.MainWindow,
2372
                        Theme = new VisualStudio2013Theme(),
2373
                        Header = "안내",
2374
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2375
                    });
2376
                    return;
2377
                }
2378
                else
2379
                {
2380
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2381
                    if (item != null)
2382
                    {
2383
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2384
                    }
2385
                }
2386

    
2387
                switch (controlType)
2388
                {
2389
                    case ControlType.Coordinate:
2390
                        {
2391
                            if (e.LeftButton == MouseButtonState.Pressed)
2392
                            {
2393
                                if (currentControl is CoordinateControl)
2394
                                {
2395
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2396
                                    {
2397
                                        return;
2398
                                    }
2399

    
2400
                                    CreateCommand.Instance.Execute(currentControl);
2401

    
2402
                                    currentControl = null;
2403
                                    this.cursor = Cursors.Arrow;
2404
                                }
2405
                                else
2406
                                {
2407
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2408
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2409
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2410
                                    {
2411
                                        currentControl = null;
2412
                                        this.cursor = Cursors.Arrow;
2413
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2414
                                        return;
2415
                                    }
2416
                                    else
2417
                                    {
2418
                                        currentControl = new CoordinateControl
2419
                                        {
2420
                                            Background = new SolidColorBrush(Colors.Black),
2421
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2422
                                            ControlType = ControlType.Coordinate
2423
                                        };
2424

    
2425
                                        currentControl.CommentID = Commons.shortGuid();
2426
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2427
                                        currentControl.IsNew = true;
2428

    
2429
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2430

    
2431
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2432
                                    }
2433
                                }
2434
                            }
2435
                        }
2436
                        break;
2437
                    case ControlType.InsideWhite:
2438
                        {
2439
                            if (e.LeftButton == MouseButtonState.Pressed)
2440
                            {
2441
                                if (currentControl is InsideWhiteControl)
2442
                                {
2443
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2444
                                    {
2445
                                        return;
2446
                                    }
2447

    
2448
                                    CreateCommand.Instance.Execute(currentControl);
2449

    
2450
                                    currentControl = null;
2451
                                    this.cursor = Cursors.Arrow;
2452
                                }
2453
                                else
2454
                                {
2455
                                    currentControl = new InsideWhiteControl
2456
                                    {
2457
                                        Background = new SolidColorBrush(Colors.Black),
2458
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2459
                                        ControlType = ControlType.InsideWhite
2460
                                    };
2461

    
2462
                                    currentControl.CommentID = Commons.shortGuid();
2463
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2464
                                    currentControl.IsNew = true;
2465
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2466

    
2467
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2468
                                }
2469
                            }
2470
                        }
2471
                        break;
2472
                    case ControlType.OverlapWhite:
2473
                        {
2474
                            if (e.LeftButton == MouseButtonState.Pressed)
2475
                            {
2476
                                if (currentControl is OverlapWhiteControl)
2477
                                {
2478
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2479
                                    {
2480
                                        return;
2481
                                    }
2482

    
2483
                                    CreateCommand.Instance.Execute(currentControl);
2484

    
2485
                                    currentControl = null;
2486
                                    this.cursor = Cursors.Arrow;
2487
                                }
2488
                                else
2489
                                {
2490
                                    currentControl = new OverlapWhiteControl
2491
                                    {
2492
                                        Background = new SolidColorBrush(Colors.Black),
2493
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2494
                                        ControlType = ControlType.OverlapWhite
2495
                                    };
2496

    
2497
                                    currentControl.CommentID = Commons.shortGuid();
2498
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2499
                                    currentControl.IsNew = true;
2500
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2501

    
2502
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2503
                                }
2504
                            }
2505
                        }
2506
                        break;
2507
                    case ControlType.ClipWhite:
2508
                        {
2509
                            if (e.LeftButton == MouseButtonState.Pressed)
2510
                            {
2511
                                if (currentControl is ClipWhiteControl)
2512
                                {
2513
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2514
                                    {
2515
                                        return;
2516
                                    }
2517

    
2518
                                    CreateCommand.Instance.Execute(currentControl);
2519

    
2520
                                    currentControl = null;
2521
                                    this.cursor = Cursors.Arrow;
2522
                                }
2523
                                else
2524
                                {
2525
                                    currentControl = new ClipWhiteControl
2526
                                    {
2527
                                        Background = new SolidColorBrush(Colors.Black),
2528
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2529
                                        ControlType = ControlType.ClipWhite
2530
                                    };
2531

    
2532
                                    currentControl.CommentID = Commons.shortGuid();
2533
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2534
                                    currentControl.IsNew = true;
2535
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2536

    
2537
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2538
                                }
2539
                            }
2540
                        }
2541
                        break;
2542
                    case ControlType.Rectangle:
2543
                        {
2544
                            if (e.LeftButton == MouseButtonState.Pressed)
2545
                            {
2546
                                if (currentControl is RectangleControl)
2547
                                {
2548
                                    //20180906 LJY TEST IsRotationDrawingEnable
2549
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2550
                                    {
2551
                                        return;
2552
                                    }
2553

    
2554
                                    CreateCommand.Instance.Execute(currentControl);
2555
                                    currentControl = null;
2556
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2557
                                }
2558
                                else
2559
                                {
2560
                                    currentControl = new RectangleControl
2561
                                    {
2562
                                        Background = new SolidColorBrush(Colors.Black),
2563
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2564
                                        ControlType = ControlType.Rectangle
2565
                                    };
2566

    
2567
                                    currentControl.CommentID = Commons.shortGuid();
2568
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2569
                                    currentControl.IsNew = true;
2570
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2571

    
2572
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2573
                                }
2574
                            }
2575
                        }
2576
                        break;
2577
                    case ControlType.RectCloud:
2578
                        {
2579
                            if (e.LeftButton == MouseButtonState.Pressed)
2580
                            {
2581
                                if (currentControl is RectCloudControl)
2582
                                {
2583
                                    //20180906 LJY TEST IsRotationDrawingEnable
2584
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2585
                                    {
2586
                                        return;
2587
                                    }
2588

    
2589
                                    CreateCommand.Instance.Execute(currentControl);
2590

    
2591
                                    currentControl = null;
2592
                                
2593
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2594
                                }
2595
                                else
2596
                                {
2597
                                    currentControl = new RectCloudControl
2598
                                    {
2599
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2600
                                        ControlType = ControlType.RectCloud,
2601
                                        Background = new SolidColorBrush(Colors.Black)
2602
                                    };
2603

    
2604
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2605
                                    currentControl.CommentID = Commons.shortGuid();
2606
                                    currentControl.IsNew = true;
2607
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2608
                                }
2609
                            }
2610
                        }
2611
                        break;
2612
                    case ControlType.Circle:
2613
                        {
2614
                            if (e.LeftButton == MouseButtonState.Pressed)
2615
                            {
2616
                                if (currentControl is CircleControl)
2617
                                {
2618
                                    //20180906 LJY TEST IsRotationDrawingEnable
2619
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2620
                                    {
2621
                                        return;
2622
                                    }
2623

    
2624
                                    CreateCommand.Instance.Execute(currentControl);
2625

    
2626
                                    currentControl = null;
2627
                                }
2628
                                else
2629
                                {
2630
                                    currentControl = new CircleControl
2631
                                    {
2632
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2633
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2634
                                        Background = new SolidColorBrush(Colors.Black)
2635
                                    };
2636

    
2637
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2638
                                    currentControl.CommentID = Commons.shortGuid();
2639
                                    currentControl.IsNew = true;
2640
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2641
                                }
2642
                            }
2643
                        }
2644
                        break;
2645
                    case ControlType.Triangle:
2646
                        {
2647
                            if (e.LeftButton == MouseButtonState.Pressed)
2648
                            {
2649
                                if (currentControl is TriControl)
2650
                                {
2651
                                    var content = currentControl as TriControl;
2652
                                    if (content.MidPoint == new Point(0, 0))
2653
                                    {
2654
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2655
                                    }
2656
                                    else
2657
                                    {
2658
                                        //20180906 LJY TEST IsRotationDrawingEnable
2659
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2660
                                        {
2661
                                            return;
2662
                                        }
2663

    
2664
                                        CreateCommand.Instance.Execute(currentControl);
2665

    
2666
                                        currentControl = null;
2667
                                    }
2668
                                }
2669
                                else
2670
                                {
2671
                                    currentControl = new TriControl
2672
                                    {
2673
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2674
                                        Background = new SolidColorBrush(Colors.Black),
2675
                                    };
2676

    
2677
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2678
                                    currentControl.CommentID = Commons.shortGuid();
2679
                                    currentControl.IsNew = true;
2680
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2681
                                }
2682
                            }
2683
                        }
2684
                        break;
2685
                    case ControlType.CancelLine:
2686
                    case ControlType.SingleLine:
2687
                    case ControlType.ArrowLine:
2688
                    case ControlType.TwinLine:
2689
                    case ControlType.DimLine:
2690
                        {
2691
                            if (e.LeftButton == MouseButtonState.Pressed)
2692
                            {
2693
                                if (currentControl is LineControl)
2694
                                {
2695
                                    //20180906 LJY TEST IsRotationDrawingEnable
2696
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2697
                                    {
2698
                                        return;
2699
                                    }
2700

    
2701
                                    CreateCommand.Instance.Execute(currentControl);
2702
                                    currentControl = null;
2703
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2704
                                }
2705
                                else
2706
                                {
2707
                                    currentControl = new LineControl
2708
                                    {
2709
                                        ControlType = this.controlType,
2710
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2711
                                        Background = new SolidColorBrush(Colors.Black)
2712
                                    };
2713

    
2714
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2715
                                    currentControl.CommentID = Commons.shortGuid();
2716
                                    currentControl.IsNew = true;
2717
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2718
                                    this.MainAngle.Visibility = Visibility.Visible;
2719
                                }
2720
                            }
2721
                        }
2722
                        break;
2723
                    case ControlType.PolygonControl:
2724
                        {
2725
                            if (currentControl is PolygonControl)
2726
                            {
2727
                                var control = currentControl as PolygonControl;
2728

    
2729
                                if (e.RightButton == MouseButtonState.Pressed)
2730
                                {
2731
                                    control.IsCompleted = true;
2732
                                }
2733

    
2734
                                if (!control.IsCompleted)
2735
                                {
2736
                                    control.PointSet.Add(control.EndPoint);
2737
                                }
2738
                                else
2739
                                {
2740
                                    //20180906 LJY TEST IsRotationDrawingEnable
2741
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2742
                                    {
2743
                                        return;
2744
                                    }
2745

    
2746
                                    var firstPoint = control.PointSet.First();
2747
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2748
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2749
                                    control.PointSet.Add(firstPoint);
2750

    
2751
                                    control.ApplyOverViewData();
2752

    
2753
                                    CreateCommand.Instance.Execute(currentControl);
2754
                                    control.UpdateControl();
2755
                                    currentControl = null;
2756
                                }
2757
                            }
2758
                            else
2759
                            {
2760
                                if (e.LeftButton == MouseButtonState.Pressed)
2761
                                {
2762
                                    currentControl = new PolygonControl
2763
                                    {
2764
                                        PointSet = new List<Point>(),
2765
                                    };
2766

    
2767
                                    var polygonControl = (currentControl as PolygonControl);
2768
                                    currentControl.CommentID = Commons.shortGuid();
2769
                                    currentControl.IsNew = true;
2770
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2771
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2772
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2773
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2774
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2775
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2776
                                    polygonControl.ApplyTemplate();
2777
                                    polygonControl.Visibility = Visibility.Visible;
2778
                                }
2779
                            }
2780
                        }
2781
                        break;
2782
                    case ControlType.ChainLine:
2783
                        {
2784
                            if (currentControl is PolygonControl)
2785
                            {
2786
                                var control = currentControl as PolygonControl;
2787

    
2788
                                if (e.RightButton == MouseButtonState.Pressed)
2789
                                {
2790
                                    //20180906 LJY TEST IsRotationDrawingEnable
2791
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2792
                                    {
2793
                                        return;
2794
                                    }
2795

    
2796
                                    CreateCommand.Instance.Execute(currentControl);
2797

    
2798
                                    currentControl = null;
2799
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2800
                                    return;
2801
                                }
2802

    
2803
                                if (!control.IsCompleted)
2804
                                {
2805
                                    control.PointSet.Add(control.EndPoint);
2806
                                    this.MainAngle.Visibility = Visibility.Visible;
2807
                                }
2808
                            }
2809
                            else
2810
                            {
2811
                                if (e.LeftButton == MouseButtonState.Pressed)
2812
                                {
2813
                                    MainAngle.Visibility = Visibility.Visible;
2814
                                    currentControl = new PolygonControl
2815
                                    {
2816
                                        PointSet = new List<Point>(),
2817
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2818
                                        ControlType = ControlType.ChainLine,
2819
                                        DashSize = ViewerDataModel.Instance.DashSize,
2820
                                        LineSize = ViewerDataModel.Instance.LineSize,
2821
                                        //PointC = new StylusPointSet()
2822
                                    };
2823

    
2824
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2825
                                    //{
2826
                                        var polygonControl = (currentControl as PolygonControl);
2827
                                        currentControl.CommentID = Commons.shortGuid();
2828
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2829
                                        currentControl.IsNew = true;
2830
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2831
                                        //currentControl.OnApplyTemplate();
2832
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2833
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2834
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2835
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2836
                                    //}
2837
                                }
2838
                            }
2839
                        }
2840
                        break;
2841
                    case ControlType.ArcLine:
2842
                        {
2843
                            if (e.LeftButton == MouseButtonState.Pressed)
2844
                            {
2845
                                if (currentControl is ArcControl)
2846
                                {
2847
                                    //20180906 LJY TEST IsRotationDrawingEnable
2848
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2849
                                    {
2850
                                        return;
2851
                                    }
2852

    
2853
                                    CreateCommand.Instance.Execute(currentControl);
2854

    
2855
                                    currentControl = null;
2856
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2857
                                }
2858
                                else
2859
                                {
2860
                                    currentControl = new ArcControl
2861
                                    {
2862
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2863
                                        Background = new SolidColorBrush(Colors.Black)
2864
                                    };
2865
                                    currentControl.CommentID = Commons.shortGuid();
2866
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2867
                                    currentControl.IsNew = true;
2868
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2869
                                    this.MainAngle.Visibility = Visibility.Visible;
2870
                                }
2871
                            }
2872
                            else if (e.RightButton == MouseButtonState.Pressed)
2873
                            {
2874
                                if (currentControl != null)
2875
                                {
2876
                                    (currentControl as ArcControl).setClock();
2877
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2878
                                }
2879
                            }
2880
                        }
2881
                        break;
2882
                    case ControlType.ArcArrow:
2883
                        {
2884
                            if (e.LeftButton == MouseButtonState.Pressed)
2885
                            {
2886
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2887
                                //{
2888
                                if (currentControl is ArrowArcControl)
2889
                                {
2890
                                    //20180906 LJY TEST IsRotationDrawingEnable
2891
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2892
                                    {
2893
                                        return;
2894
                                    }
2895

    
2896
                                    CreateCommand.Instance.Execute(currentControl);
2897

    
2898
                                    currentControl = null;
2899
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2900
                                }
2901
                                else
2902
                                {
2903
                                    currentControl = new ArrowArcControl
2904
                                    {
2905
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2906
                                        Background = new SolidColorBrush(Colors.Black)
2907
                                    };
2908
                                    currentControl.CommentID = Commons.shortGuid();
2909
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2910
                                    currentControl.IsNew = true;
2911
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2912
                                    this.MainAngle.Visibility = Visibility.Visible;
2913
                                }
2914
                                //}
2915
                            }
2916
                            else if (e.RightButton == MouseButtonState.Pressed)
2917
                            {
2918
                                if (currentControl != null)
2919
                                {
2920
                                    (currentControl as ArrowArcControl).setClock();
2921
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2922
                                    //(currentControl as ArcControl).ApplyTemplate();
2923
                                }
2924
                            }
2925
                        }
2926
                        break;
2927
                    case ControlType.ArrowMultiLine:
2928
                        {
2929
                            if (e.LeftButton == MouseButtonState.Pressed)
2930
                            {
2931
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2932
                                //{
2933

    
2934
                                    if (currentControl is ArrowControl_Multi)
2935
                                    {
2936
                                        var content = currentControl as ArrowControl_Multi;
2937
                                        if (content.MiddlePoint == new Point(0, 0))
2938
                                        {
2939
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2940
                                            {
2941
                                                content.MiddlePoint = content.EndPoint;
2942
                                            }
2943
                                            else
2944
                                            {
2945
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2946
                                            }
2947
                                        }
2948
                                        else
2949
                                        {
2950
                                            //20180906 LJY TEST IsRotationDrawingEnable
2951
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2952
                                            {
2953
                                                return;
2954
                                            }
2955

    
2956
                                            CreateCommand.Instance.Execute(currentControl);
2957

    
2958
                                            currentControl = null;
2959
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2960
                                        }
2961
                                    }
2962
                                    else
2963
                                    {
2964
                                        currentControl = new ArrowControl_Multi
2965
                                        {
2966
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2967
                                            Background = new SolidColorBrush(Colors.Black)
2968
                                        };
2969
                                        currentControl.CommentID = Commons.shortGuid();
2970
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2971
                                        currentControl.IsNew = true;
2972
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2973
                                        this.MainAngle.Visibility = Visibility.Visible;
2974
                                    }
2975
                                //}
2976
                            }
2977
                        }
2978
                        break;
2979
                    case ControlType.PolygonCloud:
2980
                        {
2981
                            if (currentControl is CloudControl)
2982
                            {
2983
                                var control = currentControl as CloudControl;
2984
                                if (e.RightButton == MouseButtonState.Pressed)
2985
                                {
2986
                                    control.IsCompleted = true;
2987
                                }
2988

    
2989
                                if (!control.IsCompleted)
2990
                                {
2991
                                    control.PointSet.Add(control.EndPoint);
2992
                                }
2993
                                else
2994
                                {
2995
                                    //20180906 LJY TEST IsRotationDrawingEnable
2996
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2997
                                    {
2998
                                        return;
2999
                                    }
3000

    
3001
                                    CreateCommand.Instance.Execute(currentControl);
3002

    
3003
                                    control.isTransOn = true;
3004
                                    var firstPoint = control.PointSet.First();
3005

    
3006
                                    control.PointSet.Add(firstPoint);
3007
                                    control.DrawingCloud();
3008
                                    control.ApplyOverViewData();
3009

    
3010
                                    currentControl = null;
3011
                                }
3012
                            }
3013
                            else
3014
                            {
3015
                                if (e.LeftButton == MouseButtonState.Pressed)
3016
                                {
3017
                                    currentControl = new CloudControl
3018
                                    {
3019
                                        PointSet = new List<Point>(),
3020
                                        PointC = new StylusPointSet()
3021
                                    };
3022

    
3023
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3024
                                    //{
3025
                                        var polygonControl = (currentControl as CloudControl);
3026
                                        currentControl.CommentID = Commons.shortGuid();
3027
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3028
                                        currentControl.IsNew = true;
3029
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3030

    
3031
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3032
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3033
                                    
3034
                                    //}
3035
                                }
3036
                            }
3037
                        }
3038
                        break;
3039
                    case ControlType.ImgControl:
3040
                        {
3041
                            if (e.LeftButton == MouseButtonState.Pressed)
3042
                            {
3043
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3044
                                //{
3045
                                    if (currentControl is ImgControl)
3046
                                    {
3047
                                        //20180906 LJY TEST IsRotationDrawingEnable
3048
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3049
                                        {
3050
                                            return;
3051
                                        }
3052

    
3053
                                        CreateCommand.Instance.Execute(currentControl);
3054
                                        controlType = ControlType.ImgControl;
3055
                                        currentControl = null;
3056
                                    }
3057
                                    else
3058
                                    {
3059
                                        
3060
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3061
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3062
                                        {
3063
                                            Image img = new Image();
3064
                                            if (filename.Contains(".svg"))
3065
                                            {
3066
                                                byte[] imageData = null;
3067
                                                DrawingImage image = null;
3068
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3069
                                                {
3070
                                                    imageData = web.DownloadData(new Uri(filename));
3071
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3072
                                                    image = SvgReader.Load(stream);
3073
                                                }
3074
                                                img.Source = image;
3075
                                            }
3076
                                            else
3077
                                            {
3078
                                                img.Source = new BitmapImage(new Uri(filename));
3079
                                            }
3080

    
3081
                                            currentControl = new ImgControl
3082
                                            {
3083
                                                    Background = new SolidColorBrush(Colors.Black),
3084
                                                    PointSet = new List<Point>(),
3085
                                                    FilePath = filename,
3086
                                                    ImageData = img.Source,
3087
                                                    StartPoint = canvasDrawingMouseDownPoint,
3088
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3089
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3090
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3091
                                                    ControlType = ControlType.ImgControl
3092
                                                };
3093

    
3094
                                        
3095
                                                currentControl.CommentID = Commons.shortGuid();                                            
3096
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3097
                                                currentControl.IsNew = true;
3098
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3099

    
3100
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3101
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3102
                                        }
3103
                                    }
3104
                                //}
3105
                            }
3106
                        }
3107
                        break;
3108
                    case ControlType.Date:
3109
                        {
3110
                            if (e.LeftButton == MouseButtonState.Pressed)
3111
                            {
3112
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3113
                                //{
3114
                                    if (currentControl is DateControl)
3115
                                    {
3116
                                        //20180906 LJY TEST IsRotationDrawingEnable
3117
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3118
                                        {
3119
                                            return;
3120
                                        }
3121

    
3122
                                        CreateCommand.Instance.Execute(currentControl);
3123
                                        currentControl = null;
3124

    
3125
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3126
                                        {
3127
                                            controlType = ControlType.None;
3128
                                            IsSwingMode = false;
3129
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3130
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3131
                                            mouseHandlingMode = MouseHandlingMode.None;
3132
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3133
                                            txtBatch.Visibility = Visibility.Collapsed;
3134

    
3135
                                        }
3136
                                    }
3137
                                    else
3138
                                    {
3139
                                        currentControl = new DateControl
3140
                                        {
3141
                                            StartPoint = canvasDrawingMouseDownPoint,
3142
                                            Background = new SolidColorBrush(Colors.Black)
3143
                                        };
3144
                                        currentControl.CommentID = Commons.shortGuid();
3145
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3146
                                        currentControl.IsNew = true;
3147
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3148

    
3149
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3150
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3151
                                }
3152
                                //}
3153
                            }
3154
                        }
3155
                        break;
3156
                    case ControlType.TextControl:
3157
                        {
3158
                            if (e.LeftButton == MouseButtonState.Pressed)
3159
                            {
3160
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3161
                                {
3162
                                    currentControl = new TextControl
3163
                                    {
3164
                                        ControlType = controlType
3165
                                    };
3166
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3167
                                    currentControl.CommentID = Commons.shortGuid();
3168
                                    currentControl.IsNew = true;
3169
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3170
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3171
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3172

    
3173
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3174
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3175
                                    
3176
                                    (currentControl as TextControl).ControlType_No = 0;
3177
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3178
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3179
                                    (currentControl as TextControl).ApplyTemplate();
3180
                                    (currentControl as TextControl).Base_TextBox.Focus();
3181

    
3182
                                    CreateCommand.Instance.Execute(currentControl);
3183
                                }
3184
                            }
3185
                        }
3186
                        break;
3187
                    case ControlType.TextBorder:
3188
                        {
3189
                            if (e.LeftButton == MouseButtonState.Pressed)
3190
                            {
3191
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3192
                                {
3193
                                    currentControl = new TextControl
3194
                                    {
3195
                                        ControlType = controlType
3196
                                    };
3197

    
3198
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3199
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3200
                                    currentControl.CommentID = Commons.shortGuid();
3201
                                    currentControl.IsNew = true;
3202
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3203
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3204
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3205
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3206
                                    
3207
                                    (currentControl as TextControl).ControlType_No = 1;
3208
                                    (currentControl as TextControl).Angle = Ang;
3209
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3210
                                    (currentControl as TextControl).ApplyTemplate();
3211
                                    (currentControl as TextControl).Base_TextBox.Focus();
3212
                                    CreateCommand.Instance.Execute(currentControl);
3213
                                }
3214
                            }
3215
                        }
3216
                        break;
3217
                    case ControlType.TextCloud:
3218
                        {
3219
                            if (e.LeftButton == MouseButtonState.Pressed)
3220
                            {
3221
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3222
                                {
3223
                                    currentControl = new TextControl
3224
                                    {
3225
                                        ControlType = controlType
3226
                                    };
3227

    
3228
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3229
                                    currentControl.CommentID = Commons.shortGuid();
3230
                                    currentControl.IsNew = true;
3231
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3232
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3233

    
3234
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3235
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3236
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3237

    
3238
                                    (currentControl as TextControl).Angle = Ang;
3239
                                    (currentControl as TextControl).ControlType_No = 2;
3240
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3241
                                    (currentControl as TextControl).ApplyTemplate();
3242
                                    (currentControl as TextControl).Base_TextBox.Focus();
3243
                                    CreateCommand.Instance.Execute(currentControl);
3244
                                    //currentControl = null;
3245
                                }
3246
                            }
3247
                        }
3248
                        break;
3249
                    case ControlType.ArrowTextControl:
3250
                         {
3251
                            if (e.LeftButton == MouseButtonState.Pressed)
3252
                            {
3253
                                if (currentControl is ArrowTextControl)
3254
                                {
3255
                                    //20180906 LJY TEST IsRotationDrawingEnable
3256
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3257
                                    {
3258
                                        return;
3259
                                    }
3260

    
3261
                                    CreateCommand.Instance.Execute(currentControl);
3262

    
3263
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3264
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3265
                                    (currentControl as ArrowTextControl).IsNew = false;
3266
                                    currentControl = null;
3267
                                }
3268
                                else
3269
                                {
3270
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3271
                                    //{
3272
                                        currentControl = new ArrowTextControl();
3273
                                        currentControl.CommentID = Commons.shortGuid();
3274
                                        currentControl.IsNew = true;
3275
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3276
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3277

    
3278
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3279
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3280
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3281
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3282
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3283

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

    
3287
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3288
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3289
                                        this.MainAngle.Visibility = Visibility.Visible;
3290

    
3291
                                    
3292
                                    //}
3293
                                }
3294
                            }
3295
                        }
3296
                        break;
3297
                    case ControlType.ArrowTransTextControl:
3298
                        {
3299
                            if (e.LeftButton == MouseButtonState.Pressed)
3300
                            {
3301
                                if (currentControl is ArrowTextControl)
3302
                                {
3303
                                    //20180906 LJY TEST IsRotationDrawingEnable
3304
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3305
                                    {
3306
                                        return;
3307
                                    }
3308

    
3309
                                    CreateCommand.Instance.Execute(currentControl);
3310
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3311
                                    currentControl.IsNew = false;
3312
                                    currentControl = null;
3313
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3314
                                }
3315
                                else
3316
                                {
3317
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3318
                                    //{
3319
                                    currentControl = new ArrowTextControl()
3320
                                    {
3321
                                        ControlType = ControlType.ArrowTransTextControl
3322
                                    };
3323
                                    currentControl.CommentID = Commons.shortGuid();
3324
                                    currentControl.IsNew = true;
3325
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3326
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3327
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3328
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3329
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3330
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3331
                                    (currentControl as ArrowTextControl).isFixed = true;
3332
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3333

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

    
3337
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3338
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3339
                                    (currentControl as ArrowTextControl).isTrans = true;
3340
                                }
3341
                            }
3342
                        }
3343
                        break;
3344
                    case ControlType.ArrowTextBorderControl:
3345
                         {
3346
                            if (e.LeftButton == MouseButtonState.Pressed)
3347
                            {
3348
                                if (currentControl is ArrowTextControl)
3349
                                {
3350
                                    //20180906 LJY TEST IsRotationDrawingEnable
3351
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3352
                                    {
3353
                                        return;
3354
                                    }
3355

    
3356
                                    CreateCommand.Instance.Execute(currentControl);
3357
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3358
                                    currentControl.IsNew = false;
3359
                                    currentControl = null;
3360
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3361
                                }
3362
                                else
3363
                                {
3364
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3365
                                    //{
3366
                                        currentControl = new ArrowTextControl()
3367
                                        {
3368
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3369
                                        };
3370
                                        currentControl.CommentID = Commons.shortGuid();
3371
                                        currentControl.IsNew = true;
3372
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3373
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3374

    
3375
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3376

    
3377
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3378

    
3379
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3380
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3381
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3382

    
3383
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3384
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3385
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3386
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3387
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3388
                                    //}
3389
                                }
3390
                            }
3391
                        }
3392
                        break;
3393
                    case ControlType.ArrowTransTextBorderControl:
3394
                        {
3395
                            if (e.LeftButton == MouseButtonState.Pressed)
3396
                            {
3397
                                if (currentControl is ArrowTextControl)
3398
                                {
3399
                                    //20180906 LJY TEST IsRotationDrawingEnable
3400
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3401
                                    {
3402
                                        return;
3403
                                    }
3404
                                    CreateCommand.Instance.Execute(currentControl);
3405
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3406
                                    currentControl.IsNew = false;
3407
                                    currentControl = null;
3408
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3409
                                }
3410
                                else
3411
                                {
3412
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3413
                                    //{
3414
                                    
3415

    
3416
                                    currentControl = new ArrowTextControl()
3417
                                    {
3418
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3419
                                        ControlType = ControlType.ArrowTransTextBorderControl
3420

    
3421
                                    };
3422
                                        currentControl.CommentID = Commons.shortGuid();
3423
                                        currentControl.IsNew = true;
3424
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3425
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3426

    
3427
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3428

    
3429
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3430
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3431
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3432
                                        (currentControl as ArrowTextControl).isFixed = true;
3433
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3434
                                     
3435
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3436
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3437
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3438

    
3439
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3440
                                        this.MainAngle.Visibility = Visibility.Visible;
3441
                                    
3442
                                    //20180911 LJY
3443
                                        (currentControl as ArrowTextControl).isTrans = true;
3444
                                    
3445

    
3446
                                    //}
3447
                                }
3448
                            }
3449
                        }
3450
                        break;
3451
                    case ControlType.ArrowTextCloudControl:
3452
                        {
3453
                            if (e.LeftButton == MouseButtonState.Pressed)
3454
                            {
3455
                                if (currentControl is ArrowTextControl)
3456
                                {
3457
                                    //20180906 LJY TEST IsRotationDrawingEnable
3458
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3459
                                    {
3460
                                        return;
3461
                                    }
3462
                                    CreateCommand.Instance.Execute(currentControl);
3463
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3464
                                    currentControl.IsNew = false;
3465
                                    currentControl = null;
3466
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3467
                                }
3468
                                else
3469
                                {
3470
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3471
                                    //{
3472
                                        currentControl = new ArrowTextControl()
3473
                                        {
3474
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3475
                                        };
3476
                                        currentControl.CommentID = Commons.shortGuid();
3477
                                        currentControl.IsNew = true;
3478
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3479
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3480

    
3481
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3482
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3483
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3484
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3485
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3486

    
3487
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3488
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3489
                                    
3490
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3491
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3492
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3493
                                    //}
3494
                                }
3495
                            }
3496
                        }
3497
                        break;
3498
                    case ControlType.ArrowTransTextCloudControl:
3499
                        {
3500
                            if (e.LeftButton == MouseButtonState.Pressed)
3501
                            {
3502
                                if (currentControl is ArrowTextControl)
3503
                                {
3504
                                    //20180906 LJY TEST IsRotationDrawingEnable
3505
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3506
                                    {
3507
                                        return;
3508
                                    }
3509
                                    CreateCommand.Instance.Execute(currentControl);
3510
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3511
                                    currentControl.IsNew = false;
3512
                                    currentControl = null;
3513
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3514
                                }
3515
                                else
3516
                                {
3517
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3518
                                    //{
3519
                                        currentControl = new ArrowTextControl()
3520
                                        {
3521
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3522
                                            ControlType = ControlType.ArrowTransTextCloudControl
3523

    
3524
                                        };
3525
                                        currentControl.CommentID = Commons.shortGuid();
3526
                                        currentControl.IsNew = true; 
3527
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3528
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3530

    
3531
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3532
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3533
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3534
                                        (currentControl as ArrowTextControl).isFixed = true;
3535
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3536

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

    
3540
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3541
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3542
                                        this.MainAngle.Visibility = Visibility.Visible;  
3543
                                    
3544
                                    //20180911 LJY
3545
                                        (currentControl as ArrowTextControl).isTrans = true;
3546
                                    //}
3547
                                }
3548
                            }
3549
                        }
3550
                        break;
3551
                    //강인구 추가
3552
                    case ControlType.Sign:
3553
                        {
3554
                            if (e.LeftButton == MouseButtonState.Pressed)
3555
                            {
3556
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3557
                                //{
3558
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3559

    
3560
                                    if (_sign == null)
3561
                                    {
3562
                                        txtBatch.Visibility = Visibility.Collapsed;
3563
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3564
                                        controlType = ControlType.None;
3565

    
3566
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3567
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3568
                                        return;
3569
                                    }
3570

    
3571
                                    if (currentControl is SignControl)
3572
                                    {
3573
                                        //20180906 LJY TEST IsRotationDrawingEnable
3574
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3575
                                        {
3576
                                            return;
3577
                                        }
3578

    
3579
                                        CreateCommand.Instance.Execute(currentControl);
3580
                                        currentControl = null;
3581
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3582
                                        {
3583
                                            txtBatch.Text = "Place Date";
3584
                                            controlType = ControlType.Date;
3585
                                        }
3586
                                    }
3587
                                    else
3588
                                    {
3589
                                        currentControl = new SignControl
3590
                                        {
3591
                                            Background = new SolidColorBrush(Colors.Black),
3592
                                            UserNumber = App.ViewInfo.UserID,
3593
                                            ProjectNO = App.ViewInfo.ProjectNO,
3594
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3595
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3596
                                            ControlType = ControlType.Sign
3597
                                        };
3598

    
3599
                                        currentControl.CommentID = Commons.shortGuid();
3600
                                        currentControl.IsNew = true;
3601
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3602
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3603

    
3604
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3605
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3606
                                }
3607
                                //}
3608
                            }
3609
                        }
3610
                        break;
3611
                    case ControlType.Mark:
3612
                        {
3613
                            if (e.LeftButton == MouseButtonState.Pressed)
3614
                            {
3615
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3616
                                //{
3617
                                    if (currentControl is RectangleControl)
3618
                                    {
3619
                                        //20180906 LJY TEST IsRotationDrawingEnable
3620
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3621
                                        {
3622
                                            return;
3623
                                        }
3624

    
3625
                                        CreateCommand.Instance.Execute(currentControl);
3626
                                        (currentControl as RectangleControl).ApplyOverViewData();
3627
                                        currentControl = null;
3628
                                    
3629
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3630

    
3631
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3632
                                        {
3633
                                            txtBatch.Text = "Place Signature";
3634
                                            controlType = ControlType.Sign;
3635
                                        }
3636
                                    }
3637
                                    else
3638
                                    {
3639
                                        currentControl = new RectangleControl
3640
                                        {
3641
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3642
                                            Background = new SolidColorBrush(Colors.Black),
3643
                                            ControlType = ControlType.Mark ,
3644
                                            Paint = PaintSet.Fill
3645
                                        };
3646

    
3647
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3648
                                        currentControl.CommentID = Commons.shortGuid();
3649
                                        currentControl.IsNew = true;
3650
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3651
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3652
                                    }
3653
                                //}
3654
                            }
3655
                        }
3656
                        break;
3657
                    case ControlType.Symbol:
3658
                        {
3659
                            if (e.LeftButton == MouseButtonState.Pressed)
3660
                            {
3661
                                if (currentControl is SymControl)
3662
                                {
3663
                                    //20180906 LJY TEST IsRotationDrawingEnable
3664
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3665
                                    {
3666
                                        return;
3667
                                    }
3668
                                    CreateCommand.Instance.Execute(currentControl);
3669
                                    currentControl = null;
3670
                                
3671
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3672
                                }
3673
                                else
3674
                                {
3675
                                    currentControl = new SymControl
3676
                                    {
3677
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3678
                                        Background = new SolidColorBrush(Colors.Black),
3679
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3680
                                        ControlType = ControlType.Symbol
3681
                                    };
3682

    
3683
                                    currentControl.IsNew = true;
3684
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3685
                                    currentControl.CommentID = Commons.shortGuid();
3686
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3687

    
3688
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3689
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3690
                                }
3691
                                //}
3692
                            }
3693
                        }
3694
                        break;
3695
                    case ControlType.Stamp:
3696
                        {
3697
                            if (e.LeftButton == MouseButtonState.Pressed)
3698
                            {
3699
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3700
                                //{
3701
                                    if (currentControl is SymControlN)
3702
                                    {
3703
                                        //20180906 LJY TEST IsRotationDrawingEnable
3704
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3705
                                        {
3706
                                            return;
3707
                                        }
3708

    
3709
                                        CreateCommand.Instance.Execute(currentControl);
3710
                                        currentControl = null;
3711
                                   
3712

    
3713
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3714
                                    }
3715
                                    else
3716
                                    {
3717
                                        currentControl = new SymControlN
3718
                                        {
3719
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3720
                                            Background = new SolidColorBrush(Colors.Black),
3721
                                            STAMP = App.SystemInfo.STAMP,
3722
                                            ControlType = ControlType.Stamp
3723
                                        };
3724

    
3725
                                        currentControl.IsNew = true;
3726
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3727
                                        currentControl.CommentID = Commons.shortGuid();
3728
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3729
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3730
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3731
                                }                                    
3732
                                //}
3733
                            }
3734
                        }
3735
                        break;
3736
                    case ControlType.PenControl:
3737
                        {
3738
                            if (inkBoard.Tag.ToString() == "Ink")
3739
                            {
3740
                                inkBoard.IsEnabled = true;
3741
                                StartNewStroke(canvasDrawingMouseDownPoint);
3742
                            }
3743
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3744
                            {
3745
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3746
                            }
3747
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3748
                            {
3749
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3750
                            }
3751
                            IsDrawing = true;
3752
                            return;
3753
                        }
3754
                    default:
3755
                        if (currentControl != null)
3756
                        {
3757
                            currentControl.CommentID = null;
3758
                            currentControl.IsNew = false;
3759
                        }
3760
                        break;
3761
                }
3762
            }
3763
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3764
            {
3765
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3766
                {
3767
                    bool mouseOff = false;
3768
                    foreach (var item in SelectLayer.Children)
3769
                    {
3770
                        if (item is AdornerFinal)
3771
                        {
3772

    
3773
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3774
                            if (over != null)
3775
                            {
3776
                                mouseOff = true;
3777
                            }
3778
                        }
3779
                    }
3780

    
3781
                    if (!mouseOff)
3782
                    {
3783
                        SelectionSet.Instance.UnSelect(this);
3784
                    }
3785
                }
3786
                zoomAndPanControl.CaptureMouse();
3787
                e.Handled = true;
3788
            }
3789
        }
3790

    
3791
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3792
        {
3793
            ///mouseButtonDown = e.ChangedButton;
3794
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3795
        }
3796

    
3797
        private void RemoveLineStroke(Point P)
3798
        {
3799
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3800
            if (control != null)
3801
            {
3802
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3803
            }
3804
        }
3805

    
3806
        private void RemovePointStroke(Point P)
3807
        {
3808
            foreach (Stroke hits in inkBoard.Strokes)
3809
            {
3810
                foreach (StylusPoint sty in hits.StylusPoints)
3811
                {
3812

    
3813
                }
3814
                if (hits.HitTest(P))
3815
                {
3816
                    inkBoard.Strokes.Remove(hits);
3817
                    return;
3818
                }
3819
            }
3820
        }
3821

    
3822
        private void StartNewStroke(Point P)
3823
        {
3824
            strokePoints = new StylusPointCollection();
3825
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3826
            strokePoints.Add(segment1Start);
3827
            stroke = new Stroke(strokePoints);
3828

    
3829
            stroke.DrawingAttributes.Color = Colors.Red;
3830
            stroke.DrawingAttributes.Width = 4;
3831
            stroke.DrawingAttributes.Height = 4;
3832

    
3833
            inkBoard.Strokes.Add(stroke);
3834
        }
3835

    
3836
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3837
        {
3838
            ConsolidationMethod();
3839
        }
3840

    
3841
        /// <summary>
3842
        /// execute TeamConsolidationCommand
3843
        /// </summary>
3844
        public void TeamConsolidationMethod()
3845
        {
3846
            this.UpdateMyMarkupList();
3847
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3848
            {
3849
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3850
            }
3851
            else
3852
            {
3853

    
3854
                ViewerDataModel.Instance.IsConsolidate = true;
3855
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3856

    
3857
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3858
                {
3859
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3860
                    {
3861
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3862
                        return;
3863
                    }                    
3864
                }
3865
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3866
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3867
                {
3868
                    MarkupInfoList.Add(item);
3869
                }
3870
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3871
            }
3872
        }
3873

    
3874
        public void ConsolidationMethod()
3875
        {
3876
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3877
            {
3878
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3879
            }
3880
            else
3881
            {
3882
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3883
                foreach (var item in this.gridViewMarkup.SelectedItems)
3884
                {
3885
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3886
                }
3887
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3888
                
3889
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3890
            }
3891
        }
3892

    
3893
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3894
        {
3895
            if (App.ViewInfo != null)
3896
            {
3897
                btnConsolidate = (sender as RadRibbonButton);
3898
                if (!App.ViewInfo.NewCommentPermission)
3899
                {
3900
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3901
                }
3902
            }
3903
        }
3904

    
3905
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3906
        {
3907
            TeamConsolidationMethod();
3908
        }
3909

    
3910
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3911
        {
3912
            btnTeamConsolidate = sender as RadRibbonButton;
3913
            if (App.ViewInfo != null)
3914
            {
3915
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3916
                {
3917
                    if (btnConsolidate != null)
3918
                    {
3919
                        btnConsolidate.Visibility = Visibility.Collapsed;
3920
                    }
3921

    
3922
                    if (!App.ViewInfo.NewCommentPermission)
3923
                    {
3924
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3925
                    }
3926
                }
3927
                else
3928
                {
3929
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3930
                }
3931
            }
3932
        }
3933

    
3934
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3935
        {
3936
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3937
            if (item != null)
3938
            {
3939
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3940

    
3941
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3942
            }
3943
            else
3944
            {
3945
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3946
            }
3947
        }
3948

    
3949
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3950
        {
3951
            btnFinalPDF = sender as RadRibbonButton;
3952
            if (App.ViewInfo != null)
3953
            {
3954
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3955
                {
3956
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3957
                    if (btnConsolidate != null)
3958
                    {
3959
                        btnConsolidate.Visibility = Visibility.Collapsed;
3960
                    }
3961
                }
3962
            }
3963
        }
3964

    
3965
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3966
        {
3967
            UpdateMyMarkupList();
3968

    
3969
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3970
            {
3971
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3972
            }
3973
            else
3974
            {
3975
                ViewerDataModel.Instance.IsConsolidate = true;
3976
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3977
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3978

    
3979
                string project_no = App.ViewInfo.ProjectNO;
3980
                string doc_id = _DocInfo.ID;
3981
                string user_id = App.ViewInfo.UserID;
3982
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3983
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3984
                {
3985
                    markupInfoItems.Add(item);
3986
                }
3987
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3988
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3989
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3990
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3991

    
3992
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3993
                if (item2 != null)
3994
                {
3995
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3996

    
3997
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
3998
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
3999
                }
4000
                else
4001
                {
4002
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4003
                }
4004
            }
4005
        }
4006

    
4007
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4008
        {
4009
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4010

    
4011
            if (App.ViewInfo != null)
4012
            {
4013
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4014
                {
4015
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4016
                }
4017
            }
4018
        }
4019

    
4020
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4021
        {
4022
            if (CompareMode.IsChecked)
4023
            {
4024
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4025
                {
4026
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4027
                }
4028
                if (ViewerDataModel.Instance.PageNumber == 0)
4029
                {
4030
                    ViewerDataModel.Instance.PageNumber = 1;
4031
                }
4032

    
4033
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4034
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4035
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4036

    
4037
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4038
            }
4039
            else
4040
            {
4041
                da.From = 1;
4042
                da.To = 1;
4043
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4044
                da.AutoReverse = false;
4045
                canvas_compareBorder.Children.Clear();
4046
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4047
            }
4048
        }
4049

    
4050
        private void Sync_Click(object sender, RoutedEventArgs e)
4051
        {
4052
            if (Sync.IsChecked)
4053
            {
4054
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4055
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4056
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4057
            }
4058
        }
4059

    
4060
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4061
        {
4062
            if (UserList.IsChecked)
4063
            {
4064
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4065
            }
4066
            else
4067
            {
4068
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4069
            }
4070
        }
4071

    
4072
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4073
        {
4074

    
4075
            if (BalanceMode.IsChecked)
4076
            {
4077
                ViewerDataModel.Instance.PageBalanceMode = true;
4078
            }
4079
            else
4080
            {
4081
                ViewerDataModel.Instance.PageBalanceMode = false;
4082
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4083
            }
4084
        }
4085

    
4086
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4087
        {
4088
            //초기화
4089
            testPanel2.IsHidden = true;
4090
            ViewerDataModel.Instance.PageBalanceMode = false;
4091
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4092
            ViewerDataModel.Instance.PageNumber = 0;
4093
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4094
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4095
            UserList.IsChecked = false;
4096
            BalanceMode.IsChecked = false;
4097
        }
4098

    
4099
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4100
        {
4101
            if ((sender as System.Windows.Controls.Control).Tag != null)
4102
            {
4103
                //Compare 초기화
4104
                CompareMode.IsChecked = false;
4105
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4106

    
4107
                if (ViewerDataModel.Instance.PageNumber == 0)
4108
                {
4109
                    ViewerDataModel.Instance.PageNumber = 1;
4110
                }
4111

    
4112
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4113
                {
4114
                }
4115
                else
4116
                {
4117
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4118
                }
4119

    
4120
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4121
                {
4122

    
4123
                }
4124
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4125
                {
4126
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4127
                }
4128

    
4129
                if (!testPanel2.IsHidden)
4130
                {
4131
                    if (IsSyncPDFMode)
4132
                    {
4133
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4134
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4135

    
4136
                        if (pdfpath.IsDownloading)
4137
                        {
4138
                            pdfpath.DownloadCompleted += (ex, arg) =>
4139
                            {
4140
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4141
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4142
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4143
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4144
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4145
                            };
4146
                        }
4147
                        else
4148
                        {
4149
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4150
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4151
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4152

    
4153
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4154
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4155
                        }
4156

    
4157
                    }
4158
                    else
4159
                    {
4160
                        string uri = "";
4161

    
4162
                        if (userData.COMPANY != "EXT")
4163
                        {
4164
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4165
                        }
4166
                        else
4167
                        {
4168
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4169
                        }
4170

    
4171
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4172

    
4173
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4174
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4175
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4176

    
4177
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4178
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4179

    
4180
                        if (defaultBitmapImage_Compare.IsDownloading)
4181
                        {
4182
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4183
                            {
4184
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4185
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4186
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4187

    
4188
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4189
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4190
                            };
4191
                        }
4192
                    }
4193

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

    
4198
                    foreach (var item in gridSelectionRevItem)
4199
                    {
4200
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4201
                        {
4202
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4203
                        });
4204
                    }
4205

    
4206
                    //강인구 추가
4207
                    zoomAndPanControl2.ZoomTo(new Rect
4208
                    {
4209
                        X = 0,
4210
                        Y = 0,
4211
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4212
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4213
                    });
4214

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

    
4217
                }
4218
            }
4219
        }
4220

    
4221
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4222
        {
4223
            if (MarkupMode.IsChecked)
4224
            {
4225
                IsSyncPDFMode = true;
4226

    
4227
                var uri = CurrentRev.TO_VENDOR;
4228

    
4229
                if (ViewerDataModel.Instance.PageNumber == 0)
4230
                {
4231
                    ViewerDataModel.Instance.PageNumber = 1;
4232
                }
4233

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

    
4238
                if (pdfpath.IsDownloading)
4239
                {
4240
                    pdfpath.DownloadCompleted += (ex, arg) =>
4241
                    {
4242
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4243
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4244
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4245
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4246
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4247
                    };
4248
                }
4249
                else
4250
                {
4251
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4252
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4253
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4254

    
4255
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4256
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4257
                }
4258
            }
4259
            else
4260
            {
4261
                IsSyncPDFMode = false;
4262
                string uri = "";
4263
                if (userData.COMPANY != "EXT")
4264
                {
4265
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4266
                }
4267
                else
4268
                {
4269
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4270
                }
4271

    
4272
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4273

    
4274
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4275
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4276
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4277

    
4278
                if (defaultBitmapImage_Compare.IsDownloading)
4279
                {
4280
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4281
                    {
4282
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4283
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4284
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4285
                    };
4286
                }
4287
                zoomAndPanControl2.ApplyTemplate();
4288
                zoomAndPanControl2.UpdateLayout();
4289
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4290
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4291
            }
4292
        }
4293

    
4294
        private void RadButton_Click(object sender, RoutedEventArgs e)
4295
        {
4296
            gridViewHistory_Busy.IsBusy = true;
4297

    
4298
            RadButton instance = sender as RadButton;
4299
            if (instance.CommandParameter != null)
4300
            {
4301
                CurrentRev = instance.CommandParameter as VPRevision;
4302
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4303
                {
4304
                    if (ea.Error == null && ea.Result != null)
4305
                    {
4306
                        testPanel2.IsHidden = false;
4307

    
4308
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4309
                        foreach(var info in ea.Result)
4310
                        {
4311
                            if(info.UserID == App.ViewInfo.UserID)
4312
                            {
4313
                                info.userDelete = true;
4314
                                info.DisplayColor = "FFFF0000";
4315
                            }
4316
                            else
4317
                            {
4318
                                info.userDelete = false;
4319
                            }
4320
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4321
                        }
4322
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4323

    
4324
                        string uri = "";
4325
                        if (userData.COMPANY != "EXT")
4326
                        {
4327
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4328
                        }
4329
                        else
4330
                        {
4331
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4332
                        }
4333

    
4334
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4335

    
4336
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4337

    
4338
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4339
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4340
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4341

    
4342
                        if (defaultBitmapImage_Compare.IsDownloading)
4343
                        {
4344
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4345
                            {
4346
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4347
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4348
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4349
                            };
4350
                        }
4351

    
4352
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4353
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4354
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4355
                        zoomAndPanControl2.ApplyTemplate();
4356
                        zoomAndPanControl2.UpdateLayout();
4357

    
4358
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4359
                        {
4360
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4361
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4362
                        }
4363

    
4364
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4365
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4366
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4367

    
4368
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4369
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4370
                        gridViewHistory_Busy.IsBusy = false;
4371
                    }
4372

    
4373
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4374
                };
4375
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4376
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4377
            }
4378
        }
4379

    
4380
        public void Sync_Event(VPRevision Currnet_Rev)
4381
        {
4382
            CurrentRev = Currnet_Rev;
4383

    
4384
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4385
            {
4386
                if (ea.Error == null && ea.Result != null)
4387
                {
4388
                    testPanel2.IsHidden = false;
4389

    
4390
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4391
                    foreach(var info in ea.Result)
4392
                    {
4393
                        if(info.UserID == App.ViewInfo.UserID)
4394
                        {
4395
                            info.userDelete = true;
4396
                            info.DisplayColor = "FFFF0000";
4397
                        }
4398
                        else
4399
                        {
4400
                            info.userDelete = false;
4401
                        }
4402
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4403
                    }
4404
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4405

    
4406
                    string uri = "";
4407
                    if (userData.COMPANY != "EXT")
4408
                    {
4409
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4410
                    }
4411
                    else
4412
                    {
4413
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4414
                    }
4415

    
4416
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4417

    
4418
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4419

    
4420
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4421
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4422
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4423

    
4424
                    if (defaultBitmapImage_Compare.IsDownloading)
4425
                    {
4426
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4427
                        {
4428
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4429
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4430
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4431
                        };
4432
                    }
4433

    
4434

    
4435
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4436
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4437
                    zoomAndPanControl2.ApplyTemplate();
4438
                    zoomAndPanControl2.UpdateLayout();
4439

    
4440
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4441
                    {
4442
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4443
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4444
                    }
4445
                    //}
4446

    
4447
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4448
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4449
                    gridViewHistory_Busy.IsBusy = false;
4450
                }
4451
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4452

    
4453
            };
4454
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4455
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4456
        }
4457

    
4458
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4459
        {
4460
            if (sender is Image)
4461
            {
4462
                if ((sender as Image).Tag != null)
4463
                {
4464
                    var pdfUrl = (sender as Image).Tag.ToString();
4465
                    System.Diagnostics.Process.Start(pdfUrl);
4466
                }
4467
                else
4468
                {
4469
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4470
                }
4471
            }
4472
        }
4473

    
4474
        private void Create_Symbol(object sender, RoutedEventArgs e)
4475
        {
4476
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4477

    
4478
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4479
            {
4480
                DialogMessage_Alert("Please Select Controls", "Alert");
4481
            }
4482
            else //선택된 것이 있으면
4483
            {
4484
                string MarkupData = "";
4485
                adorner_ = new AdornerFinal();
4486

    
4487
                foreach (var item in SelectLayer.Children)
4488
                {
4489
                    if (item.GetType().Name == "AdornerFinal")
4490
                    {
4491
                        adorner_ = (item as Controls.AdornerFinal);
4492
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4493
                        {
4494
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4495
                            {
4496
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4497
                                MarkupData += markupReturn.ConvertData;
4498
                            }
4499
                        }
4500
                    }
4501
                }
4502
                DialogParameters parameters = new DialogParameters()
4503
                {
4504
                    Owner = Application.Current.MainWindow,
4505
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4506
                    DefaultPromptResultValue = "Custom State",
4507
                    Content = "Name :",
4508
                    Header = "Insert Custom Symbol Name",
4509
                    Theme = new VisualStudio2013Theme(),
4510
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4511
                };
4512
                RadWindow.Prompt(parameters);
4513
            }
4514

    
4515
        }
4516
        public int symbolselectindex = 0;
4517
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4518
        {
4519
            //Save save = new Save();
4520
            try
4521
            {
4522
                string svgfilename = null;
4523
                if (symbolname != null)
4524
                {
4525
                    if (symbolpng == true || symbolsvg == true)
4526
                    {
4527
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4528
                        string guid = Commons.shortGuid();
4529

    
4530
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4531
                        //Check_Uri.UriCheck();
4532
                        fileUploader.RunCompleted += (ex, arg) =>
4533
                        {
4534
                            filename = arg.Result;
4535
                            if (symbolpng == true)
4536
                            {
4537
                                if (filename != null)
4538
                                { 
4539
                                    if (symbolselectindex == 0)
4540
                                    {
4541
                                        SymbolSave(symbolname, filename, data);
4542
                                    }
4543
                                    else
4544
                                    {
4545
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4546
                                    }
4547
                                    DataBind();
4548
                                }                                
4549
                            }
4550

    
4551
                            if (symbolsvg == true)
4552
                            {
4553
                                try
4554
                                {
4555
                                    var defaultBitmapImage = new BitmapImage();
4556
                                    defaultBitmapImage.BeginInit();
4557
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4558
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4559
                                    Check_Uri.UriCheck(filename);
4560
                                    defaultBitmapImage.UriSource = new Uri(filename);
4561
                                    defaultBitmapImage.EndInit();
4562

    
4563
                                    System.Drawing.Bitmap image;
4564

    
4565
                                    if (defaultBitmapImage.IsDownloading)
4566
                                    {
4567
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4568
                                        {
4569
                                            defaultBitmapImage.Freeze();
4570
                                            image = GetBitmap(defaultBitmapImage);
4571
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4572
                                            Process potrace = new Process
4573
                                            {
4574
                                                StartInfo = new ProcessStartInfo
4575
                                                {
4576
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4577
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4578
                                                    RedirectStandardInput = true,
4579
                                                    RedirectStandardOutput = true,
4580
                                                    RedirectStandardError = true,
4581
                                                    UseShellExecute = false,
4582
                                                    CreateNoWindow = true,
4583
                                                    WindowStyle = ProcessWindowStyle.Hidden
4584
                                                },
4585
                                            };
4586

    
4587
                                            StringBuilder svgBuilder = new StringBuilder();
4588
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4589
                                            {
4590
                                                svgBuilder.AppendLine(e2.Data);
4591
                                            };
4592

    
4593
                                            potrace.EnableRaisingEvents = true;
4594
                                            potrace.Start();
4595
                                            potrace.Exited += (sender, e) =>
4596
                                            {
4597
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4598
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4599
                                                Check_Uri.UriCheck(svgfilename);
4600
                                                if (symbolselectindex == 0)
4601
                                                {
4602
                                                    SymbolSave(symbolname, svgfilename, data);
4603
                                                }
4604
                                                else
4605
                                                {
4606
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4607
                                                }
4608

    
4609
                                                DataBind();
4610
                                            };
4611
                                            potrace.WaitForExit();
4612
                                        };
4613
                                    }
4614
                                    else
4615
                                    {
4616
                                        //GC.Collect();
4617
                                    }
4618
                                }
4619
                                catch(Exception ee)
4620
                                {
4621
                                    DialogMessage_Alert("" + ee, "Alert");
4622
                                }
4623
                            }
4624
                        };                                             
4625
                    }
4626
                }
4627
            }
4628
            catch (Exception e)
4629
            {
4630
                //DialogMessage_Alert(e + "", "Alert");
4631
            }            
4632
        }
4633

    
4634
        public void SymbolSave(string Name, string Url, string Data)
4635
        {
4636
            try
4637
            {
4638
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4639
                {
4640
                    ID = Commons.shortGuid(),
4641
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4642
                    NAME = Name,
4643
                    IMAGE_URL = Url,
4644
                    DATA = Data
4645
                };
4646

    
4647
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4648
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4649
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4650
            }
4651
            catch (Exception)
4652
            {
4653
                throw;
4654
            }
4655
        }
4656

    
4657
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4658
        {
4659
            try
4660
            {
4661
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4662
                {
4663
                    ID = Commons.shortGuid(),
4664
                    DEPARTMENT = Department,
4665
                    NAME = Name,
4666
                    IMAGE_URL = Url,
4667
                    DATA = Data
4668
                };
4669
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4670
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4671
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4672
            }
4673
            catch (Exception)
4674
            {
4675
                throw;
4676
            }
4677
        }
4678

    
4679
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4680
        {           
4681
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4682
            DataBind();
4683
        }
4684

    
4685
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4686
        {
4687
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4688
            DataBind();
4689
        }
4690
        private void DataBind()
4691
        {
4692
            try
4693
            {
4694
                Symbol_Custom Custom = new Symbol_Custom();
4695
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4696
                
4697
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4698
                foreach (var item in symbol_Private)
4699
                {
4700
                    Custom.Name = item.NAME;
4701
                    Custom.ImageUri = item.IMAGE_URL;
4702
                    Custom.ID = item.ID;
4703
                    Custom_List.Add(Custom);
4704
                    Custom = new Symbol_Custom();
4705
                }
4706
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4707
                
4708
                Custom = new Symbol_Custom();
4709
                Custom_List = new List<Symbol_Custom>();
4710

    
4711
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4712

    
4713
                List<SYMBOL_PUBLIC> symbol_Public;
4714

    
4715
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4716
                {
4717
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4718
                }
4719
                else
4720
                {
4721
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4722
                }
4723
                foreach (var item in symbol_Public)
4724
                {
4725
                    Custom.Name = item.NAME;
4726
                    Custom.ImageUri = item.IMAGE_URL;
4727
                    Custom.ID = item.ID;
4728
                    Custom_List.Add(Custom);
4729
                    Custom = new Symbol_Custom();
4730
                }
4731
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4732
                BaseClient.Close();                
4733
            }
4734
            catch(Exception e)
4735
            {
4736
                //DialogMessage_Alert("DataBind", "Alert");
4737
            }
4738
            
4739
        }
4740
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4741
        {
4742
            try
4743
            {
4744
                if (args.PromptResult != null)
4745
                {
4746
                    if (args.DialogResult.Value)
4747
                    {
4748
                        PngBitmapEncoder _Encoder = symImage(data);
4749

    
4750
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4751
                        _Encoder.Save(fs);
4752
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4753

    
4754
                        byte[] Img_byte = fs.ToArray();
4755

    
4756
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4757
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4758
                        Check_Uri.UriCheck(filename);
4759
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4760
                        {
4761
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4762
                        }
4763
                        else
4764
                        {
4765
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4766
                        }
4767
                        DataBind();
4768
                    }
4769
                }
4770
            }
4771
            catch(Exception ex)
4772
            {
4773
                DialogMessage_Alert("" + ex, "Alert");
4774
            }
4775
        }
4776

    
4777
        public PngBitmapEncoder symImage(string data)
4778
        {
4779

    
4780
            Canvas _canvas = new Canvas();
4781
            _canvas.Background = Brushes.White;
4782
            _canvas.Width = adorner_.BorderSize.Width;
4783
            _canvas.Height = adorner_.BorderSize.Height;
4784
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4785

    
4786
            BitmapEncoder encoder = new PngBitmapEncoder();
4787

    
4788

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

    
4791
            DrawingVisual dv = new DrawingVisual();
4792

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

    
4796
            using (DrawingContext ctx = dv.RenderOpen())
4797
            {
4798
                VisualBrush vb = new VisualBrush(_canvas);
4799
                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)));
4800
            }
4801

    
4802
            try
4803
            {
4804
                renderBitmap.Render(dv);
4805

    
4806
                //GC.Collect();
4807
                GC.WaitForPendingFinalizers();
4808
                //GC.Collect();
4809
                // encode png data
4810
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4811
                // puch rendered bitmap into it
4812
                pngEncoder.Interlace = PngInterlaceOption.Off;
4813
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4814
                return pngEncoder;
4815

    
4816
            }
4817
            catch //(Exception ex)
4818
            {
4819
                return null;
4820
            }
4821

    
4822
        }
4823

    
4824
        public void DialogMessage_Alert(string content, string header)
4825
        {
4826
            var box = new TextBlock();
4827
            box.MinWidth = 400;
4828
            box.FontSize = 11;
4829
            //box.FontSize = 12;
4830
            box.Text = content;
4831
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4832

    
4833
            DialogParameters parameters = new DialogParameters()
4834
            {
4835
                Owner = Application.Current.MainWindow,
4836
                Content = box,
4837
                Header = header,
4838
                Theme = new VisualStudio2013Theme(),
4839
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4840
            };            
4841
            RadWindow.Alert(parameters);
4842
        }
4843

    
4844
        #region 캡쳐 기능
4845

    
4846
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4847
        {
4848
            if (x < 0)
4849
            {
4850
                width += x;
4851
                x = 0;
4852
            }
4853
            if (y < 0)
4854
            {
4855
                height += y;
4856
                y = 0;
4857

    
4858
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4859
            }
4860
            if (x + width > zoomAndPanCanvas.ActualWidth)
4861
            {
4862
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4863
            }
4864
            if (y + height > zoomAndPanCanvas.ActualHeight)
4865
            {
4866
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4867
            }
4868

    
4869
            byte[] pixels = CopyPixels(x, y, width, height);
4870

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

    
4873
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4874
        }
4875

    
4876
        public byte[] CopyPixels(int x, int y, int width, int height)
4877
        {
4878
            byte[] pixels = new byte[width * height * 4];
4879
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4880

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

    
4884
            return pixels;
4885
        }
4886

    
4887
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4888
        {
4889
            DrawingVisual drawingVisual = new DrawingVisual();
4890
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4891

    
4892
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4893
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4894
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4895
            drawingContext.Close();
4896

    
4897
            // 비트맵으로 변환합니다.
4898
            RenderTargetBitmap target =
4899
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4900
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4901

    
4902
            target.Render(drawingVisual);
4903
            return target;
4904
        }
4905

    
4906
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4907
        {
4908
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4909
            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);
4910
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4911
            bmp.UnlockBits(data);
4912
            return bmp;
4913
        }
4914
        public string symbolname = null;
4915
        public bool symbolsvg = true;
4916
        public bool symbolpng = true;
4917

    
4918
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4919
        {
4920
            System.Drawing.Bitmap image = GetBitmap(source);
4921
            //흰색 제거
4922
            //image.MakeTransparent(System.Drawing.Color.White);
4923

    
4924
            var imageStream = new System.IO.MemoryStream();
4925
            byte[] imageBytes = null;
4926
            using (imageStream)
4927
            {
4928
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4929
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4930
                imageStream.Position = 0;
4931
                imageBytes = imageStream.ToArray();
4932
            }
4933

    
4934
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4935

    
4936
            RadWindow CheckPop = new RadWindow();
4937
            //Alert check = new Alert(Msg);
4938

    
4939
            CheckPop = new RadWindow
4940
            {
4941
                MinWidth = 400,
4942
                MinHeight = 100,
4943
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4944
                Header = "Alert",
4945
                Content = symbolPrompt,
4946
                //DialogResult = 
4947
                ResizeMode = System.Windows.ResizeMode.NoResize,
4948
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4949
                IsTopmost = true,
4950
            };
4951
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4952
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4953
            CheckPop.ShowDialog();
4954

    
4955
            /*
4956
            DialogParameters parameters = new DialogParameters()
4957
            {
4958
                Owner = Application.Current.MainWindow,
4959
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4960
                DefaultPromptResultValue = "Custom State",
4961
                Content = "Name :",
4962
                Header = "Insert Custom Symbol Name",
4963
                Theme = new VisualStudio2013Theme(),
4964
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4965
            };            
4966
            RadWindow.Prompt(parameters);
4967
            */
4968
        }
4969

    
4970
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4971
        {
4972
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4973
            KCOMDataModel.DataModel.CHECK_LIST check_;
4974
            string Result = streamToBase64.ImageToBase64(source);
4975
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4976
            string projectno = App.ViewInfo.ProjectNO;
4977
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4978

    
4979
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4980
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4981
            if (Item != null)
4982
            {
4983
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4984
            }
4985
            else
4986
            {
4987
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4988
            }
4989

    
4990
            if (Item == null)
4991
            {
4992
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
4993
                {
4994
                    ID = Commons.shortGuid(),
4995
                    USER_ID = App.ViewInfo.UserID,
4996
                    IMAGE_URL = Result,
4997
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4998
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4999
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5000
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5001
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5002
                    STATUS = "False",
5003
                    CREATE_TIME = DateTime.Now,
5004
                    UPDATE_TIME = DateTime.Now,
5005
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5006
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5007
                };
5008
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5009
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5010
                //this.BaseClient.AddCheckList(projectno, check_);
5011
            }
5012
            else
5013
            {
5014
                Item.IMAGE_URL = Result;
5015
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5016
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5017
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5018
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5019
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5020
            }
5021

    
5022
        }
5023

    
5024
        public void Set_Capture()
5025
        {
5026
            double x = canvasDrawingMouseDownPoint.X;
5027
            double y = canvasDrawingMouseDownPoint.Y;
5028
            double width = dragCaptureBorder.Width;
5029
            double height = dragCaptureBorder.Height;
5030

    
5031
            if (width > 5 || height > 5)
5032
            {
5033
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5034
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5035
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5036
            }
5037
        }
5038
        #endregion
5039

    
5040
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5041
        {
5042
            multi_Undo_Data = new Multi_Undo_data();
5043

    
5044
            multi_Undo_Data.Markup = control;
5045

    
5046
            if ((control as IShapeControl) != null)
5047
            {
5048
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5049
            }
5050
            if ((control as IDashControl) != null)
5051
            {
5052
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5053
            }
5054
            if ((control as IPath) != null)
5055
            {
5056
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5057
            }
5058
            if ((control as UIElement) != null)
5059
            {
5060
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5061
            }
5062

    
5063
            return multi_Undo_Data;
5064
        }
5065

    
5066
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5067
        {
5068
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5069
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5070
            {
5071
                if (items.UserID == Select_ID)
5072
                {
5073
                    foreach (var item in items.MarkupList)
5074
                    {
5075
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5076
                        {
5077
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5078
                                items.MarkupInfoID, Commons.shortGuid());
5079
                        }
5080
                    }
5081
                }
5082
            }
5083
        }
5084

    
5085
        /// <summary>
5086
        /// convert inkcontrol to polygoncontrol
5087
        /// </summary>
5088
        public void ConvertInkControlToPolygon()
5089
        {
5090
            if (inkBoard.Strokes.Count > 0)
5091
            {
5092
                inkBoard.Strokes.ToList().ForEach(stroke =>
5093
                {
5094
                    InkToPath ip = new InkToPath();
5095

    
5096
                    List<Point> inkPointSet = new List<Point>();
5097
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5098

    
5099
                    PolygonControl pc = new PolygonControl()
5100
                    {
5101
                        Angle = 0,
5102
                        PointSet = inkPointSet,
5103
                        ControlType = ControlType.Ink
5104
                    };
5105
                    pc.StartPoint = inkPointSet[0];
5106
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5107
                    pc.LineSize = 3;
5108
                    pc.CommentID = Commons.shortGuid();
5109
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5110

    
5111
                    if (pc.PointSet.Count > 0)
5112
                    {
5113
                        CreateCommand.Instance.Execute(pc);
5114
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5115
                    }
5116
                });
5117
                inkBoard.Strokes.Clear();
5118
            }
5119
        }
5120

    
5121
        /// <summary>
5122
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5123
        /// </summary>
5124
        /// <author>ingu</author>
5125
        /// <date>2018.06.05</date>
5126
        /// <param name="getPoint"></param>
5127
        /// <returns></returns>
5128
        private bool IsGetoutpoint(Point getPoint)
5129
        {
5130
            if (getPoint == new Point())
5131
            {
5132
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5133
                currentControl = null;
5134
                return true;
5135
            }
5136

    
5137
            return false;
5138
        }
5139

    
5140
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5141
        {
5142
            e.Effects = DragDropEffects.Copy;
5143
        }
5144

    
5145
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5146
        {
5147
            e.Effects = DragDropEffects.Copy;
5148
        }
5149

    
5150
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5151
        {
5152
            e.Effects = DragDropEffects.None;
5153
        }
5154

    
5155
        /*
5156
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5157
        {
5158
            try
5159
            {
5160
                if (e.Data.GetDataPresent(typeof(string)))
5161
                {
5162
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5163
                    string dragData = e.Data.GetData(typeof(string)) as string;
5164
                    Move_Symbol(sender, dragData);
5165
                }
5166
            }
5167
            catch (Exception ex)
5168
            {
5169
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5170
            }            
5171
        }
5172
        */
5173
    }
5174
}
클립보드 이미지 추가 (최대 크기: 500 MB)