프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu

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 670a4be2 humkyung
using KCOMDataModel.DataModel;
31 d7548b21 ljiyeon
using System.Xml;
32 6707a5c7 ljiyeon
using static KCOM.TempFile;
33
using System.Windows.Threading;
34
using System.Diagnostics;
35
using System.Threading;
36 510cbd2a ljiyeon
using System.Windows.Resources;
37 53880c83 ljiyeon
using Svg2Xaml;
38
using System.Runtime.InteropServices;
39
using System.Windows.Media.Effects;
40 684ef11c ljiyeon
using MarkupToPDF.Controls.Cad;
41 036650a0 humkyung
using MarkupToPDF.Controls.Parsing;
42 fddb48f7 ljiyeon
using Telerik.Windows.Data;
43
using System.ComponentModel;
44 787a4489 KangIngu
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 a0bab669 KangIngu
    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 787a4489 KangIngu
    /// <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 e6a9ddaf humkyung
        private Move move = new Move();
128 787a4489 KangIngu
        private double[] rotateValue = { 0, 90, 180, 270 };
129
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
130
        private static readonly double DragThreshold = 5;
131 eb2b9248 KangIngu
        private System.Windows.Input.Cursor cursor { get; set; }
132 787a4489 KangIngu
        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 80458c15 ljiyeon
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
147
148 787a4489 KangIngu
        public string Filename_ { get; set; }
149
        public double L_Size = 0;
150
        public AdornerFinal adorner_;
151
        public Multi_Undo_data multi_Undo_Data;
152 5ce56a3a KangIngu
        public string Symbol_ID = "";
153 787a4489 KangIngu
        /// <summary>
154
        /// Set to 'true' when the left mouse-button is down.
155
        /// </summary>
156 9f473fb7 KangIngu
        public bool isLeftMouseButtonDownOnWindow = false;
157 787a4489 KangIngu
158
        public InkPresenter _InkBoard = null;
159
        Stroke stroke;
160
        Boolean IsDrawing = false;
161
        StylusPointCollection strokePoints;
162 53880c83 ljiyeon
        //StylusPointCollection erasePoints;
163 787a4489 KangIngu
        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 90e7968d ljiyeon
237 787a4489 KangIngu
        public MainMenu()
238
        {
239 e0204db0 djkim
            //InitializeComponent();    
240 90e7968d ljiyeon
            this.Loaded += MainMenu_Loaded;
241 787a4489 KangIngu
        }
242 6707a5c7 ljiyeon
243
        public class TempDt
244
        {
245
            public int PageNumber { get; set; }
246
            public string CommentID { get; set; }
247
            public string ConvertData { get; set; }
248
            public int DATA_TYPE { get; set; }
249
            public string MarkupInfoID { get; set; }
250
            public int IsUpdate { get; set; }
251
        }
252
253
        List<TempDt> tempDtList = new List<TempDt>();
254 90e7968d ljiyeon
255 787a4489 KangIngu
        private void SetCursor()
256
        {
257
            this.Cursor = cursor;
258
        }
259
260
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
261
        {
262
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
263 ca40e004 ljiyeon
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
264
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
265
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
266 787a4489 KangIngu
            {
267
                return true;
268
            }
269
270
            return false;
271
        }
272
273 ca40e004 ljiyeon
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
274
        {
275
            if (rotate.Angle == 90 || rotate.Angle == 270)
276
            {
277
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
278
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
279
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
280
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
281
                {
282
                    return true;
283
                }
284
            }
285
            else
286
            {
287
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
288
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
289
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
290
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
291
                {
292
                    return true;
293
                }
294 90e7968d ljiyeon
            }
295 ca40e004 ljiyeon
296
            return false;
297
        }
298
299 90e7968d ljiyeon
300 787a4489 KangIngu
        public void DeleteItem(MarkupInfoItem item)
301
        {
302
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
303
            {
304
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
305
            }
306
307
            ViewerDataModel.Instance._markupInfoList.Remove(item);
308
309
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
310
            {
311
                ViewerDataModel.Instance.MarkupControls.Remove(a);
312
            });
313
314
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
315
            {
316
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
317
            });
318
319 d62c0439 humkyung
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
320 787a4489 KangIngu
            {
321
                ComingNewBieEnd = false;
322 d62c0439 humkyung
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
323 6707a5c7 ljiyeon
                //임시파일에서도 삭제
324 a20d338f ljiyeon
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
325 787a4489 KangIngu
            });
326
327
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
328 bb3a236d ljiyeon
329 787a4489 KangIngu
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
330
            {
331
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
332
                {
333 24678e06 humkyung
                    var infoId = Commons.shortGuid();
334 787a4489 KangIngu
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
335
                    {
336
                        CreateTime = DateTime.Now,
337
                        Depatment = userData.DEPARTMENT,
338 992a98b4 KangIngu
                        UpdateTime = DateTime.Now,
339 787a4489 KangIngu
                        DisplayColor = "#FFFF0000",
340
                        UserID = userData.ID,
341
                        UserName = userData.NAME,
342
                        PageCount = 1,
343
                        Description = "",
344
                        MarkupInfoID = infoId,
345
                        MarkupList = null,
346 24678e06 humkyung
                        MarkupVersionID = Commons.shortGuid(),
347 787a4489 KangIngu
                        Consolidate = 0,
348
                        PartConsolidate = 0,
349
                        userDelete = true,
350
                        AvoidConsolidate = 0,
351
                        IsPreviewUser = true
352
                    };
353
                    App.Custom_ViewInfoId = infoId;
354
                }
355
            }
356 0f065e57 ljiyeon
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
357 787a4489 KangIngu
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
358
        }
359
360 959b3ef2 humkyung
        /// <summary>
361
        /// delete selected comments
362
        /// </summary>
363
        /// <param name="sender"></param>
364
        /// <param name="e"></param>
365 787a4489 KangIngu
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
366
        {
367
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
368 077896be humkyung
            SelectionSet.Instance.UnSelect(this);
369 787a4489 KangIngu
370
            Button content = (sender as Button);
371
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
372
373
            DeleteItem(item);
374
        }
375
376
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
377
378 6707a5c7 ljiyeon
        private static Timer timer;
379
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
380 787a4489 KangIngu
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
381 90e7968d ljiyeon
        {
382 510cbd2a ljiyeon
            InitializeComponent();
383 0c997b99 ljiyeon
            
384 90e7968d ljiyeon
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
385
386 787a4489 KangIngu
            if (App.ParameterMode)
387 6707a5c7 ljiyeon
            {
388
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
389
                imageViewer_Compare = new Image();
390
                ViewerDataModel.Instance.Capture_Opacity = 0;
391
                da.From = 0.8;
392
                da.To = 0;
393
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
394
                da.AutoReverse = true;
395 e0204db0 djkim
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
396
397
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
398 90e7968d ljiyeon
                {
399 e0204db0 djkim
                    this.SymbolPane.Visibility = Visibility.Collapsed;
400
                    this.FavoritePane.Visibility = Visibility.Collapsed;
401
                    this.drawingRotateCanvas.IsHitTestVisible = false;
402 90e7968d ljiyeon
                }
403 6707a5c7 ljiyeon
            }
404 90e7968d ljiyeon
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
405 ccf944bb ljiyeon
        }
406
407 6707a5c7 ljiyeon
        private void timercallback(Object o)
408 ccf944bb ljiyeon
        {
409 6707a5c7 ljiyeon
            Stopwatch sw = new Stopwatch();
410
            sw.Start();
411 3b484ebb ljiyeon
            TempFile.TempFileAdd();
412 6707a5c7 ljiyeon
            sw.Stop();
413 ccf944bb ljiyeon
414 90e7968d ljiyeon
            Dispatcher.InvokeAsync(new Action(delegate
415 ccf944bb ljiyeon
            {
416 6707a5c7 ljiyeon
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
417
                {
418
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
419
                }
420
            }));
421 ccf944bb ljiyeon
422 90e7968d ljiyeon
            ////GC.Collect();
423 6707a5c7 ljiyeon
        }
424 077896be humkyung
        
425 d62c0439 humkyung
        /// <summary>
426
        /// update my markuplist
427
        ///  - update existing markup data if already exist
428
        ///  - add new markup data if control is new
429
        /// </summary>
430
        public void UpdateMyMarkupList()
431 787a4489 KangIngu
        {
432 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
433 787a4489 KangIngu
            bool isComingNewBie = false;
434
435 d62c0439 humkyung
            /// add or update markup list
436
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
437 787a4489 KangIngu
            {
438 d62c0439 humkyung
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
439 90e7968d ljiyeon
440 d62c0439 humkyung
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
441
                if (exist != null) //신규 추가 된 코멘트
442
                {
443
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
444 6707a5c7 ljiyeon
                    {
445 d62c0439 humkyung
                        exist.Data = root.ConvertData;
446
                        exist.IsUpdate = true;
447
                        ComingNewBieEnd = false;
448 6707a5c7 ljiyeon
                    }
449 d62c0439 humkyung
                }
450
                else if (root.CommentID != null)
451
                {
452
                    isComingNewBie = true;
453
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
454 6707a5c7 ljiyeon
                    {
455 d62c0439 humkyung
                        ID = control.CommentID,
456
                        Data = root.ConvertData,
457
                        Data_Type = root.DATA_TYPE,
458
                        MarkupInfoID = App.Custom_ViewInfoId,
459
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
460
                        Symbol_ID = control.SymbolID,
461 c0977e97 djkim
                        //Group_ID = control.GroupID,
462 d62c0439 humkyung
                    });
463
                    ComingNewBieEnd = false;
464 787a4489 KangIngu
                }
465
            }
466
467 d62c0439 humkyung
            /// delete markup list
468
            int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
469
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
470
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
471
                          select markup).ToList();
472
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
473
            /// up to here
474 6707a5c7 ljiyeon
475 787a4489 KangIngu
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
476
            {
477
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
478
                {
479
                    ComingNewBieEnd = true;
480
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
481
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
482
                    gridViewMarkup.ItemsSource = null;
483
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
484
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
485 fddb48f7 ljiyeon
486
                    GroupDescriptor descriptor = new GroupDescriptor();
487
                    descriptor.Member = "Depatment";
488
                    descriptor.DisplayContent = "DEPT";
489
                    descriptor.SortDirection = ListSortDirection.Ascending;
490
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
491 787a4489 KangIngu
                }
492
            }
493
        }
494
495
        bool ComingNewBieEnd = false;
496
497
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
498 548c696e ljiyeon
        {
499
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
500 316d0f5c KangIngu
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
501 548c696e ljiyeon
            {
502
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
503 316d0f5c KangIngu
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
504
            }
505 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
506 787a4489 KangIngu
            ViewerDataModel.Instance.UndoDataList.Clear();
507 90e7968d ljiyeon
508 f959ea6f humkyung
            ConvertInkControlToPolygon();
509 787a4489 KangIngu
510 077896be humkyung
            SelectionSet.Instance.UnSelect(this);
511 d62c0439 humkyung
            UpdateMyMarkupList();
512 548c696e ljiyeon
513
            Logger.sendCheckLog("pageNavigator_PageChanging_변수생성 및 값 설정", 1);
514 787a4489 KangIngu
            CompareMode.IsChecked = false;
515
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
516
517
518
            #region 페이지가 벗어난 경우
519
520
            if (BalancePoint < 1)
521
            {
522
                BalancePoint = 1;
523
                ViewerDataModel.Instance.PageBalanceNumber = 0;
524
            }
525
526
            if (pageNavigator.PageCount < BalancePoint)
527
            {
528
                BalancePoint = pageNavigator.PageCount;
529
                ViewerDataModel.Instance.PageBalanceNumber = 0;
530
            }
531
532
            #endregion
533
534
            ViewerDataModel.Instance.PageNumber = BalancePoint;
535
536 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
537 a874198d humkyung
            string uri = "";
538 a1716fa5 KangIngu
            if (userData.COMPANY != "EXT")
539 a874198d humkyung
            {
540 84c48033 djkim
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
541 a874198d humkyung
            }
542
            else
543
            {
544 84c48033 djkim
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
545 a874198d humkyung
            }
546 548c696e ljiyeon
547 8a9f6742 djkim
            var defaultBitmapImage = new BitmapImage();
548
            defaultBitmapImage.BeginInit();
549
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
550
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
551
            defaultBitmapImage.UriSource = new Uri(uri);
552
            defaultBitmapImage.EndInit();
553
554
            ViewerDataModel.Instance.ImageViewPath = null;
555 548c696e ljiyeon
            GC.Collect();
556 787a4489 KangIngu
557 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
558 787a4489 KangIngu
            if (defaultBitmapImage.IsDownloading)
559
            {
560 122914ba ljiyeon
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
561 787a4489 KangIngu
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
562
                {
563 8a9f6742 djkim
                    defaultBitmapImage.Freeze();
564
                    mainPanel.UpdateLayout();
565 90e7968d ljiyeon
                    GC.Collect();
566 787a4489 KangIngu
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
567
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
568
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
569
                };
570
            }
571
572
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
573
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
574
575
576
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
577
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
578
            inkBoard.Width = zoomAndPanCanvas.Width;
579
            inkBoard.Height = zoomAndPanCanvas.Height;
580
581 90e7968d ljiyeon
582 787a4489 KangIngu
583
            if (!testPanel2.IsHidden)
584
            {
585 548c696e ljiyeon
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
586 787a4489 KangIngu
                //PDF모드일때 잠시 대기(강인구)
587
                if (IsSyncPDFMode)
588
                {
589
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
590
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
591
592 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
593 787a4489 KangIngu
                    if (pdfpath.IsDownloading)
594
                    {
595
                        pdfpath.DownloadCompleted += (ex, arg) =>
596
                        {
597 548c696e ljiyeon
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
598 787a4489 KangIngu
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
599
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
600
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
601
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
602
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
603
                        };
604
                    }
605
                    else
606
                    {
607 548c696e ljiyeon
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
608 787a4489 KangIngu
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
609
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
610
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
611
612
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
613
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
614
                    }
615
                }
616
                else
617
                {
618 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
619 a874198d humkyung
                    string uri2 = "";
620 a1716fa5 KangIngu
                    if (userData.COMPANY != "EXT")
621 a874198d humkyung
                    {
622 84c48033 djkim
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
623 a874198d humkyung
                    }
624
                    else
625
                    {
626 84c48033 djkim
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
627 a874198d humkyung
                    }
628 a1716fa5 KangIngu
629 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
630 787a4489 KangIngu
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
631
632 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
633 787a4489 KangIngu
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
634
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
635
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
636
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
637
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
638
639 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
640 787a4489 KangIngu
                    zoomAndPanControl.ZoomTo(new Rect
641
                    {
642
                        X = 0,
643
                        Y = 0,
644
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
645
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
646
                    });
647
648 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
649 787a4489 KangIngu
                    if (defaultBitmapImage_Compare.IsDownloading)
650
                    {
651
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
652
                        {
653 548c696e ljiyeon
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
654 787a4489 KangIngu
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
655
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
656
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
657 90e7968d ljiyeon
658 787a4489 KangIngu
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
659
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
660
661
                            zoomAndPanControl.ZoomTo(new Rect
662
                            {
663
                                X = 0,
664
                                Y = 0,
665
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
666
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
667
                            });
668
                        };
669
                    }
670
                }
671
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
672
            }
673
674
            this.pageNavigator.SetNextPage();
675
676
            if (zoomAndPanCanvas2.Width.IsNaN())
677
            {
678
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
679
            }
680
681 d62c0439 humkyung
            Logger.sendCheckLog("-- pageNavigator_PageChanging_ControlData Setting --", 1);
682
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
683
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
684 90e7968d ljiyeon
685 d62c0439 humkyung
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
686
            foreach (var info in gridSelectionItem)
687 787a4489 KangIngu
            {
688 d62c0439 humkyung
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
689 787a4489 KangIngu
            }
690 d62c0439 humkyung
            /// fire selection event
691
            this.gridViewMarkup.UnselectAll();
692
            this.gridViewMarkup.Select(gridSelectionItem);
693 90e7968d ljiyeon
694 787a4489 KangIngu
            if (!testPanel2.IsHidden)
695
            {
696 dd0ffcfb KangIngu
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
697
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
698
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
699
700 787a4489 KangIngu
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
701
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
702
703
704
                foreach (var item in gridSelectionRevItem)
705
                {
706
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
707
                    {
708 661b7416 humkyung
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
709 787a4489 KangIngu
                    });
710
                }
711
            }
712
713
            var instanceMain = this.ParentOfType<MainWindow>();
714
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
715 992a98b4 KangIngu
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
716 787a4489 KangIngu
717
            instanceMain.dzTopMenu.rotateOffSet = 0;
718
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
719
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
720
721
            //}
722
            SetCommentPages(true);
723
        }
724 90e7968d ljiyeon
725 6707a5c7 ljiyeon
726 3b484ebb ljiyeon
        
727 787a4489 KangIngu
728
        private void SetCommentPages(bool onlyMe = false)
729
        {
730 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
731 787a4489 KangIngu
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
732
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
733
            {
734
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
735
                instance.UserName = item.UserName;
736
                instance.Depart = item.Depatment;
737
                instance.MarkupInfoID = item.MarkupInfoID;
738
                instance.IsSelected = true;
739
                instance.isConSolidation = item.Consolidate;
740
                instance.SetColor = item.DisplayColor;
741
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
742
                {
743 d62c0439 humkyung
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
744 787a4489 KangIngu
                }
745
                else
746
                {
747
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
748
                }
749
                _pages.Add(instance);
750
            }
751
            this.pageNavigator.SetCommentList(_pages.ToList());
752
        }
753
754
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
755
        {
756
            if (e.MiddleButton == MouseButtonState.Pressed)
757
            {
758
759
            }
760
            e.Handled = true;
761
            if (e.Delta > 0)
762
            {
763
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
764
                ZoomIn(currentContentMousePoint);
765
            }
766
            else
767
            {
768
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
769
                ZoomOut(currentContentMousePoint);
770
            }
771
        }
772
773 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
774
        {
775
            e.Handled = true;
776
            if (e.Delta > 0)
777
            {
778
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
779
                ZoomIn_Sync(currentContentMousePoint);
780
            }
781
            else
782
            {
783
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
784
                ZoomOut_Sync(currentContentMousePoint);
785
            }
786
        }
787
788 787a4489 KangIngu
        #region ZoomIn & ZoomOut
789
790
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
791
        {
792
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
793
                zoomAndPanControl.ContentZoomFocusY));
794
        }
795
796
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
797
        {
798
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
799
                zoomAndPanControl.ContentZoomFocusY));
800
        }
801
802
803
        //강인구 추가 (줌 인아웃 수치 변경)
804
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
805
        private void ZoomOut(Point contentZoomCenter)
806
        {
807
            if (zoomAndPanControl.ContentScale > 0.39)
808
            {
809
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
810
            }
811
            else
812
            {
813
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
814
            }
815
816 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
817 787a4489 KangIngu
            {
818 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
819 787a4489 KangIngu
            }
820
        }
821
822
        private void ZoomIn(Point contentZoomCenter)
823
        {
824
            if (zoomAndPanControl.ContentScale > 0.19)
825
            {
826
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
827
            }
828
            else
829
            {
830
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
831
            }
832
833 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
834 787a4489 KangIngu
            {
835 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
836 787a4489 KangIngu
            }
837 a1716fa5 KangIngu
838
        }
839
840
        private void ZoomOut_Sync(Point contentZoomCenter)
841
        {
842
            if (zoomAndPanControl2.ContentScale > 0.39)
843
            {
844
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
845
            }
846
            else
847
            {
848
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
849
            }
850
851
            if (Sync.IsChecked)
852
            {
853
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
854
            }
855
        }
856
857
        private void ZoomIn_Sync(Point contentZoomCenter)
858
        {
859
            if (zoomAndPanControl2.ContentScale > 0.19)
860
            {
861
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
862
            }
863
            else
864
            {
865
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
866
            }
867
868
            if (Sync.IsChecked)
869
            {
870
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
871
            }
872 787a4489 KangIngu
        }
873
874
        private void ZoomOut()
875
        {
876
            zoomAndPanControl.ContentScale -= 0.1;
877
            //if (zoomAndPanControl2 != null)
878
            //{
879
            //    zoomAndPanControl2.ContentScale -= 0.1;
880
            //}
881
        }
882
883
        private void ZoomIn()
884
        {
885
            zoomAndPanControl.ContentScale += 0.1;
886
            //if (zoomAndPanControl2 != null)
887
            //{
888
            //    zoomAndPanControl2.ContentScale += 0.1;
889
            //}
890
        }
891
892
        #endregion
893
894
        private void init()
895
        {
896
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
897
            {
898
899
                ControlList.Clear();
900
                listBox.Items.Clear();
901
                selected_item.Clear();
902
903
                (item as IMarkupCommonData).IsSelected = false;
904
            }
905
906
        }
907
908
        private HitTestResultBehavior MyCallback(HitTestResult result)
909
        {
910
            //this.cursor = Cursors.UpArrow;
911
            var element = result.VisualHit;
912
            while (element != null && !(element is CommentUserInfo))
913
                element = VisualTreeHelper.GetParent(element);
914
915
            if (element == null)
916
            {
917
                return HitTestResultBehavior.Stop;
918
            }
919
            else
920
            {
921
                if (element is CommentUserInfo)
922
                {
923
                    if (!hitList.Contains(element))
924
                    {
925
                        hitList.Add((CommentUserInfo)element);
926
                    }
927
                    else
928
                    {
929
                        return HitTestResultBehavior.Stop;
930
                    }
931
                }
932
            }
933
            return HitTestResultBehavior.Continue;
934
        }
935
936
        public void ReleaseSelectPath()
937
        {
938
            if (SelectionPath == null)
939
            {
940
                SelectionPath = new Path();
941
                SelectionPath.Name = "";
942
            }
943
            if (SelectionPath.Name != "")
944
            {
945
                SelectionPath.Name = "None";
946
            }
947
            SelectionPath.Opacity = 0.01;
948
            SelectionPath.RenderTransform = null;
949
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
950
        }
951
952
        #region 컨트롤 초기화 
953
        public void Control_Init(object control)
954
        {
955
            if (L_Size != 0 && (control as IPath) != null)
956
            {
957
                (control as IPath).LineSize = L_Size;
958
                L_Size = 0;
959
            }
960
961
            switch (control.GetType().Name)
962
            {
963
                case "RectangleControl":
964
                    {
965
                        (control as RectangleControl).StrokeColor = Brushes.Red;
966
                    }
967
                    break;
968
                case "CircleControl":
969
                    {
970
                        (control as CircleControl).StrokeColor = Brushes.Red;
971
                    }
972
                    break;
973
                case "TriControl":
974
                    {
975
                        (control as TriControl).StrokeColor = Brushes.Red;
976
                    }
977
                    break;
978
                case "RectCloudControl":
979
                    {
980
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
981
                    }
982
                    break;
983
                case "CloudControl":
984
                    {
985
                        (control as CloudControl).StrokeColor = Brushes.Red;
986
                    }
987
                    break;
988
                case "PolygonControl":
989
                    {
990
                        (control as PolygonControl).StrokeColor = Brushes.Red;
991
                    }
992
                    break;
993
                case "ArcControl":
994
                    {
995
                        (control as ArcControl).StrokeColor = Brushes.Red;
996
                    }
997
                    break;
998 40b3ce25 ljiyeon
                case "ArrowArcControl":
999
                    {
1000
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1001
                    }
1002
                    break;
1003 787a4489 KangIngu
                case "LineControl":
1004
                    {
1005
                        (control as LineControl).StrokeColor = Brushes.Red;
1006
                    }
1007
                    break;
1008
                case "ArrowControl_Multi":
1009
                    {
1010
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1011
                    }
1012
                    break;
1013
                case "TextControl":
1014
                    {
1015
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1016
                    }
1017
                    break;
1018
                case "ArrowTextControl":
1019
                    {
1020
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1021
                    }
1022
                    break;
1023 684ef11c ljiyeon
                case "InsideWhiteControl":
1024
                    {
1025
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1026
                    }
1027
                    break;
1028
                case "OverlapWhiteControl":
1029
                    {
1030
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1031
                    }
1032
                    break;
1033
                case "ClipWhiteControl":
1034
                    {
1035
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1036
                    }
1037
                    break;
1038
                case "CoordinateControl":
1039
                    {
1040
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1041
                    }
1042
                    break;
1043 787a4489 KangIngu
            }
1044
        }
1045
        #endregion
1046
1047
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1048
        {
1049
            //Control_Init(e.Source);
1050
        }
1051 53880c83 ljiyeon
        private Window _dragdropWindow = null;
1052
1053
        [DllImport("user32.dll")]
1054
        [return: MarshalAs(UnmanagedType.Bool)]
1055
        internal static extern bool GetCursorPos(ref Win32Point pt);
1056
1057
        [StructLayout(LayoutKind.Sequential)]
1058
        internal struct Win32Point
1059
        {
1060
            public Int32 X;
1061
            public Int32 Y;
1062
        };
1063
        public string symbol_id = null;
1064
        public long symbol_group_id;
1065
        public int symbol_SelectedIndex;
1066
        public ImageSource symbol_img;
1067
        public string symbol_Data = null;
1068
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1069
        {
1070
            if (this._dragdropWindow != null)
1071
            {
1072
                this._dragdropWindow.Close();
1073
                this._dragdropWindow = null;
1074
            }
1075
1076
            symbol_id = id;
1077
            symbol_group_id = group_id;
1078
            symbol_SelectedIndex = SelectedIndex;
1079
            symbol_Data = Data_;
1080
            symbol_img = img;
1081
1082
      
1083
            CreateDragDropWindow2(img);
1084
        }
1085
1086
        private void CreateDragDropWindow2(ImageSource image)
1087
        {
1088
            this._dragdropWindow = new Window();
1089
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1090
            _dragdropWindow.WindowStyle = WindowStyle.None;
1091
            _dragdropWindow.AllowsTransparency = true;           
1092
            _dragdropWindow.AllowDrop = false;
1093
            _dragdropWindow.Background = null;
1094
            _dragdropWindow.IsHitTestVisible = false;
1095
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1096
            _dragdropWindow.Topmost = true;
1097
            _dragdropWindow.ShowInTaskbar = false;
1098
            
1099
            Rectangle r = new Rectangle();
1100
            r.Width = image.Width;
1101
            r.Height = image.Height;
1102
            r.Opacity = 0.5;            
1103
            r.Fill = new ImageBrush(image);
1104
            this._dragdropWindow.Content = r;
1105
1106
            Win32Point w32Mouse = new Win32Point();
1107
            GetCursorPos(ref w32Mouse);
1108
1109
            //w32Mouse.X = getCurrentPoint.X;
1110
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1111
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1112
            this._dragdropWindow.Show();
1113
        }
1114 787a4489 KangIngu
1115
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1116
        {
1117
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1118
            {
1119
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1120
1121
                Point currentPos = e.GetPosition(rect);
1122 d71ee575 djkim
1123 787a4489 KangIngu
                floatingTip.HorizontalOffset = currentPos.X + 20;
1124
                floatingTip.VerticalOffset = currentPos.Y;
1125
            }
1126
1127
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1128 a36a37c3 humkyung
            
1129 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1130 787a4489 KangIngu
            {
1131 e54660e8 KangIngu
                SetCursor();
1132 787a4489 KangIngu
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1133
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1134
1135
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1136
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1137
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1138 9cd2865b KangIngu
1139 a1716fa5 KangIngu
                if (Sync.IsChecked)
1140 9cd2865b KangIngu
                {
1141
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1142
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1143
                }
1144 787a4489 KangIngu
            }
1145 992a98b4 KangIngu
1146 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1147 787a4489 KangIngu
            {
1148
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1149
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1150
                SetCursor();
1151
1152
                if (currentControl != null)
1153
                {
1154
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1155
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1156
                    //강인구 추가
1157
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1158
1159
                    if ((currentControl as IPath) != null)
1160
                    {
1161
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1162
                    }
1163 5ce56a3a KangIngu
                    if ((currentControl as LineControl) != null)
1164
                    {
1165
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1166
                    }
1167
1168 787a4489 KangIngu
                    if ((currentControl as IShapeControl) != null)
1169
                    {
1170
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1171
                    }
1172
                    if ((currentControl as TextControl) != null)
1173
                    {
1174
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1175
                        {
1176
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1177
                        }
1178
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1179
                        {
1180 d4b0c723 KangIngu
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1181 787a4489 KangIngu
                        }
1182
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1183
                        {
1184
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1185
                        }
1186
                    }
1187
                    else if ((currentControl as ArrowTextControl) != null)
1188
                    {
1189
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1190
                        {
1191
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1192
                        }
1193
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1194
                        {
1195 d4b0c723 KangIngu
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1196 787a4489 KangIngu
                        }
1197
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1198
                        {
1199
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1200
                        }
1201
                    }
1202 9f473fb7 KangIngu
                    else if ((currentControl as RectCloudControl) != null)
1203
                    {
1204
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1205
                    }
1206
                    else if ((currentControl as CloudControl) != null)
1207
                    {
1208
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1209
                    }
1210 787a4489 KangIngu
1211
                    switch (controlType)
1212
                    {
1213 684ef11c ljiyeon
                        case (ControlType.Coordinate):
1214
                            {
1215
                                var control = currentControl as CoordinateControl;
1216
                                if (control != null)
1217
                                {
1218 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1219 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1220
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1221
                                }
1222
                            }
1223
                            break;
1224
                        case (ControlType.InsideWhite):
1225
                            {
1226
                                var control = currentControl as InsideWhiteControl;
1227
                                if (control != null)
1228
                                {
1229 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1230 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1231
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1232
                                    control.Paint = PaintSet.Fill;
1233
                                }
1234
                            }
1235
                            break;
1236 a6272c57 humkyung
                        case ControlType.OverlapWhite:
1237 684ef11c ljiyeon
                            {
1238
                                var control = currentControl as OverlapWhiteControl;
1239
                                if (control != null)
1240
                                {
1241 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1242 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1243
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1244
                                    control.Paint = PaintSet.Fill;
1245
                                }
1246
                            }
1247
                            break;
1248 a6272c57 humkyung
                        case ControlType.ClipWhite:
1249 684ef11c ljiyeon
                            {
1250
                                var control = currentControl as ClipWhiteControl;
1251
                                if (control != null)
1252
                                {
1253 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1254 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1255
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1256
                                    control.Paint = PaintSet.Fill;
1257
                                }
1258
                            }
1259
                            break;
1260 787a4489 KangIngu
                        case ControlType.RectCloud:
1261
                            {
1262
                                var control = currentControl as RectCloudControl;
1263
                                if (control != null)
1264
                                {
1265 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1266 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1267
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1268
                                }
1269
                            }
1270
                            break;
1271
                        case ControlType.SingleLine:
1272
                        case ControlType.CancelLine:
1273
                        case ControlType.ArrowLine:
1274
                        case ControlType.TwinLine:
1275
                        case ControlType.DimLine:
1276
                            {
1277 d71ee575 djkim
                                var control = currentControl as LineControl;
1278
                                if (control != null)
1279 787a4489 KangIngu
                                {
1280 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1281 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1282
                                }
1283
                            }
1284
                            break;
1285
1286
                        case ControlType.ArcLine:
1287
                            {
1288 d71ee575 djkim
                                var control = currentControl as ArcControl;
1289
                                if (control != null)
1290 787a4489 KangIngu
                                {
1291 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1292 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1293
                                }
1294
                            }
1295
                            break;
1296
1297
                        case ControlType.ArcArrow:
1298
                            {
1299 40b3ce25 ljiyeon
                                var control = currentControl as ArrowArcControl;
1300 d71ee575 djkim
                                if (control != null)
1301 787a4489 KangIngu
                                {
1302 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1303 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1304
                                }
1305
                            }
1306
                            break;
1307
1308
                        case ControlType.ArrowMultiLine:
1309
                            {
1310 d71ee575 djkim
                                var control = currentControl as ArrowControl_Multi;
1311
                                if (control != null)
1312 787a4489 KangIngu
                                {
1313 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1314 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1315
                                }
1316
                            }
1317
                            break;
1318
1319
                        case ControlType.Circle:
1320
                            {
1321 a6272c57 humkyung
                                if (currentControl != null)
1322 787a4489 KangIngu
                                {
1323 a6272c57 humkyung
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1324
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1325
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1326 787a4489 KangIngu
                                }
1327
                            }
1328
                            break;
1329
1330
                        case ControlType.PolygonCloud:
1331
                            {
1332
                                var control = currentControl as CloudControl;
1333
                                if (control != null)
1334
                                {
1335 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1336 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1337
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1338
                                }
1339
                            }
1340
                            break;
1341
1342
                        case ControlType.Triangle:
1343
                            {
1344
                                var control = currentControl as TriControl;
1345
                                if (control != null)
1346
                                {
1347 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1348 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1349
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1350
                                }
1351
                            }
1352
                            break;
1353
1354
                        case ControlType.ImgControl:
1355
                            {
1356
                                var control = currentControl as ImgControl;
1357
                                if (control != null)
1358
                                {
1359 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1360 787a4489 KangIngu
                                }
1361
                            }
1362
                            break;
1363
1364
                        case ControlType.Date:
1365
                            {
1366
                                var control = currentControl as DateControl;
1367
                                if (control != null)
1368
                                {
1369 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1370 787a4489 KangIngu
                                }
1371
                            }
1372
                            break;
1373
1374
                        case ControlType.ArrowTextControl:
1375
                        case ControlType.ArrowTransTextControl:
1376
                        case ControlType.ArrowTextBorderControl:
1377
                        case ControlType.ArrowTransTextBorderControl:
1378
                        case ControlType.ArrowTextCloudControl:
1379
                        case ControlType.ArrowTransTextCloudControl:
1380
                            {
1381
                                var control = currentControl as ArrowTextControl;
1382
                                if (control != null)
1383
                                {
1384 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1385 787a4489 KangIngu
                                }
1386
                            }
1387
                            break;
1388
                        case ControlType.PolygonControl:
1389 e6a9ddaf humkyung
                        case ControlType.ChainLine:
1390 787a4489 KangIngu
                            {
1391
                                var control = currentControl as PolygonControl;
1392
                                if (control != null)
1393
                                {
1394 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1395 787a4489 KangIngu
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1396
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1397
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1398
                                }
1399
                            }
1400
                            break;
1401
                        case ControlType.Sign:
1402
                            {
1403
                                var control = currentControl as SignControl;
1404
                                if (control != null)
1405
                                {
1406 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1407 787a4489 KangIngu
                                }
1408
                            }
1409
                            break;
1410
                        case ControlType.Symbol:
1411
                            {
1412
                                var control = currentControl as SymControl;
1413
                                if (control != null)
1414
                                {
1415 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1416 787a4489 KangIngu
                                }
1417
                            }
1418
                            break;
1419
                        case ControlType.Stamp:
1420
                            {
1421
                                var control = currentControl as SymControlN;
1422
                                if (control != null)
1423
                                {
1424 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1425 787a4489 KangIngu
                                }
1426
                            }
1427
                            break;
1428 a6272c57 humkyung
                        case ControlType.Rectangle:
1429 787a4489 KangIngu
                        case ControlType.Mark:
1430
                            {
1431
                                var control = currentControl as RectangleControl;
1432
                                if (control != null)
1433
                                {
1434 a6272c57 humkyung
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1435
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1436 787a4489 KangIngu
                                }
1437
                            }
1438
                            break;
1439
                        case ControlType.PenControl:
1440
                            {
1441
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1442
                                //inkBoard.Strokes.Add(stroke);
1443
                            }
1444
                            break;
1445
                        default:
1446
                            break;
1447
                    }
1448
                }
1449
            }
1450 29cf2c0c humkyung
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1451
            {
1452
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1453
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1454
                SetCursor();
1455
                if (currentControl == null)
1456
                {
1457
                    switch (controlType)
1458
                    {
1459
                        case ControlType.PenControl:
1460
                            {
1461
                                if (inkBoard.Tag.ToString() == "Ink")
1462
                                {
1463
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1464
                                }
1465
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1466
                                {
1467
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1468
                                }
1469
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1470
                                {
1471
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1472
                                }
1473
1474
                                //inkBoard.Strokes.Add(stroke);
1475
                            }
1476
                            break;
1477
                    }
1478
                    return;
1479
                }
1480
            }
1481 e6a9ddaf humkyung
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1482
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1483
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1484 787a4489 KangIngu
            {
1485
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1486
1487
                if (isDraggingSelectionRect)
1488
                {
1489
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1490
                    e.Handled = true;
1491
                }
1492
                else if (isLeftMouseButtonDownOnWindow)
1493
                {
1494
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1495
                    double dragDistance = Math.Abs(dragDelta.Length);
1496
1497
                    if (dragDistance > DragThreshold)
1498
                    {
1499
                        isDraggingSelectionRect = true;
1500
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1501
                    }
1502
1503
                    e.Handled = true;
1504
                }
1505
1506
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1507
                {
1508
                }
1509
                else
1510
                {
1511
                    e.Handled = true;
1512
                }
1513
            }
1514 e6a9ddaf humkyung
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1515 53880c83 ljiyeon
            { //symbol      
1516
                if(_dragdropWindow != null)
1517
                {
1518
                    Win32Point w32Mouse = new Win32Point();
1519
                    GetCursorPos(ref w32Mouse);
1520
1521
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1522
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1523
                }                
1524
            }
1525 e6a9ddaf humkyung
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1526
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1527 787a4489 KangIngu
            {
1528 05009a0e ljiyeon
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1529 e6a9ddaf humkyung
                if(control != null)
1530 787a4489 KangIngu
                {
1531
                    this.cursor = Cursors.Hand;
1532
                    SetCursor();
1533
                }
1534
                else
1535
                {
1536 510cbd2a ljiyeon
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1537 787a4489 KangIngu
                    SetCursor();
1538
                }
1539
            }
1540
            else
1541
            {
1542
            }
1543
        }
1544
1545 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1546
        {
1547 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1548 a1716fa5 KangIngu
            {
1549
                SetCursor();
1550
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1551
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1552
1553
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1554
1555
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1556
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1557
1558
                if (Sync.IsChecked)
1559
                {
1560
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1561
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1562
                }
1563
            }
1564
        }
1565
1566 787a4489 KangIngu
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1567
1568
        private EllipseGeometry hitArea = new EllipseGeometry();
1569
1570
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1571
        {
1572
            IsDrawing = false;
1573
1574
            if (mouseHandlingMode != MouseHandlingMode.None)
1575
            {
1576
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1577
                {
1578 510cbd2a ljiyeon
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1579 787a4489 KangIngu
1580
                    SetCursor();
1581
1582
                    switch (controlType)
1583
                    {
1584
                        case ControlType.None:
1585
                            break;
1586
                        case ControlType.Rectangle:
1587
                            {
1588
1589
                            }
1590
                            break;
1591
                        case ControlType.PenControl:
1592
                            {
1593
1594
                            }
1595
                            break;
1596
                        default:
1597
                            break;
1598
                    }
1599
                }
1600 9f473fb7 KangIngu
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1601 787a4489 KangIngu
                {
1602
                    if (isLeftMouseButtonDownOnWindow)
1603
                    {
1604
                        bool wasDragSelectionApplied = false;
1605
1606
                        if (isDraggingSelectionRect)
1607
                        {
1608 53880c83 ljiyeon
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1609
                            {
1610
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1611
                                mouseHandlingMode = MouseHandlingMode.None;
1612
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1613
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1614
                                Set_Symbol_Capture(endPoint);
1615
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1616
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1617
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1618
                            }
1619
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1620 787a4489 KangIngu
                            {
1621
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1622
                                mouseHandlingMode = MouseHandlingMode.None;
1623
                                Set_Capture();
1624
1625
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1626
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1627
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1628
                            }
1629 9f473fb7 KangIngu
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1630 787a4489 KangIngu
                            {
1631
                                ApplyDragSelectionRect();
1632
                            }
1633 9f473fb7 KangIngu
                            else
1634
                            {
1635
                                double x = Canvas.GetLeft(dragZoomBorder);
1636
                                double y = Canvas.GetTop(dragZoomBorder);
1637
                                double width = dragZoomBorder.Width;
1638
                                double height = dragZoomBorder.Height;
1639
                                Rect dragRect = new Rect(x, y, width, height);
1640
1641
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1642
1643
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1644
                            }
1645 787a4489 KangIngu
1646 9f473fb7 KangIngu
                            isDraggingSelectionRect = false;
1647 787a4489 KangIngu
                            e.Handled = true;
1648
                            wasDragSelectionApplied = true;
1649
                        }
1650
1651
                        if (isLeftMouseButtonDownOnWindow)
1652
                        {
1653
                            isLeftMouseButtonDownOnWindow = false;
1654
                            this.ReleaseMouseCapture();
1655
                            e.Handled = true;
1656
                        }
1657
1658
                        if (!wasDragSelectionApplied)
1659
                        {
1660
                            init();
1661
                        }
1662
                    }
1663
                }
1664 e6a9ddaf humkyung
                else if (e.RightButton == MouseButtonState.Pressed)
1665 787a4489 KangIngu
                {
1666 510cbd2a ljiyeon
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1667 787a4489 KangIngu
                    SetCursor();
1668
                }
1669
1670
                zoomAndPanControl.ReleaseMouseCapture();
1671
1672
1673
                e.Handled = true;
1674
            }
1675
            else
1676
            {
1677 510cbd2a ljiyeon
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1678 787a4489 KangIngu
                SetCursor();
1679
            }
1680
1681 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
1682 787a4489 KangIngu
            //controlType = ControlType.SingleLine;
1683
        }
1684
1685 53880c83 ljiyeon
        public void Set_Symbol_Capture(Point endPoint)
1686
        {       
1687
            double x = canvasDrawingMouseDownPoint.X;
1688
            double y = canvasDrawingMouseDownPoint.Y;
1689
            if(x > endPoint.X)
1690
            {
1691
                x = endPoint.X;
1692
                y = endPoint.Y;
1693
            }
1694
1695
            double width = dragCaptureBorder.Width;
1696
            double height = dragCaptureBorder.Height;
1697
1698
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1699
1700
            if (x < 0)
1701
            {
1702
                width += x;
1703
                x = 0;
1704
            }
1705
            if (y < 0)
1706
            {
1707
                height += y;
1708
                y = 0;
1709
1710
                width = (int)canvasImage.PixelWidth - x;
1711
            }
1712
            if (x + width > canvasImage.PixelWidth)
1713
            {
1714
                width = (int)canvasImage.PixelWidth - x;
1715
            }
1716
            if (y + height > canvasImage.PixelHeight)
1717
            {
1718
                height = (int)canvasImage.PixelHeight - y;
1719
            }
1720
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1721
1722
            string uri = "";
1723
            if (userData.COMPANY != "EXT")
1724
            {
1725 84c48033 djkim
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1726 53880c83 ljiyeon
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1727
            }
1728
            else
1729
            {
1730 84c48033 djkim
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1731 53880c83 ljiyeon
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1732
            }
1733
1734
            var defaultBitmapImage = new BitmapImage();
1735
            defaultBitmapImage.BeginInit();
1736
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1737
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1738
            defaultBitmapImage.UriSource = new Uri(uri);
1739
            defaultBitmapImage.EndInit();
1740
1741 90e7968d ljiyeon
            //GC.Collect();
1742 53880c83 ljiyeon
1743
            if (defaultBitmapImage.IsDownloading)
1744
            {
1745
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1746
                {
1747
                    defaultBitmapImage.Freeze();
1748 90e7968d ljiyeon
                    //GC.Collect();
1749 53880c83 ljiyeon
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1750
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1751
                };
1752
            }
1753
        }
1754
1755 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1756
        {
1757 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
1758 a1716fa5 KangIngu
        }
1759
1760 787a4489 KangIngu
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1761
        {
1762 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
1763 53880c83 ljiyeon
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1764 787a4489 KangIngu
        }
1765
1766
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1767
        {
1768
1769
        }
1770
1771 4804a4fb humkyung
        /// <summary>
1772
        /// select items by dragging
1773
        /// </summary>
1774 787a4489 KangIngu
        private void ApplyDragSelectionRect()
1775
        {
1776
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1777
1778
            double x = Canvas.GetLeft(dragSelectionBorder);
1779
            double y = Canvas.GetTop(dragSelectionBorder);
1780
            double width = dragSelectionBorder.Width;
1781
            double height = dragSelectionBorder.Height;
1782
            Boolean Flag = false;
1783
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1784 f87a00b1 ljiyeon
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1785 787a4489 KangIngu
1786 e6a9ddaf humkyung
            Rect dragRect = new Rect(x, y, width, height);
1787
            ///dragRect.Inflate(width / 10, height / 10);
1788 787a4489 KangIngu
1789
            foreach (var item in Items)
1790
            {
1791 91efe37a humkyung
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1792 787a4489 KangIngu
1793
                if (Flag)
1794
                {
1795
                    adornerSet.Add(item);
1796 05009a0e ljiyeon
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1797 787a4489 KangIngu
                    Control_Style(item);
1798
                }
1799
            }
1800
            if (adornerSet.Count > 0)
1801
            {
1802
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1803
                SelectLayer.Children.Add(final);
1804
            }
1805
        }
1806
1807
        private void InitDragSelectionRect(Point pt1, Point pt2)
1808
        {
1809 9f473fb7 KangIngu
            //캡쳐 중
1810
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1811
            {
1812
                dragCaptureBorder.Visibility = Visibility.Visible;
1813
            }
1814 787a4489 KangIngu
            //선택 중
1815 9f473fb7 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1816 787a4489 KangIngu
            {
1817 e54660e8 KangIngu
1818 787a4489 KangIngu
                dragSelectionBorder.Visibility = Visibility.Visible;
1819
            }
1820
            else
1821
            {
1822 9f473fb7 KangIngu
                dragZoomBorder.Visibility = Visibility.Visible;
1823 787a4489 KangIngu
            }
1824
            UpdateDragSelectionRect(pt1, pt2);
1825
        }
1826
1827
        /// <summary>
1828
        /// Update the position and size of the rectangle used for drag selection.
1829
        /// </summary>
1830
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1831
        {
1832
            double x, y, width, height;
1833
1834
            //
1835
            // Determine x,y,width and height of the rect inverting the points if necessary.
1836
            // 
1837
1838
            if (pt2.X < pt1.X)
1839
            {
1840
                x = pt2.X;
1841
                width = pt1.X - pt2.X;
1842
            }
1843
            else
1844
            {
1845
                x = pt1.X;
1846
                width = pt2.X - pt1.X;
1847
            }
1848
1849
            if (pt2.Y < pt1.Y)
1850
            {
1851
                y = pt2.Y;
1852
                height = pt1.Y - pt2.Y;
1853
            }
1854
            else
1855
            {
1856
                y = pt1.Y;
1857
                height = pt2.Y - pt1.Y;
1858
            }
1859
1860
            //
1861
            // Update the coordinates of the rectangle used for drag selection.
1862
            //
1863 9f473fb7 KangIngu
            //캡쳐 중
1864
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1865
            {
1866
                Canvas.SetLeft(dragCaptureBorder, x);
1867
                Canvas.SetTop(dragCaptureBorder, y);
1868
                dragCaptureBorder.Width = width;
1869
                dragCaptureBorder.Height = height;
1870
            }
1871 787a4489 KangIngu
            //선택 중
1872 a1716fa5 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1873 787a4489 KangIngu
            {
1874
                Canvas.SetLeft(dragSelectionBorder, x);
1875
                Canvas.SetTop(dragSelectionBorder, y);
1876
                dragSelectionBorder.Width = width;
1877
                dragSelectionBorder.Height = height;
1878
            }
1879
            else
1880
            {
1881 9f473fb7 KangIngu
                Canvas.SetLeft(dragZoomBorder, x);
1882
                Canvas.SetTop(dragZoomBorder, y);
1883
                dragZoomBorder.Width = width;
1884
                dragZoomBorder.Height = height;
1885 787a4489 KangIngu
            }
1886
        }
1887
1888
        private void drawingPannelRotate(double angle)
1889
        {
1890 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1891 787a4489 KangIngu
            rotate.Angle = angle;
1892
            var rotationNum = Math.Abs((rotate.Angle / 90));
1893
1894
            if (angle == 90 || angle == 270)
1895
            {
1896
                double emptySize = zoomAndPanCanvas.Width;
1897
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1898
                zoomAndPanCanvas.Height = emptySize;
1899
            }
1900
            if (angle == 0)
1901
            {
1902
                translate.X = 0;
1903
                translate.Y = 0;
1904
            }
1905
            else if (angle == 90)
1906
            {
1907
                translate.X = zoomAndPanCanvas.Width;
1908
                translate.Y = 0;
1909
            }
1910
            else if (angle == 180)
1911
            {
1912
                translate.X = zoomAndPanCanvas.Width;
1913
                translate.Y = zoomAndPanCanvas.Height;
1914
            }
1915
            else
1916
            {
1917
                translate.X = 0;
1918
                translate.Y = zoomAndPanCanvas.Height;
1919
            }
1920
1921
            zoomAndPanControl.RotationAngle = rotate.Angle;
1922
1923
1924
            if (!testPanel2.IsHidden)
1925
            {
1926
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1927
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1928
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1929
            }
1930
1931
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1932
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1933
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1934
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1935
            ViewerDataModel.Instance.Angle = rotate.Angle;
1936
        }
1937
1938 53880c83 ljiyeon
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1939 787a4489 KangIngu
        {
1940 53880c83 ljiyeon
            string Data_ = "";
1941
1942
            try
1943
            {
1944
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1945
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1946
                if (Data_ != null || Data_ != "")
1947
                {
1948
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1949
                }
1950
                else
1951
                {
1952
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1953
                }
1954
1955 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1956
                //{
1957
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1958
                //    STATE = 0,
1959
                //};
1960 53880c83 ljiyeon
                if (Data_ != null)
1961
                {
1962
                    Image img = new Image();
1963
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1964
                    if (Data_.Contains(".svg"))
1965
                    {
1966
                        byte[] imageData = null;
1967
                        DrawingImage image = null;
1968
                        using (System.Net.WebClient web = new System.Net.WebClient())
1969
                        {
1970
                            imageData = web.DownloadData(new Uri(Data_));
1971
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1972
                            image = SvgReader.Load(stream);
1973
                        }
1974
                        img.Source = image;
1975
                    }
1976
                    else
1977
                    {
1978
                        img.Source = new BitmapImage(new Uri(Data_));
1979
                    }
1980
1981
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1982
                    {
1983
                        PointSet = new List<Point>(),
1984
                        FilePath = Data_,
1985
                        ImageData = img.Source,
1986
                        StartPoint = canvasZoomPanningMouseDownPoint,
1987
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
1988
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
1989
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
1990
                        canvasZoomPanningMouseDownPoint.Y),
1991
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
1992
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
1993
                    };
1994
1995
                    currentControl.PointSet = new List<Point>
1996
                                        {
1997
                                            currentControl.StartPoint,
1998
                                            currentControl.LeftBottomPoint,
1999
                                            currentControl.EndPoint,
2000
                                            currentControl.TopRightPoint,
2001
                                        };
2002
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2003
                    UndoData = new Undo_data()
2004
                    {
2005
                        IsUndo = false,
2006
                        Event = Event_Type.Create,
2007
                        EventTime = DateTime.Now,
2008
                        Markup_List = new List<Multi_Undo_data>()
2009
                    };
2010
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2011
                    {
2012
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2013
                    });
2014
2015
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2016
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2017
                    UndoData.Markup_List.Add(multi_Undo_Data);
2018
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2019
2020
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2021 24678e06 humkyung
                    currentControl.CommentID = Commons.shortGuid();
2022 53880c83 ljiyeon
                    currentControl.SymbolID = id;
2023
                    currentControl.GroupID = group_id;
2024
                    currentControl.ApplyTemplate();
2025
                    currentControl.SetImage();
2026
2027
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2028
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2029
                    SelectLayer.Children.Add(final);
2030
                }
2031
            }
2032
            catch (Exception ex)
2033
            {
2034
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2035
            }
2036
        }
2037
2038
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2039
        {            
2040 992a98b4 KangIngu
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2041 be04d12c djkim
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2042 992a98b4 KangIngu
            {
2043
                set_option.Value = double.Parse(set_option.ContentText);
2044
            }
2045
2046 f959ea6f humkyung
            ConvertInkControlToPolygon();
2047 787a4489 KangIngu
2048 d62c0439 humkyung
            ///TODO:
2049 787a4489 KangIngu
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2050
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2051
2052 a1716fa5 KangIngu
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2053 787a4489 KangIngu
            {
2054
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2055
            }
2056 d62c0439 humkyung
            /// up to here
2057 787a4489 KangIngu
2058
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2059
            {
2060
                if (arrow_text as ArrowTextControl != null)
2061
                {
2062
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2063
                }
2064
            }
2065
2066 49b217ad humkyung
            //if (currentControl != null)
2067 787a4489 KangIngu
            {
2068
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2069
                if (text_item_ != null)
2070
                {
2071
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2072
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2073
                    (text_item_ as TextControl).EnableEditing = false;
2074 49b217ad humkyung
                    currentControl = null;
2075 787a4489 KangIngu
                }
2076
2077
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2078 49b217ad humkyung
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2079 787a4489 KangIngu
                {
2080
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2081
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2082 49b217ad humkyung
                    currentControl = null;
2083 787a4489 KangIngu
                }
2084
            }
2085
2086 ca40e004 ljiyeon
            double Ang = 0;                                          
2087 787a4489 KangIngu
            if (rotate.Angle != 0)
2088
            {
2089
                Ang = 360 - rotate.Angle;
2090
            }
2091
2092
            if (e.OriginalSource is System.Windows.Controls.Image)
2093
            {
2094
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2095
            }
2096 e54660e8 KangIngu
2097 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2098 53880c83 ljiyeon
            {                
2099
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2100
                if(symbol_id != null)
2101
                {
2102
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2103
                }                
2104
            }
2105
2106 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2107 53880c83 ljiyeon
            {
2108
                if (this._dragdropWindow != null)
2109
                {
2110
                    this._dragdropWindow.Close();
2111
                    this._dragdropWindow = null;
2112
                    symbol_id = null;
2113
                }
2114
            }
2115
2116 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed)
2117 787a4489 KangIngu
            {
2118
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2119
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2120
2121 510cbd2a ljiyeon
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2122 787a4489 KangIngu
                SetCursor();
2123
2124 f513c215 humkyung
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2125 787a4489 KangIngu
            }
2126 f513c215 humkyung
2127 e6a9ddaf humkyung
            if (e.MiddleButton == MouseButtonState.Pressed)
2128 787a4489 KangIngu
            {
2129
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2130
                cursor = Cursors.SizeAll;
2131
                SetCursor();
2132
            }
2133 e6a9ddaf humkyung
            if (e.RightButton == MouseButtonState.Pressed)
2134 787a4489 KangIngu
            {
2135
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2136
                cursor = Cursors.SizeAll;
2137
                SetCursor();
2138
            }
2139 e6a9ddaf humkyung
            else if (e.XButton1 == MouseButtonState.Pressed)
2140 787a4489 KangIngu
            {
2141
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2142
                {
2143
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2144
                }
2145
2146
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2147
2148
            }
2149 e6a9ddaf humkyung
            else if (e.XButton2 == MouseButtonState.Pressed)
2150 787a4489 KangIngu
            {
2151
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2152
                {
2153
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2154
                }
2155
            }
2156
2157 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2158 787a4489 KangIngu
            {
2159
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2160
                {
2161
                    if (SelectLayer.Children.Count == 0)
2162
                    {
2163
                        isLeftMouseButtonDownOnWindow = true;
2164
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2165
                    }
2166
2167
                    if (controlType == ControlType.None)
2168
                    {
2169
                        isLeftMouseButtonDownOnWindow = true;
2170
                    }
2171
                }
2172
2173 f513c215 humkyung
                /// 캡쳐 모드 설정
2174 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2175
                {
2176
                    dragCaptureBorder.Visibility = Visibility.Visible;
2177
                    isLeftMouseButtonDownOnWindow = true;
2178
                }
2179
2180 f513c215 humkyung
                /// 줌 모드 설정
2181 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2182
                {
2183
                    isLeftMouseButtonDownOnWindow = true;
2184 1066bae3 ljiyeon
                }
2185 787a4489 KangIngu
2186 05009a0e ljiyeon
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2187 787a4489 KangIngu
                if (control != null)
2188
                {
2189 d62c0439 humkyung
                    AdornerFinal final = null;
2190 787a4489 KangIngu
2191
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2192
                    {
2193 d62c0439 humkyung
                        /// 기존 selection 해제
2194 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
2195 d62c0439 humkyung
2196 787a4489 KangIngu
                        final = new AdornerFinal(control);
2197
2198 f513c215 humkyung
                        this.Control_Style(control);
2199 787a4489 KangIngu
2200
                        if ((control as IPath) != null)
2201
                        {
2202
                            if ((control as IPath).LineSize != 0)
2203
                            {
2204
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2205
                            }
2206
                        }
2207
                        if ((control as IShapeControl) != null)
2208
                        {
2209
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2210
                            {
2211
                                ViewerDataModel.Instance.checkHatchShape = true;
2212
                            }
2213
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2214
                            {
2215
                                ViewerDataModel.Instance.checkFillShape = true;
2216
                            }
2217
                            else
2218
                            {
2219
                                ViewerDataModel.Instance.checkHatchShape = false;
2220
                                ViewerDataModel.Instance.checkFillShape = false;
2221
                            }
2222
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2223
                        }
2224 9f473fb7 KangIngu
2225 787a4489 KangIngu
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2226 d4b0c723 KangIngu
2227
                        if ((control as TextControl) != null)
2228
                        {
2229 71d7e0bf 송근호
                            if(!((control as TextControl).EnableEditing)) {
2230
                                (control as TextControl).EnableEditing = true;
2231
                            }
2232
2233 d4b0c723 KangIngu
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2234
                            {
2235
                                ViewerDataModel.Instance.checkTextStyle = true;
2236
                            }
2237
                            else
2238
                            {
2239
                                ViewerDataModel.Instance.checkTextStyle = false;
2240
                            }
2241
2242
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2243
                            {
2244
                                ViewerDataModel.Instance.checkTextStyle = true;
2245
                            }
2246
                            else
2247
                            {
2248
                                ViewerDataModel.Instance.checkTextStyle = false;
2249
                            }
2250
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2251
                            {
2252
                                ViewerDataModel.Instance.checkTextWeight = true;
2253
                            }
2254
                            else
2255
                            {
2256
                                ViewerDataModel.Instance.checkTextWeight = false;
2257
                            }
2258
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2259
                            {
2260
                                ViewerDataModel.Instance.checkUnderLine = true;
2261
                            }
2262
                            else
2263
                            {
2264
                                ViewerDataModel.Instance.checkUnderLine = false;
2265
                            }
2266
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2267
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2268 e54660e8 KangIngu
2269 d4b0c723 KangIngu
                        }
2270
                        else if ((control as ArrowTextControl) != null)
2271
                        {
2272 71d7e0bf 송근호
                            if (!((control as ArrowTextControl).EnableEditing)){
2273
                                (control as ArrowTextControl).EnableEditing = true;
2274
                            }
2275 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2276 d4b0c723 KangIngu
                            {
2277 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = true;
2278
                            }
2279
                            else
2280
                            {
2281
                                ViewerDataModel.Instance.checkTextStyle = false;
2282
                            }
2283
2284
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2285
                            {
2286
                                ViewerDataModel.Instance.checkTextStyle = true;
2287 d4b0c723 KangIngu
                            }
2288 e17af42b KangIngu
                            else
2289 d4b0c723 KangIngu
                            {
2290 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = false;
2291 d4b0c723 KangIngu
                            }
2292 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2293 d4b0c723 KangIngu
                            {
2294 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextWeight = true;
2295
                            }
2296
                            else
2297
                            {
2298
                                ViewerDataModel.Instance.checkTextWeight = false;
2299
                            }
2300
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2301
                            {
2302
                                ViewerDataModel.Instance.checkUnderLine = true;
2303
                            }
2304
                            else
2305
                            {
2306
                                ViewerDataModel.Instance.checkUnderLine = false;
2307 d4b0c723 KangIngu
                            }
2308
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2309
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2310
                        }
2311 9f473fb7 KangIngu
                        else if ((control as RectCloudControl) != null)
2312
                        {
2313
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2314
                        }
2315
                        else if ((control as CloudControl) != null)
2316
                        {
2317
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2318
                        }
2319 787a4489 KangIngu
                    }
2320
                    else
2321
                    {
2322 d62c0439 humkyung
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2323
                        SelectionSet.Instance.UnSelect(this);
2324 787a4489 KangIngu
                        comment.Add(control);
2325
2326
                        Control_Style(control);
2327
2328
                        final = new AdornerFinal(comment);
2329
                    }
2330
2331 f513c215 humkyung
                    if (final != null)
2332
                    {
2333
                        this.SelectLayer.Children.Add(final);
2334
                    }
2335 6707a5c7 ljiyeon
                }              
2336 787a4489 KangIngu
            }
2337
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2338 6707a5c7 ljiyeon
            {               
2339 787a4489 KangIngu
                init();
2340
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2341
                if (cursor != Cursors.SizeAll)
2342
                {
2343
                    cursor = Cursors.Cross;
2344
                    SetCursor();
2345
                }
2346
                bool init_user = false;
2347
                foreach (var user in gridViewMarkup.Items)
2348
                {
2349
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2350
                    {
2351
                        init_user = true;
2352
                    }
2353
                }
2354
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2355
                {
2356
                    RadWindow.Alert(new DialogParameters
2357
                    {
2358 b9b01f8e ljiyeon
                        Owner = Application.Current.MainWindow,
2359 787a4489 KangIngu
                        Theme = new VisualStudio2013Theme(),
2360
                        Header = "안내",
2361
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2362
                    });
2363
                    return;
2364
                }
2365
                else
2366
                {
2367
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2368
                    if (item != null)
2369
                    {
2370
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2371
                    }
2372
                }
2373
2374 75448f5e ljiyeon
                switch (controlType)
2375 787a4489 KangIngu
                {
2376 684ef11c ljiyeon
                    case ControlType.Coordinate:
2377
                        {
2378 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2379 684ef11c ljiyeon
                            {
2380
                                if (currentControl is CoordinateControl)
2381
                                {
2382
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2383
                                    {
2384
                                        return;
2385
                                    }
2386
2387 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2388 684ef11c ljiyeon
2389
                                    currentControl = null;
2390
                                    this.cursor = Cursors.Arrow;
2391
                                }
2392
                                else
2393
                                {
2394
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2395 d62c0439 humkyung
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2396 684ef11c ljiyeon
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2397
                                    {
2398
                                        currentControl = null;
2399
                                        this.cursor = Cursors.Arrow;
2400
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2401
                                        return;
2402
                                    }
2403
                                    else
2404
                                    {
2405
                                        currentControl = new CoordinateControl
2406
                                        {
2407
                                            Background = new SolidColorBrush(Colors.Black),
2408 f67f164e humkyung
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2409 684ef11c ljiyeon
                                            ControlType = ControlType.Coordinate
2410
                                        };
2411
2412 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
2413 684ef11c ljiyeon
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2414
                                        currentControl.IsNew = true;
2415
2416
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2417
2418
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2419
                                    }
2420
                                }
2421
                            }
2422
                        }
2423
                        break;
2424
                    case ControlType.InsideWhite:
2425
                        {
2426 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2427 684ef11c ljiyeon
                            {
2428
                                if (currentControl is InsideWhiteControl)
2429
                                {
2430
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2431
                                    {
2432
                                        return;
2433
                                    }
2434
2435 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2436 684ef11c ljiyeon
2437
                                    currentControl = null;
2438
                                    this.cursor = Cursors.Arrow;
2439
                                }
2440
                                else
2441
                                {
2442
                                    currentControl = new InsideWhiteControl
2443
                                    {
2444
                                        Background = new SolidColorBrush(Colors.Black),
2445 f67f164e humkyung
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2446 684ef11c ljiyeon
                                        ControlType = ControlType.InsideWhite
2447
                                    };
2448
2449 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2450 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2451
                                    currentControl.IsNew = true;
2452
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2453
2454
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2455
                                }
2456
                            }
2457
                        }
2458
                        break;
2459
                    case ControlType.OverlapWhite:
2460
                        {
2461 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2462 684ef11c ljiyeon
                            {
2463
                                if (currentControl is OverlapWhiteControl)
2464
                                {
2465
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2466
                                    {
2467
                                        return;
2468
                                    }
2469
2470 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2471 684ef11c ljiyeon
2472
                                    currentControl = null;
2473
                                    this.cursor = Cursors.Arrow;
2474
                                }
2475
                                else
2476
                                {
2477
                                    currentControl = new OverlapWhiteControl
2478
                                    {
2479
                                        Background = new SolidColorBrush(Colors.Black),
2480 f67f164e humkyung
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2481 684ef11c ljiyeon
                                        ControlType = ControlType.OverlapWhite
2482
                                    };
2483
2484 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2485 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2486
                                    currentControl.IsNew = true;
2487
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2488
2489
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2490
                                }
2491
                            }
2492
                        }
2493
                        break;
2494
                    case ControlType.ClipWhite:
2495
                        {
2496 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2497 684ef11c ljiyeon
                            {
2498
                                if (currentControl is ClipWhiteControl)
2499
                                {
2500
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2501
                                    {
2502
                                        return;
2503
                                    }
2504
2505 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2506 684ef11c ljiyeon
2507
                                    currentControl = null;
2508
                                    this.cursor = Cursors.Arrow;
2509
                                }
2510
                                else
2511
                                {
2512
                                    currentControl = new ClipWhiteControl
2513
                                    {
2514
                                        Background = new SolidColorBrush(Colors.Black),
2515 a6272c57 humkyung
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2516 684ef11c ljiyeon
                                        ControlType = ControlType.ClipWhite
2517
                                    };
2518
2519 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2520 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2521
                                    currentControl.IsNew = true;
2522
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2523
2524
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2525
                                }
2526
                            }
2527
                        }
2528
                        break;
2529 787a4489 KangIngu
                    case ControlType.Rectangle:
2530
                        {
2531 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2532 787a4489 KangIngu
                            {
2533 f67f164e humkyung
                                if (currentControl is RectangleControl)
2534
                                {
2535
                                    //20180906 LJY TEST IsRotationDrawingEnable
2536
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2537 787a4489 KangIngu
                                    {
2538 f67f164e humkyung
                                        return;
2539
                                    }
2540 787a4489 KangIngu
2541 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2542
                                    currentControl = null;
2543 510cbd2a ljiyeon
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2544 f67f164e humkyung
                                }
2545
                                else
2546
                                {
2547
                                    currentControl = new RectangleControl
2548 787a4489 KangIngu
                                    {
2549 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
2550
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2551
                                        ControlType = ControlType.Rectangle
2552
                                    };
2553 787a4489 KangIngu
2554 f67f164e humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2555
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2556
                                    currentControl.IsNew = true;
2557
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2558 787a4489 KangIngu
2559 f67f164e humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2560
                                }
2561 787a4489 KangIngu
                            }
2562
                        }
2563
                        break;
2564
                    case ControlType.RectCloud:
2565
                        {
2566 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2567 787a4489 KangIngu
                            {
2568 f67f164e humkyung
                                if (currentControl is RectCloudControl)
2569
                                {
2570
                                    //20180906 LJY TEST IsRotationDrawingEnable
2571
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2572 787a4489 KangIngu
                                    {
2573 f67f164e humkyung
                                        return;
2574
                                    }
2575 e66f22eb KangIngu
2576 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2577 787a4489 KangIngu
2578 f67f164e humkyung
                                    currentControl = null;
2579
                                
2580
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2581
                                }
2582
                                else
2583
                                {
2584
                                    currentControl = new RectCloudControl
2585 787a4489 KangIngu
                                    {
2586 f67f164e humkyung
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2587
                                        ControlType = ControlType.RectCloud,
2588
                                        Background = new SolidColorBrush(Colors.Black)
2589
                                    };
2590 787a4489 KangIngu
2591 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2592
                                    currentControl.CommentID = Commons.shortGuid();
2593
                                    currentControl.IsNew = true;
2594
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2595
                                }
2596 787a4489 KangIngu
                            }
2597
                        }
2598
                        break;
2599
                    case ControlType.Circle:
2600
                        {
2601 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2602 787a4489 KangIngu
                            {
2603 f67f164e humkyung
                                if (currentControl is CircleControl)
2604
                                {
2605
                                    //20180906 LJY TEST IsRotationDrawingEnable
2606
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2607 787a4489 KangIngu
                                    {
2608 f67f164e humkyung
                                        return;
2609
                                    }
2610 e66f22eb KangIngu
2611 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2612 787a4489 KangIngu
2613 f67f164e humkyung
                                    currentControl = null;
2614
                                }
2615
                                else
2616
                                {
2617
                                    currentControl = new CircleControl
2618 787a4489 KangIngu
                                    {
2619 f67f164e humkyung
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2620
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2621
                                        Background = new SolidColorBrush(Colors.Black)
2622
                                    };
2623 787a4489 KangIngu
2624 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2625
                                    currentControl.CommentID = Commons.shortGuid();
2626
                                    currentControl.IsNew = true;
2627
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2628
                                }
2629 787a4489 KangIngu
                            }
2630
                        }
2631
                        break;
2632
                    case ControlType.Triangle:
2633
                        {
2634 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2635 787a4489 KangIngu
                            {
2636 f67f164e humkyung
                                if (currentControl is TriControl)
2637
                                {
2638
                                    var content = currentControl as TriControl;
2639
                                    if (content.MidPoint == new Point(0, 0))
2640 787a4489 KangIngu
                                    {
2641 f67f164e humkyung
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2642 787a4489 KangIngu
                                    }
2643
                                    else
2644
                                    {
2645 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
2646 f67f164e humkyung
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2647 e66f22eb KangIngu
                                        {
2648
                                            return;
2649
                                        }
2650
2651 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
2652 787a4489 KangIngu
2653
                                        currentControl = null;
2654
                                    }
2655 f67f164e humkyung
                                }
2656
                                else
2657
                                {
2658
                                    currentControl = new TriControl
2659 787a4489 KangIngu
                                    {
2660 f67f164e humkyung
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2661
                                        Background = new SolidColorBrush(Colors.Black),
2662
                                    };
2663 787a4489 KangIngu
2664 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2665
                                    currentControl.CommentID = Commons.shortGuid();
2666
                                    currentControl.IsNew = true;
2667
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2668
                                }
2669 787a4489 KangIngu
                            }
2670
                        }
2671
                        break;
2672
                    case ControlType.CancelLine:
2673 f67f164e humkyung
                    case ControlType.SingleLine:
2674
                    case ControlType.ArrowLine:
2675
                    case ControlType.TwinLine:
2676
                    case ControlType.DimLine:
2677 787a4489 KangIngu
                        {
2678 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2679 787a4489 KangIngu
                            {
2680 f67f164e humkyung
                                if (currentControl is LineControl)
2681
                                {
2682
                                    //20180906 LJY TEST IsRotationDrawingEnable
2683
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2684 787a4489 KangIngu
                                    {
2685 f67f164e humkyung
                                        return;
2686 787a4489 KangIngu
                                    }
2687 f67f164e humkyung
2688
                                    CreateCommand.Instance.Execute(currentControl);
2689
                                    currentControl = null;
2690
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2691
                                }
2692
                                else
2693
                                {
2694
                                    currentControl = new LineControl
2695 787a4489 KangIngu
                                    {
2696 f67f164e humkyung
                                        ControlType = this.controlType,
2697
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2698
                                        Background = new SolidColorBrush(Colors.Black)
2699
                                    };
2700 787a4489 KangIngu
2701 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2702
                                    currentControl.CommentID = Commons.shortGuid();
2703
                                    currentControl.IsNew = true;
2704
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2705
                                    this.MainAngle.Visibility = Visibility.Visible;
2706
                                }
2707 787a4489 KangIngu
                            }
2708
                        }
2709
                        break;
2710 f67f164e humkyung
                    case ControlType.PolygonControl:
2711 787a4489 KangIngu
                        {
2712 f67f164e humkyung
                            if (currentControl is PolygonControl)
2713 787a4489 KangIngu
                            {
2714 f67f164e humkyung
                                var control = currentControl as PolygonControl;
2715 e66f22eb KangIngu
2716 f67f164e humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
2717
                                {
2718
                                    control.IsCompleted = true;
2719
                                }
2720 787a4489 KangIngu
2721 f67f164e humkyung
                                if (!control.IsCompleted)
2722
                                {
2723
                                    control.PointSet.Add(control.EndPoint);
2724
                                }
2725
                                else
2726
                                {
2727
                                    //20180906 LJY TEST IsRotationDrawingEnable
2728
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2729 787a4489 KangIngu
                                    {
2730 f67f164e humkyung
                                        return;
2731 787a4489 KangIngu
                                    }
2732 e66f22eb KangIngu
2733 f67f164e humkyung
                                    var firstPoint = control.PointSet.First();
2734
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2735
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2736
                                    control.PointSet.Add(firstPoint);
2737 787a4489 KangIngu
2738 f67f164e humkyung
                                    control.ApplyOverViewData();
2739
2740
                                    CreateCommand.Instance.Execute(currentControl);
2741
                                    control.updateControl();
2742
                                    currentControl = null;
2743
                                }
2744 787a4489 KangIngu
                            }
2745 f67f164e humkyung
                            else
2746 787a4489 KangIngu
                            {
2747 f67f164e humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
2748
                                {
2749
                                    currentControl = new PolygonControl
2750 787a4489 KangIngu
                                    {
2751 f67f164e humkyung
                                        PointSet = new List<Point>(),
2752
                                    };
2753 787a4489 KangIngu
2754 f67f164e humkyung
                                    var polygonControl = (currentControl as PolygonControl);
2755
                                    currentControl.CommentID = Commons.shortGuid();
2756
                                    currentControl.IsNew = true;
2757
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2758
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2759
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2760
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2761
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2762
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2763
                                    polygonControl.ApplyTemplate();
2764
                                    polygonControl.Visibility = Visibility.Visible;
2765
                                }
2766 787a4489 KangIngu
                            }
2767
                        }
2768
                        break;
2769
                    case ControlType.ChainLine:
2770
                        {
2771
                            if (currentControl is PolygonControl)
2772
                            {
2773
                                var control = currentControl as PolygonControl;
2774
2775 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
2776 787a4489 KangIngu
                                {
2777 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
2778
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2779 e66f22eb KangIngu
                                    {
2780
                                        return;
2781
                                    }
2782
2783 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2784 787a4489 KangIngu
2785
                                    currentControl = null;
2786 2eac4f76 KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2787 787a4489 KangIngu
                                    return;
2788
                                }
2789
2790
                                if (!control.IsCompleted)
2791
                                {
2792
                                    control.PointSet.Add(control.EndPoint);
2793 2eac4f76 KangIngu
                                    this.MainAngle.Visibility = Visibility.Visible;
2794 787a4489 KangIngu
                                }
2795
                            }
2796
                            else
2797
                            {
2798 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
2799 787a4489 KangIngu
                                {
2800 2eac4f76 KangIngu
                                    MainAngle.Visibility = Visibility.Visible;
2801 787a4489 KangIngu
                                    currentControl = new PolygonControl
2802
                                    {
2803
                                        PointSet = new List<Point>(),
2804
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2805
                                        ControlType = ControlType.ChainLine,
2806
                                        DashSize = ViewerDataModel.Instance.DashSize,
2807
                                        LineSize = ViewerDataModel.Instance.LineSize,
2808
                                        //PointC = new StylusPointSet()
2809
                                    };
2810
2811 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2812
                                    //{
2813 787a4489 KangIngu
                                        var polygonControl = (currentControl as PolygonControl);
2814 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
2815 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2816
                                        currentControl.IsNew = true;
2817
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2818
                                        //currentControl.OnApplyTemplate();
2819
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2820
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2821
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2822
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2823 e66f22eb KangIngu
                                    //}
2824 787a4489 KangIngu
                                }
2825
                            }
2826
                        }
2827
                        break;
2828
                    case ControlType.ArcLine:
2829
                        {
2830 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2831 787a4489 KangIngu
                            {
2832 f67f164e humkyung
                                if (currentControl is ArcControl)
2833
                                {
2834
                                    //20180906 LJY TEST IsRotationDrawingEnable
2835
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2836 787a4489 KangIngu
                                    {
2837 f67f164e humkyung
                                        return;
2838
                                    }
2839 e66f22eb KangIngu
2840 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2841 787a4489 KangIngu
2842 f67f164e humkyung
                                    currentControl = null;
2843
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2844
                                }
2845
                                else
2846
                                {
2847
                                    currentControl = new ArcControl
2848 787a4489 KangIngu
                                    {
2849 f67f164e humkyung
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2850
                                        Background = new SolidColorBrush(Colors.Black)
2851
                                    };
2852
                                    currentControl.CommentID = Commons.shortGuid();
2853
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2854
                                    currentControl.IsNew = true;
2855
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2856
                                    this.MainAngle.Visibility = Visibility.Visible;
2857
                                }
2858 787a4489 KangIngu
                            }
2859 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
2860 787a4489 KangIngu
                            {
2861
                                if (currentControl != null)
2862
                                {
2863
                                    (currentControl as ArcControl).setClock();
2864 05f4d127 KangIngu
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2865 787a4489 KangIngu
                                }
2866
                            }
2867
                        }
2868
                        break;
2869
                    case ControlType.ArcArrow:
2870
                        {
2871 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2872 787a4489 KangIngu
                            {
2873 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2874
                                //{
2875 40b3ce25 ljiyeon
                                if (currentControl is ArrowArcControl)
2876
                                {
2877
                                    //20180906 LJY TEST IsRotationDrawingEnable
2878
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2879 787a4489 KangIngu
                                    {
2880 40b3ce25 ljiyeon
                                        return;
2881
                                    }
2882 e66f22eb KangIngu
2883 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2884 787a4489 KangIngu
2885 40b3ce25 ljiyeon
                                    currentControl = null;
2886
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2887
                                }
2888
                                else
2889
                                {
2890
                                    currentControl = new ArrowArcControl
2891 787a4489 KangIngu
                                    {
2892 a6272c57 humkyung
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2893 40b3ce25 ljiyeon
                                        Background = new SolidColorBrush(Colors.Black)
2894
                                    };
2895 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2896 40b3ce25 ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2897
                                    currentControl.IsNew = true;
2898
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2899
                                    this.MainAngle.Visibility = Visibility.Visible;
2900
                                }
2901 e66f22eb KangIngu
                                //}
2902 787a4489 KangIngu
                            }
2903 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
2904 787a4489 KangIngu
                            {
2905 40b3ce25 ljiyeon
                                if (currentControl != null)
2906
                                {
2907
                                    (currentControl as ArrowArcControl).setClock();
2908
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2909
                                    //(currentControl as ArcControl).ApplyTemplate();
2910
                                }
2911 787a4489 KangIngu
                            }
2912
                        }
2913
                        break;
2914
                    case ControlType.ArrowMultiLine:
2915
                        {
2916 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2917 787a4489 KangIngu
                            {
2918 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2919
                                //{
2920 787a4489 KangIngu
2921
                                    if (currentControl is ArrowControl_Multi)
2922
                                    {
2923
                                        var content = currentControl as ArrowControl_Multi;
2924
                                        if (content.MiddlePoint == new Point(0, 0))
2925
                                        {
2926 2eac4f76 KangIngu
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2927
                                            {
2928
                                                content.MiddlePoint = content.EndPoint;
2929
                                            }
2930
                                            else
2931
                                            {
2932
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2933
                                            }
2934 787a4489 KangIngu
                                        }
2935
                                        else
2936
                                        {
2937 ca40e004 ljiyeon
                                            //20180906 LJY TEST IsRotationDrawingEnable
2938
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2939 e66f22eb KangIngu
                                            {
2940
                                                return;
2941
                                            }
2942
2943 f513c215 humkyung
                                            CreateCommand.Instance.Execute(currentControl);
2944 787a4489 KangIngu
2945
                                            currentControl = null;
2946 5ce56a3a KangIngu
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2947 787a4489 KangIngu
                                        }
2948
                                    }
2949
                                    else
2950
                                    {
2951
                                        currentControl = new ArrowControl_Multi
2952
                                        {
2953
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2954
                                            Background = new SolidColorBrush(Colors.Black)
2955
                                        };
2956 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
2957 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2958
                                        currentControl.IsNew = true;
2959
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2960 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
2961 787a4489 KangIngu
                                    }
2962 e66f22eb KangIngu
                                //}
2963 787a4489 KangIngu
                            }
2964
                        }
2965
                        break;
2966
                    case ControlType.PolygonCloud:
2967
                        {
2968
                            if (currentControl is CloudControl)
2969
                            {
2970
                                var control = currentControl as CloudControl;
2971 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
2972 787a4489 KangIngu
                                {
2973
                                    control.IsCompleted = true;
2974
                                }
2975
2976
                                if (!control.IsCompleted)
2977
                                {
2978
                                    control.PointSet.Add(control.EndPoint);
2979
                                }
2980
                                else
2981
                                {
2982 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
2983
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2984 e66f22eb KangIngu
                                    {
2985
                                        return;
2986
                                    }
2987
2988 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2989 787a4489 KangIngu
2990
                                    control.isTransOn = true;
2991
                                    var firstPoint = control.PointSet.First();
2992
2993
                                    control.PointSet.Add(firstPoint);
2994
                                    control.DrawingCloud();
2995
                                    control.ApplyOverViewData();
2996
2997
                                    currentControl = null;
2998
                                }
2999
                            }
3000
                            else
3001
                            {
3002 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3003 787a4489 KangIngu
                                {
3004
                                    currentControl = new CloudControl
3005
                                    {
3006
                                        PointSet = new List<Point>(),
3007
                                        PointC = new StylusPointSet()
3008
                                    };
3009
3010 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3011
                                    //{
3012 787a4489 KangIngu
                                        var polygonControl = (currentControl as CloudControl);
3013 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3014 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3015
                                        currentControl.IsNew = true;
3016
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3017
3018
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3019
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3020 b9ce7aee ljiyeon
                                    
3021 e66f22eb KangIngu
                                    //}
3022 787a4489 KangIngu
                                }
3023
                            }
3024
                        }
3025
                        break;
3026
                    case ControlType.ImgControl:
3027
                        {
3028 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3029 787a4489 KangIngu
                            {
3030 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3031
                                //{
3032 787a4489 KangIngu
                                    if (currentControl is ImgControl)
3033
                                    {
3034 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3035
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3036 e66f22eb KangIngu
                                        {
3037
                                            return;
3038
                                        }
3039
3040 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3041 53880c83 ljiyeon
                                        controlType = ControlType.ImgControl;
3042 787a4489 KangIngu
                                        currentControl = null;
3043
                                    }
3044
                                    else
3045
                                    {
3046 c73426a9 ljiyeon
                                        
3047 787a4489 KangIngu
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3048 53880c83 ljiyeon
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3049 787a4489 KangIngu
                                        {
3050
                                            Image img = new Image();
3051 53880c83 ljiyeon
                                            if (filename.Contains(".svg"))
3052
                                            {
3053
                                                byte[] imageData = null;
3054
                                                DrawingImage image = null;
3055
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3056
                                                {
3057
                                                    imageData = web.DownloadData(new Uri(filename));
3058
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3059
                                                    image = SvgReader.Load(stream);
3060
                                                }
3061
                                                img.Source = image;
3062
                                            }
3063
                                            else
3064
                                            {
3065
                                                img.Source = new BitmapImage(new Uri(filename));
3066
                                            }
3067 787a4489 KangIngu
3068
                                            currentControl = new ImgControl
3069
                                            {
3070 53880c83 ljiyeon
                                                    Background = new SolidColorBrush(Colors.Black),
3071
                                                    PointSet = new List<Point>(),
3072
                                                    FilePath = filename,
3073
                                                    ImageData = img.Source,
3074
                                                    StartPoint = canvasDrawingMouseDownPoint,
3075
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3076
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3077
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3078
                                                    ControlType = ControlType.ImgControl
3079
                                                };
3080
3081
                                        
3082 24678e06 humkyung
                                                currentControl.CommentID = Commons.shortGuid();                                            
3083 53880c83 ljiyeon
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3084
                                                currentControl.IsNew = true;
3085
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3086
3087
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3088
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3089
                                        }
3090 787a4489 KangIngu
                                    }
3091 e66f22eb KangIngu
                                //}
3092 787a4489 KangIngu
                            }
3093
                        }
3094
                        break;
3095
                    case ControlType.Date:
3096
                        {
3097 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3098 787a4489 KangIngu
                            {
3099 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3100
                                //{
3101 787a4489 KangIngu
                                    if (currentControl is DateControl)
3102
                                    {
3103 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3104
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3105 e66f22eb KangIngu
                                        {
3106
                                            return;
3107
                                        }
3108
3109 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3110 787a4489 KangIngu
                                        currentControl = null;
3111
3112
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3113
                                        {
3114
                                            controlType = ControlType.None;
3115
                                            IsSwingMode = false;
3116
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3117
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3118
                                            mouseHandlingMode = MouseHandlingMode.None;
3119
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3120
                                            txtBatch.Visibility = Visibility.Collapsed;
3121
3122
                                        }
3123
                                    }
3124
                                    else
3125
                                    {
3126
                                        currentControl = new DateControl
3127
                                        {
3128 a6272c57 humkyung
                                            StartPoint = canvasDrawingMouseDownPoint,
3129 787a4489 KangIngu
                                            Background = new SolidColorBrush(Colors.Black)
3130
                                        };
3131 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3132 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3133
                                        currentControl.IsNew = true;
3134
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3135 ca40e004 ljiyeon
3136
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3137
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3138
                                }
3139 e66f22eb KangIngu
                                //}
3140 787a4489 KangIngu
                            }
3141
                        }
3142
                        break;
3143
                    case ControlType.TextControl:
3144
                        {
3145 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3146 787a4489 KangIngu
                            {
3147
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3148
                                {
3149
                                    currentControl = new TextControl
3150
                                    {
3151
                                        ControlType = controlType
3152
                                    };
3153 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3154 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3155 8742caa5 humkyung
                                    currentControl.IsNew = true;
3156
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3157
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3158 1066bae3 ljiyeon
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3159
3160 8742caa5 humkyung
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3161
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3162 6b5d33c6 djkim
                                    
3163 8742caa5 humkyung
                                    (currentControl as TextControl).ControlType_No = 0;
3164
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3165
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3166 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3167
                                    (currentControl as TextControl).Base_TextBox.Focus();
3168 787a4489 KangIngu
3169 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3170 787a4489 KangIngu
                                }
3171
                            }
3172
                        }
3173
                        break;
3174
                    case ControlType.TextBorder:
3175
                        {
3176 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3177 787a4489 KangIngu
                            {
3178
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3179
                                {
3180
                                    currentControl = new TextControl
3181
                                    {
3182
                                        ControlType = controlType
3183
                                    };
3184
3185 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3186 787a4489 KangIngu
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3187 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3188 787a4489 KangIngu
                                    currentControl.IsNew = true;
3189
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3190
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3191
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3192
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3193 6b5d33c6 djkim
                                    
3194 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 1;
3195
                                    (currentControl as TextControl).Angle = Ang;
3196
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3197 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3198
                                    (currentControl as TextControl).Base_TextBox.Focus();
3199 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3200 787a4489 KangIngu
                                }
3201
                            }
3202
                        }
3203
                        break;
3204
                    case ControlType.TextCloud:
3205
                        {
3206 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3207 787a4489 KangIngu
                            {
3208
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3209
                                {
3210
                                    currentControl = new TextControl
3211
                                    {
3212
                                        ControlType = controlType
3213
                                    };
3214 610a4b86 KangIngu
3215
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3216 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3217 787a4489 KangIngu
                                    currentControl.IsNew = true;
3218
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3219
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3220
3221
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3222
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3223 6b5d33c6 djkim
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3224 787a4489 KangIngu
3225
                                    (currentControl as TextControl).Angle = Ang;
3226
                                    (currentControl as TextControl).ControlType_No = 2;
3227
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3228 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3229
                                    (currentControl as TextControl).Base_TextBox.Focus();
3230 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3231 49b217ad humkyung
                                    //currentControl = null;
3232 787a4489 KangIngu
                                }
3233
                            }
3234
                        }
3235
                        break;
3236
                    case ControlType.ArrowTextControl:
3237 ca40e004 ljiyeon
                         {
3238 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3239 787a4489 KangIngu
                            {
3240
                                if (currentControl is ArrowTextControl)
3241
                                {
3242 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3243
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3244 e66f22eb KangIngu
                                    {
3245
                                        return;
3246 f513c215 humkyung
                                    }
3247 e66f22eb KangIngu
3248 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3249 787a4489 KangIngu
3250
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3251
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3252 49b217ad humkyung
                                    (currentControl as ArrowTextControl).IsNew = false;
3253 787a4489 KangIngu
                                    currentControl = null;
3254
                                }
3255
                                else
3256
                                {
3257 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3258
                                    //{
3259 787a4489 KangIngu
                                        currentControl = new ArrowTextControl();
3260 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3261 787a4489 KangIngu
                                        currentControl.IsNew = true;
3262
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3263
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3264
3265
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3266
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3267
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3268 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3269 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3270
3271 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3272
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3273 787a4489 KangIngu
3274 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3275 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3276 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3277 ca40e004 ljiyeon
3278
                                    
3279 e66f22eb KangIngu
                                    //}
3280 787a4489 KangIngu
                                }
3281
                            }
3282
                        }
3283
                        break;
3284
                    case ControlType.ArrowTransTextControl:
3285
                        {
3286 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3287 787a4489 KangIngu
                            {
3288
                                if (currentControl is ArrowTextControl)
3289
                                {
3290 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3291
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3292 e66f22eb KangIngu
                                    {
3293
                                        return;
3294 f513c215 humkyung
                                    }
3295 e66f22eb KangIngu
3296 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3297 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3298 49b217ad humkyung
                                    currentControl.IsNew = false;
3299 787a4489 KangIngu
                                    currentControl = null;
3300 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3301 787a4489 KangIngu
                                }
3302
                                else
3303
                                {
3304 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3305
                                    //{
3306 ca40e004 ljiyeon
                                         currentControl = new ArrowTextControl();
3307 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3308 787a4489 KangIngu
                                        currentControl.IsNew = true;
3309
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3310
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3311
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3312
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3313 ca40e004 ljiyeon
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3314 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3315 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isFixed = true;
3316
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3317
3318 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3319
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3320
3321
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3322 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3323 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).isTrans = true;
3324 787a4489 KangIngu
                                }
3325
                            }
3326
                        }
3327
                        break;
3328
                    case ControlType.ArrowTextBorderControl:
3329 ca40e004 ljiyeon
                         {
3330 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3331 787a4489 KangIngu
                            {
3332
                                if (currentControl is ArrowTextControl)
3333
                                {
3334 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3335
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3336 e66f22eb KangIngu
                                    {
3337
                                        return;
3338
                                    }
3339
3340 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3341 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3342 49b217ad humkyung
                                    currentControl.IsNew = false;
3343 787a4489 KangIngu
                                    currentControl = null;
3344 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3345 787a4489 KangIngu
                                }
3346
                                else
3347
                                {
3348 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3349
                                    //{
3350 787a4489 KangIngu
                                        currentControl = new ArrowTextControl()
3351
                                        {
3352
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3353
                                        };
3354 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3355 787a4489 KangIngu
                                        currentControl.IsNew = true;
3356
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3357
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3358
3359
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3360
3361
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3362
3363
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3364
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3365 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3366 787a4489 KangIngu
3367 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3368
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3369
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3370 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3371 ca40e004 ljiyeon
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3372 e66f22eb KangIngu
                                    //}
3373 787a4489 KangIngu
                                }
3374
                            }
3375
                        }
3376
                        break;
3377
                    case ControlType.ArrowTransTextBorderControl:
3378
                        {
3379 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3380 787a4489 KangIngu
                            {
3381
                                if (currentControl is ArrowTextControl)
3382
                                {
3383 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3384
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3385 e66f22eb KangIngu
                                    {
3386
                                        return;
3387
                                    }
3388 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3389 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3390 49b217ad humkyung
                                    currentControl.IsNew = false;
3391 787a4489 KangIngu
                                    currentControl = null;
3392 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3393 787a4489 KangIngu
                                }
3394
                                else
3395
                                {
3396 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3397
                                    //{
3398 ca40e004 ljiyeon
                                    
3399
3400
                                    currentControl = new ArrowTextControl()
3401 787a4489 KangIngu
                                        {
3402
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3403
                                        };
3404 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3405 787a4489 KangIngu
                                        currentControl.IsNew = true;
3406
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3407
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3408
3409
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3410
3411
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3412 ca40e004 ljiyeon
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3413 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3414 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isFixed = true;
3415
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3416 ca40e004 ljiyeon
                                     
3417
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3418
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3419 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3420
3421 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3422 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3423 ca40e004 ljiyeon
                                    
3424
                                    //20180911 LJY
3425
                                        (currentControl as ArrowTextControl).isTrans = true;
3426
                                    
3427
3428 e66f22eb KangIngu
                                    //}
3429 787a4489 KangIngu
                                }
3430
                            }
3431
                        }
3432
                        break;
3433
                    case ControlType.ArrowTextCloudControl:
3434
                        {
3435 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3436 787a4489 KangIngu
                            {
3437
                                if (currentControl is ArrowTextControl)
3438
                                {
3439 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3440
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3441 e66f22eb KangIngu
                                    {
3442
                                        return;
3443
                                    }
3444 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3445 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3446 49b217ad humkyung
                                    currentControl.IsNew = false;
3447 787a4489 KangIngu
                                    currentControl = null;
3448 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3449 787a4489 KangIngu
                                }
3450
                                else
3451
                                {
3452 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3453
                                    //{
3454 787a4489 KangIngu
                                        currentControl = new ArrowTextControl()
3455
                                        {
3456
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3457
                                        };
3458 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3459 787a4489 KangIngu
                                        currentControl.IsNew = true;
3460
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3461
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3462
3463
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3464
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3465 ca40e004 ljiyeon
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3466 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3467 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3468
3469 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3470
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3471
                                    
3472
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3473 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3474 ca40e004 ljiyeon
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3475 e66f22eb KangIngu
                                    //}
3476 787a4489 KangIngu
                                }
3477
                            }
3478
                        }
3479
                        break;
3480
                    case ControlType.ArrowTransTextCloudControl:
3481
                        {
3482 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3483 787a4489 KangIngu
                            {
3484
                                if (currentControl is ArrowTextControl)
3485
                                {
3486 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3487
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3488 e66f22eb KangIngu
                                    {
3489
                                        return;
3490
                                    }
3491 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3492 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3493 49b217ad humkyung
                                    currentControl.IsNew = false;
3494 787a4489 KangIngu
                                    currentControl = null;
3495 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3496 787a4489 KangIngu
                                }
3497
                                else
3498
                                {
3499 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3500
                                    //{
3501 787a4489 KangIngu
                                        currentControl = new ArrowTextControl()
3502
                                        {
3503
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3504
                                        };
3505 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3506 ca40e004 ljiyeon
                                        currentControl.IsNew = true; 
3507 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3508
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3509
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3510
3511
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3512 ca40e004 ljiyeon
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3513 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3514 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isFixed = true;
3515
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3516
3517 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3518
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3519 787a4489 KangIngu
3520 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3521 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3522 ca40e004 ljiyeon
                                        this.MainAngle.Visibility = Visibility.Visible;  
3523
                                    
3524
                                    //20180911 LJY
3525
                                        (currentControl as ArrowTextControl).isTrans = true;
3526 e66f22eb KangIngu
                                    //}
3527 787a4489 KangIngu
                                }
3528
                            }
3529
                        }
3530
                        break;
3531
                    //강인구 추가
3532
                    case ControlType.Sign:
3533
                        {
3534 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3535 787a4489 KangIngu
                            {
3536 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3537
                                //{
3538 661b7416 humkyung
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3539 992a98b4 KangIngu
3540
                                    if (_sign == null)
3541
                                    {
3542
                                        txtBatch.Visibility = Visibility.Collapsed;
3543
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3544
                                        controlType = ControlType.None;
3545
3546
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3547
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3548
                                        return;
3549
                                    }
3550
3551 787a4489 KangIngu
                                    if (currentControl is SignControl)
3552
                                    {
3553 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3554
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3555 e66f22eb KangIngu
                                        {
3556
                                            return;
3557
                                        }
3558
3559 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3560 787a4489 KangIngu
                                        currentControl = null;
3561
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3562
                                        {
3563 999c9e40 humkyung
                                            txtBatch.Text = "Place Date";
3564 787a4489 KangIngu
                                            controlType = ControlType.Date;
3565
                                        }
3566
                                    }
3567
                                    else
3568
                                    {
3569
                                        currentControl = new SignControl
3570
                                        {
3571
                                            Background = new SolidColorBrush(Colors.Black),
3572
                                            UserNumber = App.ViewInfo.UserID,
3573 a6272c57 humkyung
                                            ProjectNO = App.ViewInfo.ProjectNO,
3574 787a4489 KangIngu
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3575
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3576
                                            ControlType = ControlType.Sign
3577
                                        };
3578
3579 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3580 787a4489 KangIngu
                                        currentControl.IsNew = true;
3581
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3582
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3583 ca40e004 ljiyeon
3584
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3585
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3586
                                }
3587 e66f22eb KangIngu
                                //}
3588 787a4489 KangIngu
                            }
3589
                        }
3590
                        break;
3591
                    case ControlType.Mark:
3592
                        {
3593 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3594 787a4489 KangIngu
                            {
3595 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3596
                                //{
3597 787a4489 KangIngu
                                    if (currentControl is RectangleControl)
3598
                                    {
3599 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3600
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3601 e66f22eb KangIngu
                                        {
3602
                                            return;
3603
                                        }
3604
3605 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3606 787a4489 KangIngu
                                        (currentControl as RectangleControl).ApplyOverViewData();
3607
                                        currentControl = null;
3608 510cbd2a ljiyeon
                                    
3609
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3610 787a4489 KangIngu
3611
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3612
                                        {
3613 999c9e40 humkyung
                                            txtBatch.Text = "Place Signature";
3614 787a4489 KangIngu
                                            controlType = ControlType.Sign;
3615
                                        }
3616
                                    }
3617
                                    else
3618
                                    {
3619
                                        currentControl = new RectangleControl
3620
                                        {
3621 a6272c57 humkyung
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3622 787a4489 KangIngu
                                            Background = new SolidColorBrush(Colors.Black),
3623 a6272c57 humkyung
                                            ControlType = ControlType.Mark ,
3624 787a4489 KangIngu
                                            Paint = PaintSet.Fill
3625
                                        };
3626
3627
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3628 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3629 787a4489 KangIngu
                                        currentControl.IsNew = true;
3630
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3631
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3632
                                    }
3633 e66f22eb KangIngu
                                //}
3634 787a4489 KangIngu
                            }
3635
                        }
3636
                        break;
3637
                    case ControlType.Symbol:
3638
                        {
3639 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3640 787a4489 KangIngu
                            {
3641 a6272c57 humkyung
                                if (currentControl is SymControl)
3642
                                {
3643
                                    //20180906 LJY TEST IsRotationDrawingEnable
3644
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3645 787a4489 KangIngu
                                    {
3646 a6272c57 humkyung
                                        return;
3647 787a4489 KangIngu
                                    }
3648 a6272c57 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3649
                                    currentControl = null;
3650
                                
3651
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3652
                                }
3653
                                else
3654
                                {
3655
                                    currentControl = new SymControl
3656 787a4489 KangIngu
                                    {
3657 a6272c57 humkyung
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3658
                                        Background = new SolidColorBrush(Colors.Black),
3659
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3660
                                        ControlType = ControlType.Symbol
3661
                                    };
3662 787a4489 KangIngu
3663 a6272c57 humkyung
                                    currentControl.IsNew = true;
3664
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3665
                                    currentControl.CommentID = Commons.shortGuid();
3666
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3667 ca40e004 ljiyeon
3668 a6272c57 humkyung
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3669
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3670 ca40e004 ljiyeon
                                }
3671 e66f22eb KangIngu
                                //}
3672 787a4489 KangIngu
                            }
3673
                        }
3674
                        break;
3675
                    case ControlType.Stamp:
3676
                        {
3677 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3678 787a4489 KangIngu
                            {
3679 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3680
                                //{
3681 787a4489 KangIngu
                                    if (currentControl is SymControlN)
3682
                                    {
3683 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3684
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3685 e66f22eb KangIngu
                                        {
3686
                                            return;
3687
                                        }
3688
3689 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3690 787a4489 KangIngu
                                        currentControl = null;
3691 510cbd2a ljiyeon
                                   
3692
3693
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3694 787a4489 KangIngu
                                    }
3695
                                    else
3696
                                    {
3697
                                        currentControl = new SymControlN
3698
                                        {
3699
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3700
                                            Background = new SolidColorBrush(Colors.Black),
3701 a6272c57 humkyung
                                            STAMP = App.SystemInfo.STAMP,
3702 787a4489 KangIngu
                                            ControlType = ControlType.Stamp
3703
                                        };
3704
3705
                                        currentControl.IsNew = true;
3706
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3707 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3708 787a4489 KangIngu
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3709 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3710
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3711
                                }                                    
3712 e66f22eb KangIngu
                                //}
3713 787a4489 KangIngu
                            }
3714
                        }
3715
                        break;
3716
                    case ControlType.PenControl:
3717
                        {
3718
                            if (inkBoard.Tag.ToString() == "Ink")
3719
                            {
3720
                                inkBoard.IsEnabled = true;
3721
                                StartNewStroke(canvasDrawingMouseDownPoint);
3722
                            }
3723
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3724
                            {
3725
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3726
                            }
3727
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3728
                            {
3729
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3730
                            }
3731
                            IsDrawing = true;
3732
                            return;
3733
                        }
3734
                    default:
3735
                        if (currentControl != null)
3736
                        {
3737
                            currentControl.CommentID = null;
3738
                            currentControl.IsNew = false;
3739
                        }
3740
                        break;
3741
                }
3742
            }
3743 e6a9ddaf humkyung
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3744 787a4489 KangIngu
            {
3745
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3746
                {
3747
                    bool mouseOff = false;
3748
                    foreach (var item in SelectLayer.Children)
3749
                    {
3750
                        if (item is AdornerFinal)
3751
                        {
3752
3753 4913851c humkyung
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3754 787a4489 KangIngu
                            if (over != null)
3755
                            {
3756
                                mouseOff = true;
3757
                            }
3758
                        }
3759
                    }
3760
3761
                    if (!mouseOff)
3762
                    {
3763 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
3764 787a4489 KangIngu
                    }
3765
                }
3766
                zoomAndPanControl.CaptureMouse();
3767
                e.Handled = true;
3768
            }
3769
        }
3770 e54660e8 KangIngu
3771 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3772
        {
3773 e6a9ddaf humkyung
            ///mouseButtonDown = e.ChangedButton;
3774 a1716fa5 KangIngu
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3775
        }
3776
3777 787a4489 KangIngu
        private void RemoveLineStroke(Point P)
3778
        {
3779 05009a0e ljiyeon
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3780 787a4489 KangIngu
            if (control != null)
3781
            {
3782 f729ef4e humkyung
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3783 787a4489 KangIngu
            }
3784
        }
3785
3786
        private void RemovePointStroke(Point P)
3787
        {
3788
            foreach (Stroke hits in inkBoard.Strokes)
3789
            {
3790
                foreach (StylusPoint sty in hits.StylusPoints)
3791
                {
3792
3793
                }
3794
                if (hits.HitTest(P))
3795
                {
3796
                    inkBoard.Strokes.Remove(hits);
3797
                    return;
3798
                }
3799
            }
3800
        }
3801
3802
        private void StartNewStroke(Point P)
3803
        {
3804
            strokePoints = new StylusPointCollection();
3805
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3806
            strokePoints.Add(segment1Start);
3807
            stroke = new Stroke(strokePoints);
3808
3809
            stroke.DrawingAttributes.Color = Colors.Red;
3810
            stroke.DrawingAttributes.Width = 4;
3811
            stroke.DrawingAttributes.Height = 4;
3812
3813
            inkBoard.Strokes.Add(stroke);
3814
3815
        }
3816
3817
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3818
        {
3819
            ConsolidationMethod();
3820
        }
3821
3822 102476f6 humkyung
        /// <summary>
3823
        /// execute TeamConsolidationCommand
3824
        /// </summary>
3825 04a7385a djkim
        public void TeamConsolidationMethod()
3826
        {
3827 102476f6 humkyung
            this.UpdateMyMarkupList();
3828 04a7385a djkim
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3829
            {
3830
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3831
            }
3832
            else
3833
            {
3834 8129f2a5 ljiyeon
3835
                ViewerDataModel.Instance.IsConsolidate = true;
3836
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3837
3838 04a7385a djkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3839
                {
3840
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3841
                    {
3842
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3843
                        return;
3844
                    }                    
3845
                }
3846 102476f6 humkyung
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3847 04a7385a djkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3848 90e7968d ljiyeon
                {
3849 102476f6 humkyung
                    MarkupInfoList.Add(item);
3850 04a7385a djkim
                }
3851 102476f6 humkyung
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3852 04a7385a djkim
            }
3853
        }
3854 102476f6 humkyung
3855 787a4489 KangIngu
        public void ConsolidationMethod()
3856
        {
3857
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3858
            {
3859
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3860
            }
3861
            else
3862 90e7968d ljiyeon
            {
3863 35a96e24 humkyung
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3864
                foreach (var item in this.gridViewMarkup.SelectedItems)
3865
                {
3866
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3867
                }
3868
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3869 8129f2a5 ljiyeon
                
3870 35a96e24 humkyung
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3871 787a4489 KangIngu
            }
3872
        }
3873
3874
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3875
        {
3876
            if (App.ViewInfo != null)
3877
            {
3878
                btnConsolidate = (sender as RadRibbonButton);
3879
                if (!App.ViewInfo.NewCommentPermission)
3880
                {
3881
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3882
                }
3883
            }
3884
        }
3885
3886
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3887
        {
3888 04a7385a djkim
            TeamConsolidationMethod();
3889 787a4489 KangIngu
        }
3890
3891
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3892
        {
3893
            btnTeamConsolidate = sender as RadRibbonButton;
3894
            if (App.ViewInfo != null)
3895
            {
3896
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3897
                {
3898
                    if (btnConsolidate != null)
3899
                    {
3900
                        btnConsolidate.Visibility = Visibility.Collapsed;
3901
                    }
3902
3903
                    if (!App.ViewInfo.NewCommentPermission)
3904
                    {
3905
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3906
                    }
3907
                }
3908
                else
3909
                {
3910
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3911
                }
3912
            }
3913
        }
3914
3915
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3916
        {
3917
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3918
            if (item != null)
3919
            {
3920 90e7968d ljiyeon
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3921 0f065e57 ljiyeon
3922 787a4489 KangIngu
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3923
            }
3924
            else
3925
            {
3926
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3927
            }
3928
        }
3929
3930
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3931
        {
3932
            btnFinalPDF = sender as RadRibbonButton;
3933
            if (App.ViewInfo != null)
3934
            {
3935
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3936
                {
3937
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3938
                    if (btnConsolidate != null)
3939
                    {
3940
                        btnConsolidate.Visibility = Visibility.Collapsed;
3941
                    }
3942
                }
3943
            }
3944
        }
3945
3946 80458c15 ljiyeon
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3947
        {
3948 d62c0439 humkyung
            UpdateMyMarkupList();
3949 80458c15 ljiyeon
3950
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3951
            {
3952
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3953
            }
3954
            else
3955
            {
3956
                ViewerDataModel.Instance.IsConsolidate = true;
3957
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3958
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3959
3960
                string project_no = App.ViewInfo.ProjectNO;
3961
                string doc_id = _DocInfo.ID;
3962
                string user_id = App.ViewInfo.UserID;
3963
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3964
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3965
                {
3966
                    markupInfoItems.Add(item);
3967
                }
3968
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3969
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3970
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3971 1126281e djkim
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3972 80458c15 ljiyeon
3973 1126281e djkim
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3974 80458c15 ljiyeon
                if (item2 != null)
3975
                {
3976
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3977
3978
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
3979 1126281e djkim
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
3980 80458c15 ljiyeon
                }
3981
                else
3982
                {
3983
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3984
                }
3985 90e7968d ljiyeon
            }
3986 80458c15 ljiyeon
        }
3987
3988
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
3989 90e7968d ljiyeon
        {
3990 80458c15 ljiyeon
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
3991
3992
            if (App.ViewInfo != null)
3993
            {
3994
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
3995
                {
3996 90e7968d ljiyeon
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3997 80458c15 ljiyeon
                }
3998 90e7968d ljiyeon
            }
3999 80458c15 ljiyeon
        }
4000
4001 787a4489 KangIngu
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4002
        {
4003
            if (CompareMode.IsChecked)
4004
            {
4005
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4006
                {
4007
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4008
                }
4009
                if (ViewerDataModel.Instance.PageNumber == 0)
4010
                {
4011
                    ViewerDataModel.Instance.PageNumber = 1;
4012
                }
4013
4014 90e7968d ljiyeon
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4015 0f065e57 ljiyeon
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4016 90e7968d ljiyeon
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4017 0f065e57 ljiyeon
4018 d9cf7d6e djkim
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4019 787a4489 KangIngu
            }
4020
            else
4021
            {
4022
                da.From = 1;
4023
                da.To = 1;
4024
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4025
                da.AutoReverse = false;
4026
                canvas_compareBorder.Children.Clear();
4027
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4028
            }
4029
        }
4030
4031 9cd2865b KangIngu
        private void Sync_Click(object sender, RoutedEventArgs e)
4032
        {
4033 a1716fa5 KangIngu
            if (Sync.IsChecked)
4034 9cd2865b KangIngu
            {
4035
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4036
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4037
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4038
            }
4039
        }
4040
4041 787a4489 KangIngu
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4042
        {
4043
            if (UserList.IsChecked)
4044
            {
4045
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4046
            }
4047
            else
4048
            {
4049
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4050
            }
4051
        }
4052
4053
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4054
        {
4055
4056
            if (BalanceMode.IsChecked)
4057
            {
4058
                ViewerDataModel.Instance.PageBalanceMode = true;
4059
            }
4060
            else
4061
            {
4062
                ViewerDataModel.Instance.PageBalanceMode = false;
4063
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4064
            }
4065
        }
4066
4067
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4068
        {
4069
            //초기화
4070
            testPanel2.IsHidden = true;
4071
            ViewerDataModel.Instance.PageBalanceMode = false;
4072
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4073
            ViewerDataModel.Instance.PageNumber = 0;
4074
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4075
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4076
            UserList.IsChecked = false;
4077
            BalanceMode.IsChecked = false;
4078
        }
4079
4080
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4081
        {
4082
            if ((sender as System.Windows.Controls.Control).Tag != null)
4083
            {
4084
                //Compare 초기화
4085
                CompareMode.IsChecked = false;
4086
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4087
4088
                if (ViewerDataModel.Instance.PageNumber == 0)
4089
                {
4090
                    ViewerDataModel.Instance.PageNumber = 1;
4091
                }
4092
4093
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4094
                {
4095
                }
4096
                else
4097
                {
4098
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4099
                }
4100
4101
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4102
                {
4103
4104
                }
4105
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4106
                {
4107
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4108
                }
4109
4110
                if (!testPanel2.IsHidden)
4111
                {
4112
                    if (IsSyncPDFMode)
4113
                    {
4114
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4115
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4116
4117
                        if (pdfpath.IsDownloading)
4118
                        {
4119
                            pdfpath.DownloadCompleted += (ex, arg) =>
4120
                            {
4121
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4122
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4123
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4124
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4125
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4126
                            };
4127
                        }
4128
                        else
4129
                        {
4130
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4131
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4132
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4133
4134
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4135
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4136
                        }
4137
4138
                    }
4139
                    else
4140
                    {
4141 a874198d humkyung
                        string uri = "";
4142
4143
                        if (userData.COMPANY != "EXT")
4144
                        {
4145 84c48033 djkim
                            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);
4146 a874198d humkyung
                        }
4147
                        else
4148
                        {
4149 84c48033 djkim
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4150 a874198d humkyung
                        }
4151 787a4489 KangIngu
4152
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4153
4154
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4155
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4156
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4157
4158
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4159
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4160
4161
                        if (defaultBitmapImage_Compare.IsDownloading)
4162
                        {
4163
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4164
                            {
4165
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4166
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4167
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4168
4169
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4170
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4171
                            };
4172
                        }
4173
                    }
4174
4175
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4176
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4177
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4178
4179
                    foreach (var item in gridSelectionRevItem)
4180
                    {
4181
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4182
                        {
4183 661b7416 humkyung
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4184 787a4489 KangIngu
                        });
4185
                    }
4186 e54660e8 KangIngu
4187 787a4489 KangIngu
                    //강인구 추가
4188
                    zoomAndPanControl2.ZoomTo(new Rect
4189
                    {
4190
                        X = 0,
4191
                        Y = 0,
4192
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4193
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4194
                    });
4195 ae56d52d KangIngu
4196 787a4489 KangIngu
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4197
4198
                }
4199
            }
4200
        }
4201
4202
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4203
        {
4204
            if (MarkupMode.IsChecked)
4205
            {
4206
                IsSyncPDFMode = true;
4207
4208
                var uri = CurrentRev.TO_VENDOR;
4209 ae56d52d KangIngu
4210 787a4489 KangIngu
                if (ViewerDataModel.Instance.PageNumber == 0)
4211
                {
4212
                    ViewerDataModel.Instance.PageNumber = 1;
4213
                }
4214
4215
                //PDF모드 잠시 대기(강인구)
4216
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4217
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4218
4219
                if (pdfpath.IsDownloading)
4220
                {
4221
                    pdfpath.DownloadCompleted += (ex, arg) =>
4222
                    {
4223
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4224
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4225
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4226
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4227
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4228
                    };
4229
                }
4230
                else
4231
                {
4232
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4233
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4234
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4235
4236
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4237
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4238
                }
4239
            }
4240
            else
4241
            {
4242
                IsSyncPDFMode = false;
4243 a874198d humkyung
                string uri = "";
4244
                if (userData.COMPANY != "EXT")
4245
                {
4246 84c48033 djkim
                    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);
4247 a874198d humkyung
                }
4248
                else
4249
                {
4250 84c48033 djkim
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4251 a874198d humkyung
                }
4252 787a4489 KangIngu
4253
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4254
4255
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4256
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4257
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4258
4259
                if (defaultBitmapImage_Compare.IsDownloading)
4260
                {
4261
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4262
                    {
4263
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4264
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4265
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4266
                    };
4267
                }
4268
                zoomAndPanControl2.ApplyTemplate();
4269
                zoomAndPanControl2.UpdateLayout();
4270
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4271
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4272
            }
4273
        }
4274
4275
        private void RadButton_Click(object sender, RoutedEventArgs e)
4276
        {
4277
            gridViewHistory_Busy.IsBusy = true;
4278
4279
            RadButton instance = sender as RadButton;
4280
            if (instance.CommandParameter != null)
4281
            {
4282
                CurrentRev = instance.CommandParameter as VPRevision;
4283
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4284
                {
4285
                    if (ea.Error == null && ea.Result != null)
4286
                    {
4287
                        testPanel2.IsHidden = false;
4288
4289 d128ceb2 humkyung
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4290
                        foreach(var info in ea.Result)
4291
                        {
4292
                            if(info.UserID == App.ViewInfo.UserID)
4293
                            {
4294
                                info.userDelete = true;
4295
                                info.DisplayColor = "FFFF0000";
4296
                            }
4297
                            else
4298
                            {
4299
                                info.userDelete = false;
4300
                            }
4301
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4302
                        }
4303 787a4489 KangIngu
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4304
4305 a874198d humkyung
                        string uri = "";
4306
                        if (userData.COMPANY != "EXT")
4307
                        {
4308 84c48033 djkim
                            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);
4309 a874198d humkyung
                        }
4310
                        else
4311
                        {
4312 84c48033 djkim
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4313 a874198d humkyung
                        }
4314 787a4489 KangIngu
4315
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4316
4317
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4318
4319
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4320
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4321
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4322
4323
                        if (defaultBitmapImage_Compare.IsDownloading)
4324
                        {
4325
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4326
                            {
4327
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4328
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4329
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4330
                            };
4331
                        }
4332
4333
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4334
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4335
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4336
                        zoomAndPanControl2.ApplyTemplate();
4337
                        zoomAndPanControl2.UpdateLayout();
4338
4339
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4340
                        {
4341
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4342
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4343
                        }
4344
4345 9cd2865b KangIngu
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4346
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4347
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4348
4349 787a4489 KangIngu
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4350
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4351
                        gridViewHistory_Busy.IsBusy = false;
4352
                    }
4353 0f065e57 ljiyeon
4354
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4355 90e7968d ljiyeon
                };
4356 787a4489 KangIngu
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4357 0f065e57 ljiyeon
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4358 787a4489 KangIngu
            }
4359
        }
4360
4361
        public void Sync_Event(VPRevision Currnet_Rev)
4362
        {
4363
            CurrentRev = Currnet_Rev;
4364
4365
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4366
            {
4367
                if (ea.Error == null && ea.Result != null)
4368
                {
4369
                    testPanel2.IsHidden = false;
4370
4371 d128ceb2 humkyung
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4372
                    foreach(var info in ea.Result)
4373
                    {
4374
                        if(info.UserID == App.ViewInfo.UserID)
4375
                        {
4376
                            info.userDelete = true;
4377
                            info.DisplayColor = "FFFF0000";
4378
                        }
4379
                        else
4380
                        {
4381
                            info.userDelete = false;
4382
                        }
4383
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4384
                    }
4385 787a4489 KangIngu
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4386
4387 a874198d humkyung
                    string uri = "";
4388 a1716fa5 KangIngu
                    if (userData.COMPANY != "EXT")
4389 a874198d humkyung
                    {
4390 84c48033 djkim
                        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);
4391 a874198d humkyung
                    }
4392
                    else
4393
                    {
4394 84c48033 djkim
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4395 a874198d humkyung
                    }
4396 787a4489 KangIngu
4397
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4398
4399
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4400
4401
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4402
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4403
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4404
4405
                    if (defaultBitmapImage_Compare.IsDownloading)
4406
                    {
4407
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4408
                        {
4409
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4410
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4411
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4412
                        };
4413
                    }
4414 90e7968d ljiyeon
4415
4416 787a4489 KangIngu
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4417
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4418
                    zoomAndPanControl2.ApplyTemplate();
4419
                    zoomAndPanControl2.UpdateLayout();
4420
4421
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4422
                    {
4423
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4424
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4425
                    }
4426
                    //}
4427
4428
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4429
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4430 90e7968d ljiyeon
                    gridViewHistory_Busy.IsBusy = false;
4431 787a4489 KangIngu
                }
4432 0f065e57 ljiyeon
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4433 90e7968d ljiyeon
4434 787a4489 KangIngu
            };
4435 0f065e57 ljiyeon
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4436 90e7968d ljiyeon
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4437 787a4489 KangIngu
        }
4438
4439
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4440
        {
4441
            if (sender is Image)
4442
            {
4443
                if ((sender as Image).Tag != null)
4444
                {
4445
                    var pdfUrl = (sender as Image).Tag.ToString();
4446
                    System.Diagnostics.Process.Start(pdfUrl);
4447
                }
4448
                else
4449
                {
4450
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4451
                }
4452
            }
4453
        }
4454
4455
        private void Create_Symbol(object sender, RoutedEventArgs e)
4456
        {
4457 5529d2a2 humkyung
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4458 787a4489 KangIngu
4459
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4460
            {
4461
                DialogMessage_Alert("Please Select Controls", "Alert");
4462
            }
4463
            else //선택된 것이 있으면
4464
            {
4465
                string MarkupData = "";
4466
                adorner_ = new AdornerFinal();
4467
4468
                foreach (var item in SelectLayer.Children)
4469
                {
4470
                    if (item.GetType().Name == "AdornerFinal")
4471
                    {
4472
                        adorner_ = (item as Controls.AdornerFinal);
4473 4913851c humkyung
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4474 787a4489 KangIngu
                        {
4475
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4476
                            {
4477 5529d2a2 humkyung
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4478 787a4489 KangIngu
                                MarkupData += markupReturn.ConvertData;
4479
                            }
4480
                        }
4481
                    }
4482
                }
4483
                DialogParameters parameters = new DialogParameters()
4484
                {
4485 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
4486 787a4489 KangIngu
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4487
                    DefaultPromptResultValue = "Custom State",
4488
                    Content = "Name :",
4489
                    Header = "Insert Custom Symbol Name",
4490
                    Theme = new VisualStudio2013Theme(),
4491
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4492
                };
4493
                RadWindow.Prompt(parameters);
4494
            }
4495
4496
        }
4497 53880c83 ljiyeon
        public int symbolselectindex = 0;
4498
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4499
        {
4500
            //Save save = new Save();
4501
            try
4502
            {
4503
                string svgfilename = null;
4504
                if (symbolname != null)
4505
                {
4506
                    if (symbolpng == true || symbolsvg == true)
4507
                    {
4508
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4509 24678e06 humkyung
                        string guid = Commons.shortGuid();
4510 53880c83 ljiyeon
4511
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4512 c73426a9 ljiyeon
                        //Check_Uri.UriCheck();
4513 53880c83 ljiyeon
                        fileUploader.RunCompleted += (ex, arg) =>
4514
                        {
4515
                            filename = arg.Result;
4516
                            if (symbolpng == true)
4517
                            {
4518
                                if (filename != null)
4519
                                { 
4520
                                    if (symbolselectindex == 0)
4521
                                    {
4522
                                        SymbolSave(symbolname, filename, data);
4523
                                    }
4524
                                    else
4525
                                    {
4526
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4527
                                    }
4528
                                    DataBind();
4529
                                }                                
4530
                            }
4531
4532
                            if (symbolsvg == true)
4533
                            {
4534 c73426a9 ljiyeon
                                try
4535 53880c83 ljiyeon
                                {
4536 c73426a9 ljiyeon
                                    var defaultBitmapImage = new BitmapImage();
4537
                                    defaultBitmapImage.BeginInit();
4538
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4539
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4540
                                    Check_Uri.UriCheck(filename);
4541
                                    defaultBitmapImage.UriSource = new Uri(filename);
4542
                                    defaultBitmapImage.EndInit();
4543 53880c83 ljiyeon
4544 c73426a9 ljiyeon
                                    System.Drawing.Bitmap image;
4545 53880c83 ljiyeon
4546 c73426a9 ljiyeon
                                    if (defaultBitmapImage.IsDownloading)
4547
                                    {
4548
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4549 53880c83 ljiyeon
                                        {
4550 c73426a9 ljiyeon
                                            defaultBitmapImage.Freeze();
4551
                                            image = GetBitmap(defaultBitmapImage);
4552
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4553
                                            Process potrace = new Process
4554 53880c83 ljiyeon
                                            {
4555 c73426a9 ljiyeon
                                                StartInfo = new ProcessStartInfo
4556
                                                {
4557
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4558
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4559
                                                    RedirectStandardInput = true,
4560
                                                    RedirectStandardOutput = true,
4561
                                                    RedirectStandardError = true,
4562
                                                    UseShellExecute = false,
4563
                                                    CreateNoWindow = true,
4564
                                                    WindowStyle = ProcessWindowStyle.Hidden
4565
                                                },
4566
                                            };
4567 53880c83 ljiyeon
4568 c73426a9 ljiyeon
                                            StringBuilder svgBuilder = new StringBuilder();
4569
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4570 53880c83 ljiyeon
                                            {
4571 c73426a9 ljiyeon
                                                svgBuilder.AppendLine(e2.Data);
4572
                                            };
4573
4574
                                            potrace.EnableRaisingEvents = true;
4575
                                            potrace.Start();
4576
                                            potrace.Exited += (sender, e) =>
4577 53880c83 ljiyeon
                                            {
4578 c73426a9 ljiyeon
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4579
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4580
                                                Check_Uri.UriCheck(svgfilename);
4581
                                                if (symbolselectindex == 0)
4582
                                                {
4583
                                                    SymbolSave(symbolname, svgfilename, data);
4584
                                                }
4585
                                                else
4586
                                                {
4587
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4588
                                                }
4589 53880c83 ljiyeon
4590 c73426a9 ljiyeon
                                                DataBind();
4591
                                            };
4592
                                            potrace.WaitForExit();
4593 53880c83 ljiyeon
                                        };
4594 c73426a9 ljiyeon
                                    }
4595
                                    else
4596
                                    {
4597
                                        //GC.Collect();
4598
                                    }
4599 53880c83 ljiyeon
                                }
4600 c73426a9 ljiyeon
                                catch(Exception ee)
4601 90e7968d ljiyeon
                                {
4602 c73426a9 ljiyeon
                                    DialogMessage_Alert("" + ee, "Alert");
4603 90e7968d ljiyeon
                                }
4604 53880c83 ljiyeon
                            }
4605
                        };                                             
4606
                    }
4607
                }
4608
            }
4609
            catch (Exception e)
4610
            {
4611
                //DialogMessage_Alert(e + "", "Alert");
4612
            }            
4613
        }
4614
4615
        public void SymbolSave(string Name, string Url, string Data)
4616
        {
4617
            try
4618
            {
4619
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4620
                {
4621 24678e06 humkyung
                    ID = Commons.shortGuid(),
4622 53880c83 ljiyeon
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4623
                    NAME = Name,
4624
                    IMAGE_URL = Url,
4625
                    DATA = Data
4626
                };
4627
4628
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4629
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4630
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4631
            }
4632
            catch (Exception)
4633
            {
4634
                throw;
4635
            }
4636
        }
4637
4638
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4639
        {
4640
            try
4641
            {
4642
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4643
                {
4644 24678e06 humkyung
                    ID = Commons.shortGuid(),
4645 53880c83 ljiyeon
                    DEPARTMENT = Department,
4646
                    NAME = Name,
4647
                    IMAGE_URL = Url,
4648
                    DATA = Data
4649
                };
4650
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4651
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4652
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4653
            }
4654
            catch (Exception)
4655
            {
4656
                throw;
4657
            }
4658
        }
4659
4660
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4661
        {           
4662
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4663
            DataBind();
4664
        }
4665
4666
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4667
        {
4668
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4669
            DataBind();
4670
        }
4671
        private void DataBind()
4672
        {
4673
            try
4674
            {
4675
                Symbol_Custom Custom = new Symbol_Custom();
4676
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4677 5928384e djkim
                
4678 bb3a236d ljiyeon
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4679 53880c83 ljiyeon
                foreach (var item in symbol_Private)
4680
                {
4681
                    Custom.Name = item.NAME;
4682
                    Custom.ImageUri = item.IMAGE_URL;
4683
                    Custom.ID = item.ID;
4684
                    Custom_List.Add(Custom);
4685
                    Custom = new Symbol_Custom();
4686
                }
4687
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4688
                
4689
                Custom = new Symbol_Custom();
4690
                Custom_List = new List<Symbol_Custom>();
4691
4692 bb3a236d ljiyeon
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4693 53880c83 ljiyeon
4694
                List<SYMBOL_PUBLIC> symbol_Public;
4695 787a4489 KangIngu
4696 53880c83 ljiyeon
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4697
                {
4698 bb3a236d ljiyeon
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4699 53880c83 ljiyeon
                }
4700
                else
4701
                {
4702 bb3a236d ljiyeon
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4703 53880c83 ljiyeon
                }
4704
                foreach (var item in symbol_Public)
4705
                {
4706
                    Custom.Name = item.NAME;
4707
                    Custom.ImageUri = item.IMAGE_URL;
4708
                    Custom.ID = item.ID;
4709
                    Custom_List.Add(Custom);
4710
                    Custom = new Symbol_Custom();
4711
                }
4712
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4713 bb3a236d ljiyeon
                BaseClient.Close();                
4714 53880c83 ljiyeon
            }
4715
            catch(Exception e)
4716
            {
4717
                //DialogMessage_Alert("DataBind", "Alert");
4718
            }
4719
            
4720
        }
4721 787a4489 KangIngu
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4722
        {
4723 c73426a9 ljiyeon
            try
4724 787a4489 KangIngu
            {
4725 c73426a9 ljiyeon
                if (args.PromptResult != null)
4726 53880c83 ljiyeon
                {
4727 c73426a9 ljiyeon
                    if (args.DialogResult.Value)
4728
                    {
4729
                        PngBitmapEncoder _Encoder = symImage(data);
4730 787a4489 KangIngu
4731 c73426a9 ljiyeon
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4732
                        _Encoder.Save(fs);
4733
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4734 787a4489 KangIngu
4735 c73426a9 ljiyeon
                        byte[] Img_byte = fs.ToArray();
4736 787a4489 KangIngu
4737 c73426a9 ljiyeon
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4738 24678e06 humkyung
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4739 c73426a9 ljiyeon
                        Check_Uri.UriCheck(filename);
4740
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4741
                        {
4742 de6499db humkyung
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4743 c73426a9 ljiyeon
                        }
4744
                        else
4745
                        {
4746 de6499db humkyung
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4747 c73426a9 ljiyeon
                        }
4748
                        DataBind();
4749 53880c83 ljiyeon
                    }
4750
                }
4751 787a4489 KangIngu
            }
4752 c73426a9 ljiyeon
            catch(Exception ex)
4753
            {
4754
                DialogMessage_Alert("" + ex, "Alert");
4755
            }
4756 787a4489 KangIngu
        }
4757
4758
        public PngBitmapEncoder symImage(string data)
4759
        {
4760
4761
            Canvas _canvas = new Canvas();
4762
            _canvas.Background = Brushes.White;
4763
            _canvas.Width = adorner_.BorderSize.Width;
4764
            _canvas.Height = adorner_.BorderSize.Height;
4765 5529d2a2 humkyung
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4766 787a4489 KangIngu
4767
            BitmapEncoder encoder = new PngBitmapEncoder();
4768
4769
4770
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
4771
4772
            DrawingVisual dv = new DrawingVisual();
4773
4774
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
4775
            _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)));
4776
4777
            using (DrawingContext ctx = dv.RenderOpen())
4778
            {
4779
                VisualBrush vb = new VisualBrush(_canvas);
4780
                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)));
4781
            }
4782
4783
            try
4784
            {
4785
                renderBitmap.Render(dv);
4786
4787 90e7968d ljiyeon
                //GC.Collect();
4788 787a4489 KangIngu
                GC.WaitForPendingFinalizers();
4789 90e7968d ljiyeon
                //GC.Collect();
4790 787a4489 KangIngu
                // encode png data
4791
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4792
                // puch rendered bitmap into it
4793
                pngEncoder.Interlace = PngInterlaceOption.Off;
4794
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4795
                return pngEncoder;
4796
4797
            }
4798 53880c83 ljiyeon
            catch //(Exception ex)
4799 787a4489 KangIngu
            {
4800
                return null;
4801
            }
4802
4803
        }
4804
4805
        public void DialogMessage_Alert(string content, string header)
4806
        {
4807
            var box = new TextBlock();
4808
            box.MinWidth = 400;
4809
            box.FontSize = 11;
4810
            //box.FontSize = 12;
4811
            box.Text = content;
4812
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4813
4814
            DialogParameters parameters = new DialogParameters()
4815
            {
4816 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
4817 787a4489 KangIngu
                Content = box,
4818
                Header = header,
4819
                Theme = new VisualStudio2013Theme(),
4820
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4821 90e7968d ljiyeon
            };            
4822 787a4489 KangIngu
            RadWindow.Alert(parameters);
4823
        }
4824
4825
        #region 캡쳐 기능
4826
4827
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4828
        {
4829
            if (x < 0)
4830
            {
4831
                width += x;
4832
                x = 0;
4833
            }
4834
            if (y < 0)
4835
            {
4836
                height += y;
4837
                y = 0;
4838
4839
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4840
            }
4841
            if (x + width > zoomAndPanCanvas.ActualWidth)
4842
            {
4843
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4844
            }
4845
            if (y + height > zoomAndPanCanvas.ActualHeight)
4846
            {
4847
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4848
            }
4849
4850
            byte[] pixels = CopyPixels(x, y, width, height);
4851
4852
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4853
4854
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4855
        }
4856
4857
        public byte[] CopyPixels(int x, int y, int width, int height)
4858
        {
4859
            byte[] pixels = new byte[width * height * 4];
4860
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4861
4862
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
4863
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
4864
4865
            return pixels;
4866
        }
4867
4868
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4869
        {
4870
            DrawingVisual drawingVisual = new DrawingVisual();
4871
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4872
4873
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4874
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4875
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4876
            drawingContext.Close();
4877
4878
            // 비트맵으로 변환합니다.
4879
            RenderTargetBitmap target =
4880
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4881
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4882
4883
            target.Render(drawingVisual);
4884
            return target;
4885
        }
4886
4887 53880c83 ljiyeon
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4888
        {
4889
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4890
            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);
4891
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4892
            bmp.UnlockBits(data);
4893
            return bmp;
4894
        }
4895
        public string symbolname = null;
4896
        public bool symbolsvg = true;
4897
        public bool symbolpng = true;
4898
4899
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4900
        {
4901
            System.Drawing.Bitmap image = GetBitmap(source);
4902
            //흰색 제거
4903
            //image.MakeTransparent(System.Drawing.Color.White);
4904
4905
            var imageStream = new System.IO.MemoryStream();
4906
            byte[] imageBytes = null;
4907
            using (imageStream)
4908
            {
4909
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4910
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4911
                imageStream.Position = 0;
4912
                imageBytes = imageStream.ToArray();
4913
            }
4914
4915
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4916
4917
            RadWindow CheckPop = new RadWindow();
4918
            //Alert check = new Alert(Msg);
4919
4920
            CheckPop = new RadWindow
4921
            {
4922
                MinWidth = 400,
4923
                MinHeight = 100,
4924
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4925
                Header = "Alert",
4926
                Content = symbolPrompt,
4927
                //DialogResult = 
4928
                ResizeMode = System.Windows.ResizeMode.NoResize,
4929
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4930
                IsTopmost = true,
4931
            };
4932
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4933
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4934
            CheckPop.ShowDialog();
4935
4936
            /*
4937
            DialogParameters parameters = new DialogParameters()
4938
            {
4939
                Owner = Application.Current.MainWindow,
4940
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4941
                DefaultPromptResultValue = "Custom State",
4942
                Content = "Name :",
4943
                Header = "Insert Custom Symbol Name",
4944
                Theme = new VisualStudio2013Theme(),
4945
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4946
            };            
4947
            RadWindow.Prompt(parameters);
4948
            */
4949
        }
4950
4951 787a4489 KangIngu
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4952
        {
4953
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4954
            KCOMDataModel.DataModel.CHECK_LIST check_;
4955
            string Result = streamToBase64.ImageToBase64(source);
4956
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4957 6c781c0c djkim
            string projectno = App.ViewInfo.ProjectNO;
4958
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4959 0f065e57 ljiyeon
4960
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4961 6c781c0c djkim
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4962 90e7968d ljiyeon
            if (Item != null)
4963 0f065e57 ljiyeon
            {
4964
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4965
            }
4966
            else
4967
            {
4968
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4969
            }
4970 90e7968d ljiyeon
4971 6c781c0c djkim
            if (Item == null)
4972 787a4489 KangIngu
            {
4973 6c781c0c djkim
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
4974 787a4489 KangIngu
                {
4975 24678e06 humkyung
                    ID = Commons.shortGuid(),
4976 6c781c0c djkim
                    USER_ID = App.ViewInfo.UserID,
4977
                    IMAGE_URL = Result,
4978
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4979
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4980
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4981
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4982
                    PROJECT_NO = App.ViewInfo.ProjectNO,
4983
                    STATUS = "False",
4984
                    CREATE_TIME = DateTime.Now,
4985
                    UPDATE_TIME = DateTime.Now,
4986
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4987
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
4988
                };
4989 0f065e57 ljiyeon
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
4990
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
4991
                //this.BaseClient.AddCheckList(projectno, check_);
4992 787a4489 KangIngu
            }
4993 6c781c0c djkim
            else
4994
            {
4995
                Item.IMAGE_URL = Result;
4996
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4997 90e7968d ljiyeon
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4998 0f065e57 ljiyeon
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
4999
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5000
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5001 6c781c0c djkim
            }
5002 90e7968d ljiyeon
5003 787a4489 KangIngu
        }
5004
5005
        public void Set_Capture()
5006 90e7968d ljiyeon
        {
5007 787a4489 KangIngu
            double x = canvasDrawingMouseDownPoint.X;
5008
            double y = canvasDrawingMouseDownPoint.Y;
5009
            double width = dragCaptureBorder.Width;
5010
            double height = dragCaptureBorder.Height;
5011
5012
            if (width > 5 || height > 5)
5013
            {
5014
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5015
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5016
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5017
            }
5018
        }
5019
        #endregion
5020
5021
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5022
        {
5023
            multi_Undo_Data = new Multi_Undo_data();
5024
5025
            multi_Undo_Data.Markup = control;
5026
5027
            if ((control as IShapeControl) != null)
5028
            {
5029
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5030
            }
5031
            if ((control as IDashControl) != null)
5032
            {
5033
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5034
            }
5035
            if ((control as IPath) != null)
5036
            {
5037
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5038
            }
5039
            if ((control as UIElement) != null)
5040
            {
5041
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5042
            }
5043
5044
            return multi_Undo_Data;
5045
        }
5046
5047
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5048
        {
5049
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5050
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5051
            {
5052
                if (items.UserID == Select_ID)
5053
                {
5054
                    foreach (var item in items.MarkupList)
5055
                    {
5056
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5057
                        {
5058 661b7416 humkyung
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5059 24678e06 humkyung
                                items.MarkupInfoID, Commons.shortGuid());
5060 787a4489 KangIngu
                        }
5061
                    }
5062
                }
5063
            }
5064
        }
5065 d62c0439 humkyung
5066 f959ea6f humkyung
        /// <summary>
5067
        /// convert inkcontrol to polygoncontrol
5068
        /// </summary>
5069
        public void ConvertInkControlToPolygon()
5070 787a4489 KangIngu
        {
5071 f959ea6f humkyung
            Logger.sendCheckLog("pageNavigator_PageChanging_ConvertInkControlToPolygon", 1);
5072 787a4489 KangIngu
            if (inkBoard.Strokes.Count > 0)
5073
            {
5074
                inkBoard.Strokes.ToList().ForEach(stroke =>
5075
                {
5076
                    InkToPath ip = new InkToPath();
5077 f959ea6f humkyung
5078 787a4489 KangIngu
                    List<Point> inkPointSet = new List<Point>();
5079 f959ea6f humkyung
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5080
5081
                    PolygonControl pc = new PolygonControl()
5082 787a4489 KangIngu
                    {
5083
                        Angle = 0,
5084 f959ea6f humkyung
                        PointSet = inkPointSet,
5085 787a4489 KangIngu
                        ControlType = ControlType.Ink
5086
                    };
5087 f959ea6f humkyung
                    pc.StartPoint = inkPointSet[0];
5088
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5089
                    pc.LineSize = 3;
5090
                    pc.CommentID = Commons.shortGuid();
5091
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5092 787a4489 KangIngu
5093 f959ea6f humkyung
                    if (pc.PointSet.Count > 0)
5094
                    {
5095
                        CreateCommand.Instance.Execute(pc);
5096 787a4489 KangIngu
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5097
                    }
5098
                });
5099 f959ea6f humkyung
                inkBoard.Strokes.Clear();
5100 787a4489 KangIngu
            }
5101
        }
5102 17a22987 KangIngu
5103 4318fdeb KangIngu
        /// <summary>
5104 e66f22eb KangIngu
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5105
        /// </summary>
5106
        /// <author>ingu</author>
5107
        /// <date>2018.06.05</date>
5108
        /// <param name="getPoint"></param>
5109
        /// <returns></returns>
5110
        private bool IsGetoutpoint(Point getPoint)
5111 670a4be2 humkyung
        {
5112 e66f22eb KangIngu
            if (getPoint == new Point())
5113 670a4be2 humkyung
            {
5114 e66f22eb KangIngu
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5115
                currentControl = null;
5116
                return true;
5117 670a4be2 humkyung
            }
5118
5119 e66f22eb KangIngu
            return false;
5120 670a4be2 humkyung
        }
5121 e66f22eb KangIngu
5122 5b46312f djkim
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5123
        {
5124
            e.Effects = DragDropEffects.Copy;
5125
        }
5126
5127
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5128
        {
5129
            e.Effects = DragDropEffects.Copy;
5130
        }
5131
5132
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5133
        {
5134
            e.Effects = DragDropEffects.None;
5135
        }
5136
5137 e6a9ddaf humkyung
        /*
5138 5b46312f djkim
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5139
        {
5140 90e7968d ljiyeon
            try
5141 5b46312f djkim
            {
5142 90e7968d ljiyeon
                if (e.Data.GetDataPresent(typeof(string)))
5143
                {
5144
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5145
                    string dragData = e.Data.GetData(typeof(string)) as string;
5146
                    Move_Symbol(sender, dragData);
5147
                }
5148 5b46312f djkim
            }
5149 90e7968d ljiyeon
            catch (Exception ex)
5150
            {
5151
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5152
            }            
5153 5b46312f djkim
        }
5154 e6a9ddaf humkyung
        */
5155 787a4489 KangIngu
    }
5156 5a6a5dd1 humkyung
}
클립보드 이미지 추가 (최대 크기: 500 MB)