프로젝트

일반

사용자정보

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

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

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

1 233ef333 taeseongkim
using IKCOM;
2 2b9b3656 taeseongkim
using KCOM.Common;
3
using KCOM.Controls;
4
using KCOM.Events;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using MarkupToPDF.Controls.Cad;
8 787a4489 KangIngu
using MarkupToPDF.Controls.Common;
9 2b9b3656 taeseongkim
using MarkupToPDF.Controls.Etc;
10 787a4489 KangIngu
using MarkupToPDF.Controls.Line;
11 2b9b3656 taeseongkim
using MarkupToPDF.Controls.Parsing;
12 787a4489 KangIngu
using MarkupToPDF.Controls.Polygon;
13
using MarkupToPDF.Controls.Shape;
14
using MarkupToPDF.Controls.Text;
15 2b9b3656 taeseongkim
using Svg2Xaml;
16 787a4489 KangIngu
using System;
17
using System.Collections.Generic;
18 2b9b3656 taeseongkim
using System.Diagnostics;
19 787a4489 KangIngu
using System.Linq;
20 2b9b3656 taeseongkim
using System.Reflection;
21
using System.Runtime.InteropServices;
22 787a4489 KangIngu
using System.Text;
23 2b9b3656 taeseongkim
using System.Threading;
24
using System.Threading.Tasks;
25
using System.Web;
26 787a4489 KangIngu
using System.Windows;
27
using System.Windows.Controls;
28 2b9b3656 taeseongkim
using System.Windows.Ink;
29 787a4489 KangIngu
using System.Windows.Input;
30
using System.Windows.Media;
31
using System.Windows.Media.Imaging;
32
using System.Windows.Shapes;
33 6707a5c7 ljiyeon
using System.Windows.Threading;
34 2b9b3656 taeseongkim
using Telerik.Windows.Controls;
35 fddb48f7 ljiyeon
using Telerik.Windows.Data;
36 2b9b3656 taeseongkim
using static KCOM.TempFile;
37 787a4489 KangIngu
38
namespace KCOM.Views
39
{
40
    public static class ControlExtensions
41
    {
42
        public static T Clone<T>(this T controlToClone)
43
            where T : System.Windows.Controls.Control
44
        {
45
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
46
47
            T instance = Activator.CreateInstance<T>();
48
49
            foreach (PropertyInfo propInfo in controlProperties)
50
            {
51
                if (propInfo.CanWrite)
52
                {
53
                    if (propInfo.Name != "WindowTarget")
54
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
55
                }
56
            }
57
            return instance;
58
        }
59
    }
60
61 a0bab669 KangIngu
    public class MyConsole
62
    {
63
        private readonly System.Threading.ManualResetEvent _readLineSignal;
64
        private string _lastLine;
65 233ef333 taeseongkim
66 a0bab669 KangIngu
        public MyConsole()
67
        {
68
            _readLineSignal = new System.Threading.ManualResetEvent(false);
69
            Gui = new TextBox();
70
            Gui.AcceptsReturn = true;
71
            Gui.KeyUp += OnKeyUp;
72
        }
73
74
        private void OnKeyUp(object sender, KeyEventArgs e)
75
        {
76
            // this is always fired on UI thread
77
            if (e.Key == Key.Enter)
78
            {
79
                // quick and dirty, but that is not relevant to your question
80
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
81
                // now, when you detected that user typed a line, set signal
82
                _readLineSignal.Set();
83
            }
84
        }
85
86
        public TextBox Gui { get; private set; }
87
88
        public string ReadLine()
89
        {
90
            // that should always be called from non-ui thread
91
            if (Gui.Dispatcher.CheckAccess())
92
                throw new Exception("Cannot be called on UI thread");
93
            // reset signal
94
            _readLineSignal.Reset();
95
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
96
            _readLineSignal.WaitOne();
97
            // we got signalled - return line user typed.
98
            return _lastLine;
99
        }
100
101
        public void WriteLine(string line)
102
        {
103
            if (!Gui.Dispatcher.CheckAccess())
104
            {
105
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
106
                return;
107
            }
108
109
            Gui.Text += line + Environment.NewLine;
110
        }
111
    }
112
113 787a4489 KangIngu
    /// <summary>
114
    /// MainMenu.xaml에 대한 상호 작용 논리
115
    /// </summary>
116
    public partial class MainMenu : UserControl
117
    {
118
        #region 프로퍼티
119 233ef333 taeseongkim
120 787a4489 KangIngu
        public CommentUserInfo currentControl { get; set; }
121
        public ControlType controlType { get; set; }
122 e6a9ddaf humkyung
        private Move move = new Move();
123 787a4489 KangIngu
        private double[] rotateValue = { 0, 90, 180, 270 };
124
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
125
        private static readonly double DragThreshold = 5;
126 eb2b9248 KangIngu
        private System.Windows.Input.Cursor cursor { get; set; }
127 c7fde400 taeseongkim
128
        /// <summary>
129
        ///  문서의 마우스 위치
130
        /// </summary>
131
        public Point CanvasDrawingMouseDownPoint;
132
133 787a4489 KangIngu
        public string filename { get; set; }
134
        private Point canvasZoomPanningMouseDownPoint;
135
        public Point getCurrentPoint;
136
        private Point canvasZoommovingMouseDownPoint;
137 233ef333 taeseongkim
        private List<object> ControlList = new List<object>();
138 787a4489 KangIngu
        private ListBox listBox = new ListBox();
139
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
140
        private bool isDraggingSelectionRect = false;
141 233ef333 taeseongkim
        private DrawingAttributes inkDA = new DrawingAttributes();
142 787a4489 KangIngu
        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 233ef333 taeseongkim
154 787a4489 KangIngu
        /// <summary>
155
        /// Set to 'true' when the left mouse-button is down.
156
        /// </summary>
157 9f473fb7 KangIngu
        public bool isLeftMouseButtonDownOnWindow = false;
158 787a4489 KangIngu
159
        public InkPresenter _InkBoard = null;
160 233ef333 taeseongkim
        private Stroke stroke;
161
        private Boolean IsDrawing = false;
162
        private StylusPointCollection strokePoints;
163
164 53880c83 ljiyeon
        //StylusPointCollection erasePoints;
165 233ef333 taeseongkim
        private RenderTargetBitmap canvasImage;
166
167
        private Point Sync_Offset_Point;
168 787a4489 KangIngu
169
        //강인구 테스트
170
        private Path _SelectionPath { get; set; }
171 233ef333 taeseongkim
172 787a4489 KangIngu
        public Path SelectionPath
173
        {
174
            get
175
            {
176
                return _SelectionPath;
177
            }
178
            set
179
            {
180
                if (_SelectionPath != value)
181
                {
182
                    _SelectionPath = value;
183
                    RaisePropertyChanged("SelectionPath");
184
                }
185
            }
186
        }
187
188
        private System.Windows.Controls.Image _imageViewer { get; set; }
189 233ef333 taeseongkim
190 787a4489 KangIngu
        public System.Windows.Controls.Image imageViewer
191
        {
192
            get
193
            {
194
                if (_imageViewer == null)
195
                {
196
                    _imageViewer = new System.Windows.Controls.Image();
197
                    return _imageViewer;
198
                }
199
                else
200
                {
201
                    return _imageViewer;
202
                }
203
            }
204
            set
205
            {
206
                if (_imageViewer != value)
207
                {
208
                    _imageViewer = value;
209
                }
210
            }
211
        }
212
213
        public bool IsSyncPDFMode { get; set; }
214
215
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
216 233ef333 taeseongkim
217 787a4489 KangIngu
        public System.Windows.Controls.Image imageViewer_Compare
218
        {
219
            get
220
            {
221
                if (_imageViewer_Compare == null)
222
                {
223
                    _imageViewer_Compare = new System.Windows.Controls.Image();
224
                    return _imageViewer_Compare;
225
                }
226
                else
227
                {
228
                    return _imageViewer_Compare;
229
                }
230
            }
231
            set
232
            {
233
                if (_imageViewer_Compare != value)
234
                {
235
                    _imageViewer_Compare = value;
236
                }
237
            }
238
        }
239
240 233ef333 taeseongkim
        #endregion 프로퍼티
241 90e7968d ljiyeon
242 787a4489 KangIngu
        public MainMenu()
243
        {
244 233ef333 taeseongkim
            //App.splashString(ISplashMessage.MAINMENU_0);
245
            InitializeComponent();
246 f65e6c02 taeseongkim
247 dea506e2 taeseongkim
            //List<testItem> testItems = new List<testItem>
248
            //{
249
            //    new testItem{Title = "test1"},
250
            //    new testItem{Title = "test2"},
251
            //    new testItem{Title = "test3"},
252
            //    new testItem{Title = "test4"},
253
            //};
254 f65e6c02 taeseongkim
255 dea506e2 taeseongkim
            //lstSymbolPrivate.ItemsSource = testItems;
256 f65e6c02 taeseongkim
257 90e7968d ljiyeon
            this.Loaded += MainMenu_Loaded;
258 787a4489 KangIngu
        }
259 6707a5c7 ljiyeon
260
        public class TempDt
261
        {
262
            public int PageNumber { get; set; }
263
            public string CommentID { get; set; }
264
            public string ConvertData { get; set; }
265
            public int DATA_TYPE { get; set; }
266
            public string MarkupInfoID { get; set; }
267
            public int IsUpdate { get; set; }
268
        }
269
270 233ef333 taeseongkim
        private List<TempDt> tempDtList = new List<TempDt>();
271 90e7968d ljiyeon
272 787a4489 KangIngu
        private void SetCursor()
273
        {
274
            this.Cursor = cursor;
275
        }
276
277 69f41aab humkyung
        /// <summary>
278
        /// get image url
279
        /// </summary>
280
        /// <author>humkyung</author>
281
        /// <param name="sDocumentID"></param>
282
        /// <returns></returns>
283 6dcbe4a7 humkyung
        public string GetImageURL(string sDocumentID, int iPageNo)
284 69f41aab humkyung
        {
285
            string uri = string.Empty;
286
287
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
288
            if (userData.COMPANY != "EXT")
289
            {
290
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
291
            }
292
            else
293
            {
294
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
295
            }
296
297
            return uri;
298
        }
299
300 52827a4c djkim
        /// <summary>
301
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
302
        /// </summary>
303
        /// <returns></returns>
304
        public string GetOriginalPDFURL()
305
        {
306
            string uri = string.Empty;
307
            string sDocumentID = this._DocItem.DOCUMENT_ID;
308
            string filename = string.Empty;
309
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
310
            {
311
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
312
            }
313
            else
314
            {
315
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
316
            }
317 0f26a9aa taeseongkim
318 77cdac33 taeseongkim
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
319
320
            if (!string.IsNullOrWhiteSpace(directUri))
321 52827a4c djkim
            {
322 77cdac33 taeseongkim
                uri = string.Format(directUri, filename);
323 52827a4c djkim
            }
324
            else
325
            {
326 77cdac33 taeseongkim
                string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
327
                if (userData.COMPANY != "EXT")
328
                {
329
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
330
                }
331
                else
332
                {
333
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
334
                }
335
                uri = uri.Replace(".png", "");
336 52827a4c djkim
            }
337 77cdac33 taeseongkim
338 52827a4c djkim
            return uri;
339
        }
340 0f26a9aa taeseongkim
341 787a4489 KangIngu
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
342
        {
343
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
344 ca40e004 ljiyeon
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
345
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
346
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
347 787a4489 KangIngu
            {
348
                return true;
349
            }
350
351
            return false;
352
        }
353
354 ca40e004 ljiyeon
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
355
        {
356
            if (rotate.Angle == 90 || rotate.Angle == 270)
357
            {
358
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
359
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
360
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
361
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
362
                {
363
                    return true;
364
                }
365
            }
366
            else
367
            {
368
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
369
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
370
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
371
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
372
                {
373
                    return true;
374
                }
375 90e7968d ljiyeon
            }
376 ca40e004 ljiyeon
377
            return false;
378
        }
379
380 787a4489 KangIngu
        public void DeleteItem(MarkupInfoItem item)
381
        {
382
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
383
            {
384 233ef333 taeseongkim
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
385
            }
386 787a4489 KangIngu
387
            ViewerDataModel.Instance._markupInfoList.Remove(item);
388
389
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
390
            {
391
                ViewerDataModel.Instance.MarkupControls.Remove(a);
392
            });
393
394
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
395
            {
396
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
397 39f0624f ljiyeon
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
398 4eb052e4 ljiyeon
                null, Event_Type.Delete, a.CommentID, null);
399 787a4489 KangIngu
            });
400
401 d62c0439 humkyung
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
402 787a4489 KangIngu
            {
403 d62c0439 humkyung
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
404 6707a5c7 ljiyeon
                //임시파일에서도 삭제
405 233ef333 taeseongkim
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
406 787a4489 KangIngu
            });
407
408
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
409 bb3a236d ljiyeon
410 787a4489 KangIngu
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
411
            {
412
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
413
                {
414 24678e06 humkyung
                    var infoId = Commons.shortGuid();
415 787a4489 KangIngu
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
416
                    {
417
                        CreateTime = DateTime.Now,
418
                        Depatment = userData.DEPARTMENT,
419 992a98b4 KangIngu
                        UpdateTime = DateTime.Now,
420 787a4489 KangIngu
                        DisplayColor = "#FFFF0000",
421
                        UserID = userData.ID,
422
                        UserName = userData.NAME,
423
                        PageCount = 1,
424
                        Description = "",
425
                        MarkupInfoID = infoId,
426
                        MarkupList = null,
427 24678e06 humkyung
                        MarkupVersionID = Commons.shortGuid(),
428 787a4489 KangIngu
                        Consolidate = 0,
429
                        PartConsolidate = 0,
430
                        userDelete = true,
431
                        AvoidConsolidate = 0,
432
                        IsPreviewUser = true
433
                    };
434
                    App.Custom_ViewInfoId = infoId;
435
                }
436
            }
437 664ea2e1 taeseongkim
            //Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
438 233ef333 taeseongkim
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
439 787a4489 KangIngu
        }
440
441 959b3ef2 humkyung
        /// <summary>
442
        /// delete selected comments
443
        /// </summary>
444
        /// <param name="sender"></param>
445
        /// <param name="e"></param>
446 787a4489 KangIngu
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
447
        {
448 d7e20d2d taeseongkim
            //정말 삭제 하시겠습니까?
449 17202508 ljiyeon
            DialogParameters parameters = new DialogParameters()
450 c35e49f5 ljiyeon
            {
451 17202508 ljiyeon
                Owner = Application.Current.MainWindow,
452 3d4d6da9 ljiyeon
                Content = new TextBlock()
453 233ef333 taeseongkim
                {
454 3d4d6da9 ljiyeon
                    MinWidth = 400,
455
                    FontSize = 11,
456 d7e20d2d taeseongkim
                    Text = "Are you sure you want to delete?",
457 3d4d6da9 ljiyeon
                    TextWrapping = System.Windows.TextWrapping.Wrap
458
                },
459 17202508 ljiyeon
                Header = "Confirm",
460
                Theme = new VisualStudio2013Theme(),
461
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
462
                OkButtonContent = "Yes",
463
                CancelButtonContent = "No",
464
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
465
                {
466 233ef333 taeseongkim
                    if (wc.DialogResult == true)
467 17202508 ljiyeon
                    {
468
                        //선택된 어도너가 있을시 삭제가 되지 않음
469
                        SelectionSet.Instance.UnSelect(this);
470 787a4489 KangIngu
471 17202508 ljiyeon
                        Button content = (sender as Button);
472
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
473 787a4489 KangIngu
474 17202508 ljiyeon
                        DeleteItem(item);
475
                    }
476
                }
477
            };
478
            RadWindow.Confirm(parameters);
479 787a4489 KangIngu
        }
480
481 233ef333 taeseongkim
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
482 787a4489 KangIngu
483 6707a5c7 ljiyeon
        private static Timer timer;
484
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
485 233ef333 taeseongkim
486 787a4489 KangIngu
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
487 90e7968d ljiyeon
        {
488 233ef333 taeseongkim
            //InitializeComponent();
489 90e7968d ljiyeon
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
490
491 787a4489 KangIngu
            if (App.ParameterMode)
492 6707a5c7 ljiyeon
            {
493 2007ecaa taeseongkim
494 f7caaaaf ljiyeon
                App.splashString(ISplashMessage.MAINMENU_1);
495 54a28343 taeseongkim
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
496 6707a5c7 ljiyeon
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
497 afaa7c92 djkim
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
498 2007ecaa taeseongkim
499 6707a5c7 ljiyeon
                imageViewer_Compare = new Image();
500
                ViewerDataModel.Instance.Capture_Opacity = 0;
501
                da.From = 0.8;
502
                da.To = 0;
503
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
504
                da.AutoReverse = true;
505 e0204db0 djkim
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
506
507
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
508 90e7968d ljiyeon
                {
509 e0204db0 djkim
                    this.SymbolPane.Visibility = Visibility.Collapsed;
510
                    this.FavoritePane.Visibility = Visibility.Collapsed;
511
                    this.drawingRotateCanvas.IsHitTestVisible = false;
512 90e7968d ljiyeon
                }
513 8411f02d ljiyeon
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
514 6707a5c7 ljiyeon
            }
515 6af42ff0 taeseongkim
516 2007ecaa taeseongkim
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
517 ccf944bb ljiyeon
        }
518
519 2007ecaa taeseongkim
        private void DownloadOriginalFile()
520 6af42ff0 taeseongkim
        {
521 2007ecaa taeseongkim
            #region 임시파일 다운로드
522 9d5b4bc2 taeseongkim
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
523 77cdac33 taeseongkim
       
524
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
525
            bool isRestDownload = false;
526
527
            if (!string.IsNullOrWhiteSpace(directUri))
528
            {
529
                isRestDownload = true;
530
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
531
532
                downloadurl = string.Format(directUri, filename);
533
             }
534
            else
535
            {
536
                downloadurl = GetOriginalPDFURL();
537
            }
538 9d5b4bc2 taeseongkim
539
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
540
            
541
            string endpoint = Common.Commons.shortGuid() + "file";
542 2007ecaa taeseongkim
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
543
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
544
            wcfServer.Start();
545 9d5b4bc2 taeseongkim
            
546 77cdac33 taeseongkim
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
547 2007ecaa taeseongkim
            #endregion
548
        }
549 6af42ff0 taeseongkim
550 2007ecaa taeseongkim
        string instnaceFile;
551
        string downloadurl;
552 6af42ff0 taeseongkim
553 2007ecaa taeseongkim
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
554
        {
555 6a19b48d taeseongkim
            try
556
            {
557
                Dispatcher.BeginInvoke((Action)delegate () { ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress; });
558 6af42ff0 taeseongkim
559 6a19b48d taeseongkim
                if (e.IsFinish)
560
                {
561
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
562
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
563
                    (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
564
                    //(sender as IIpc.WcfServer).Stop();
565
                }
566
            }
567
            catch (Exception ex)
568 6af42ff0 taeseongkim
            {
569 6a19b48d taeseongkim
                throw;
570 6af42ff0 taeseongkim
            }
571
        }
572 afaa7c92 djkim
573 6707a5c7 ljiyeon
        private void timercallback(Object o)
574 ccf944bb ljiyeon
        {
575 6707a5c7 ljiyeon
            Stopwatch sw = new Stopwatch();
576
            sw.Start();
577 3b484ebb ljiyeon
            TempFile.TempFileAdd();
578 6707a5c7 ljiyeon
            sw.Stop();
579 ccf944bb ljiyeon
580 90e7968d ljiyeon
            Dispatcher.InvokeAsync(new Action(delegate
581 ccf944bb ljiyeon
            {
582 233ef333 taeseongkim
                if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
583 6707a5c7 ljiyeon
                {
584
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
585
                }
586
            }));
587 ccf944bb ljiyeon
588 90e7968d ljiyeon
            ////GC.Collect();
589 6707a5c7 ljiyeon
        }
590 233ef333 taeseongkim
591 d62c0439 humkyung
        /// <summary>
592
        /// update my markuplist
593
        ///  - update existing markup data if already exist
594
        ///  - add new markup data if control is new
595
        /// </summary>
596
        public void UpdateMyMarkupList()
597 787a4489 KangIngu
        {
598 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
599 787a4489 KangIngu
600 d62c0439 humkyung
            /// add or update markup list
601
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
602 787a4489 KangIngu
            {
603 d62c0439 humkyung
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
604 90e7968d ljiyeon
605 d62c0439 humkyung
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
606
                if (exist != null) //신규 추가 된 코멘트
607
                {
608
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
609 6707a5c7 ljiyeon
                    {
610 d62c0439 humkyung
                        exist.Data = root.ConvertData;
611
                        exist.IsUpdate = true;
612 6707a5c7 ljiyeon
                    }
613 d62c0439 humkyung
                }
614
                else if (root.CommentID != null)
615
                {
616
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
617 6707a5c7 ljiyeon
                    {
618 d62c0439 humkyung
                        ID = control.CommentID,
619
                        Data = root.ConvertData,
620
                        Data_Type = root.DATA_TYPE,
621
                        MarkupInfoID = App.Custom_ViewInfoId,
622
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
623
                        Symbol_ID = control.SymbolID,
624 c0977e97 djkim
                        //Group_ID = control.GroupID,
625 d62c0439 humkyung
                    });
626 787a4489 KangIngu
                }
627
            }
628
629 24c5e56c taeseongkim
            //if (this.pageNavigator.CurrentPage != null)
630
            //{
631
            //    /// delete markup list
632
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
633 6b6e937c taeseongkim
634 24c5e56c taeseongkim
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
635
            //                   where (markup.PageNumber == iPageNo)
636
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
637
            //                   select markup).ToList();
638 6b6e937c taeseongkim
639 24c5e56c taeseongkim
            //    foreach (var markup in deleted)
640
            //    {
641
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
642
            //    }
643
            //}
644
            //else
645
            //{
646
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
647
            //}
648 0585d5cc taeseongkim
649 d62c0439 humkyung
            /// up to here
650 6707a5c7 ljiyeon
651 129ca191 humkyung
            //if (modified)
652
            //{
653
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
654
            //    {
655
            //        ComingNewBieEnd = true;
656
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
657
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
658
            //        gridViewMarkup.ItemsSource = null;
659
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
660
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
661
662
            //        GroupDescriptor descriptor = new GroupDescriptor();
663
            //        descriptor.Member = "Depatment";
664
            //        descriptor.DisplayContent = "DEPT";
665
            //        descriptor.SortDirection = ListSortDirection.Ascending;
666
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
667
            //    }
668
            //}
669 787a4489 KangIngu
        }
670
671 cb5c7f06 humkyung
        /// <summary>
672
        /// start page changing
673
        ///  - save controls if page is modified
674
        ///  - starting download page image
675
        /// </summary>
676
        /// <param name="sender"></param>
677
        /// <param name="e"></param>
678 cdfb57ff taeseongkim
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
679 548c696e ljiyeon
        {
680 24c5e56c taeseongkim
            //await Task.Delay(10);
681 d7e20d2d taeseongkim
682 72424099 taeseongkim
            // 마크업 로드
683
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
684 24c5e56c taeseongkim
685 4f017ed3 taeseongkim
            ViewerDataModel.Instance.PageAngle = e.CurrentPage.PAGE_ANGLE;
686 24c5e56c taeseongkim
687 4f017ed3 taeseongkim
            var token = ViewerDataModel.Instance.NewCancellationToken();
688
            
689
            await MarkupLoadAsync(e.PageNumber, ViewerDataModel.Instance.PageAngle, token);
690 e8557bd7 taeseongkim
691 dea506e2 taeseongkim
            // 페이지 이미지 변경
692 24c5e56c taeseongkim
            await PageChangingAsync(e.CurrentPage, e.PageNumber, token);
693 d7e20d2d taeseongkim
        }
694
695 24c5e56c taeseongkim
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
696 233ef333 taeseongkim
        {
697 d7e20d2d taeseongkim
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
698 233ef333 taeseongkim
699 787a4489 KangIngu
            #region 페이지가 벗어난 경우
700
701
            if (BalancePoint < 1)
702
            {
703
                BalancePoint = 1;
704
                ViewerDataModel.Instance.PageBalanceNumber = 0;
705
            }
706
707
            if (pageNavigator.PageCount < BalancePoint)
708
            {
709
                BalancePoint = pageNavigator.PageCount;
710
                ViewerDataModel.Instance.PageBalanceNumber = 0;
711
            }
712
713 233ef333 taeseongkim
            #endregion 페이지가 벗어난 경우
714 787a4489 KangIngu
715 752b18ef taeseongkim
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
716 787a4489 KangIngu
717 d7e20d2d taeseongkim
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
718
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
719 cdfb57ff taeseongkim
            var contentScale = zoomAndPanControl.ContentScale;
720 8614f701 taeseongkim
721 92442e4a taeseongkim
            #region 페이지 이미지 로딩 수정
722 8a9f6742 djkim
723 24c5e56c taeseongkim
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
724 233ef333 taeseongkim
725 d48260a2 djkim
            ScaleImage(pageWidth, pageHeight);
726
727
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
728
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
729
730
            zoomAndPanCanvas.Width = pageWidth;
731
            zoomAndPanCanvas.Height = pageHeight;
732
733
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
734
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
735
736
            inkBoard.Width = pageWidth;
737
            inkBoard.Height = pageHeight;
738 cdfb57ff taeseongkim
739 233ef333 taeseongkim
            #endregion 페이지 이미지 로딩 수정
740 90e7968d ljiyeon
741 787a4489 KangIngu
            if (!testPanel2.IsHidden)
742
            {
743 548c696e ljiyeon
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
744 787a4489 KangIngu
                //PDF모드일때 잠시 대기(강인구)
745
                if (IsSyncPDFMode)
746
                {
747
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
748 752b18ef taeseongkim
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
749 787a4489 KangIngu
750 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
751 787a4489 KangIngu
                    if (pdfpath.IsDownloading)
752
                    {
753
                        pdfpath.DownloadCompleted += (ex, arg) =>
754
                        {
755 548c696e ljiyeon
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
756 787a4489 KangIngu
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
757
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
758
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
759
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
760
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
761
                        };
762
                    }
763
                    else
764
                    {
765 548c696e ljiyeon
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
766 787a4489 KangIngu
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
767
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
768
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
769
770
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
771
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
772
                    }
773
                }
774
                else
775
                {
776 752b18ef taeseongkim
                    Logger.sendCheckLog("Compare Image Download", 1);
777
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
778
                    ComparePageLoad(compareImageUri,false);
779 787a4489 KangIngu
                }
780 752b18ef taeseongkim
781 787a4489 KangIngu
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
782
            }
783
784 f4ec4218 taeseongkim
            SearchFocusBorder.Visibility = Visibility.Collapsed;
785
786 d7e20d2d taeseongkim
            this.pageNavigator.ChangePage(changePageNumber);
787 cdfb57ff taeseongkim
        }
788
789 752b18ef taeseongkim
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
790
        {
791
            /// 현재 보고 있는 VP와 같은 크기로 로딩
792
            ViewerDataModel.Instance.ImageViewPath_C = null;
793
794
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
795
            {
796
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
797
            }
798
            else
799
            {
800
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
801
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
802
            }
803
804
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
805
            {
806
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
807
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
808
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
809
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
810
811
                zoomAndPanControl.ZoomTo(new Rect
812
                {
813
                    X = 0,
814
                    Y = 0,
815
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
816
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
817
                });
818
819
                if (Sync.IsChecked)
820
                {
821
                    Sync_Click(null, new RoutedEventArgs());
822
                }
823
824
                if (CompareMode.IsChecked)
825
                {
826
                    SyncCompare_Click(null, new RoutedEventArgs());
827
                }
828
            }
829
        }
830
831 3ffd4b2d humkyung
        /// <summary>
832
        /// called after page is changed
833
        /// </summary>
834
        /// <param name="sender"></param>
835
        /// <param name="e"></param>
836 a1142a6b taeseongkim
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
837 3ffd4b2d humkyung
        {
838 a1142a6b taeseongkim
            //if (zoomAndPanCanvas.Width.IsNaN())
839
            //{
840 d5096d58 taeseongkim
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
841
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
842
            //    );
843 a1142a6b taeseongkim
            //}
844 233ef333 taeseongkim
845 d7e20d2d taeseongkim
            var instanceMain = ViewerDataModel.Instance.SystemMain;
846
847 315ae55e taeseongkim
            instanceMain.dzMainMenu.CanvasDrawingMouseDownPoint = new Point(ViewerDataModel.Instance.ImageViewWidth / 2, ViewerDataModel.Instance.ImageViewHeight / 2);
848
849 d7e20d2d taeseongkim
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
850
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
851
852
            instanceMain.dzTopMenu.rotateOffSet = 0;
853
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
854
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
855
856
            /// 페이지의 모든 마크업을 로드한 후 호출
857
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
858 d5096d58 taeseongkim
            ViewerDataModel.Instance.LoadPageMarkupFinish(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
859 e1c892f7 taeseongkim
860
            //Point startPoint = new Point(15, 15);
861
862
            //var markupinfo = ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID).First();
863
864
            ////var rect = GetRectControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
865
866
            ////var txtApproved = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID,
867
            ////                             "APPROVED",30, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, 15);
868
869
            ////var txtCreator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
870
            ////                , "By HYOSUNG", 18, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, txtApproved.StartPoint.Y + txtApproved.BoxHeight + 3);
871
872
            //var symCtrl = GetSymNControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
873
874
            //var bottom = Rect.Offset(symCtrl.ItemRect, new Vector(0, symCtrl.ItemRect.Height));
875
876
            //var txtOriginator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
877
            //               , App.ViewInfo.UserID, 18, FontWeights.Bold, TextAlignment.Left, bottom, bottom.Top + 3);
878
879
            //var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" };
880
881
            //var txtDate = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
882
            //               , DateTime.Now.ToString("d", dtfi), 18, FontWeights.Bold, TextAlignment.Left, bottom, txtOriginator.StartPoint.Y + txtOriginator.BoxHeight + 2);
883
884
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
885
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
886
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
887
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
888
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
889
890
            //symCtrl.ApplyTemplate();
891
            ////txtApproved.ApplyTemplate();
892
            ////txtCreator.ApplyTemplate();
893
            //txtOriginator.ApplyTemplate();
894
            //txtDate.ApplyTemplate();
895
896
            ////SetTextControl(txtApproved);
897
            ////SetTextControl(txtCreator);
898
            //SetTextControl(txtOriginator);
899
            //SetTextControl(txtDate);
900
901
            //multi_Undo_Data = new Multi_Undo_data();
902
903
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
904
            //{
905
            //    IsUndo = false,
906
            //    Event = Event_Type.Create,
907
            //    EventTime = DateTime.Now,
908
            //    Markup_List = new List<Multi_Undo_data>()
909
            //};
910
911
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
912
            //UndoData.Markup_List.Add(multi_Undo_Data);
913
914
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
915
            ////UndoData.Markup_List.Add(multi_Undo_Data);
916
917
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
918
            ////UndoData.Markup_List.Add(multi_Undo_Data);
919
920
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
921
            //UndoData.Markup_List.Add(multi_Undo_Data);
922
923
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
924
            //UndoData.Markup_List.Add(multi_Undo_Data);
925
926
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
927
928
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
929
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
930
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
931
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
932
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
933
        }
934
935
        private void SetTextControl(TextControl textControl)
936
        {
937
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
938
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
939
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
940
        }
941
942
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
943
        {
944
            SymControlN result = null;
945
946
            try
947
            {
948
                double height = 80;
949
                double itemWidth = 180;
950
951
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
952
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
953
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
954
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
955
956
                result = new SymControlN
957
                {
958
                    CommentID = Commons.shortGuid(),
959
                    MarkupInfoID = markupInfoId,
960
                    UserID = userId,
961
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
962
                    StartPoint = startPoint,
963
                    EndPoint = endPoint,
964
                    CommentAngle = 0,
965
                    LeftBottomPoint = leftBottomPoint,
966
                    TopRightPoint = topRightPoint,
967
                    Opacity = 1,
968
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
969
                    Memo = null
970
                };
971
            }
972
            catch (Exception ex)
973
            {
974
                System.Diagnostics.Debug.WriteLine(ex.ToString());
975
            }
976
977
            return result;
978
        }
979
980 233ef333 taeseongkim
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
981 e1c892f7 taeseongkim
        {
982
            RectangleControl result = null;
983
984
            try
985
            {
986
                double height = 80;
987
                double itemWidth = 180;
988
989
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
990
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
991
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
992
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
993
994
                result = new RectangleControl
995
                {
996
                    CommentID = Commons.shortGuid(),
997
                    MarkupInfoID = markupInfoId,
998
                    LineSize = 5,
999
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
1000
                    StartPoint = startPoint,
1001
                    EndPoint = endPoint,
1002
                    CommentAngle = 0,
1003
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1004
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1005
                    FillColor = null,
1006
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1007
                    Opacity = 1,
1008
                    LeftBottomPoint = leftBottomPoint,
1009
                    TopRightPoint = topRightPoint,
1010 233ef333 taeseongkim
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1011 e1c892f7 taeseongkim
                    UserID = userId,
1012
                    Memo = null
1013
                };
1014
            }
1015
            catch (Exception ex)
1016
            {
1017
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1018
            }
1019
1020
            return result;
1021
        }
1022
1023 233ef333 taeseongkim
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1024 e1c892f7 taeseongkim
        {
1025
            TextControl result = null;
1026
1027
            try
1028
            {
1029 233ef333 taeseongkim
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1030 e1c892f7 taeseongkim
1031
                double startPositionX = parentRect.X;
1032
1033
                switch (textAlignment)
1034
                {
1035
                    case TextAlignment.Right:
1036
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1037
                        break;
1038 233ef333 taeseongkim
1039 e1c892f7 taeseongkim
                    case TextAlignment.Center:
1040
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1041
                        break;
1042
                }
1043
1044
                Point startPosition = new Point
1045
                {
1046
                    X = startPositionX,
1047
                    Y = positionY
1048
                };
1049 233ef333 taeseongkim
1050 e1c892f7 taeseongkim
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1051
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1052
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1053
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1054
1055
                result = new TextControl
1056
                {
1057
                    CommentID = Commons.shortGuid(),
1058
                    MarkupInfoID = markupInfoId,
1059
                    Text = Text,
1060
                    StartPoint = startPoint,
1061
                    EndPoint = endPoint,
1062
                    CanvasX = startPosition.X,
1063
                    CanvasY = startPosition.Y,
1064
                    BoxWidth = txtSize.Width,
1065
                    BoxHeight = txtSize.Height,
1066
                    ControlType_No = 0,
1067
                    LineSize = new Thickness(5),
1068
                    TextSize = fontSize,
1069
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1070
                    FontSize = 10,
1071
                    UserID = userId,
1072
                    IsHighLight = false,
1073
                    CommentAngle = 0,
1074
                    PointSet = new List<Point>(),
1075
                    Opacity = 1,
1076
                    IsSelected = false,
1077
                    TextFamily = new FontFamily("Tahoma"),
1078
                    TextStyle = FontStyles.Normal,
1079
                    TextWeight = FontWeights.Bold
1080
                };
1081
            }
1082
            catch (Exception ex)
1083
            {
1084
            }
1085
1086
            return result;
1087
        }
1088 233ef333 taeseongkim
1089 e1c892f7 taeseongkim
        public static Size ShapeMeasure(UIElement e)
1090
        {
1091
            // Measured Size is bounded to be less than maxSize
1092
            Size maxSize = new Size(
1093
                 double.PositiveInfinity,
1094
                 double.PositiveInfinity);
1095
            e.Measure(maxSize);
1096
            return e.DesiredSize;
1097 d7e20d2d taeseongkim
        }
1098
1099 4f017ed3 taeseongkim
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1100 ac4f1e13 taeseongkim
        {
1101
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1102
            stopwatch.Start();
1103
1104 3ffd4b2d humkyung
            /// 컨트롤을 새로 생성한다.
1105
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1106
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1107 e8557bd7 taeseongkim
1108 ac4f1e13 taeseongkim
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1109
1110 d7e20d2d taeseongkim
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1111 233ef333 taeseongkim
            {
1112 24c5e56c taeseongkim
                if (cts.IsCancellationRequested)
1113
                {
1114
                    return;
1115
                }
1116
1117 5ee1c547 송근호
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1118 3ffd4b2d humkyung
                if (info != null)
1119
                {
1120
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1121
                    if (info.UserID == App.ViewInfo.UserID)
1122
                    {
1123 a1e2ba68 taeseongkim
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1124 3ffd4b2d humkyung
                                        markup.MarkupInfoID, markup.ID);
1125
                        control.Visibility = Visibility.Hidden;
1126
                    }
1127
                    else
1128
                    {
1129 a1e2ba68 taeseongkim
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1130 3ffd4b2d humkyung
                                                                markup.MarkupInfoID, markup.ID);
1131
                        control.Visibility = Visibility.Hidden;
1132
                    }
1133
                }
1134
            };
1135
            /// up to here
1136
1137 ac4f1e13 taeseongkim
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1138
1139 3ffd4b2d humkyung
            /// fire selection event
1140
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1141
            this.gridViewMarkup.UnselectAll();
1142
            this.gridViewMarkup.Select(gridSelectionItem);
1143
1144
            if (!testPanel2.IsHidden)
1145
            {
1146
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1147
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1148
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1149
1150
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1151
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1152
1153
                foreach (var item in gridSelectionRevItem)
1154
                {
1155 ac4f1e13 taeseongkim
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1156
1157
                    foreach (var markupitem in markupitems)
1158 3ffd4b2d humkyung
                    {
1159 a1e2ba68 taeseongkim
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1160 24c5e56c taeseongkim
1161
                        if (cts.IsCancellationRequested)
1162
                        {
1163
                            return;
1164
                        }
1165 ac4f1e13 taeseongkim
                    }
1166 3ffd4b2d humkyung
                }
1167
            }
1168 ac4f1e13 taeseongkim
1169 24c5e56c taeseongkim
            SetCommentPages(cts);
1170 3ffd4b2d humkyung
        }
1171
1172 24c5e56c taeseongkim
        public void SetCommentPages(CancellationToken? cts)
1173 787a4489 KangIngu
        {
1174 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1175 787a4489 KangIngu
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1176
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1177 ed3740c4 djkim
            {
1178
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1179 233ef333 taeseongkim
                if (item.MarkupList != null)
1180 787a4489 KangIngu
                {
1181 ed3740c4 djkim
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1182
                    instance.UserName = item.UserName;
1183
                    instance.Depart = item.Depatment;
1184
                    instance.MarkupInfoID = item.MarkupInfoID;
1185
                    instance.IsSelected = true;
1186
                    instance.isConSolidation = item.Consolidate;
1187
                    instance.SetColor = item.DisplayColor;
1188
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1189
                    {
1190
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1191
                    }
1192
                    else
1193
                    {
1194
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1195
                    }
1196
                    _pages.Add(instance);
1197 233ef333 taeseongkim
                }
1198 24c5e56c taeseongkim
1199
                if (cts != null)
1200
                {
1201
                    if (cts.Value.IsCancellationRequested)
1202
                        return;
1203
                }
1204 ed3740c4 djkim
            }
1205 233ef333 taeseongkim
1206 24c5e56c taeseongkim
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1207 ed3740c4 djkim
        }
1208
1209
        public void MarkupitemViewUpdate(string markupinfo_id)
1210
        {
1211
            //db에 업데이트 한 list 를 view 에 업데이트
1212
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1213
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1214
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1215
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1216
            if (dbinfo.MarkupList.Count > 0)
1217
            {
1218
                if (viewinfo.MarkupList != null)
1219
                {
1220
                    viewinfo.MarkupList.Clear();
1221
                    viewinfo.MarkupList = null;
1222 e05fe8ab djkim
                }
1223 6a19b48d taeseongkim
1224 ed3740c4 djkim
                viewinfo.MarkupList = new List<MarkupItem>();
1225
                foreach (var item in dbinfo.MarkupList)
1226 e05fe8ab djkim
                {
1227 6a19b48d taeseongkim
                    System.Diagnostics.Debug.WriteLine(item.ID);
1228 ed3740c4 djkim
                    viewinfo.MarkupList.Add(item);
1229 e05fe8ab djkim
                }
1230 787a4489 KangIngu
            }
1231
        }
1232
1233 a1142a6b taeseongkim
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1234 787a4489 KangIngu
        {
1235 f06cce07 taeseongkim
            var instance = ViewerDataModel.Instance;
1236
1237 233ef333 taeseongkim
            if (instance.IsWheelPageChanage)
1238 787a4489 KangIngu
            {
1239 a1142a6b taeseongkim
                return;
1240
            }
1241
1242
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1243
            {
1244
                int changePage = 0;
1245 233ef333 taeseongkim
1246 f87dfb18 taeseongkim
                if (e.Delta > 0)
1247
                {
1248 a1142a6b taeseongkim
                    if (0 < instance.ContentOffsetY)
1249 f06cce07 taeseongkim
                    {
1250
                        Vector dragOffset = new Vector(0, e.Delta);
1251
                        MoveZoomAndPanControl(dragOffset);
1252
                    }
1253
                    //else
1254
                    //{
1255 a1142a6b taeseongkim
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1256
                    //    {
1257
                    //        instance.IsWheelPageChanage = true;
1258
                    //        changePage -= 1;
1259
                    //    }
1260 f06cce07 taeseongkim
                    //}
1261 f87dfb18 taeseongkim
                }
1262 233ef333 taeseongkim
                else if (e.Delta < 0)
1263 f87dfb18 taeseongkim
                {
1264 f06cce07 taeseongkim
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1265
                    {
1266 233ef333 taeseongkim
                        Vector dragOffset = new Vector(0, e.Delta);
1267 f06cce07 taeseongkim
                        MoveZoomAndPanControl(dragOffset);
1268
                    }
1269
                    //else
1270
                    //{
1271 a1142a6b taeseongkim
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1272
                    //    {
1273
                    //        instance.IsWheelPageChanage = true;
1274
                    //        changePage += 1;
1275
                    //    }
1276 f06cce07 taeseongkim
                    //}
1277 f87dfb18 taeseongkim
                }
1278 a1142a6b taeseongkim
1279
                //if (changePage != 0)
1280
                //{
1281
                //    await Task.Factory.StartNew(() =>
1282
                //    {
1283
                //        double beforeScale = instance.ContentScale;
1284
1285
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1286
1287
                //        handler = (snd, evt) =>
1288
                //        {
1289
                //            /// 최상단으로 이전 zoomScale로 위치한다
1290
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1291
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1292
                //            instance.IsWheelPageChanage = false;
1293
                //            pageNavigator.PageChanged -= handler;
1294
                //        };
1295
1296
                //        pageNavigator.PageChanged += handler;
1297
1298
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1299
                //    });
1300
1301
                //}
1302 787a4489 KangIngu
            }
1303
            else
1304
            {
1305 f87dfb18 taeseongkim
                e.Handled = true;
1306
                if (e.Delta > 0)
1307
                {
1308
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1309
                    ZoomIn(currentContentMousePoint);
1310
                }
1311
                else
1312
                {
1313
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1314
                    ZoomOut(currentContentMousePoint);
1315
                }
1316 787a4489 KangIngu
            }
1317
        }
1318
1319 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1320
        {
1321
            e.Handled = true;
1322
            if (e.Delta > 0)
1323
            {
1324
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1325
                ZoomIn_Sync(currentContentMousePoint);
1326
            }
1327
            else
1328
            {
1329
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1330
                ZoomOut_Sync(currentContentMousePoint);
1331
            }
1332
        }
1333
1334 787a4489 KangIngu
        #region ZoomIn & ZoomOut
1335
1336
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1337
        {
1338
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1339
                zoomAndPanControl.ContentZoomFocusY));
1340
        }
1341
1342
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1343
        {
1344
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1345
                zoomAndPanControl.ContentZoomFocusY));
1346
        }
1347
1348
        //강인구 추가 (줌 인아웃 수치 변경)
1349
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1350
        private void ZoomOut(Point contentZoomCenter)
1351
        {
1352
            if (zoomAndPanControl.ContentScale > 0.39)
1353
            {
1354
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1355
            }
1356
            else
1357
            {
1358
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1359
            }
1360
1361 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1362 787a4489 KangIngu
            {
1363 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1364 787a4489 KangIngu
            }
1365
        }
1366
1367
        private void ZoomIn(Point contentZoomCenter)
1368
        {
1369
            if (zoomAndPanControl.ContentScale > 0.19)
1370
            {
1371
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1372
            }
1373
            else
1374
            {
1375
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1376
            }
1377
1378 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1379 787a4489 KangIngu
            {
1380 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1381 787a4489 KangIngu
            }
1382 a1716fa5 KangIngu
        }
1383
1384
        private void ZoomOut_Sync(Point contentZoomCenter)
1385
        {
1386
            if (zoomAndPanControl2.ContentScale > 0.39)
1387
            {
1388
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1389
            }
1390
            else
1391
            {
1392
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1393
            }
1394
1395
            if (Sync.IsChecked)
1396
            {
1397
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1398
            }
1399
        }
1400
1401
        private void ZoomIn_Sync(Point contentZoomCenter)
1402
        {
1403
            if (zoomAndPanControl2.ContentScale > 0.19)
1404
            {
1405
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1406
            }
1407
            else
1408
            {
1409
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1410
            }
1411
1412
            if (Sync.IsChecked)
1413
            {
1414
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1415
            }
1416 787a4489 KangIngu
        }
1417
1418
        private void ZoomOut()
1419
        {
1420
            zoomAndPanControl.ContentScale -= 0.1;
1421
            //if (zoomAndPanControl2 != null)
1422
            //{
1423
            //    zoomAndPanControl2.ContentScale -= 0.1;
1424
            //}
1425
        }
1426
1427
        private void ZoomIn()
1428
        {
1429
            zoomAndPanControl.ContentScale += 0.1;
1430
            //if (zoomAndPanControl2 != null)
1431
            //{
1432
            //    zoomAndPanControl2.ContentScale += 0.1;
1433
            //}
1434
        }
1435
1436 233ef333 taeseongkim
        #endregion ZoomIn & ZoomOut
1437 787a4489 KangIngu
1438
        private void init()
1439
        {
1440
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1441
            {
1442
                ControlList.Clear();
1443
                listBox.Items.Clear();
1444
                selected_item.Clear();
1445
1446
                (item as IMarkupCommonData).IsSelected = false;
1447
            }
1448
        }
1449
1450
        private HitTestResultBehavior MyCallback(HitTestResult result)
1451
        {
1452
            //this.cursor = Cursors.UpArrow;
1453
            var element = result.VisualHit;
1454
            while (element != null && !(element is CommentUserInfo))
1455
                element = VisualTreeHelper.GetParent(element);
1456
1457
            if (element == null)
1458
            {
1459
                return HitTestResultBehavior.Stop;
1460
            }
1461
            else
1462
            {
1463
                if (element is CommentUserInfo)
1464
                {
1465
                    if (!hitList.Contains(element))
1466
                    {
1467
                        hitList.Add((CommentUserInfo)element);
1468
                    }
1469
                    else
1470
                    {
1471
                        return HitTestResultBehavior.Stop;
1472
                    }
1473
                }
1474
            }
1475
            return HitTestResultBehavior.Continue;
1476
        }
1477
1478
        public void ReleaseSelectPath()
1479
        {
1480
            if (SelectionPath == null)
1481
            {
1482
                SelectionPath = new Path();
1483
                SelectionPath.Name = "";
1484
            }
1485
            if (SelectionPath.Name != "")
1486
            {
1487
                SelectionPath.Name = "None";
1488
            }
1489
            SelectionPath.Opacity = 0.01;
1490
            SelectionPath.RenderTransform = null;
1491
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1492
        }
1493
1494 233ef333 taeseongkim
        #region 컨트롤 초기화
1495
1496 787a4489 KangIngu
        public void Control_Init(object control)
1497
        {
1498
            if (L_Size != 0 && (control as IPath) != null)
1499
            {
1500
                (control as IPath).LineSize = L_Size;
1501
                L_Size = 0;
1502
            }
1503
1504
            switch (control.GetType().Name)
1505
            {
1506
                case "RectangleControl":
1507
                    {
1508
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1509
                    }
1510
                    break;
1511 233ef333 taeseongkim
1512 787a4489 KangIngu
                case "CircleControl":
1513
                    {
1514
                        (control as CircleControl).StrokeColor = Brushes.Red;
1515
                    }
1516
                    break;
1517 233ef333 taeseongkim
1518 787a4489 KangIngu
                case "TriControl":
1519
                    {
1520
                        (control as TriControl).StrokeColor = Brushes.Red;
1521
                    }
1522
                    break;
1523 233ef333 taeseongkim
1524 787a4489 KangIngu
                case "RectCloudControl":
1525
                    {
1526
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1527
                    }
1528
                    break;
1529 233ef333 taeseongkim
1530 787a4489 KangIngu
                case "CloudControl":
1531
                    {
1532
                        (control as CloudControl).StrokeColor = Brushes.Red;
1533
                    }
1534
                    break;
1535 233ef333 taeseongkim
1536 787a4489 KangIngu
                case "PolygonControl":
1537
                    {
1538
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1539
                    }
1540
                    break;
1541 233ef333 taeseongkim
1542 787a4489 KangIngu
                case "ArcControl":
1543
                    {
1544
                        (control as ArcControl).StrokeColor = Brushes.Red;
1545
                    }
1546
                    break;
1547 233ef333 taeseongkim
1548 40b3ce25 ljiyeon
                case "ArrowArcControl":
1549
                    {
1550
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1551
                    }
1552
                    break;
1553 233ef333 taeseongkim
1554 787a4489 KangIngu
                case "LineControl":
1555
                    {
1556
                        (control as LineControl).StrokeColor = Brushes.Red;
1557
                    }
1558
                    break;
1559 233ef333 taeseongkim
1560 787a4489 KangIngu
                case "ArrowControl_Multi":
1561
                    {
1562
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1563
                    }
1564
                    break;
1565 233ef333 taeseongkim
1566 787a4489 KangIngu
                case "TextControl":
1567
                    {
1568
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1569
                    }
1570
                    break;
1571 233ef333 taeseongkim
1572 787a4489 KangIngu
                case "ArrowTextControl":
1573
                    {
1574
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1575
                    }
1576
                    break;
1577 233ef333 taeseongkim
1578 684ef11c ljiyeon
                case "InsideWhiteControl":
1579
                    {
1580
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1581
                    }
1582
                    break;
1583 233ef333 taeseongkim
1584 684ef11c ljiyeon
                case "OverlapWhiteControl":
1585
                    {
1586
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1587
                    }
1588
                    break;
1589 233ef333 taeseongkim
1590 684ef11c ljiyeon
                case "ClipWhiteControl":
1591
                    {
1592
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1593
                    }
1594
                    break;
1595 233ef333 taeseongkim
1596 684ef11c ljiyeon
                case "CoordinateControl":
1597
                    {
1598
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1599
                    }
1600
                    break;
1601 787a4489 KangIngu
            }
1602
        }
1603 233ef333 taeseongkim
1604
        #endregion 컨트롤 초기화
1605 787a4489 KangIngu
1606
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1607
        {
1608
            //Control_Init(e.Source);
1609
        }
1610 233ef333 taeseongkim
1611 7211e0c2 ljiyeon
        //private Window _dragdropWindow = null;
1612 53880c83 ljiyeon
1613
        [DllImport("user32.dll")]
1614
        [return: MarshalAs(UnmanagedType.Bool)]
1615
        internal static extern bool GetCursorPos(ref Win32Point pt);
1616
1617
        [StructLayout(LayoutKind.Sequential)]
1618
        internal struct Win32Point
1619
        {
1620
            public Int32 X;
1621
            public Int32 Y;
1622
        };
1623 233ef333 taeseongkim
1624 7211e0c2 ljiyeon
        /*
1625
       public string symbol_id = null;
1626
       public long symbol_group_id;
1627
       public int symbol_SelectedIndex;
1628
       public ImageSource symbol_img;
1629
       public string symbol_Data = null;
1630
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1631
       {
1632
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1633
               zoomAndPanCanvas.ActualHeight / 2));
1634
1635
               if (this._dragdropWindow != null)
1636
               {
1637
                   this._dragdropWindow.Close();
1638
                   this._dragdropWindow = null;
1639
               }
1640
1641
               symbol_id = id;
1642
               symbol_group_id = group_id;
1643
               symbol_SelectedIndex = SelectedIndex;
1644
               symbol_Data = Data_;
1645
               symbol_img = img;
1646
1647
               CreateDragDropWindow2(img);
1648
    }
1649 53880c83 ljiyeon
1650 7211e0c2 ljiyeon
    private void CreateDragDropWindow2(ImageSource image)
1651 53880c83 ljiyeon
        {
1652
            this._dragdropWindow = new Window();
1653 902faaea taeseongkim
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1654 53880c83 ljiyeon
            _dragdropWindow.WindowStyle = WindowStyle.None;
1655 233ef333 taeseongkim
            _dragdropWindow.AllowsTransparency = true;
1656 53880c83 ljiyeon
            _dragdropWindow.AllowDrop = false;
1657
            _dragdropWindow.Background = null;
1658
            _dragdropWindow.IsHitTestVisible = false;
1659
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1660
            _dragdropWindow.Topmost = true;
1661
            _dragdropWindow.ShowInTaskbar = false;
1662 233ef333 taeseongkim
1663 53880c83 ljiyeon
            Rectangle r = new Rectangle();
1664
            r.Width = image.Width;
1665
            r.Height = image.Height;
1666 233ef333 taeseongkim
            r.Opacity = 0.5;
1667 53880c83 ljiyeon
            r.Fill = new ImageBrush(image);
1668
            this._dragdropWindow.Content = r;
1669
1670
            Win32Point w32Mouse = new Win32Point();
1671
            GetCursorPos(ref w32Mouse);
1672
1673
            //w32Mouse.X = getCurrentPoint.X;
1674
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1675 233ef333 taeseongkim
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1676 53880c83 ljiyeon
            this._dragdropWindow.Show();
1677
        }
1678 f87dfb18 taeseongkim
1679 7211e0c2 ljiyeon
         */
1680 f87dfb18 taeseongkim
1681
        public void MoveZoomAndPanControl(Vector dragOffset)
1682
        {
1683
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1684
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1685
1686
            if (Sync.IsChecked)
1687
            {
1688
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1689
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1690
            }
1691
        }
1692
1693 787a4489 KangIngu
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1694
        {
1695 b74a9c91 taeseongkim
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1696
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1697
            //if(this.txtBatch.Visibility == Visibility.Visible)
1698 787a4489 KangIngu
            {
1699
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1700
1701
                Point currentPos = e.GetPosition(rect);
1702 d71ee575 djkim
1703 787a4489 KangIngu
                floatingTip.HorizontalOffset = currentPos.X + 20;
1704
                floatingTip.VerticalOffset = currentPos.Y;
1705
            }
1706
1707
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1708 233ef333 taeseongkim
1709 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1710 787a4489 KangIngu
            {
1711 e54660e8 KangIngu
                SetCursor();
1712 787a4489 KangIngu
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1713
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1714
1715
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1716 9cd2865b KangIngu
1717 f87dfb18 taeseongkim
                MoveZoomAndPanControl(dragOffset);
1718 787a4489 KangIngu
            }
1719 992a98b4 KangIngu
1720 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1721 787a4489 KangIngu
            {
1722
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1723
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1724
                SetCursor();
1725
1726
                if (currentControl != null)
1727
                {
1728 c7fde400 taeseongkim
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1729
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1730 787a4489 KangIngu
                    //강인구 추가
1731
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1732
1733
                    if ((currentControl as IPath) != null)
1734
                    {
1735
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1736
                    }
1737 5ce56a3a KangIngu
                    if ((currentControl as LineControl) != null)
1738
                    {
1739
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1740
                    }
1741
1742 787a4489 KangIngu
                    if ((currentControl as IShapeControl) != null)
1743
                    {
1744
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1745
                    }
1746
                    if ((currentControl as TextControl) != null)
1747
                    {
1748
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1749
                        {
1750
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1751
                        }
1752
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1753
                        {
1754 d4b0c723 KangIngu
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1755 787a4489 KangIngu
                        }
1756
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1757
                        {
1758
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1759
                        }
1760
                    }
1761
                    else if ((currentControl as ArrowTextControl) != null)
1762
                    {
1763
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1764
                        {
1765
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1766
                        }
1767
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1768
                        {
1769 d4b0c723 KangIngu
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1770 787a4489 KangIngu
                        }
1771
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1772
                        {
1773
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1774
                        }
1775
                    }
1776 9f473fb7 KangIngu
                    else if ((currentControl as RectCloudControl) != null)
1777
                    {
1778
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1779
                    }
1780
                    else if ((currentControl as CloudControl) != null)
1781
                    {
1782
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1783
                    }
1784 787a4489 KangIngu
1785 168f8027 taeseongkim
                    #region // 모든 컨트롤의 공통기능 제어
1786 233ef333 taeseongkim
1787 168f8027 taeseongkim
                    if (controlType != ControlType.PenControl)
1788
                    {
1789 233ef333 taeseongkim
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1790 43e1d368 taeseongkim
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1791 168f8027 taeseongkim
                    }
1792
1793 233ef333 taeseongkim
                    #endregion // 모든 컨트롤의 공통기능 제어
1794 168f8027 taeseongkim
1795
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1796
1797 787a4489 KangIngu
                    switch (controlType)
1798
                    {
1799 684ef11c ljiyeon
                        case (ControlType.Coordinate):
1800
                            {
1801
                                var control = currentControl as CoordinateControl;
1802
                                if (control != null)
1803
                                {
1804 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1805 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1806
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1807
                                }
1808
                            }
1809
                            break;
1810 233ef333 taeseongkim
1811 684ef11c ljiyeon
                        case (ControlType.InsideWhite):
1812
                            {
1813
                                var control = currentControl as InsideWhiteControl;
1814
                                if (control != null)
1815
                                {
1816 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1817 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1818
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1819
                                    control.Paint = PaintSet.Fill;
1820
                                }
1821
                            }
1822
                            break;
1823 233ef333 taeseongkim
1824 a6272c57 humkyung
                        case ControlType.OverlapWhite:
1825 684ef11c ljiyeon
                            {
1826
                                var control = currentControl as OverlapWhiteControl;
1827
                                if (control != null)
1828
                                {
1829 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1830 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1831
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1832
                                    control.Paint = PaintSet.Fill;
1833
                                }
1834
                            }
1835
                            break;
1836 233ef333 taeseongkim
1837 a6272c57 humkyung
                        case ControlType.ClipWhite:
1838 684ef11c ljiyeon
                            {
1839
                                var control = currentControl as ClipWhiteControl;
1840
                                if (control != null)
1841
                                {
1842 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1843 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1844
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1845
                                    control.Paint = PaintSet.Fill;
1846
                                }
1847
                            }
1848
                            break;
1849 233ef333 taeseongkim
1850 787a4489 KangIngu
                        case ControlType.RectCloud:
1851
                            {
1852
                                var control = currentControl as RectCloudControl;
1853
                                if (control != null)
1854
                                {
1855 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1856 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1857
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1858
                                }
1859
                            }
1860
                            break;
1861 233ef333 taeseongkim
1862 787a4489 KangIngu
                        case ControlType.SingleLine:
1863
                        case ControlType.CancelLine:
1864
                        case ControlType.ArrowLine:
1865
                        case ControlType.TwinLine:
1866
                        case ControlType.DimLine:
1867
                            {
1868 d71ee575 djkim
                                var control = currentControl as LineControl;
1869
                                if (control != null)
1870 787a4489 KangIngu
                                {
1871 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1872 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1873
                                }
1874
                            }
1875
                            break;
1876
1877
                        case ControlType.ArcLine:
1878
                            {
1879 d71ee575 djkim
                                var control = currentControl as ArcControl;
1880
                                if (control != null)
1881 787a4489 KangIngu
                                {
1882 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1883 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1884
                                }
1885
                            }
1886
                            break;
1887
1888
                        case ControlType.ArcArrow:
1889
                            {
1890 40b3ce25 ljiyeon
                                var control = currentControl as ArrowArcControl;
1891 d71ee575 djkim
                                if (control != null)
1892 787a4489 KangIngu
                                {
1893 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1894 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1895
                                }
1896
                            }
1897
                            break;
1898
1899
                        case ControlType.ArrowMultiLine:
1900
                            {
1901 d71ee575 djkim
                                var control = currentControl as ArrowControl_Multi;
1902
                                if (control != null)
1903 787a4489 KangIngu
                                {
1904 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1905 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1906
                                }
1907
                            }
1908
                            break;
1909
1910
                        case ControlType.Circle:
1911
                            {
1912 168f8027 taeseongkim
                                var control = currentControl as CircleControl;
1913
1914
                                if (control != null)
1915 787a4489 KangIngu
                                {
1916 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1917
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1918
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1919 787a4489 KangIngu
                                }
1920
                            }
1921
                            break;
1922
1923
                        case ControlType.PolygonCloud:
1924
                            {
1925
                                var control = currentControl as CloudControl;
1926
                                if (control != null)
1927
                                {
1928 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1929 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1930
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1931
                                }
1932
                            }
1933
                            break;
1934
1935
                        case ControlType.Triangle:
1936
                            {
1937
                                var control = currentControl as TriControl;
1938
                                if (control != null)
1939
                                {
1940 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1941 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1942
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1943
                                }
1944
                            }
1945
                            break;
1946
1947
                        case ControlType.ImgControl:
1948
                            {
1949
                                var control = currentControl as ImgControl;
1950
                                if (control != null)
1951
                                {
1952 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1953 787a4489 KangIngu
                                }
1954
                            }
1955
                            break;
1956
1957
                        case ControlType.Date:
1958
                            {
1959
                                var control = currentControl as DateControl;
1960
                                if (control != null)
1961
                                {
1962 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1963 787a4489 KangIngu
                                }
1964
                            }
1965
                            break;
1966
1967
                        case ControlType.ArrowTextControl:
1968
                        case ControlType.ArrowTransTextControl:
1969
                        case ControlType.ArrowTextBorderControl:
1970
                        case ControlType.ArrowTransTextBorderControl:
1971
                        case ControlType.ArrowTextCloudControl:
1972
                        case ControlType.ArrowTransTextCloudControl:
1973
                            {
1974
                                var control = currentControl as ArrowTextControl;
1975
                                if (control != null)
1976
                                {
1977 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1978 787a4489 KangIngu
                                }
1979
                            }
1980
                            break;
1981 233ef333 taeseongkim
1982 787a4489 KangIngu
                        case ControlType.PolygonControl:
1983 e6a9ddaf humkyung
                        case ControlType.ChainLine:
1984 787a4489 KangIngu
                            {
1985
                                var control = currentControl as PolygonControl;
1986
                                if (control != null)
1987
                                {
1988 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1989 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1990
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1991
                                }
1992
                            }
1993
                            break;
1994 233ef333 taeseongkim
1995 787a4489 KangIngu
                        case ControlType.Sign:
1996
                            {
1997
                                var control = currentControl as SignControl;
1998
                                if (control != null)
1999
                                {
2000 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2001 787a4489 KangIngu
                                }
2002
                            }
2003
                            break;
2004 233ef333 taeseongkim
2005 787a4489 KangIngu
                        case ControlType.Symbol:
2006
                            {
2007
                                var control = currentControl as SymControl;
2008
                                if (control != null)
2009
                                {
2010 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2011 787a4489 KangIngu
                                }
2012
                            }
2013
                            break;
2014 233ef333 taeseongkim
2015 787a4489 KangIngu
                        case ControlType.Stamp:
2016
                            {
2017 cd988cd8 djkim
                                var control = currentControl as SymControlN;
2018
                                if (control != null)
2019 787a4489 KangIngu
                                {
2020 cd988cd8 djkim
                                    if (control.STAMP != null)
2021 cbaa3c91 ljiyeon
                                    {
2022 168f8027 taeseongkim
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2023 cbaa3c91 ljiyeon
                                    }
2024 cd988cd8 djkim
                                    else
2025
                                    {
2026
                                        currentControl = null;
2027 902faaea taeseongkim
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2028 cd988cd8 djkim
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2029
                                    }
2030 168f8027 taeseongkim
                                }
2031 787a4489 KangIngu
                            }
2032
                            break;
2033 233ef333 taeseongkim
2034 a6272c57 humkyung
                        case ControlType.Rectangle:
2035 787a4489 KangIngu
                        case ControlType.Mark:
2036
                            {
2037
                                var control = currentControl as RectangleControl;
2038
                                if (control != null)
2039
                                {
2040 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2041
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2042 7a5210f1 humkyung
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2043 787a4489 KangIngu
                                }
2044
                            }
2045
                            break;
2046 233ef333 taeseongkim
2047 787a4489 KangIngu
                        case ControlType.PenControl:
2048
                            {
2049
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2050
                                //inkBoard.Strokes.Add(stroke);
2051
                            }
2052
                            break;
2053 233ef333 taeseongkim
2054 787a4489 KangIngu
                        default:
2055
                            break;
2056
                    }
2057 168f8027 taeseongkim
2058 233ef333 taeseongkim
                    #endregion // 각 컨트롤의 특별한 기능을 제어한다.
2059
2060 4f017ed3 taeseongkim
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2061 168f8027 taeseongkim
                    {
2062 4f017ed3 taeseongkim
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2063 168f8027 taeseongkim
                    }
2064 787a4489 KangIngu
                }
2065
            }
2066 233ef333 taeseongkim
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2067 29cf2c0c humkyung
            {
2068
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2069
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2070
                SetCursor();
2071
                if (currentControl == null)
2072
                {
2073
                    switch (controlType)
2074
                    {
2075
                        case ControlType.PenControl:
2076
                            {
2077
                                if (inkBoard.Tag.ToString() == "Ink")
2078
                                {
2079
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2080
                                }
2081
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2082
                                {
2083
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2084
                                }
2085
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2086
                                {
2087
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2088
                                }
2089
2090
                                //inkBoard.Strokes.Add(stroke);
2091
                            }
2092
                            break;
2093
                    }
2094
                    return;
2095
                }
2096
            }
2097 233ef333 taeseongkim
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2098
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2099 e6a9ddaf humkyung
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2100 787a4489 KangIngu
            {
2101
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2102
2103
                if (isDraggingSelectionRect)
2104
                {
2105 c7fde400 taeseongkim
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2106 787a4489 KangIngu
                    e.Handled = true;
2107
                }
2108
                else if (isLeftMouseButtonDownOnWindow)
2109
                {
2110 c7fde400 taeseongkim
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2111 787a4489 KangIngu
                    double dragDistance = Math.Abs(dragDelta.Length);
2112
2113
                    if (dragDistance > DragThreshold)
2114
                    {
2115
                        isDraggingSelectionRect = true;
2116 c7fde400 taeseongkim
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2117 787a4489 KangIngu
                    }
2118
2119
                    e.Handled = true;
2120
                }
2121
2122 c7fde400 taeseongkim
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2123 787a4489 KangIngu
                {
2124
                }
2125
                else
2126
                {
2127
                    e.Handled = true;
2128
                }
2129
            }
2130 7211e0c2 ljiyeon
            /*
2131 e6a9ddaf humkyung
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2132 233ef333 taeseongkim
            { //symbol
2133 53880c83 ljiyeon
                if(_dragdropWindow != null)
2134
                {
2135
                    Win32Point w32Mouse = new Win32Point();
2136
                    GetCursorPos(ref w32Mouse);
2137
2138
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2139
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2140 233ef333 taeseongkim
                }
2141 53880c83 ljiyeon
            }
2142 7211e0c2 ljiyeon
            */
2143 233ef333 taeseongkim
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2144 e6a9ddaf humkyung
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2145 787a4489 KangIngu
            {
2146 a342d378 taeseongkim
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2147 233ef333 taeseongkim
                if (control != null)
2148 787a4489 KangIngu
                {
2149
                    this.cursor = Cursors.Hand;
2150
                    SetCursor();
2151
                }
2152
                else
2153
                {
2154 902faaea taeseongkim
                    if (this.Cursor != Cursors.None)
2155
                    {
2156
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2157
                        SetCursor();
2158
                    }
2159 787a4489 KangIngu
                }
2160
            }
2161
            else
2162
            {
2163
            }
2164
        }
2165
2166 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2167
        {
2168 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2169 a1716fa5 KangIngu
            {
2170
                SetCursor();
2171
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2172
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2173
2174
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2175
2176
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2177
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2178
2179
                if (Sync.IsChecked)
2180
                {
2181
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2182
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2183
                }
2184
            }
2185
        }
2186
2187 787a4489 KangIngu
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2188
2189
        private EllipseGeometry hitArea = new EllipseGeometry();
2190
2191
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2192
        {
2193
            IsDrawing = false;
2194 233ef333 taeseongkim
2195 787a4489 KangIngu
            if (mouseHandlingMode != MouseHandlingMode.None)
2196
            {
2197
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2198
                {
2199 902faaea taeseongkim
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2200 787a4489 KangIngu
2201
                    SetCursor();
2202
2203
                    switch (controlType)
2204
                    {
2205
                        case ControlType.None:
2206
                            break;
2207 233ef333 taeseongkim
2208 787a4489 KangIngu
                        case ControlType.Rectangle:
2209
                            {
2210
                            }
2211
                            break;
2212 233ef333 taeseongkim
2213 787a4489 KangIngu
                        case ControlType.PenControl:
2214
                            {
2215
                            }
2216
                            break;
2217 233ef333 taeseongkim
2218 787a4489 KangIngu
                        default:
2219
                            break;
2220 233ef333 taeseongkim
                    }
2221 787a4489 KangIngu
                }
2222 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)
2223 787a4489 KangIngu
                {
2224
                    if (isLeftMouseButtonDownOnWindow)
2225
                    {
2226
                        bool wasDragSelectionApplied = false;
2227
2228
                        if (isDraggingSelectionRect)
2229
                        {
2230 53880c83 ljiyeon
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2231
                            {
2232
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2233
                                mouseHandlingMode = MouseHandlingMode.None;
2234
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2235
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2236
                                Set_Symbol_Capture(endPoint);
2237
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2238 233ef333 taeseongkim
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2239 53880c83 ljiyeon
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2240
                            }
2241
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2242 787a4489 KangIngu
                            {
2243
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2244
                                mouseHandlingMode = MouseHandlingMode.None;
2245
                                Set_Capture();
2246
2247
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2248
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2249
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2250
                            }
2251 9f473fb7 KangIngu
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2252 787a4489 KangIngu
                            {
2253
                                ApplyDragSelectionRect();
2254
                            }
2255 9f473fb7 KangIngu
                            else
2256
                            {
2257
                                double x = Canvas.GetLeft(dragZoomBorder);
2258
                                double y = Canvas.GetTop(dragZoomBorder);
2259
                                double width = dragZoomBorder.Width;
2260
                                double height = dragZoomBorder.Height;
2261
                                Rect dragRect = new Rect(x, y, width, height);
2262
2263
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2264
2265
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2266
                            }
2267 787a4489 KangIngu
2268 9f473fb7 KangIngu
                            isDraggingSelectionRect = false;
2269 787a4489 KangIngu
                            e.Handled = true;
2270
                            wasDragSelectionApplied = true;
2271
                        }
2272
2273
                        if (isLeftMouseButtonDownOnWindow)
2274
                        {
2275
                            isLeftMouseButtonDownOnWindow = false;
2276
                            this.ReleaseMouseCapture();
2277
                            e.Handled = true;
2278
                        }
2279
2280
                        if (!wasDragSelectionApplied)
2281
                        {
2282
                            init();
2283
                        }
2284
                    }
2285
                }
2286 e6a9ddaf humkyung
                else if (e.RightButton == MouseButtonState.Pressed)
2287 787a4489 KangIngu
                {
2288 902faaea taeseongkim
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2289 787a4489 KangIngu
                    SetCursor();
2290
                }
2291
2292
                zoomAndPanControl.ReleaseMouseCapture();
2293
2294
                e.Handled = true;
2295
            }
2296
            else
2297
            {
2298 902faaea taeseongkim
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2299 787a4489 KangIngu
                SetCursor();
2300
            }
2301
2302 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2303 787a4489 KangIngu
            //controlType = ControlType.SingleLine;
2304
        }
2305
2306 53880c83 ljiyeon
        public void Set_Symbol_Capture(Point endPoint)
2307 233ef333 taeseongkim
        {
2308 c7fde400 taeseongkim
            double x = CanvasDrawingMouseDownPoint.X;
2309
            double y = CanvasDrawingMouseDownPoint.Y;
2310 233ef333 taeseongkim
            if (x > endPoint.X)
2311 53880c83 ljiyeon
            {
2312
                x = endPoint.X;
2313
                y = endPoint.Y;
2314
            }
2315
2316
            double width = dragCaptureBorder.Width;
2317
            double height = dragCaptureBorder.Height;
2318
2319
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2320
2321
            if (x < 0)
2322
            {
2323
                width += x;
2324
                x = 0;
2325
            }
2326
            if (y < 0)
2327
            {
2328
                height += y;
2329
                y = 0;
2330
2331
                width = (int)canvasImage.PixelWidth - x;
2332
            }
2333
            if (x + width > canvasImage.PixelWidth)
2334
            {
2335
                width = (int)canvasImage.PixelWidth - x;
2336
            }
2337
            if (y + height > canvasImage.PixelHeight)
2338
            {
2339
                height = (int)canvasImage.PixelHeight - y;
2340
            }
2341
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2342
2343 69f41aab humkyung
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2344 53880c83 ljiyeon
            var defaultBitmapImage = new BitmapImage();
2345
            defaultBitmapImage.BeginInit();
2346
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2347
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2348
            defaultBitmapImage.UriSource = new Uri(uri);
2349
            defaultBitmapImage.EndInit();
2350
2351 90e7968d ljiyeon
            //GC.Collect();
2352 53880c83 ljiyeon
2353
            if (defaultBitmapImage.IsDownloading)
2354
            {
2355
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2356
                {
2357
                    defaultBitmapImage.Freeze();
2358 90e7968d ljiyeon
                    //GC.Collect();
2359 53880c83 ljiyeon
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2360
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2361
                };
2362
            }
2363
        }
2364
2365 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2366
        {
2367 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2368 a1716fa5 KangIngu
        }
2369
2370 787a4489 KangIngu
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2371
        {
2372 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2373 902faaea taeseongkim
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2374 787a4489 KangIngu
        }
2375
2376
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2377
        {
2378
        }
2379
2380 4804a4fb humkyung
        /// <summary>
2381
        /// select items by dragging
2382
        /// </summary>
2383 787a4489 KangIngu
        private void ApplyDragSelectionRect()
2384
        {
2385
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2386
2387
            double x = Canvas.GetLeft(dragSelectionBorder);
2388
            double y = Canvas.GetTop(dragSelectionBorder);
2389
            double width = dragSelectionBorder.Width;
2390
            double height = dragSelectionBorder.Height;
2391
            Boolean Flag = false;
2392
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2393 f87a00b1 ljiyeon
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2394 787a4489 KangIngu
2395 e6a9ddaf humkyung
            Rect dragRect = new Rect(x, y, width, height);
2396
            ///dragRect.Inflate(width / 10, height / 10);
2397 787a4489 KangIngu
2398
            foreach (var item in Items)
2399
            {
2400 91efe37a humkyung
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2401 787a4489 KangIngu
2402
                if (Flag)
2403
                {
2404
                    adornerSet.Add(item);
2405 05009a0e ljiyeon
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2406 787a4489 KangIngu
                    Control_Style(item);
2407
                }
2408
            }
2409
            if (adornerSet.Count > 0)
2410
            {
2411
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2412
                SelectLayer.Children.Add(final);
2413
            }
2414
        }
2415
2416
        private void InitDragSelectionRect(Point pt1, Point pt2)
2417
        {
2418 9f473fb7 KangIngu
            //캡쳐 중
2419
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2420
            {
2421
                dragCaptureBorder.Visibility = Visibility.Visible;
2422
            }
2423 787a4489 KangIngu
            //선택 중
2424 9f473fb7 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2425 787a4489 KangIngu
            {
2426
                dragSelectionBorder.Visibility = Visibility.Visible;
2427
            }
2428
            else
2429
            {
2430 9f473fb7 KangIngu
                dragZoomBorder.Visibility = Visibility.Visible;
2431 787a4489 KangIngu
            }
2432
            UpdateDragSelectionRect(pt1, pt2);
2433
        }
2434
2435
        /// <summary>
2436
        /// Update the position and size of the rectangle used for drag selection.
2437
        /// </summary>
2438
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2439
        {
2440
            double x, y, width, height;
2441
2442
            //
2443
            // Determine x,y,width and height of the rect inverting the points if necessary.
2444 233ef333 taeseongkim
            //
2445 787a4489 KangIngu
2446
            if (pt2.X < pt1.X)
2447
            {
2448
                x = pt2.X;
2449
                width = pt1.X - pt2.X;
2450
            }
2451
            else
2452
            {
2453
                x = pt1.X;
2454
                width = pt2.X - pt1.X;
2455
            }
2456
2457
            if (pt2.Y < pt1.Y)
2458
            {
2459
                y = pt2.Y;
2460
                height = pt1.Y - pt2.Y;
2461
            }
2462
            else
2463
            {
2464
                y = pt1.Y;
2465
                height = pt2.Y - pt1.Y;
2466
            }
2467
2468
            //
2469
            // Update the coordinates of the rectangle used for drag selection.
2470
            //
2471 9f473fb7 KangIngu
            //캡쳐 중
2472
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2473
            {
2474
                Canvas.SetLeft(dragCaptureBorder, x);
2475
                Canvas.SetTop(dragCaptureBorder, y);
2476
                dragCaptureBorder.Width = width;
2477
                dragCaptureBorder.Height = height;
2478
            }
2479 787a4489 KangIngu
            //선택 중
2480 a1716fa5 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2481 787a4489 KangIngu
            {
2482
                Canvas.SetLeft(dragSelectionBorder, x);
2483
                Canvas.SetTop(dragSelectionBorder, y);
2484
                dragSelectionBorder.Width = width;
2485
                dragSelectionBorder.Height = height;
2486
            }
2487
            else
2488
            {
2489 9f473fb7 KangIngu
                Canvas.SetLeft(dragZoomBorder, x);
2490
                Canvas.SetTop(dragZoomBorder, y);
2491
                dragZoomBorder.Width = width;
2492
                dragZoomBorder.Height = height;
2493 787a4489 KangIngu
            }
2494
        }
2495
2496
        private void drawingPannelRotate(double angle)
2497
        {
2498 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2499 787a4489 KangIngu
            rotate.Angle = angle;
2500
            var rotationNum = Math.Abs((rotate.Angle / 90));
2501
2502
            if (angle == 90 || angle == 270)
2503
            {
2504
                double emptySize = zoomAndPanCanvas.Width;
2505
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2506
                zoomAndPanCanvas.Height = emptySize;
2507
            }
2508
            if (angle == 0)
2509
            {
2510
                translate.X = 0;
2511
                translate.Y = 0;
2512
            }
2513
            else if (angle == 90)
2514
            {
2515
                translate.X = zoomAndPanCanvas.Width;
2516
                translate.Y = 0;
2517
            }
2518
            else if (angle == 180)
2519
            {
2520
                translate.X = zoomAndPanCanvas.Width;
2521
                translate.Y = zoomAndPanCanvas.Height;
2522
            }
2523
            else
2524
            {
2525
                translate.X = 0;
2526
                translate.Y = zoomAndPanCanvas.Height;
2527
            }
2528
2529
            zoomAndPanControl.RotationAngle = rotate.Angle;
2530
2531
            if (!testPanel2.IsHidden)
2532
            {
2533
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2534
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2535
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2536
            }
2537
2538
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2539
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2540
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2541
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2542 4f017ed3 taeseongkim
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2543 787a4489 KangIngu
        }
2544
2545 497bbe52 ljiyeon
        private void syncPannelRotate(double angle)
2546
        {
2547
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2548
            rotate.Angle = angle;
2549
            var rotationNum = Math.Abs((rotate.Angle / 90));
2550
2551
            if (angle == 90 || angle == 270)
2552
            {
2553
                double emptySize = zoomAndPanCanvas2.Width;
2554
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2555
                zoomAndPanCanvas2.Height = emptySize;
2556
            }
2557
            if (angle == 0)
2558
            {
2559
                translate2.X = 0;
2560
                translate2.Y = 0;
2561
            }
2562
            else if (angle == 90)
2563
            {
2564
                translate2.X = zoomAndPanCanvas2.Width;
2565
                translate2.Y = 0;
2566
            }
2567
            else if (angle == 180)
2568
            {
2569
                translate2.X = zoomAndPanCanvas2.Width;
2570
                translate2.Y = zoomAndPanCanvas2.Height;
2571
            }
2572
            else
2573
            {
2574
                translate2.X = 0;
2575
                translate2.Y = zoomAndPanCanvas2.Height;
2576
            }
2577
2578
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2579
        }
2580
2581 53880c83 ljiyeon
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2582 787a4489 KangIngu
        {
2583 53880c83 ljiyeon
            string Data_ = "";
2584
2585
            try
2586
            {
2587 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2588 53880c83 ljiyeon
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2589
                if (Data_ != null || Data_ != "")
2590
                {
2591 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2592 53880c83 ljiyeon
                }
2593
                else
2594
                {
2595 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2596 53880c83 ljiyeon
                }
2597
2598 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2599
                //{
2600
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2601
                //    STATE = 0,
2602
                //};
2603 53880c83 ljiyeon
                if (Data_ != null)
2604
                {
2605
                    Image img = new Image();
2606
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2607
                    if (Data_.Contains(".svg"))
2608
                    {
2609
                        byte[] imageData = null;
2610
                        DrawingImage image = null;
2611
                        using (System.Net.WebClient web = new System.Net.WebClient())
2612
                        {
2613
                            imageData = web.DownloadData(new Uri(Data_));
2614
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2615
                            image = SvgReader.Load(stream);
2616
                        }
2617
                        img.Source = image;
2618
                    }
2619
                    else
2620
                    {
2621
                        img.Source = new BitmapImage(new Uri(Data_));
2622
                    }
2623
2624
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2625
                    {
2626
                        PointSet = new List<Point>(),
2627
                        FilePath = Data_,
2628
                        ImageData = img.Source,
2629
                        StartPoint = canvasZoomPanningMouseDownPoint,
2630 233ef333 taeseongkim
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2631 53880c83 ljiyeon
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2632 233ef333 taeseongkim
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2633 53880c83 ljiyeon
                        canvasZoomPanningMouseDownPoint.Y),
2634
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2635
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2636
                    };
2637
2638
                    currentControl.PointSet = new List<Point>
2639
                                        {
2640
                                            currentControl.StartPoint,
2641
                                            currentControl.LeftBottomPoint,
2642
                                            currentControl.EndPoint,
2643
                                            currentControl.TopRightPoint,
2644
                                        };
2645
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2646
                    UndoData = new Undo_data()
2647
                    {
2648
                        IsUndo = false,
2649
                        Event = Event_Type.Create,
2650
                        EventTime = DateTime.Now,
2651
                        Markup_List = new List<Multi_Undo_data>()
2652
                    };
2653
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2654
                    {
2655
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2656
                    });
2657
2658
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2659
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2660
                    UndoData.Markup_List.Add(multi_Undo_Data);
2661
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2662
2663
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2664 24678e06 humkyung
                    currentControl.CommentID = Commons.shortGuid();
2665 53880c83 ljiyeon
                    currentControl.SymbolID = id;
2666
                    currentControl.GroupID = group_id;
2667
                    currentControl.ApplyTemplate();
2668
                    currentControl.SetImage();
2669
2670
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2671
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2672
                    SelectLayer.Children.Add(final);
2673
                }
2674
            }
2675
            catch (Exception ex)
2676
            {
2677
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2678
            }
2679
        }
2680
2681 6a19b48d taeseongkim
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2682
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2683 10de973b taeseongkim
        {
2684 992a98b4 KangIngu
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2685 be04d12c djkim
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2686 992a98b4 KangIngu
            {
2687
                set_option.Value = double.Parse(set_option.ContentText);
2688 5d55f6fb ljiyeon
                //set_option.Focusable = false;
2689 3c71b3a5 taeseongkim
                zoomAndPanControl.Focus();
2690 992a98b4 KangIngu
            }
2691
2692 f959ea6f humkyung
            ConvertInkControlToPolygon();
2693 787a4489 KangIngu
2694 1b2cf911 taeseongkim
            // 텍스트가 없으면 삭제됨
2695 787a4489 KangIngu
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2696
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2697
2698 a1716fa5 KangIngu
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2699 787a4489 KangIngu
            {
2700 1b2cf911 taeseongkim
                DeleteCommand.Instance.Execute(new[] { text_item });
2701
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2702 787a4489 KangIngu
            }
2703 1305c420 taeseongkim
2704 d62c0439 humkyung
            /// up to here
2705 787a4489 KangIngu
2706 b7813553 djkim
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2707 787a4489 KangIngu
            {
2708 b7813553 djkim
                if (item as ArrowTextControl != null)
2709 787a4489 KangIngu
                {
2710 b7813553 djkim
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2711 787a4489 KangIngu
                }
2712 76688e76 djkim
                else if (item as TextControl != null)
2713
                {
2714
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2715
                }
2716 787a4489 KangIngu
            }
2717
2718 49b217ad humkyung
            //if (currentControl != null)
2719 787a4489 KangIngu
            {
2720 a6f7f9b6 djkim
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2721
                if (text_item_ != null)
2722 787a4489 KangIngu
                {
2723
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2724
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2725 233ef333 taeseongkim
                    (text_item_ as TextControl).IsEditingMode = false;
2726 49b217ad humkyung
                    currentControl = null;
2727 787a4489 KangIngu
                }
2728
2729
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2730 49b217ad humkyung
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2731 787a4489 KangIngu
                {
2732
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2733
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2734 49b217ad humkyung
                    currentControl = null;
2735 787a4489 KangIngu
                }
2736
            }
2737
2738 233ef333 taeseongkim
            double Ang = 0;
2739 787a4489 KangIngu
            if (rotate.Angle != 0)
2740
            {
2741
                Ang = 360 - rotate.Angle;
2742
            }
2743
2744
            if (e.OriginalSource is System.Windows.Controls.Image)
2745
            {
2746
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2747
            }
2748 7211e0c2 ljiyeon
            /*
2749 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2750 233ef333 taeseongkim
            {
2751 53880c83 ljiyeon
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2752
                if(symbol_id != null)
2753
                {
2754
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2755 233ef333 taeseongkim
                }
2756 53880c83 ljiyeon
            }
2757
2758 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2759 53880c83 ljiyeon
            {
2760
                if (this._dragdropWindow != null)
2761
                {
2762
                    this._dragdropWindow.Close();
2763
                    this._dragdropWindow = null;
2764
                    symbol_id = null;
2765
                }
2766
            }
2767 7211e0c2 ljiyeon
            */
2768 53880c83 ljiyeon
2769 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed)
2770 787a4489 KangIngu
            {
2771 c7fde400 taeseongkim
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2772 787a4489 KangIngu
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2773
2774 902faaea taeseongkim
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2775 787a4489 KangIngu
                SetCursor();
2776
2777 315ae55e taeseongkim
                if (!ViewerDataModel.Instance.IsPressCtrl)
2778
                {
2779
                    SelectionSet.Instance.UnSelect(this);
2780
                }
2781 787a4489 KangIngu
            }
2782 f513c215 humkyung
2783 e6a9ddaf humkyung
            if (e.MiddleButton == MouseButtonState.Pressed)
2784 787a4489 KangIngu
            {
2785
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2786
                cursor = Cursors.SizeAll;
2787
                SetCursor();
2788
            }
2789 e6a9ddaf humkyung
            if (e.RightButton == MouseButtonState.Pressed)
2790 787a4489 KangIngu
            {
2791
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2792
                cursor = Cursors.SizeAll;
2793
                SetCursor();
2794
            }
2795 e6a9ddaf humkyung
            else if (e.XButton1 == MouseButtonState.Pressed)
2796 787a4489 KangIngu
            {
2797
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2798
                {
2799 3908a575 humkyung
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2800 787a4489 KangIngu
                }
2801
2802 3908a575 humkyung
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2803 787a4489 KangIngu
            }
2804 e6a9ddaf humkyung
            else if (e.XButton2 == MouseButtonState.Pressed)
2805 787a4489 KangIngu
            {
2806
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2807
                {
2808
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2809
                }
2810
            }
2811
2812 1305c420 taeseongkim
            bool isArrowTextEdit = false;
2813
2814
            if (currentControl is ArrowTextControl textControl)
2815
            {
2816
                if (textControl.IsEditingMode)
2817
                    isArrowTextEdit = true;
2818
            }
2819
2820 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2821 787a4489 KangIngu
            {
2822
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2823
                {
2824
                    if (SelectLayer.Children.Count == 0)
2825
                    {
2826
                        isLeftMouseButtonDownOnWindow = true;
2827
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2828
                    }
2829
2830
                    if (controlType == ControlType.None)
2831
                    {
2832
                        isLeftMouseButtonDownOnWindow = true;
2833
                    }
2834
                }
2835
2836 f513c215 humkyung
                /// 캡쳐 모드 설정
2837 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2838
                {
2839
                    dragCaptureBorder.Visibility = Visibility.Visible;
2840
                    isLeftMouseButtonDownOnWindow = true;
2841
                }
2842
2843 f513c215 humkyung
                /// 줌 모드 설정
2844 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2845
                {
2846
                    isLeftMouseButtonDownOnWindow = true;
2847 1066bae3 ljiyeon
                }
2848 787a4489 KangIngu
2849 a342d378 taeseongkim
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2850 b643fcca taeseongkim
2851 233ef333 taeseongkim
                if (control == null)
2852 787a4489 KangIngu
                {
2853 b643fcca taeseongkim
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2854
                }
2855
                else
2856
                {
2857 233ef333 taeseongkim
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2858
                    {
2859
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2860
                    }
2861 b643fcca taeseongkim
2862 d62c0439 humkyung
                    AdornerFinal final = null;
2863 787a4489 KangIngu
2864
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2865
                    {
2866 d62c0439 humkyung
                        /// 기존 selection 해제
2867 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
2868 d62c0439 humkyung
2869 787a4489 KangIngu
                        final = new AdornerFinal(control);
2870
2871 f513c215 humkyung
                        this.Control_Style(control);
2872 787a4489 KangIngu
2873
                        if ((control as IPath) != null)
2874
                        {
2875
                            if ((control as IPath).LineSize != 0)
2876
                            {
2877
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2878
                            }
2879
                        }
2880
                        if ((control as IShapeControl) != null)
2881
                        {
2882
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2883
                            {
2884
                                ViewerDataModel.Instance.checkHatchShape = true;
2885
                            }
2886
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2887
                            {
2888
                                ViewerDataModel.Instance.checkFillShape = true;
2889
                            }
2890
                            else
2891
                            {
2892
                                ViewerDataModel.Instance.checkHatchShape = false;
2893
                                ViewerDataModel.Instance.checkFillShape = false;
2894
                            }
2895
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2896
                        }
2897 9f473fb7 KangIngu
2898 787a4489 KangIngu
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2899 d4b0c723 KangIngu
2900
                        if ((control as TextControl) != null)
2901
                        {
2902 c206d293 taeseongkim
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2903
2904 233ef333 taeseongkim
                            if (!((control as TextControl).EnableEditing))
2905
                            {
2906 71d7e0bf 송근호
                                (control as TextControl).EnableEditing = true;
2907
                            }
2908 d4b0c723 KangIngu
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2909
                            {
2910
                                ViewerDataModel.Instance.checkTextStyle = true;
2911
                            }
2912
                            else
2913
                            {
2914
                                ViewerDataModel.Instance.checkTextStyle = false;
2915
                            }
2916
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2917
                            {
2918
                                ViewerDataModel.Instance.checkTextWeight = true;
2919
                            }
2920
                            else
2921
                            {
2922
                                ViewerDataModel.Instance.checkTextWeight = false;
2923
                            }
2924
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2925
                            {
2926
                                ViewerDataModel.Instance.checkUnderLine = true;
2927
                            }
2928
                            else
2929
                            {
2930
                                ViewerDataModel.Instance.checkUnderLine = false;
2931
                            }
2932
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2933
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2934
                        }
2935
                        else if ((control as ArrowTextControl) != null)
2936
                        {
2937 24c5e56c taeseongkim
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2938
2939 120b8b00 송근호
                            if (!((control as ArrowTextControl).EnableEditing))
2940
                            {
2941 71d7e0bf 송근호
                                (control as ArrowTextControl).EnableEditing = true;
2942
                            }
2943 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2944 d4b0c723 KangIngu
                            {
2945 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = true;
2946
                            }
2947
                            else
2948 d4b0c723 KangIngu
                            {
2949 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = false;
2950 d4b0c723 KangIngu
                            }
2951 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2952 d4b0c723 KangIngu
                            {
2953 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextWeight = true;
2954
                            }
2955
                            else
2956
                            {
2957
                                ViewerDataModel.Instance.checkTextWeight = false;
2958
                            }
2959
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2960
                            {
2961
                                ViewerDataModel.Instance.checkUnderLine = true;
2962
                            }
2963
                            else
2964
                            {
2965
                                ViewerDataModel.Instance.checkUnderLine = false;
2966 d4b0c723 KangIngu
                            }
2967
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2968
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2969
                        }
2970 9f473fb7 KangIngu
                        else if ((control as RectCloudControl) != null)
2971
                        {
2972
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2973
                        }
2974
                        else if ((control as CloudControl) != null)
2975
                        {
2976
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2977
                        }
2978 787a4489 KangIngu
                    }
2979
                    else
2980
                    {
2981 d62c0439 humkyung
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2982
                        SelectionSet.Instance.UnSelect(this);
2983 787a4489 KangIngu
                        comment.Add(control);
2984
2985
                        Control_Style(control);
2986
2987
                        final = new AdornerFinal(comment);
2988
                    }
2989
2990 f513c215 humkyung
                    if (final != null)
2991
                    {
2992
                        this.SelectLayer.Children.Add(final);
2993
                    }
2994 b643fcca taeseongkim
                }
2995 787a4489 KangIngu
            }
2996
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2997 233ef333 taeseongkim
            {
2998 1305c420 taeseongkim
2999
3000 787a4489 KangIngu
                init();
3001
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3002
                if (cursor != Cursors.SizeAll)
3003
                {
3004
                    cursor = Cursors.Cross;
3005
                    SetCursor();
3006
                }
3007
                bool init_user = false;
3008
                foreach (var user in gridViewMarkup.Items)
3009
                {
3010
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3011
                    {
3012
                        init_user = true;
3013
                    }
3014
                }
3015
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3016
                {
3017 d7e20d2d taeseongkim
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3018 787a4489 KangIngu
                    RadWindow.Alert(new DialogParameters
3019
                    {
3020 b9b01f8e ljiyeon
                        Owner = Application.Current.MainWindow,
3021 787a4489 KangIngu
                        Theme = new VisualStudio2013Theme(),
3022 d7e20d2d taeseongkim
                        Header = "Info",
3023
                        Content = "Existing comments already existed. Select from the user list first",
3024 787a4489 KangIngu
                    });
3025
                    return;
3026
                }
3027
                else
3028
                {
3029
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3030
                    if (item != null)
3031
                    {
3032
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3033
                    }
3034
                }
3035 1305c420 taeseongkim
                
3036 75448f5e ljiyeon
                switch (controlType)
3037 787a4489 KangIngu
                {
3038 684ef11c ljiyeon
                    case ControlType.Coordinate:
3039
                        {
3040 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3041 684ef11c ljiyeon
                            {
3042
                                if (currentControl is CoordinateControl)
3043
                                {
3044
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3045
                                    {
3046
                                        return;
3047
                                    }
3048
3049 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3050 684ef11c ljiyeon
3051
                                    currentControl = null;
3052
                                    this.cursor = Cursors.Arrow;
3053
                                }
3054
                                else
3055
                                {
3056
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3057 d62c0439 humkyung
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3058 684ef11c ljiyeon
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3059
                                    {
3060
                                        currentControl = null;
3061
                                        this.cursor = Cursors.Arrow;
3062
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3063
                                        return;
3064
                                    }
3065
                                    else
3066
                                    {
3067
                                        currentControl = new CoordinateControl
3068
                                        {
3069
                                            Background = new SolidColorBrush(Colors.Black),
3070 c7fde400 taeseongkim
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3071 684ef11c ljiyeon
                                            ControlType = ControlType.Coordinate
3072
                                        };
3073
3074 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3075 684ef11c ljiyeon
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3076
                                        currentControl.IsNew = true;
3077
3078
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3079
3080
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3081
                                    }
3082
                                }
3083
                            }
3084
                        }
3085
                        break;
3086 233ef333 taeseongkim
3087 684ef11c ljiyeon
                    case ControlType.InsideWhite:
3088
                        {
3089 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3090 684ef11c ljiyeon
                            {
3091
                                if (currentControl is InsideWhiteControl)
3092
                                {
3093
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3094
                                    {
3095
                                        return;
3096
                                    }
3097
3098 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3099 684ef11c ljiyeon
3100
                                    currentControl = null;
3101
                                    this.cursor = Cursors.Arrow;
3102
                                }
3103
                                else
3104
                                {
3105
                                    currentControl = new InsideWhiteControl
3106
                                    {
3107
                                        Background = new SolidColorBrush(Colors.Black),
3108 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3109 684ef11c ljiyeon
                                        ControlType = ControlType.InsideWhite
3110
                                    };
3111
3112 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3113 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3114
                                    currentControl.IsNew = true;
3115
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3116
3117
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3118
                                }
3119
                            }
3120
                        }
3121
                        break;
3122 233ef333 taeseongkim
3123 684ef11c ljiyeon
                    case ControlType.OverlapWhite:
3124
                        {
3125 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3126 684ef11c ljiyeon
                            {
3127
                                if (currentControl is OverlapWhiteControl)
3128
                                {
3129
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3130
                                    {
3131
                                        return;
3132
                                    }
3133
3134 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3135 684ef11c ljiyeon
3136
                                    currentControl = null;
3137
                                    this.cursor = Cursors.Arrow;
3138
                                }
3139
                                else
3140
                                {
3141
                                    currentControl = new OverlapWhiteControl
3142
                                    {
3143
                                        Background = new SolidColorBrush(Colors.Black),
3144 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3145 684ef11c ljiyeon
                                        ControlType = ControlType.OverlapWhite
3146
                                    };
3147
3148 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3149 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3150
                                    currentControl.IsNew = true;
3151
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3152
3153
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3154
                                }
3155
                            }
3156
                        }
3157
                        break;
3158 233ef333 taeseongkim
3159 684ef11c ljiyeon
                    case ControlType.ClipWhite:
3160
                        {
3161 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3162 684ef11c ljiyeon
                            {
3163
                                if (currentControl is ClipWhiteControl)
3164
                                {
3165
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3166
                                    {
3167
                                        return;
3168
                                    }
3169
3170 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3171 684ef11c ljiyeon
3172
                                    currentControl = null;
3173
                                    this.cursor = Cursors.Arrow;
3174
                                }
3175
                                else
3176
                                {
3177
                                    currentControl = new ClipWhiteControl
3178
                                    {
3179
                                        Background = new SolidColorBrush(Colors.Black),
3180 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3181 684ef11c ljiyeon
                                        ControlType = ControlType.ClipWhite
3182
                                    };
3183
3184 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3185 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3186
                                    currentControl.IsNew = true;
3187
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3188
3189
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3190
                                }
3191
                            }
3192
                        }
3193
                        break;
3194 233ef333 taeseongkim
3195 787a4489 KangIngu
                    case ControlType.Rectangle:
3196
                        {
3197 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3198 787a4489 KangIngu
                            {
3199 f67f164e humkyung
                                if (currentControl is RectangleControl)
3200
                                {
3201
                                    //20180906 LJY TEST IsRotationDrawingEnable
3202
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3203 787a4489 KangIngu
                                    {
3204 f67f164e humkyung
                                        return;
3205
                                    }
3206 787a4489 KangIngu
3207 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3208
                                    currentControl = null;
3209 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3210 f67f164e humkyung
                                }
3211
                                else
3212
                                {
3213
                                    currentControl = new RectangleControl
3214 787a4489 KangIngu
                                    {
3215 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
3216 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3217 f67f164e humkyung
                                        ControlType = ControlType.Rectangle
3218
                                    };
3219 787a4489 KangIngu
3220 f67f164e humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3221
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3222
                                    currentControl.IsNew = true;
3223
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3224 787a4489 KangIngu
3225 f67f164e humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3226
                                }
3227 787a4489 KangIngu
                            }
3228
                        }
3229
                        break;
3230 233ef333 taeseongkim
3231 787a4489 KangIngu
                    case ControlType.RectCloud:
3232
                        {
3233 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3234 787a4489 KangIngu
                            {
3235 f67f164e humkyung
                                if (currentControl is RectCloudControl)
3236
                                {
3237
                                    //20180906 LJY TEST IsRotationDrawingEnable
3238
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3239 787a4489 KangIngu
                                    {
3240 f67f164e humkyung
                                        return;
3241
                                    }
3242 e66f22eb KangIngu
3243 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3244 787a4489 KangIngu
3245 f67f164e humkyung
                                    currentControl = null;
3246 233ef333 taeseongkim
3247 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3248 f67f164e humkyung
                                }
3249
                                else
3250
                                {
3251
                                    currentControl = new RectCloudControl
3252 787a4489 KangIngu
                                    {
3253 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3254 f67f164e humkyung
                                        ControlType = ControlType.RectCloud,
3255
                                        Background = new SolidColorBrush(Colors.Black)
3256
                                    };
3257 787a4489 KangIngu
3258 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3259
                                    currentControl.CommentID = Commons.shortGuid();
3260
                                    currentControl.IsNew = true;
3261
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3262
                                }
3263 787a4489 KangIngu
                            }
3264
                        }
3265
                        break;
3266 233ef333 taeseongkim
3267 787a4489 KangIngu
                    case ControlType.Circle:
3268
                        {
3269 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3270 787a4489 KangIngu
                            {
3271 f67f164e humkyung
                                if (currentControl is CircleControl)
3272
                                {
3273
                                    //20180906 LJY TEST IsRotationDrawingEnable
3274
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3275 787a4489 KangIngu
                                    {
3276 f67f164e humkyung
                                        return;
3277
                                    }
3278 e66f22eb KangIngu
3279 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3280 787a4489 KangIngu
3281 f67f164e humkyung
                                    currentControl = null;
3282
                                }
3283
                                else
3284
                                {
3285
                                    currentControl = new CircleControl
3286 787a4489 KangIngu
                                    {
3287 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3288
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3289 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3290
                                    };
3291 787a4489 KangIngu
3292 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3293
                                    currentControl.CommentID = Commons.shortGuid();
3294
                                    currentControl.IsNew = true;
3295
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3296
                                }
3297 787a4489 KangIngu
                            }
3298
                        }
3299
                        break;
3300 233ef333 taeseongkim
3301 787a4489 KangIngu
                    case ControlType.Triangle:
3302
                        {
3303 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3304 787a4489 KangIngu
                            {
3305 f67f164e humkyung
                                if (currentControl is TriControl)
3306
                                {
3307
                                    var content = currentControl as TriControl;
3308
                                    if (content.MidPoint == new Point(0, 0))
3309 787a4489 KangIngu
                                    {
3310 c7fde400 taeseongkim
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3311 787a4489 KangIngu
                                    }
3312
                                    else
3313
                                    {
3314 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3315 f67f164e humkyung
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3316 e66f22eb KangIngu
                                        {
3317
                                            return;
3318
                                        }
3319
3320 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3321 787a4489 KangIngu
3322
                                        currentControl = null;
3323
                                    }
3324 f67f164e humkyung
                                }
3325
                                else
3326
                                {
3327
                                    currentControl = new TriControl
3328 787a4489 KangIngu
                                    {
3329 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3330 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
3331
                                    };
3332 787a4489 KangIngu
3333 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3334
                                    currentControl.CommentID = Commons.shortGuid();
3335
                                    currentControl.IsNew = true;
3336
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3337
                                }
3338 787a4489 KangIngu
                            }
3339
                        }
3340
                        break;
3341 233ef333 taeseongkim
3342 787a4489 KangIngu
                    case ControlType.CancelLine:
3343 f67f164e humkyung
                    case ControlType.SingleLine:
3344
                    case ControlType.ArrowLine:
3345
                    case ControlType.TwinLine:
3346
                    case ControlType.DimLine:
3347 787a4489 KangIngu
                        {
3348 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3349 787a4489 KangIngu
                            {
3350 f67f164e humkyung
                                if (currentControl is LineControl)
3351
                                {
3352
                                    //20180906 LJY TEST IsRotationDrawingEnable
3353
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3354 787a4489 KangIngu
                                    {
3355 f67f164e humkyung
                                        return;
3356 787a4489 KangIngu
                                    }
3357 f67f164e humkyung
3358
                                    CreateCommand.Instance.Execute(currentControl);
3359
                                    currentControl = null;
3360 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3361 f67f164e humkyung
                                }
3362
                                else
3363
                                {
3364
                                    currentControl = new LineControl
3365 787a4489 KangIngu
                                    {
3366 f67f164e humkyung
                                        ControlType = this.controlType,
3367 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3368 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3369
                                    };
3370 787a4489 KangIngu
3371 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3372
                                    currentControl.CommentID = Commons.shortGuid();
3373
                                    currentControl.IsNew = true;
3374
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3375 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3376 f67f164e humkyung
                                }
3377 787a4489 KangIngu
                            }
3378
                        }
3379
                        break;
3380 233ef333 taeseongkim
3381 f67f164e humkyung
                    case ControlType.PolygonControl:
3382 787a4489 KangIngu
                        {
3383 f67f164e humkyung
                            if (currentControl is PolygonControl)
3384 787a4489 KangIngu
                            {
3385 f67f164e humkyung
                                var control = currentControl as PolygonControl;
3386 e66f22eb KangIngu
3387 f67f164e humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3388
                                {
3389
                                    control.IsCompleted = true;
3390
                                }
3391 787a4489 KangIngu
3392 f67f164e humkyung
                                if (!control.IsCompleted)
3393
                                {
3394
                                    control.PointSet.Add(control.EndPoint);
3395
                                }
3396
                                else
3397
                                {
3398
                                    //20180906 LJY TEST IsRotationDrawingEnable
3399
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3400 787a4489 KangIngu
                                    {
3401 f67f164e humkyung
                                        return;
3402 787a4489 KangIngu
                                    }
3403 e66f22eb KangIngu
3404 f67f164e humkyung
                                    var firstPoint = control.PointSet.First();
3405
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3406
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3407
                                    control.PointSet.Add(firstPoint);
3408 787a4489 KangIngu
3409 f67f164e humkyung
                                    control.ApplyOverViewData();
3410
3411
                                    CreateCommand.Instance.Execute(currentControl);
3412 0d00f9c8 humkyung
                                    control.UpdateControl();
3413 f67f164e humkyung
                                    currentControl = null;
3414
                                }
3415 787a4489 KangIngu
                            }
3416 f67f164e humkyung
                            else
3417 787a4489 KangIngu
                            {
3418 f67f164e humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3419
                                {
3420
                                    currentControl = new PolygonControl
3421 787a4489 KangIngu
                                    {
3422 f67f164e humkyung
                                        PointSet = new List<Point>(),
3423
                                    };
3424 787a4489 KangIngu
3425 f67f164e humkyung
                                    var polygonControl = (currentControl as PolygonControl);
3426
                                    currentControl.CommentID = Commons.shortGuid();
3427
                                    currentControl.IsNew = true;
3428
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3429 c7fde400 taeseongkim
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3430
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3431
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3432
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3433 f67f164e humkyung
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3434
                                    polygonControl.ApplyTemplate();
3435
                                    polygonControl.Visibility = Visibility.Visible;
3436
                                }
3437 787a4489 KangIngu
                            }
3438
                        }
3439
                        break;
3440 233ef333 taeseongkim
3441 787a4489 KangIngu
                    case ControlType.ChainLine:
3442
                        {
3443
                            if (currentControl is PolygonControl)
3444
                            {
3445
                                var control = currentControl as PolygonControl;
3446
3447 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3448 787a4489 KangIngu
                                {
3449 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3450
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3451 e66f22eb KangIngu
                                    {
3452
                                        return;
3453
                                    }
3454
3455 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3456 787a4489 KangIngu
3457
                                    currentControl = null;
3458 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3459 787a4489 KangIngu
                                    return;
3460
                                }
3461
3462
                                if (!control.IsCompleted)
3463
                                {
3464
                                    control.PointSet.Add(control.EndPoint);
3465 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3466 787a4489 KangIngu
                                }
3467
                            }
3468
                            else
3469
                            {
3470 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3471 787a4489 KangIngu
                                {
3472 2eac4f76 KangIngu
                                    MainAngle.Visibility = Visibility.Visible;
3473 787a4489 KangIngu
                                    currentControl = new PolygonControl
3474
                                    {
3475
                                        PointSet = new List<Point>(),
3476
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3477
                                        ControlType = ControlType.ChainLine,
3478
                                        DashSize = ViewerDataModel.Instance.DashSize,
3479
                                        LineSize = ViewerDataModel.Instance.LineSize,
3480
                                        //PointC = new StylusPointSet()
3481
                                    };
3482
3483 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3484
                                    //{
3485 233ef333 taeseongkim
                                    var polygonControl = (currentControl as PolygonControl);
3486
                                    currentControl.CommentID = Commons.shortGuid();
3487
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3488
                                    currentControl.IsNew = true;
3489
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3490
                                    //currentControl.OnApplyTemplate();
3491
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3492
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3493
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3494
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3495 e66f22eb KangIngu
                                    //}
3496 787a4489 KangIngu
                                }
3497
                            }
3498
                        }
3499
                        break;
3500 233ef333 taeseongkim
3501 787a4489 KangIngu
                    case ControlType.ArcLine:
3502
                        {
3503 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3504 787a4489 KangIngu
                            {
3505 f67f164e humkyung
                                if (currentControl is ArcControl)
3506
                                {
3507
                                    //20180906 LJY TEST IsRotationDrawingEnable
3508
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3509 787a4489 KangIngu
                                    {
3510 f67f164e humkyung
                                        return;
3511
                                    }
3512 e66f22eb KangIngu
3513 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3514 787a4489 KangIngu
3515 f67f164e humkyung
                                    currentControl = null;
3516 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3517 f67f164e humkyung
                                }
3518
                                else
3519
                                {
3520
                                    currentControl = new ArcControl
3521 787a4489 KangIngu
                                    {
3522 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3523 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3524
                                    };
3525
                                    currentControl.CommentID = Commons.shortGuid();
3526
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3527
                                    currentControl.IsNew = true;
3528
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3530 f67f164e humkyung
                                }
3531 787a4489 KangIngu
                            }
3532 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
3533 787a4489 KangIngu
                            {
3534
                                if (currentControl != null)
3535
                                {
3536
                                    (currentControl as ArcControl).setClock();
3537 05f4d127 KangIngu
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3538 787a4489 KangIngu
                                }
3539
                            }
3540
                        }
3541
                        break;
3542 233ef333 taeseongkim
3543 787a4489 KangIngu
                    case ControlType.ArcArrow:
3544
                        {
3545 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3546 787a4489 KangIngu
                            {
3547 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3548
                                //{
3549 40b3ce25 ljiyeon
                                if (currentControl is ArrowArcControl)
3550
                                {
3551
                                    //20180906 LJY TEST IsRotationDrawingEnable
3552
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3553 787a4489 KangIngu
                                    {
3554 40b3ce25 ljiyeon
                                        return;
3555
                                    }
3556 e66f22eb KangIngu
3557 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3558 787a4489 KangIngu
3559 40b3ce25 ljiyeon
                                    currentControl = null;
3560 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3561 40b3ce25 ljiyeon
                                }
3562
                                else
3563
                                {
3564
                                    currentControl = new ArrowArcControl
3565 787a4489 KangIngu
                                    {
3566 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3567 40b3ce25 ljiyeon
                                        Background = new SolidColorBrush(Colors.Black)
3568
                                    };
3569 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3570 40b3ce25 ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3571
                                    currentControl.IsNew = true;
3572
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3573 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3574 40b3ce25 ljiyeon
                                }
3575 e66f22eb KangIngu
                                //}
3576 787a4489 KangIngu
                            }
3577 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
3578 787a4489 KangIngu
                            {
3579 40b3ce25 ljiyeon
                                if (currentControl != null)
3580
                                {
3581
                                    (currentControl as ArrowArcControl).setClock();
3582 24c5e56c taeseongkim
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3583 40b3ce25 ljiyeon
                                    //(currentControl as ArcControl).ApplyTemplate();
3584
                                }
3585 787a4489 KangIngu
                            }
3586
                        }
3587
                        break;
3588 233ef333 taeseongkim
3589 787a4489 KangIngu
                    case ControlType.ArrowMultiLine:
3590
                        {
3591 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3592 787a4489 KangIngu
                            {
3593 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3594
                                //{
3595 233ef333 taeseongkim
                                if (currentControl is ArrowControl_Multi)
3596
                                {
3597
                                    var content = currentControl as ArrowControl_Multi;
3598
                                    if (content.MiddlePoint == new Point(0, 0))
3599 787a4489 KangIngu
                                    {
3600 233ef333 taeseongkim
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3601 787a4489 KangIngu
                                        {
3602 233ef333 taeseongkim
                                            content.MiddlePoint = content.EndPoint;
3603 787a4489 KangIngu
                                        }
3604
                                        else
3605
                                        {
3606 233ef333 taeseongkim
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3607 787a4489 KangIngu
                                        }
3608
                                    }
3609
                                    else
3610
                                    {
3611 233ef333 taeseongkim
                                        //20180906 LJY TEST IsRotationDrawingEnable
3612
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3613 787a4489 KangIngu
                                        {
3614 233ef333 taeseongkim
                                            return;
3615
                                        }
3616
3617
                                        CreateCommand.Instance.Execute(currentControl);
3618
3619
                                        currentControl = null;
3620
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3621 787a4489 KangIngu
                                    }
3622 233ef333 taeseongkim
                                }
3623
                                else
3624
                                {
3625
                                    currentControl = new ArrowControl_Multi
3626
                                    {
3627
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3628
                                        Background = new SolidColorBrush(Colors.Black)
3629
                                    };
3630
                                    currentControl.CommentID = Commons.shortGuid();
3631
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3632
                                    currentControl.IsNew = true;
3633
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3634
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3635
                                }
3636 e66f22eb KangIngu
                                //}
3637 787a4489 KangIngu
                            }
3638
                        }
3639
                        break;
3640 233ef333 taeseongkim
3641 787a4489 KangIngu
                    case ControlType.PolygonCloud:
3642
                        {
3643
                            if (currentControl is CloudControl)
3644
                            {
3645
                                var control = currentControl as CloudControl;
3646 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3647 787a4489 KangIngu
                                {
3648
                                    control.IsCompleted = true;
3649
                                }
3650
3651
                                if (!control.IsCompleted)
3652
                                {
3653
                                    control.PointSet.Add(control.EndPoint);
3654
                                }
3655
                                else
3656
                                {
3657 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3658
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3659 e66f22eb KangIngu
                                    {
3660
                                        return;
3661
                                    }
3662
3663 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3664 787a4489 KangIngu
3665
                                    control.isTransOn = true;
3666
                                    var firstPoint = control.PointSet.First();
3667
3668
                                    control.PointSet.Add(firstPoint);
3669
                                    control.DrawingCloud();
3670
                                    control.ApplyOverViewData();
3671
3672
                                    currentControl = null;
3673
                                }
3674
                            }
3675
                            else
3676
                            {
3677 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3678 787a4489 KangIngu
                                {
3679
                                    currentControl = new CloudControl
3680
                                    {
3681
                                        PointSet = new List<Point>(),
3682
                                        PointC = new StylusPointSet()
3683
                                    };
3684
3685 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3686
                                    //{
3687 233ef333 taeseongkim
                                    var polygonControl = (currentControl as CloudControl);
3688
                                    currentControl.CommentID = Commons.shortGuid();
3689
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3690
                                    currentControl.IsNew = true;
3691
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3692
3693
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3694
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3695 787a4489 KangIngu
3696 e66f22eb KangIngu
                                    //}
3697 787a4489 KangIngu
                                }
3698
                            }
3699
                        }
3700
                        break;
3701 233ef333 taeseongkim
3702 787a4489 KangIngu
                    case ControlType.ImgControl:
3703
                        {
3704 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3705 787a4489 KangIngu
                            {
3706 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3707
                                //{
3708 233ef333 taeseongkim
                                if (currentControl is ImgControl)
3709
                                {
3710
                                    //20180906 LJY TEST IsRotationDrawingEnable
3711
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3712 787a4489 KangIngu
                                    {
3713 233ef333 taeseongkim
                                        return;
3714 787a4489 KangIngu
                                    }
3715 233ef333 taeseongkim
3716
                                    CreateCommand.Instance.Execute(currentControl);
3717
                                    controlType = ControlType.ImgControl;
3718
                                    currentControl = null;
3719
                                }
3720
                                else
3721
                                {
3722
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3723
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3724 787a4489 KangIngu
                                    {
3725 b42dd24d taeseongkim
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3726
                                        UriBuilder uri = new UriBuilder(filename);
3727
                                        uri.Host = downloadUri.Host;
3728
                                        uri.Port = downloadUri.Port;
3729
3730 233ef333 taeseongkim
                                        Image img = new Image();
3731
                                        if (filename.Contains(".svg"))
3732 787a4489 KangIngu
                                        {
3733 233ef333 taeseongkim
                                            byte[] imageData = null;
3734
                                            DrawingImage image = null;
3735
                                            using (System.Net.WebClient web = new System.Net.WebClient())
3736 53880c83 ljiyeon
                                            {
3737 b42dd24d taeseongkim
                                                imageData = web.DownloadData(uri.Uri);
3738 233ef333 taeseongkim
                                                System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3739
                                                image = SvgReader.Load(stream);
3740 53880c83 ljiyeon
                                            }
3741 233ef333 taeseongkim
                                            img.Source = image;
3742
                                        }
3743
                                        else
3744
                                        {
3745 b42dd24d taeseongkim
                                            img.Source = new BitmapImage(uri.Uri);
3746 233ef333 taeseongkim
                                        }
3747 787a4489 KangIngu
3748 233ef333 taeseongkim
                                        currentControl = new ImgControl
3749
                                        {
3750
                                            Background = new SolidColorBrush(Colors.Black),
3751
                                            PointSet = new List<Point>(),
3752 b42dd24d taeseongkim
                                            FilePath = uri.Uri.ToString(),
3753 233ef333 taeseongkim
                                            ImageData = img.Source,
3754
                                            StartPoint = CanvasDrawingMouseDownPoint,
3755
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3756
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3757
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3758
                                            ControlType = ControlType.ImgControl
3759
                                        };
3760
3761
                                        currentControl.CommentID = Commons.shortGuid();
3762
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3763
                                        currentControl.IsNew = true;
3764
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3765
3766
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3767 fa48eb85 taeseongkim
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3768
                                    }
3769 233ef333 taeseongkim
                                }
3770 e66f22eb KangIngu
                                //}
3771 787a4489 KangIngu
                            }
3772
                        }
3773
                        break;
3774 233ef333 taeseongkim
3775 787a4489 KangIngu
                    case ControlType.Date:
3776
                        {
3777 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3778 787a4489 KangIngu
                            {
3779 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3780
                                //{
3781 6b6e937c taeseongkim
                                if (currentControl is DateControl)
3782
                                {
3783
                                    //20180906 LJY TEST IsRotationDrawingEnable
3784
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3785 787a4489 KangIngu
                                    {
3786 6b6e937c taeseongkim
                                        return;
3787
                                    }
3788 e66f22eb KangIngu
3789 6b6e937c taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
3790
                                    currentControl = null;
3791 787a4489 KangIngu
3792 6b6e937c taeseongkim
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3793 b74a9c91 taeseongkim
                                    { 
3794 6b6e937c taeseongkim
                                        controlType = ControlType.None;
3795
                                        IsSwingMode = false;
3796
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3797
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3798
                                        mouseHandlingMode = MouseHandlingMode.None;
3799
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3800
                                        txtBatch.Visibility = Visibility.Collapsed;
3801 787a4489 KangIngu
                                    }
3802 6b6e937c taeseongkim
                                }
3803
                                else
3804
                                {
3805
                                    currentControl = new DateControl
3806 787a4489 KangIngu
                                    {
3807 6b6e937c taeseongkim
                                        StartPoint = CanvasDrawingMouseDownPoint,
3808
                                        Background = new SolidColorBrush(Colors.Black)
3809
                                    };
3810
                                    currentControl.CommentID = Commons.shortGuid();
3811
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3812
                                    currentControl.IsNew = true;
3813
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3814 ca40e004 ljiyeon
3815 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3816 6b6e937c taeseongkim
                                    if (currentControl is ImgControl)
3817
                                    {
3818 fa48eb85 taeseongkim
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3819 6b6e937c taeseongkim
                                    }
3820 ca40e004 ljiyeon
                                }
3821 e66f22eb KangIngu
                                //}
3822 787a4489 KangIngu
                            }
3823
                        }
3824
                        break;
3825 233ef333 taeseongkim
3826 787a4489 KangIngu
                    case ControlType.TextControl:
3827
                        {
3828 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3829 787a4489 KangIngu
                            {
3830
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3831
                                {
3832
                                    currentControl = new TextControl
3833
                                    {
3834
                                        ControlType = controlType
3835
                                    };
3836 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3837 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3838 8742caa5 humkyung
                                    currentControl.IsNew = true;
3839
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3840
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3841 1066bae3 ljiyeon
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3842
3843 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3844
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3845 233ef333 taeseongkim
3846 8742caa5 humkyung
                                    (currentControl as TextControl).ControlType_No = 0;
3847 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3848 8742caa5 humkyung
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3849 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3850
                                    (currentControl as TextControl).Base_TextBox.Focus();
3851 4fcb686a taeseongkim
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3852 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3853 787a4489 KangIngu
                                }
3854
                            }
3855
                        }
3856
                        break;
3857 233ef333 taeseongkim
3858 787a4489 KangIngu
                    case ControlType.TextBorder:
3859
                        {
3860 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3861 787a4489 KangIngu
                            {
3862
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3863
                                {
3864
                                    currentControl = new TextControl
3865
                                    {
3866
                                        ControlType = controlType
3867
                                    };
3868
3869 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3870 787a4489 KangIngu
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3871 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3872 787a4489 KangIngu
                                    currentControl.IsNew = true;
3873
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3874
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3875 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3876
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3877 233ef333 taeseongkim
3878 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 1;
3879 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle = Ang;
3880 787a4489 KangIngu
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3881 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3882
                                    (currentControl as TextControl).Base_TextBox.Focus();
3883 4fcb686a taeseongkim
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3884 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3885 787a4489 KangIngu
                                }
3886
                            }
3887
                        }
3888
                        break;
3889 233ef333 taeseongkim
3890 787a4489 KangIngu
                    case ControlType.TextCloud:
3891
                        {
3892 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3893 787a4489 KangIngu
                            {
3894
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3895
                                {
3896
                                    currentControl = new TextControl
3897
                                    {
3898
                                        ControlType = controlType
3899
                                    };
3900 610a4b86 KangIngu
3901
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3902 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3903 787a4489 KangIngu
                                    currentControl.IsNew = true;
3904
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3905
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3906
3907
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3908 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3909
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3910 787a4489 KangIngu
3911 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle = Ang;
3912 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 2;
3913
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3914 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3915 4fcb686a taeseongkim
3916
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3917
3918 6b5d33c6 djkim
                                    (currentControl as TextControl).Base_TextBox.Focus();
3919 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3920 664ea2e1 taeseongkim
                                    
3921 49b217ad humkyung
                                    //currentControl = null;
3922 787a4489 KangIngu
                                }
3923
                            }
3924
                        }
3925
                        break;
3926 233ef333 taeseongkim
3927 787a4489 KangIngu
                    case ControlType.ArrowTextControl:
3928 233ef333 taeseongkim
                        {
3929 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3930 787a4489 KangIngu
                            {
3931
                                if (currentControl is ArrowTextControl)
3932
                                {
3933 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3934
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3935 e66f22eb KangIngu
                                    {
3936
                                        return;
3937 f513c215 humkyung
                                    }
3938 e66f22eb KangIngu
3939 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3940 1305c420 taeseongkim
3941 b74a9c91 taeseongkim
                                    try
3942
                                    {
3943 1305c420 taeseongkim
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3944
                                        {
3945
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3946
                                        }
3947 b74a9c91 taeseongkim
                                    }
3948
                                    catch (Exception ex)
3949
                                    {
3950
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3951
                                    }
3952 787a4489 KangIngu
3953
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3954
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3955 49b217ad humkyung
                                    (currentControl as ArrowTextControl).IsNew = false;
3956 787a4489 KangIngu
                                    currentControl = null;
3957
                                }
3958
                                else
3959
                                {
3960 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3961
                                    //{
3962 907a99b3 taeseongkim
                                    currentControl = new ArrowTextControl()
3963
                                    {
3964
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3965
                                    };
3966
3967 233ef333 taeseongkim
                                    currentControl.CommentID = Commons.shortGuid();
3968
                                    currentControl.IsNew = true;
3969
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3970 1305c420 taeseongkim
3971
                                    try
3972
                                    {
3973
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3974
                                    }
3975
                                    catch (Exception ex)
3976
                                    {
3977
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3978
                                    }
3979 787a4489 KangIngu
3980 233ef333 taeseongkim
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3981
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3982
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3983
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3984
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3985 787a4489 KangIngu
3986 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3987 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3988 787a4489 KangIngu
3989 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3990 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3991 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3992 233ef333 taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3993 ca40e004 ljiyeon
3994 e66f22eb KangIngu
                                    //}
3995 787a4489 KangIngu
                                }
3996
                            }
3997
                        }
3998
                        break;
3999 233ef333 taeseongkim
4000 787a4489 KangIngu
                    case ControlType.ArrowTransTextControl:
4001
                        {
4002 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4003 787a4489 KangIngu
                            {
4004
                                if (currentControl is ArrowTextControl)
4005
                                {
4006 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4007
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4008 e66f22eb KangIngu
                                    {
4009
                                        return;
4010 f513c215 humkyung
                                    }
4011 e66f22eb KangIngu
4012 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4013 55d4f382 송근호
4014 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4015 233ef333 taeseongkim
4016 49b217ad humkyung
                                    currentControl.IsNew = false;
4017 787a4489 KangIngu
                                    currentControl = null;
4018 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4019 787a4489 KangIngu
                                }
4020
                                else
4021
                                {
4022 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4023
                                    //{
4024 120b8b00 송근호
                                    currentControl = new ArrowTextControl()
4025
                                    {
4026 907a99b3 taeseongkim
                                        ControlType = ControlType.ArrowTransTextControl,
4027
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4028 120b8b00 송근호
                                    };
4029
                                    currentControl.CommentID = Commons.shortGuid();
4030
                                    currentControl.IsNew = true;
4031
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4032
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4033
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4034 c7fde400 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4035 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4036 120b8b00 송근호
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4037
                                    (currentControl as ArrowTextControl).isFixed = true;
4038
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4039 787a4489 KangIngu
4040 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4041 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4042 ca40e004 ljiyeon
4043 120b8b00 송근호
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4044
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4045
                                    (currentControl as ArrowTextControl).isTrans = true;
4046 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4047 787a4489 KangIngu
                                }
4048
                            }
4049
                        }
4050
                        break;
4051 233ef333 taeseongkim
4052 787a4489 KangIngu
                    case ControlType.ArrowTextBorderControl:
4053 233ef333 taeseongkim
                        {
4054 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4055 787a4489 KangIngu
                            {
4056
                                if (currentControl is ArrowTextControl)
4057
                                {
4058 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4059
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4060 e66f22eb KangIngu
                                    {
4061
                                        return;
4062
                                    }
4063
4064 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4065 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4066 49b217ad humkyung
                                    currentControl.IsNew = false;
4067 787a4489 KangIngu
                                    currentControl = null;
4068 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4069 787a4489 KangIngu
                                }
4070
                                else
4071
                                {
4072 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4073
                                    //{
4074 233ef333 taeseongkim
                                    currentControl = new ArrowTextControl()
4075
                                    {
4076 907a99b3 taeseongkim
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4077
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4078 233ef333 taeseongkim
                                    };
4079
                                    currentControl.CommentID = Commons.shortGuid();
4080
                                    currentControl.IsNew = true;
4081
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4082
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4083 787a4489 KangIngu
4084 233ef333 taeseongkim
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4085
4086
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4087 787a4489 KangIngu
4088 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4089
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4090
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4091 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4092 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4093
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4094
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4095
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4096
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4097 e66f22eb KangIngu
                                    //}
4098 787a4489 KangIngu
                                }
4099
                            }
4100
                        }
4101
                        break;
4102 233ef333 taeseongkim
4103 787a4489 KangIngu
                    case ControlType.ArrowTransTextBorderControl:
4104
                        {
4105 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4106 787a4489 KangIngu
                            {
4107
                                if (currentControl is ArrowTextControl)
4108
                                {
4109 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4110
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4111 e66f22eb KangIngu
                                    {
4112
                                        return;
4113
                                    }
4114 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4115 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4116 49b217ad humkyung
                                    currentControl.IsNew = false;
4117 787a4489 KangIngu
                                    currentControl = null;
4118 55d4f382 송근호
4119 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4120 787a4489 KangIngu
                                }
4121
                                else
4122
                                {
4123 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4124
                                    //{
4125 ca40e004 ljiyeon
                                    currentControl = new ArrowTextControl()
4126 120b8b00 송근호
                                    {
4127
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4128 4f017ed3 taeseongkim
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4129
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4130 120b8b00 송근호
                                    };
4131 4f017ed3 taeseongkim
                                    
4132 233ef333 taeseongkim
                                    currentControl.CommentID = Commons.shortGuid();
4133
                                    currentControl.IsNew = true;
4134
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4135
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4136 787a4489 KangIngu
4137 233ef333 taeseongkim
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4138
4139
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4140
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4141
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4142
                                    (currentControl as ArrowTextControl).isFixed = true;
4143
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4144
4145
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4146
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4147
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4148 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4149 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4150
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4151 787a4489 KangIngu
4152 ca40e004 ljiyeon
                                    //20180911 LJY
4153 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).isTrans = true;
4154 ca40e004 ljiyeon
4155 e66f22eb KangIngu
                                    //}
4156 787a4489 KangIngu
                                }
4157
                            }
4158
                        }
4159
                        break;
4160 233ef333 taeseongkim
4161 787a4489 KangIngu
                    case ControlType.ArrowTextCloudControl:
4162
                        {
4163 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4164 787a4489 KangIngu
                            {
4165
                                if (currentControl is ArrowTextControl)
4166
                                {
4167 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4168
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4169 e66f22eb KangIngu
                                    {
4170
                                        return;
4171
                                    }
4172 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4173 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4174 49b217ad humkyung
                                    currentControl.IsNew = false;
4175 787a4489 KangIngu
                                    currentControl = null;
4176 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4177 787a4489 KangIngu
                                }
4178
                                else
4179
                                {
4180 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4181
                                    //{
4182 233ef333 taeseongkim
                                    currentControl = new ArrowTextControl()
4183
                                    {
4184 907a99b3 taeseongkim
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4185 4fcb686a taeseongkim
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4186
                                        ControlType = ControlType.ArrowTextCloudControl
4187 233ef333 taeseongkim
                                    };
4188
                                    currentControl.CommentID = Commons.shortGuid();
4189
                                    currentControl.IsNew = true;
4190
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4191
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4192 787a4489 KangIngu
4193 233ef333 taeseongkim
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4194
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4195
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4196
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4197
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4198 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4199 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4200
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4201
4202
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4203
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4204
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4205 e66f22eb KangIngu
                                    //}
4206 787a4489 KangIngu
                                }
4207
                            }
4208
                        }
4209
                        break;
4210 233ef333 taeseongkim
4211 787a4489 KangIngu
                    case ControlType.ArrowTransTextCloudControl:
4212
                        {
4213 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4214 787a4489 KangIngu
                            {
4215
                                if (currentControl is ArrowTextControl)
4216
                                {
4217 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4218
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4219 e66f22eb KangIngu
                                    {
4220
                                        return;
4221
                                    }
4222 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4223 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4224 49b217ad humkyung
                                    currentControl.IsNew = false;
4225 787a4489 KangIngu
                                    currentControl = null;
4226 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4227 787a4489 KangIngu
                                }
4228
                                else
4229
                                {
4230 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4231
                                    //{
4232 233ef333 taeseongkim
                                    currentControl = new ArrowTextControl()
4233
                                    {
4234
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4235 907a99b3 taeseongkim
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4236
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4237 233ef333 taeseongkim
                                    };
4238
                                    currentControl.CommentID = Commons.shortGuid();
4239
                                    currentControl.IsNew = true;
4240
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4241
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4242
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4243 120b8b00 송근호
4244 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4245
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4246
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4247
                                    (currentControl as ArrowTextControl).isFixed = true;
4248
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4249
4250
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4251
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4252 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4253 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4254
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4255
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4256 787a4489 KangIngu
4257 ca40e004 ljiyeon
                                    //20180911 LJY
4258 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).isTrans = true;
4259 e66f22eb KangIngu
                                    //}
4260 787a4489 KangIngu
                                }
4261
                            }
4262
                        }
4263
                        break;
4264
                    //강인구 추가
4265
                    case ControlType.Sign:
4266
                        {
4267 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4268 787a4489 KangIngu
                            {
4269 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4270
                                //{
4271 d7e20d2d taeseongkim
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4272 992a98b4 KangIngu
4273 d7e20d2d taeseongkim
                                if (_sign == null)
4274 233ef333 taeseongkim
                                {
4275
                                    txtBatch.Visibility = Visibility.Collapsed;
4276
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4277
                                    controlType = ControlType.None;
4278
4279
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4280
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4281
                                    return;
4282
                                }
4283 74abcf6f taeseongkim
                                else
4284
                                {
4285
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4286
                                    {
4287
                                        Application.Current.Resources.Add("UserSign", _sign);
4288
                                    }
4289
                                    else
4290
                                    {
4291
                                        Application.Current.Resources["UserSign"] = _sign;
4292
                                    }
4293
                                }
4294 992a98b4 KangIngu
4295 233ef333 taeseongkim
                                if (currentControl is SignControl)
4296
                                {
4297
                                    //20180906 LJY TEST IsRotationDrawingEnable
4298
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4299
                                    {
4300 992a98b4 KangIngu
                                        return;
4301
                                    }
4302
4303 233ef333 taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
4304
                                    currentControl = null;
4305
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4306 787a4489 KangIngu
                                    {
4307 233ef333 taeseongkim
                                        txtBatch.Text = "Place Date";
4308
                                        controlType = ControlType.Date;
4309 787a4489 KangIngu
                                    }
4310 233ef333 taeseongkim
                                }
4311
                                else
4312
                                {
4313
                                    currentControl = new SignControl
4314 787a4489 KangIngu
                                    {
4315 233ef333 taeseongkim
                                        Background = new SolidColorBrush(Colors.Black),
4316
                                        UserNumber = App.ViewInfo.UserID,
4317
                                        ProjectNO = App.ViewInfo.ProjectNO,
4318
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4319
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4320
                                        ControlType = ControlType.Sign
4321
                                    };
4322 787a4489 KangIngu
4323 233ef333 taeseongkim
                                    currentControl.CommentID = Commons.shortGuid();
4324
                                    currentControl.IsNew = true;
4325
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4326
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4327 ca40e004 ljiyeon
4328 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4329
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4330 ca40e004 ljiyeon
                                }
4331 e66f22eb KangIngu
                                //}
4332 787a4489 KangIngu
                            }
4333
                        }
4334
                        break;
4335 233ef333 taeseongkim
4336 787a4489 KangIngu
                    case ControlType.Mark:
4337
                        {
4338 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4339 787a4489 KangIngu
                            {
4340 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4341
                                //{
4342 233ef333 taeseongkim
                                if (currentControl is RectangleControl)
4343
                                {
4344
                                    //20180906 LJY TEST IsRotationDrawingEnable
4345
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4346 787a4489 KangIngu
                                    {
4347 233ef333 taeseongkim
                                        return;
4348
                                    }
4349 e66f22eb KangIngu
4350 233ef333 taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
4351
                                    (currentControl as RectangleControl).ApplyOverViewData();
4352
                                    currentControl = null;
4353 787a4489 KangIngu
4354 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4355 233ef333 taeseongkim
4356
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4357
                                    {
4358
                                        txtBatch.Text = "Place Signature";
4359
                                        controlType = ControlType.Sign;
4360 787a4489 KangIngu
                                    }
4361 233ef333 taeseongkim
                                }
4362
                                else
4363
                                {
4364
                                    currentControl = new RectangleControl
4365 787a4489 KangIngu
                                    {
4366 233ef333 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4367
                                        Background = new SolidColorBrush(Colors.Black),
4368
                                        ControlType = ControlType.Mark,
4369
                                        Paint = PaintSet.Fill
4370
                                    };
4371 787a4489 KangIngu
4372 233ef333 taeseongkim
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4373
                                    currentControl.CommentID = Commons.shortGuid();
4374
                                    currentControl.IsNew = true;
4375
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4376
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4377
                                }
4378 e66f22eb KangIngu
                                //}
4379 787a4489 KangIngu
                            }
4380
                        }
4381
                        break;
4382 233ef333 taeseongkim
4383 787a4489 KangIngu
                    case ControlType.Symbol:
4384
                        {
4385 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4386 787a4489 KangIngu
                            {
4387 a6272c57 humkyung
                                if (currentControl is SymControl)
4388
                                {
4389
                                    //20180906 LJY TEST IsRotationDrawingEnable
4390
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4391 787a4489 KangIngu
                                    {
4392 a6272c57 humkyung
                                        return;
4393 787a4489 KangIngu
                                    }
4394 a6272c57 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4395
                                    currentControl = null;
4396 233ef333 taeseongkim
4397 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4398 a6272c57 humkyung
                                }
4399
                                else
4400
                                {
4401
                                    currentControl = new SymControl
4402 787a4489 KangIngu
                                    {
4403 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4404 a6272c57 humkyung
                                        Background = new SolidColorBrush(Colors.Black),
4405
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4406
                                        ControlType = ControlType.Symbol
4407
                                    };
4408 787a4489 KangIngu
4409 a6272c57 humkyung
                                    currentControl.IsNew = true;
4410
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4411
                                    currentControl.CommentID = Commons.shortGuid();
4412
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4413 ca40e004 ljiyeon
4414 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4415 fa48eb85 taeseongkim
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4416 ca40e004 ljiyeon
                                }
4417 e66f22eb KangIngu
                                //}
4418 787a4489 KangIngu
                            }
4419
                        }
4420
                        break;
4421 233ef333 taeseongkim
4422 787a4489 KangIngu
                    case ControlType.Stamp:
4423
                        {
4424 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4425 787a4489 KangIngu
                            {
4426 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4427
                                //{
4428 233ef333 taeseongkim
                                if (currentControl is SymControlN)
4429
                                {
4430
                                    //20180906 LJY TEST IsRotationDrawingEnable
4431
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4432 787a4489 KangIngu
                                    {
4433 233ef333 taeseongkim
                                        return;
4434
                                    }
4435 e66f22eb KangIngu
4436 233ef333 taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
4437
                                    currentControl = null;
4438 510cbd2a ljiyeon
4439 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4440 233ef333 taeseongkim
                                }
4441
                                else
4442
                                {
4443
                                    currentControl = new SymControlN
4444 787a4489 KangIngu
                                    {
4445 233ef333 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4446
                                        Background = new SolidColorBrush(Colors.Black),
4447
                                        STAMP = App.SystemInfo.STAMP,
4448 43e1d368 taeseongkim
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4449 233ef333 taeseongkim
                                        ControlType = ControlType.Stamp
4450
                                    };
4451 787a4489 KangIngu
4452 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4453
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4454
                                    currentControl.CommentID = Commons.shortGuid();
4455
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4456
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4457
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4458
                                }
4459 e66f22eb KangIngu
                                //}
4460 787a4489 KangIngu
                            }
4461
                        }
4462
                        break;
4463 233ef333 taeseongkim
4464 787a4489 KangIngu
                    case ControlType.PenControl:
4465
                        {
4466
                            if (inkBoard.Tag.ToString() == "Ink")
4467
                            {
4468
                                inkBoard.IsEnabled = true;
4469 c7fde400 taeseongkim
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4470 787a4489 KangIngu
                            }
4471
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4472
                            {
4473 c7fde400 taeseongkim
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4474 787a4489 KangIngu
                            }
4475
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4476
                            {
4477 c7fde400 taeseongkim
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4478 787a4489 KangIngu
                            }
4479
                            IsDrawing = true;
4480
                            return;
4481
                        }
4482
                    default:
4483
                        if (currentControl != null)
4484
                        {
4485
                            currentControl.CommentID = null;
4486
                            currentControl.IsNew = false;
4487
                        }
4488
                        break;
4489
                }
4490 fa48eb85 taeseongkim
4491 4fcb686a taeseongkim
                try
4492
                {
4493
                    if (currentControl is ITextControl)
4494
                    {
4495
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4496
4497
                        if(textBox.Count() > 0)
4498
                        {
4499
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4500
                            specialcharRemove.Attach(textBox.First());
4501
                        }
4502
                        else
4503
                        {
4504
4505
                        }
4506
4507
                    }
4508
                }
4509
                catch (Exception ex)
4510
                {
4511
                    System.Diagnostics.Debug.WriteLine(ex);
4512
4513
                }
4514
4515 1b2cf911 taeseongkim
                if (currentControl is ArrowTextControl)
4516
                {
4517
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4518
                    {
4519
                        var control = snd as ArrowTextControl;
4520
4521
                        if (string.IsNullOrEmpty(control.ArrowText))
4522
                        {
4523
                            DeleteCommand.Instance.Execute(new [] { control });
4524
                        }
4525
                    };
4526
4527
                }
4528 b74a9c91 taeseongkim
4529
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4530
                {
4531
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4532
                    {
4533
                        MacroHelper.MacroAction();
4534
                    }
4535
                    //if (currentControl.ControlType)
4536
                    //txtBatch.Text = "Draw a TextBox";
4537
                    //controlType = ControlType.ArrowTextBorderControl;
4538
                }
4539
4540 4f017ed3 taeseongkim
                //if (currentControl != null)
4541
                //{
4542
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4543
                //}
4544 787a4489 KangIngu
            }
4545 e6a9ddaf humkyung
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4546 787a4489 KangIngu
            {
4547 b74a9c91 taeseongkim
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4548
             
4549
4550 787a4489 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4551
                {
4552
                    bool mouseOff = false;
4553
                    foreach (var item in SelectLayer.Children)
4554
                    {
4555
                        if (item is AdornerFinal)
4556
                        {
4557 4913851c humkyung
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4558 787a4489 KangIngu
                            if (over != null)
4559
                            {
4560
                                mouseOff = true;
4561
                            }
4562
                        }
4563
                    }
4564
4565
                    if (!mouseOff)
4566
                    {
4567 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
4568 787a4489 KangIngu
                    }
4569
                }
4570
                zoomAndPanControl.CaptureMouse();
4571
                e.Handled = true;
4572
            }
4573
        }
4574 e54660e8 KangIngu
4575 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4576
        {
4577 e6a9ddaf humkyung
            ///mouseButtonDown = e.ChangedButton;
4578 a1716fa5 KangIngu
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4579
        }
4580
4581 787a4489 KangIngu
        private void RemoveLineStroke(Point P)
4582
        {
4583 a342d378 taeseongkim
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4584 787a4489 KangIngu
            if (control != null)
4585
            {
4586 f729ef4e humkyung
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4587 787a4489 KangIngu
            }
4588
        }
4589
4590
        private void RemovePointStroke(Point P)
4591
        {
4592
            foreach (Stroke hits in inkBoard.Strokes)
4593
            {
4594
                foreach (StylusPoint sty in hits.StylusPoints)
4595
                {
4596
                }
4597
                if (hits.HitTest(P))
4598
                {
4599
                    inkBoard.Strokes.Remove(hits);
4600
                    return;
4601
                }
4602
            }
4603
        }
4604
4605
        private void StartNewStroke(Point P)
4606
        {
4607
            strokePoints = new StylusPointCollection();
4608
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4609
            strokePoints.Add(segment1Start);
4610
            stroke = new Stroke(strokePoints);
4611
4612
            stroke.DrawingAttributes.Color = Colors.Red;
4613
            stroke.DrawingAttributes.Width = 4;
4614
            stroke.DrawingAttributes.Height = 4;
4615
4616
            inkBoard.Strokes.Add(stroke);
4617
        }
4618
4619 77cdac33 taeseongkim
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4620 787a4489 KangIngu
        {
4621 b42dd24d taeseongkim
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4622
            //// update mylist and gridview
4623
            //this.UpdateMyMarkupList();
4624
4625
            //bool result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4626
4627
            //if (result)
4628
            //{
4629 6a19b48d taeseongkim
            btnFinalPDF.IsEnabled = false;
4630
            btnConsolidate.IsEnabled = false;
4631
            await  ConsolidationMethod();
4632 b42dd24d taeseongkim
            //}
4633
            //else
4634
            //{
4635
            //    MessageBox.Show("오류");
4636
            //}
4637 787a4489 KangIngu
        }
4638
4639 102476f6 humkyung
        /// <summary>
4640
        /// execute TeamConsolidationCommand
4641
        /// </summary>
4642 77cdac33 taeseongkim
        public void TeamConsolidationMethod2()
4643 04a7385a djkim
        {
4644
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4645
            {
4646
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4647
            }
4648
            else
4649
            {
4650 8129f2a5 ljiyeon
4651 77cdac33 taeseongkim
                ViewerDataModel.Instance.IsConsolidate = true;
4652
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4653
                // update mylist and gridview
4654
        
4655 43e1d368 taeseongkim
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4656 77cdac33 taeseongkim
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4657
                ViewerDataModel.Instance.IsConsolidate = false;
4658
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4659 04a7385a djkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4660
                {
4661
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4662
                    {
4663
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4664
                        return;
4665 233ef333 taeseongkim
                    }
4666 04a7385a djkim
                }
4667 102476f6 humkyung
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4668 04a7385a djkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4669 90e7968d ljiyeon
                {
4670 102476f6 humkyung
                    MarkupInfoList.Add(item);
4671 04a7385a djkim
                }
4672 77cdac33 taeseongkim
4673 102476f6 humkyung
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4674 04a7385a djkim
            }
4675
        }
4676 77cdac33 taeseongkim
        public async void TeamConsolidationMethod()
4677 787a4489 KangIngu
        {
4678 b42dd24d taeseongkim
            bool result = false;
4679
4680 787a4489 KangIngu
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4681
            {
4682
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4683
            }
4684
            else
4685 90e7968d ljiyeon
            {
4686 77cdac33 taeseongkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4687 35a96e24 humkyung
                {
4688 77cdac33 taeseongkim
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4689
                    {
4690
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4691
                    }
4692 35a96e24 humkyung
                }
4693 233ef333 taeseongkim
4694 77cdac33 taeseongkim
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4695
4696
                if (isSave)
4697
                {
4698
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4699
4700
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4701
                     
4702
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4703
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4704
                    {
4705
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4706
                    }
4707
4708
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4709
                    result = true;
4710
                }
4711
            }
4712
        }
4713
4714
        public async Task<bool> ConsolidationMethod()
4715
        {
4716
            bool result = false;
4717
4718
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4719
            {
4720
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4721
            }
4722
            else
4723
            {
4724 1d79913e taeseongkim
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4725 77cdac33 taeseongkim
4726
                if (isSave)
4727
                {
4728
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4729
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4730
4731
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4732
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4733
                    {
4734
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4735
                    }
4736
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4737
4738 1d79913e taeseongkim
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4739 77cdac33 taeseongkim
                }
4740 787a4489 KangIngu
            }
4741 b42dd24d taeseongkim
4742
            return result;
4743 787a4489 KangIngu
        }
4744
4745
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4746
        {
4747
            if (App.ViewInfo != null)
4748
            {
4749
                btnConsolidate = (sender as RadRibbonButton);
4750
                if (!App.ViewInfo.NewCommentPermission)
4751
                {
4752
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4753
                }
4754
            }
4755
        }
4756
4757
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4758
        {
4759 04a7385a djkim
            TeamConsolidationMethod();
4760 787a4489 KangIngu
        }
4761
4762
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4763
        {
4764
            btnTeamConsolidate = sender as RadRibbonButton;
4765
            if (App.ViewInfo != null)
4766
            {
4767
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4768
                {
4769
                    if (btnConsolidate != null)
4770
                    {
4771
                        btnConsolidate.Visibility = Visibility.Collapsed;
4772
                    }
4773
4774
                    if (!App.ViewInfo.NewCommentPermission)
4775
                    {
4776
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4777
                    }
4778
                }
4779
                else
4780
                {
4781
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4782
                }
4783
            }
4784
        }
4785
4786 bae83c92 taeseongkim
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4787 787a4489 KangIngu
        {
4788 b42dd24d taeseongkim
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4789
            // update mylist and gridview
4790
            this.UpdateMyMarkupList();
4791 a1e2ba68 taeseongkim
4792 43e1d368 taeseongkim
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4793 b42dd24d taeseongkim
4794 bae83c92 taeseongkim
            if(!result)
4795
            {
4796 a1e2ba68 taeseongkim
4797 bae83c92 taeseongkim
            }
4798
            else
4799 787a4489 KangIngu
            {
4800 bae83c92 taeseongkim
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4801
4802
                if (item != null)
4803 81e3c9f6 ljiyeon
                {
4804 bae83c92 taeseongkim
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4805
                    {
4806
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4807 a1e2ba68 taeseongkim
4808 bae83c92 taeseongkim
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4809
4810
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4811
                    }
4812
                    else
4813
                    {
4814
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4815
                    }
4816 81e3c9f6 ljiyeon
                }
4817
                else
4818
                {
4819 bae83c92 taeseongkim
                    //Consolidate 가 없는 경우
4820
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4821 81e3c9f6 ljiyeon
                }
4822 233ef333 taeseongkim
            }
4823 bae83c92 taeseongkim
4824 787a4489 KangIngu
        }
4825
4826
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4827
        {
4828
            btnFinalPDF = sender as RadRibbonButton;
4829
            if (App.ViewInfo != null)
4830
            {
4831 b42dd24d taeseongkim
                //btnFinalPDF.IsEnabled = false;
4832
4833 787a4489 KangIngu
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4834
                {
4835
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4836
                    if (btnConsolidate != null)
4837
                    {
4838
                        btnConsolidate.Visibility = Visibility.Collapsed;
4839
                    }
4840
                }
4841
            }
4842
        }
4843
4844 b42dd24d taeseongkim
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4845 80458c15 ljiyeon
        {
4846 b42dd24d taeseongkim
            //UpdateMyMarkupList();
4847 80458c15 ljiyeon
4848
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4849
            {
4850
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4851
            }
4852
            else
4853
            {
4854 b42dd24d taeseongkim
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4855
                //{
4856
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4857
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4858
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4859 80458c15 ljiyeon
4860 b42dd24d taeseongkim
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4861
                //// update mylist and gridview
4862
                //this.UpdateMyMarkupList();
4863
4864
                //var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4865 324fcf3e taeseongkim
4866 1305c420 taeseongkim
                Mouse.SetCursor(Cursors.Wait);
4867 324fcf3e taeseongkim
4868 77cdac33 taeseongkim
                bool result = await ConsolidationMethod();
4869 80458c15 ljiyeon
4870 77cdac33 taeseongkim
                System.Threading.Thread.Sleep(500);
4871 1305c420 taeseongkim
4872
                if (result)
4873 80458c15 ljiyeon
                {
4874 1305c420 taeseongkim
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4875
4876
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4877
                    if (item2 != null)
4878 bae83c92 taeseongkim
                    {
4879 1305c420 taeseongkim
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4880
                        {
4881
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4882 80458c15 ljiyeon
4883 1305c420 taeseongkim
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4884
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4885 bae83c92 taeseongkim
4886 1305c420 taeseongkim
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4887
4888
                            Mouse.SetCursor(Cursors.Arrow);
4889
                        }
4890
                        else
4891
                        {
4892
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4893
                        }
4894 bae83c92 taeseongkim
                    }
4895
                    else
4896
                    {
4897 1305c420 taeseongkim
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4898 bae83c92 taeseongkim
                    }
4899 80458c15 ljiyeon
                }
4900
                else
4901
                {
4902 1305c420 taeseongkim
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4903 80458c15 ljiyeon
                }
4904 1305c420 taeseongkim
4905
                Mouse.SetCursor(Cursors.Arrow);
4906 90e7968d ljiyeon
            }
4907 80458c15 ljiyeon
        }
4908
4909
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4910 90e7968d ljiyeon
        {
4911 80458c15 ljiyeon
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4912 84605c0c taeseongkim
#if Hyosung
4913
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4914
#else
4915 b42dd24d taeseongkim
4916
            //btnConsolidateFinalPDF.IsEnabled = false;
4917
4918 80458c15 ljiyeon
            if (App.ViewInfo != null)
4919
            {
4920
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4921
                {
4922 90e7968d ljiyeon
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4923 80458c15 ljiyeon
                }
4924 90e7968d ljiyeon
            }
4925 84605c0c taeseongkim
#endif
4926 80458c15 ljiyeon
        }
4927
4928 787a4489 KangIngu
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4929
        {
4930 adce8360 humkyung
            SetCompareRect();
4931 787a4489 KangIngu
        }
4932
4933 9cd2865b KangIngu
        private void Sync_Click(object sender, RoutedEventArgs e)
4934
        {
4935 a1716fa5 KangIngu
            if (Sync.IsChecked)
4936 9cd2865b KangIngu
            {
4937
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4938
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4939
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4940
            }
4941
        }
4942
4943 787a4489 KangIngu
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4944
        {
4945
            if (UserList.IsChecked)
4946
            {
4947
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4948
            }
4949
            else
4950
            {
4951
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4952
            }
4953
        }
4954
4955
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4956
        {
4957
            if (BalanceMode.IsChecked)
4958
            {
4959
                ViewerDataModel.Instance.PageBalanceMode = true;
4960
            }
4961
            else
4962
            {
4963
                ViewerDataModel.Instance.PageBalanceMode = false;
4964
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4965
            }
4966
        }
4967
4968
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4969
        {
4970
            //초기화
4971
            testPanel2.IsHidden = true;
4972
            ViewerDataModel.Instance.PageBalanceMode = false;
4973
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4974 752b18ef taeseongkim
            ViewerDataModel.Instance.SyncPageNumber = 0;
4975 787a4489 KangIngu
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4976
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4977
            UserList.IsChecked = false;
4978
            BalanceMode.IsChecked = false;
4979
        }
4980
4981 ac4f1e13 taeseongkim
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4982 787a4489 KangIngu
        {
4983
            if ((sender as System.Windows.Controls.Control).Tag != null)
4984
            {
4985
                //Compare 초기화
4986
                CompareMode.IsChecked = false;
4987
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4988 752b18ef taeseongkim
                
4989
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4990 787a4489 KangIngu
                {
4991 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4992 787a4489 KangIngu
                }
4993
4994
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4995
                {
4996
                }
4997
                else
4998
                {
4999
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5000
                }
5001
5002 752b18ef taeseongkim
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5003 787a4489 KangIngu
                {
5004
                }
5005 752b18ef taeseongkim
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5006 787a4489 KangIngu
                {
5007 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5008 787a4489 KangIngu
                }
5009
5010 d04e8ee9 taeseongkim
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5011 6b6e937c taeseongkim
5012 787a4489 KangIngu
                if (!testPanel2.IsHidden)
5013
                {
5014
                    if (IsSyncPDFMode)
5015
                    {
5016
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5017 752b18ef taeseongkim
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5018 787a4489 KangIngu
5019
                        if (pdfpath.IsDownloading)
5020
                        {
5021
                            pdfpath.DownloadCompleted += (ex, arg) =>
5022
                            {
5023
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5024
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5025
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5026
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5027
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5028
                            };
5029
                        }
5030
                        else
5031
                        {
5032
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5033
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5034
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5035
5036
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5037
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5038
                        }
5039
                    }
5040
                    else
5041
                    {
5042 752b18ef taeseongkim
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5043 787a4489 KangIngu
5044 752b18ef taeseongkim
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5045
                        ComparePageLoad(uri, isOriginalSize);
5046 787a4489 KangIngu
                    }
5047 4f017ed3 taeseongkim
                   
5048 787a4489 KangIngu
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5049
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5050
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5051
5052
                    foreach (var item in gridSelectionRevItem)
5053
                    {
5054 752b18ef taeseongkim
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5055 ac4f1e13 taeseongkim
                        foreach (var markupitem in markupitems)
5056 787a4489 KangIngu
                        {
5057 a1e2ba68 taeseongkim
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5058 ac4f1e13 taeseongkim
                        }
5059 787a4489 KangIngu
                    }
5060 e54660e8 KangIngu
5061 752b18ef taeseongkim
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5062 787a4489 KangIngu
                }
5063
            }
5064
        }
5065
5066 43d2041c taeseongkim
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5067
        {
5068
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5069
5070
            double translateX = 0;
5071
            double translateY = 0;
5072
            double angle = rotate2.Angle;
5073
5074
            if (direction == 1)
5075
            {
5076
                if (angle < 270)
5077
                {
5078
                    angle += 90;
5079
                }
5080
                else
5081
                {
5082
                    angle = 0;
5083
                }
5084
            }
5085
            else
5086
            {
5087
                if (angle > 0)
5088
                {
5089
                    angle -= 90;
5090
                }
5091
                else
5092
                {
5093
                    angle = 270;
5094
                }
5095
            }
5096
            zoomAndPanControl2.RotationAngle = angle;
5097
            zoomAndPanControl2.ScaleToFit();
5098
5099
            //if (angle == 90 || angle == 270)
5100
            //{
5101
                double emptySize = zoomAndPanCanvas2.Width;
5102
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5103
                zoomAndPanCanvas2.Height = emptySize;
5104
            //}
5105
5106
            if (angle == 90)
5107
            {
5108
                translateX = zoomAndPanCanvas2.Width;
5109
                translateY = 0;
5110
            }
5111
            else if (angle == 180)
5112
            {
5113
                translateX = zoomAndPanCanvas2.Width;
5114
                translateY = zoomAndPanCanvas2.Height;
5115
            }
5116
            else if (angle == 270)
5117
            {
5118
                translateX = 0;
5119
                translateY = zoomAndPanCanvas2.Height;
5120
            }
5121
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5122
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5123
            translate2.X = translateX;
5124
            translate2.Y = translateY;
5125
            rotate2.Angle = angle;
5126
            //translate2CompareBorder.X = translateX;
5127
            //translate2CompareBorder.Y = translateY;
5128
            //rotate2CompareBorder.Angle = angle;
5129
5130
        }
5131
5132 787a4489 KangIngu
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5133
        {
5134
            if (MarkupMode.IsChecked)
5135
            {
5136
                IsSyncPDFMode = true;
5137
5138
                var uri = CurrentRev.TO_VENDOR;
5139 ae56d52d KangIngu
5140 752b18ef taeseongkim
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5141 787a4489 KangIngu
                {
5142 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5143 787a4489 KangIngu
                }
5144
5145
                //PDF모드 잠시 대기(강인구)
5146
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5147 752b18ef taeseongkim
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5148 787a4489 KangIngu
5149
                if (pdfpath.IsDownloading)
5150
                {
5151
                    pdfpath.DownloadCompleted += (ex, arg) =>
5152
                    {
5153
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5154
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5155
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5156
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5157
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5158
                    };
5159
                }
5160
                else
5161
                {
5162
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5163
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5164
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5165
5166
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5167
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5168
                }
5169
            }
5170
            else
5171
            {
5172
                IsSyncPDFMode = false;
5173 69f41aab humkyung
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5174 787a4489 KangIngu
5175 752b18ef taeseongkim
                ComparePageLoad(uri,false);
5176 787a4489 KangIngu
5177
                zoomAndPanControl2.ApplyTemplate();
5178
                zoomAndPanControl2.UpdateLayout();
5179
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5180
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5181
            }
5182
        }
5183
5184 adce8360 humkyung
        /// <summary>
5185
        /// Compare된 영역을 초기화
5186
        /// </summary>
5187
        private void ClearCompareRect()
5188
        {
5189
            da.From = 1;
5190
            da.To = 1;
5191
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5192
            da.AutoReverse = false;
5193
            canvas_compareBorder.Children.Clear();
5194
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5195
        }
5196
5197
        /// <summary>
5198 233ef333 taeseongkim
        /// 문서 Comprare
5199 adce8360 humkyung
        /// </summary>
5200
        private void SetCompareRect()
5201
        {
5202 43d2041c taeseongkim
            canvas_compareBorder.Children.Clear();
5203
5204 adce8360 humkyung
            if (CompareMode.IsChecked)
5205
            {
5206
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5207
                {
5208
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5209
                }
5210 752b18ef taeseongkim
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5211 adce8360 humkyung
                {
5212 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5213 adce8360 humkyung
                }
5214
5215 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +"," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," + userData.COMPANY != "EXT" ? "true" : "false", 1);
5216 adce8360 humkyung
5217 41c4405e taeseongkim
                /// 비교대상원본, 비교할 대상
5218 752b18ef taeseongkim
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5219 adce8360 humkyung
            }
5220
            else
5221
            {
5222 43d2041c taeseongkim
                canvas_compareBorder.Visibility = Visibility.Hidden;
5223 adce8360 humkyung
                ClearCompareRect();
5224
            }
5225
        }
5226
5227 3212270d taeseongkim
        private void btnSync_Click(object sender, RoutedEventArgs e)
5228 787a4489 KangIngu
        {
5229
            gridViewHistory_Busy.IsBusy = true;
5230
5231
            RadButton instance = sender as RadButton;
5232
            if (instance.CommandParameter != null)
5233
            {
5234
                CurrentRev = instance.CommandParameter as VPRevision;
5235 adce8360 humkyung
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5236
5237
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5238 787a4489 KangIngu
                {
5239
                    if (ea.Error == null && ea.Result != null)
5240
                    {
5241
                        testPanel2.IsHidden = false;
5242
5243 d128ceb2 humkyung
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5244 233ef333 taeseongkim
                        foreach (var info in ea.Result)
5245 d128ceb2 humkyung
                        {
5246 233ef333 taeseongkim
                            if (info.UserID == App.ViewInfo.UserID)
5247 d128ceb2 humkyung
                            {
5248
                                info.userDelete = true;
5249 8f7f8073 taeseongkim
                                info.DisplayColor = "#FFFF0000";
5250 d128ceb2 humkyung
                            }
5251
                            else
5252
                            {
5253
                                info.userDelete = false;
5254
                            }
5255
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5256
                        }
5257 787a4489 KangIngu
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5258
5259 69f41aab humkyung
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5260 752b18ef taeseongkim
                        ComparePageLoad(uri,false);
5261 787a4489 KangIngu
5262
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5263
5264
                        zoomAndPanControl2.ApplyTemplate();
5265
                        zoomAndPanControl2.UpdateLayout();
5266 43d2041c taeseongkim
5267 787a4489 KangIngu
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5268
                        {
5269
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5270
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5271
                        }
5272
5273 9cd2865b KangIngu
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5274
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5275
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5276
5277 787a4489 KangIngu
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5278
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5279 43d2041c taeseongkim
5280
                        zoomAndPanControl.ScaleToFit();
5281
                        zoomAndPanControl2.ScaleToFit();
5282
5283 787a4489 KangIngu
                        gridViewHistory_Busy.IsBusy = false;
5284
                    }
5285 0f065e57 ljiyeon
5286 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5287 adce8360 humkyung
5288
                    if (GetSyncMarkupInfoItemshandler != null)
5289
                    {
5290
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5291
                    }
5292
5293 43d2041c taeseongkim
                    //ClearCompareRect();
5294 adce8360 humkyung
                    SetCompareRect();
5295 90e7968d ljiyeon
                };
5296 adce8360 humkyung
5297
                /// 중복 실행이 발생하여 수정함.
5298
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5299 787a4489 KangIngu
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5300 adce8360 humkyung
5301 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5302 787a4489 KangIngu
            }
5303
        }
5304 4eb052e4 ljiyeon
5305 752b18ef taeseongkim
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5306
        {
5307
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5308
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5309
5310 ffa5dbc7 taeseongkim
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5311 752b18ef taeseongkim
        }
5312
5313 94b7c12c djkim
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5314
        {
5315
            try
5316
            {
5317
                if (sender is RadButton)
5318
                {
5319
                    if ((sender as RadButton).Tag != null)
5320
                    {
5321
                        var url = (sender as RadButton).Tag.ToString();
5322
                        System.Diagnostics.Process.Start(url);
5323
                    }
5324
                    else
5325
                    {
5326
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5327
                    }
5328
                }
5329
            }
5330
            catch (Exception ex)
5331
            {
5332 664ea2e1 taeseongkim
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5333 94b7c12c djkim
            }
5334
        }
5335 787a4489 KangIngu
5336
        public void Sync_Event(VPRevision Currnet_Rev)
5337
        {
5338
            CurrentRev = Currnet_Rev;
5339
5340
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5341
            {
5342
                if (ea.Error == null && ea.Result != null)
5343
                {
5344
                    testPanel2.IsHidden = false;
5345
5346 d128ceb2 humkyung
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5347 233ef333 taeseongkim
                    foreach (var info in ea.Result)
5348 d128ceb2 humkyung
                    {
5349 233ef333 taeseongkim
                        if (info.UserID == App.ViewInfo.UserID)
5350 d128ceb2 humkyung
                        {
5351
                            info.userDelete = true;
5352 cf1cc862 taeseongkim
                            info.DisplayColor = "#FFFF0000";
5353 d128ceb2 humkyung
                        }
5354
                        else
5355
                        {
5356
                            info.userDelete = false;
5357
                        }
5358
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5359
                    }
5360 787a4489 KangIngu
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5361
5362 69f41aab humkyung
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5363 787a4489 KangIngu
5364
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5365
5366 752b18ef taeseongkim
                    ComparePageLoad(uri,false);
5367 90e7968d ljiyeon
5368 787a4489 KangIngu
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5369
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5370
                    zoomAndPanControl2.ApplyTemplate();
5371
                    zoomAndPanControl2.UpdateLayout();
5372
5373
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5374
                    {
5375
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5376
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5377
                    }
5378
                    //}
5379 30878507 taeseongkim
                    
5380 787a4489 KangIngu
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5381
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5382 90e7968d ljiyeon
                    gridViewHistory_Busy.IsBusy = false;
5383 787a4489 KangIngu
                }
5384 664ea2e1 taeseongkim
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5385 787a4489 KangIngu
            };
5386 664ea2e1 taeseongkim
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5387 90e7968d ljiyeon
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5388 787a4489 KangIngu
        }
5389
5390
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5391
        {
5392
            if (sender is Image)
5393
            {
5394
                if ((sender as Image).Tag != null)
5395
                {
5396
                    var pdfUrl = (sender as Image).Tag.ToString();
5397
                    System.Diagnostics.Process.Start(pdfUrl);
5398
                }
5399
                else
5400
                {
5401
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5402
                }
5403
            }
5404
        }
5405
5406
        private void Create_Symbol(object sender, RoutedEventArgs e)
5407
        {
5408 5529d2a2 humkyung
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5409 787a4489 KangIngu
5410
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5411
            {
5412
                DialogMessage_Alert("Please Select Controls", "Alert");
5413
            }
5414
            else //선택된 것이 있으면
5415
            {
5416
                string MarkupData = "";
5417
                adorner_ = new AdornerFinal();
5418
5419
                foreach (var item in SelectLayer.Children)
5420
                {
5421
                    if (item.GetType().Name == "AdornerFinal")
5422
                    {
5423
                        adorner_ = (item as Controls.AdornerFinal);
5424 4913851c humkyung
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5425 787a4489 KangIngu
                        {
5426
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5427
                            {
5428 5529d2a2 humkyung
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5429 787a4489 KangIngu
                                MarkupData += markupReturn.ConvertData;
5430
                            }
5431
                        }
5432
                    }
5433
                }
5434
                DialogParameters parameters = new DialogParameters()
5435
                {
5436 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
5437 787a4489 KangIngu
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5438
                    DefaultPromptResultValue = "Custom State",
5439
                    Content = "Name :",
5440
                    Header = "Insert Custom Symbol Name",
5441
                    Theme = new VisualStudio2013Theme(),
5442
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5443
                };
5444
                RadWindow.Prompt(parameters);
5445
            }
5446
        }
5447 233ef333 taeseongkim
5448 53880c83 ljiyeon
        public int symbolselectindex = 0;
5449 233ef333 taeseongkim
5450 53880c83 ljiyeon
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5451
        {
5452
            //Save save = new Save();
5453
            try
5454
            {
5455
                string svgfilename = null;
5456
                if (symbolname != null)
5457
                {
5458
                    if (symbolpng == true || symbolsvg == true)
5459
                    {
5460 76dc223b taeseongkim
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5461 24678e06 humkyung
                        string guid = Commons.shortGuid();
5462 53880c83 ljiyeon
5463
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5464 c73426a9 ljiyeon
                        //Check_Uri.UriCheck();
5465 53880c83 ljiyeon
                        fileUploader.RunCompleted += (ex, arg) =>
5466
                        {
5467
                            filename = arg.Result;
5468
                            if (symbolpng == true)
5469
                            {
5470
                                if (filename != null)
5471 233ef333 taeseongkim
                                {
5472 53880c83 ljiyeon
                                    if (symbolselectindex == 0)
5473
                                    {
5474
                                        SymbolSave(symbolname, filename, data);
5475
                                    }
5476
                                    else
5477
                                    {
5478
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5479
                                    }
5480
                                    DataBind();
5481 233ef333 taeseongkim
                                }
5482 53880c83 ljiyeon
                            }
5483
5484
                            if (symbolsvg == true)
5485
                            {
5486 c73426a9 ljiyeon
                                try
5487 53880c83 ljiyeon
                                {
5488 c73426a9 ljiyeon
                                    var defaultBitmapImage = new BitmapImage();
5489
                                    defaultBitmapImage.BeginInit();
5490
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5491
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5492
                                    Check_Uri.UriCheck(filename);
5493
                                    defaultBitmapImage.UriSource = new Uri(filename);
5494
                                    defaultBitmapImage.EndInit();
5495 53880c83 ljiyeon
5496 c73426a9 ljiyeon
                                    System.Drawing.Bitmap image;
5497 53880c83 ljiyeon
5498 c73426a9 ljiyeon
                                    if (defaultBitmapImage.IsDownloading)
5499
                                    {
5500
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5501 53880c83 ljiyeon
                                        {
5502 c73426a9 ljiyeon
                                            defaultBitmapImage.Freeze();
5503
                                            image = GetBitmap(defaultBitmapImage);
5504
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5505
                                            Process potrace = new Process
5506 53880c83 ljiyeon
                                            {
5507 c73426a9 ljiyeon
                                                StartInfo = new ProcessStartInfo
5508
                                                {
5509
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5510
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5511
                                                    RedirectStandardInput = true,
5512
                                                    RedirectStandardOutput = true,
5513
                                                    RedirectStandardError = true,
5514
                                                    UseShellExecute = false,
5515
                                                    CreateNoWindow = true,
5516
                                                    WindowStyle = ProcessWindowStyle.Hidden
5517
                                                },
5518
                                            };
5519 53880c83 ljiyeon
5520 c73426a9 ljiyeon
                                            StringBuilder svgBuilder = new StringBuilder();
5521
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5522 53880c83 ljiyeon
                                            {
5523 c73426a9 ljiyeon
                                                svgBuilder.AppendLine(e2.Data);
5524
                                            };
5525
5526
                                            potrace.EnableRaisingEvents = true;
5527
                                            potrace.Start();
5528
                                            potrace.Exited += (sender, e) =>
5529 53880c83 ljiyeon
                                            {
5530 c73426a9 ljiyeon
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5531
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5532
                                                Check_Uri.UriCheck(svgfilename);
5533
                                                if (symbolselectindex == 0)
5534
                                                {
5535
                                                    SymbolSave(symbolname, svgfilename, data);
5536
                                                }
5537
                                                else
5538
                                                {
5539
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5540
                                                }
5541 53880c83 ljiyeon
5542 c73426a9 ljiyeon
                                                DataBind();
5543
                                            };
5544
                                            potrace.WaitForExit();
5545 53880c83 ljiyeon
                                        };
5546 c73426a9 ljiyeon
                                    }
5547
                                    else
5548
                                    {
5549
                                        //GC.Collect();
5550
                                    }
5551 53880c83 ljiyeon
                                }
5552 233ef333 taeseongkim
                                catch (Exception ee)
5553 90e7968d ljiyeon
                                {
5554 c73426a9 ljiyeon
                                    DialogMessage_Alert("" + ee, "Alert");
5555 90e7968d ljiyeon
                                }
5556 53880c83 ljiyeon
                            }
5557 233ef333 taeseongkim
                        };
5558 53880c83 ljiyeon
                    }
5559
                }
5560
            }
5561
            catch (Exception e)
5562
            {
5563
                //DialogMessage_Alert(e + "", "Alert");
5564 233ef333 taeseongkim
            }
5565 53880c83 ljiyeon
        }
5566
5567
        public void SymbolSave(string Name, string Url, string Data)
5568
        {
5569
            try
5570
            {
5571
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5572
                {
5573 24678e06 humkyung
                    ID = Commons.shortGuid(),
5574 53880c83 ljiyeon
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5575
                    NAME = Name,
5576
                    IMAGE_URL = Url,
5577
                    DATA = Data
5578
                };
5579
5580
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5581 664ea2e1 taeseongkim
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5582 53880c83 ljiyeon
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5583
            }
5584
            catch (Exception)
5585
            {
5586
                throw;
5587
            }
5588
        }
5589
5590
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5591
        {
5592
            try
5593
            {
5594
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5595
                {
5596 24678e06 humkyung
                    ID = Commons.shortGuid(),
5597 53880c83 ljiyeon
                    DEPARTMENT = Department,
5598
                    NAME = Name,
5599
                    IMAGE_URL = Url,
5600
                    DATA = Data
5601
                };
5602
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5603 664ea2e1 taeseongkim
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5604 53880c83 ljiyeon
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5605
            }
5606
            catch (Exception)
5607
            {
5608
                throw;
5609
            }
5610
        }
5611
5612
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5613 233ef333 taeseongkim
        {
5614 664ea2e1 taeseongkim
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5615 53880c83 ljiyeon
            DataBind();
5616
        }
5617
5618
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5619
        {
5620 664ea2e1 taeseongkim
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5621 53880c83 ljiyeon
            DataBind();
5622
        }
5623 233ef333 taeseongkim
5624 53880c83 ljiyeon
        private void DataBind()
5625
        {
5626
            try
5627
            {
5628
                Symbol_Custom Custom = new Symbol_Custom();
5629
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5630 233ef333 taeseongkim
5631 bb3a236d ljiyeon
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5632 53880c83 ljiyeon
                foreach (var item in symbol_Private)
5633
                {
5634
                    Custom.Name = item.NAME;
5635
                    Custom.ImageUri = item.IMAGE_URL;
5636
                    Custom.ID = item.ID;
5637
                    Custom_List.Add(Custom);
5638
                    Custom = new Symbol_Custom();
5639
                }
5640
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5641 233ef333 taeseongkim
5642 53880c83 ljiyeon
                Custom = new Symbol_Custom();
5643
                Custom_List = new List<Symbol_Custom>();
5644
5645 bb3a236d ljiyeon
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5646 53880c83 ljiyeon
5647
                List<SYMBOL_PUBLIC> symbol_Public;
5648 787a4489 KangIngu
5649 53880c83 ljiyeon
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5650
                {
5651 bb3a236d ljiyeon
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5652 53880c83 ljiyeon
                }
5653
                else
5654
                {
5655 bb3a236d ljiyeon
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5656 53880c83 ljiyeon
                }
5657
                foreach (var item in symbol_Public)
5658
                {
5659
                    Custom.Name = item.NAME;
5660
                    Custom.ImageUri = item.IMAGE_URL;
5661
                    Custom.ID = item.ID;
5662
                    Custom_List.Add(Custom);
5663
                    Custom = new Symbol_Custom();
5664
                }
5665
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5666 233ef333 taeseongkim
                BaseClient.Close();
5667 53880c83 ljiyeon
            }
5668 233ef333 taeseongkim
            catch (Exception e)
5669 53880c83 ljiyeon
            {
5670
                //DialogMessage_Alert("DataBind", "Alert");
5671
            }
5672
        }
5673 233ef333 taeseongkim
5674 ac4f1e13 taeseongkim
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5675 787a4489 KangIngu
        {
5676 c73426a9 ljiyeon
            try
5677 787a4489 KangIngu
            {
5678 c73426a9 ljiyeon
                if (args.PromptResult != null)
5679 53880c83 ljiyeon
                {
5680 c73426a9 ljiyeon
                    if (args.DialogResult.Value)
5681
                    {
5682 ac4f1e13 taeseongkim
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5683 787a4489 KangIngu
5684 c73426a9 ljiyeon
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5685
                        _Encoder.Save(fs);
5686
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5687 787a4489 KangIngu
5688 c73426a9 ljiyeon
                        byte[] Img_byte = fs.ToArray();
5689 787a4489 KangIngu
5690 76dc223b taeseongkim
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5691 24678e06 humkyung
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5692 c73426a9 ljiyeon
                        Check_Uri.UriCheck(filename);
5693
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5694
                        {
5695 de6499db humkyung
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5696 c73426a9 ljiyeon
                        }
5697
                        else
5698
                        {
5699 de6499db humkyung
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5700 c73426a9 ljiyeon
                        }
5701
                        DataBind();
5702 53880c83 ljiyeon
                    }
5703
                }
5704 787a4489 KangIngu
            }
5705 233ef333 taeseongkim
            catch (Exception ex)
5706 c73426a9 ljiyeon
            {
5707
                DialogMessage_Alert("" + ex, "Alert");
5708
            }
5709 787a4489 KangIngu
        }
5710
5711 ac4f1e13 taeseongkim
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5712 787a4489 KangIngu
        {
5713
            Canvas _canvas = new Canvas();
5714
            _canvas.Background = Brushes.White;
5715
            _canvas.Width = adorner_.BorderSize.Width;
5716
            _canvas.Height = adorner_.BorderSize.Height;
5717 a1e2ba68 taeseongkim
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5718 787a4489 KangIngu
5719
            BitmapEncoder encoder = new PngBitmapEncoder();
5720
5721
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
5722
5723
            DrawingVisual dv = new DrawingVisual();
5724
5725
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5726
            _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)));
5727
5728
            using (DrawingContext ctx = dv.RenderOpen())
5729
            {
5730
                VisualBrush vb = new VisualBrush(_canvas);
5731
                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)));
5732
            }
5733
5734
            try
5735
            {
5736
                renderBitmap.Render(dv);
5737
5738 2007ecaa taeseongkim
                GC.Collect(2);
5739 787a4489 KangIngu
                GC.WaitForPendingFinalizers();
5740 90e7968d ljiyeon
                //GC.Collect();
5741 787a4489 KangIngu
                // encode png data
5742
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5743
                // puch rendered bitmap into it
5744
                pngEncoder.Interlace = PngInterlaceOption.Off;
5745
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5746
                return pngEncoder;
5747
            }
5748 53880c83 ljiyeon
            catch //(Exception ex)
5749 787a4489 KangIngu
            {
5750
                return null;
5751
            }
5752
        }
5753
5754
        public void DialogMessage_Alert(string content, string header)
5755
        {
5756 68e3cd94 taeseongkim
            App.splashScreen.Close();
5757 cf1cc862 taeseongkim
            App.FileLogger.Error(content + " " + header);
5758 68e3cd94 taeseongkim
5759 787a4489 KangIngu
            DialogParameters parameters = new DialogParameters()
5760
            {
5761 4279e717 djkim
                Owner = this.ParentOfType<MainWindow>(),
5762 0d32593b ljiyeon
                Content = new TextBlock()
5763 233ef333 taeseongkim
                {
5764 0d32593b ljiyeon
                    MinWidth = 400,
5765
                    FontSize = 11,
5766
                    Text = content,
5767
                    TextWrapping = System.Windows.TextWrapping.Wrap
5768
                },
5769 b79f786f 송근호
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5770 787a4489 KangIngu
                Header = header,
5771
                Theme = new VisualStudio2013Theme(),
5772
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5773 233ef333 taeseongkim
            };
5774 787a4489 KangIngu
            RadWindow.Alert(parameters);
5775
        }
5776
5777 233ef333 taeseongkim
        #region 캡쳐 기능
5778 787a4489 KangIngu
5779
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5780
        {
5781
            if (x < 0)
5782
            {
5783
                width += x;
5784
                x = 0;
5785
            }
5786
            if (y < 0)
5787
            {
5788
                height += y;
5789
                y = 0;
5790
5791
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5792
            }
5793
            if (x + width > zoomAndPanCanvas.ActualWidth)
5794
            {
5795
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5796
            }
5797
            if (y + height > zoomAndPanCanvas.ActualHeight)
5798
            {
5799
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5800
            }
5801
5802
            byte[] pixels = CopyPixels(x, y, width, height);
5803
5804
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5805
5806
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5807
        }
5808
5809
        public byte[] CopyPixels(int x, int y, int width, int height)
5810
        {
5811
            byte[] pixels = new byte[width * height * 4];
5812
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5813
5814
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
5815
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
5816
5817
            return pixels;
5818
        }
5819
5820
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5821
        {
5822
            DrawingVisual drawingVisual = new DrawingVisual();
5823
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5824
5825
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5826
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5827
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5828
            drawingContext.Close();
5829
5830
            // 비트맵으로 변환합니다.
5831
            RenderTargetBitmap target =
5832
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5833
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5834
5835
            target.Render(drawingVisual);
5836
            return target;
5837
        }
5838
5839 233ef333 taeseongkim
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5840 53880c83 ljiyeon
        {
5841
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5842
            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);
5843
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5844
            bmp.UnlockBits(data);
5845
            return bmp;
5846
        }
5847 233ef333 taeseongkim
5848 53880c83 ljiyeon
        public string symbolname = null;
5849
        public bool symbolsvg = true;
5850
        public bool symbolpng = true;
5851
5852
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5853
        {
5854
            System.Drawing.Bitmap image = GetBitmap(source);
5855
            //흰색 제거
5856
            //image.MakeTransparent(System.Drawing.Color.White);
5857
5858
            var imageStream = new System.IO.MemoryStream();
5859
            byte[] imageBytes = null;
5860
            using (imageStream)
5861
            {
5862
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5863
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5864
                imageStream.Position = 0;
5865
                imageBytes = imageStream.ToArray();
5866
            }
5867
5868
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5869
5870
            RadWindow CheckPop = new RadWindow();
5871
            //Alert check = new Alert(Msg);
5872
5873
            CheckPop = new RadWindow
5874
            {
5875
                MinWidth = 400,
5876
                MinHeight = 100,
5877 233ef333 taeseongkim
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5878 53880c83 ljiyeon
                Header = "Alert",
5879
                Content = symbolPrompt,
5880 233ef333 taeseongkim
                //DialogResult =
5881 53880c83 ljiyeon
                ResizeMode = System.Windows.ResizeMode.NoResize,
5882
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5883
                IsTopmost = true,
5884
            };
5885
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5886
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5887
            CheckPop.ShowDialog();
5888
5889
            /*
5890
            DialogParameters parameters = new DialogParameters()
5891
            {
5892
                Owner = Application.Current.MainWindow,
5893
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5894
                DefaultPromptResultValue = "Custom State",
5895
                Content = "Name :",
5896
                Header = "Insert Custom Symbol Name",
5897
                Theme = new VisualStudio2013Theme(),
5898
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5899 233ef333 taeseongkim
            };
5900 53880c83 ljiyeon
            RadWindow.Prompt(parameters);
5901
            */
5902
        }
5903
5904 787a4489 KangIngu
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5905
        {
5906
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5907
            KCOMDataModel.DataModel.CHECK_LIST check_;
5908
            string Result = streamToBase64.ImageToBase64(source);
5909
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5910 6c781c0c djkim
            string projectno = App.ViewInfo.ProjectNO;
5911
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5912 0f065e57 ljiyeon
5913 664ea2e1 taeseongkim
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5914 6c781c0c djkim
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5915 90e7968d ljiyeon
            if (Item != null)
5916 0f065e57 ljiyeon
            {
5917 664ea2e1 taeseongkim
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5918 0f065e57 ljiyeon
            }
5919
            else
5920
            {
5921 664ea2e1 taeseongkim
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5922 0f065e57 ljiyeon
            }
5923 90e7968d ljiyeon
5924 6c781c0c djkim
            if (Item == null)
5925 787a4489 KangIngu
            {
5926 6c781c0c djkim
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5927 787a4489 KangIngu
                {
5928 24678e06 humkyung
                    ID = Commons.shortGuid(),
5929 6c781c0c djkim
                    USER_ID = App.ViewInfo.UserID,
5930
                    IMAGE_URL = Result,
5931
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5932
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5933
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5934
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5935
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5936
                    STATUS = "False",
5937
                    CREATE_TIME = DateTime.Now,
5938
                    UPDATE_TIME = DateTime.Now,
5939
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5940
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5941
                };
5942 274cde11 taeseongkim
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5943 664ea2e1 taeseongkim
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5944 274cde11 taeseongkim
                this.BaseClient.AddCheckList(projectno, check_);
5945 787a4489 KangIngu
            }
5946 6c781c0c djkim
            else
5947
            {
5948
                Item.IMAGE_URL = Result;
5949
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5950 90e7968d ljiyeon
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5951 274cde11 taeseongkim
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5952 664ea2e1 taeseongkim
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5953 274cde11 taeseongkim
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5954 6c781c0c djkim
            }
5955 787a4489 KangIngu
        }
5956
5957
        public void Set_Capture()
5958 90e7968d ljiyeon
        {
5959 c7fde400 taeseongkim
            double x = CanvasDrawingMouseDownPoint.X;
5960
            double y = CanvasDrawingMouseDownPoint.Y;
5961 787a4489 KangIngu
            double width = dragCaptureBorder.Width;
5962
            double height = dragCaptureBorder.Height;
5963
5964
            if (width > 5 || height > 5)
5965
            {
5966
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5967
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5968
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5969
            }
5970
        }
5971 233ef333 taeseongkim
5972
        #endregion 캡쳐 기능
5973 787a4489 KangIngu
5974
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5975
        {
5976
            multi_Undo_Data = new Multi_Undo_data();
5977
5978
            multi_Undo_Data.Markup = control;
5979
5980
            if ((control as IShapeControl) != null)
5981
            {
5982
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5983
            }
5984
            if ((control as IDashControl) != null)
5985
            {
5986
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5987
            }
5988
            if ((control as IPath) != null)
5989
            {
5990
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5991
            }
5992
            if ((control as UIElement) != null)
5993
            {
5994
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5995
            }
5996
5997
            return multi_Undo_Data;
5998
        }
5999
6000 ac4f1e13 taeseongkim
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6001 787a4489 KangIngu
        {
6002 d2279f18 taeseongkim
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6003 787a4489 KangIngu
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6004
            {
6005 4f017ed3 taeseongkim
                if (items.MarkupInfoID == Select_ID)
6006 787a4489 KangIngu
                {
6007
                    foreach (var item in items.MarkupList)
6008
                    {
6009
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6010
                        {
6011 a1e2ba68 taeseongkim
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6012 233ef333 taeseongkim
                                 items.MarkupInfoID, Commons.shortGuid());
6013 787a4489 KangIngu
                        }
6014
                    }
6015
                }
6016
            }
6017
        }
6018 d62c0439 humkyung
6019 f959ea6f humkyung
        /// <summary>
6020
        /// convert inkcontrol to polygoncontrol
6021
        /// </summary>
6022
        public void ConvertInkControlToPolygon()
6023 787a4489 KangIngu
        {
6024
            if (inkBoard.Strokes.Count > 0)
6025
            {
6026
                inkBoard.Strokes.ToList().ForEach(stroke =>
6027
                {
6028
                    InkToPath ip = new InkToPath();
6029 f959ea6f humkyung
6030 787a4489 KangIngu
                    List<Point> inkPointSet = new List<Point>();
6031 f959ea6f humkyung
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6032
6033
                    PolygonControl pc = new PolygonControl()
6034 787a4489 KangIngu
                    {
6035 fa48eb85 taeseongkim
                        CommentAngle = 0,
6036 f959ea6f humkyung
                        PointSet = inkPointSet,
6037 787a4489 KangIngu
                        ControlType = ControlType.Ink
6038
                    };
6039 f959ea6f humkyung
                    pc.StartPoint = inkPointSet[0];
6040
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6041
                    pc.LineSize = 3;
6042
                    pc.CommentID = Commons.shortGuid();
6043
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6044 787a4489 KangIngu
6045 f959ea6f humkyung
                    if (pc.PointSet.Count > 0)
6046
                    {
6047
                        CreateCommand.Instance.Execute(pc);
6048 787a4489 KangIngu
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6049
                    }
6050
                });
6051 f959ea6f humkyung
                inkBoard.Strokes.Clear();
6052 787a4489 KangIngu
            }
6053
        }
6054 17a22987 KangIngu
6055 4318fdeb KangIngu
        /// <summary>
6056 e66f22eb KangIngu
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6057
        /// </summary>
6058
        /// <author>ingu</author>
6059
        /// <date>2018.06.05</date>
6060
        /// <param name="getPoint"></param>
6061
        /// <returns></returns>
6062
        private bool IsGetoutpoint(Point getPoint)
6063 670a4be2 humkyung
        {
6064 e66f22eb KangIngu
            if (getPoint == new Point())
6065 670a4be2 humkyung
            {
6066 e66f22eb KangIngu
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6067
                currentControl = null;
6068
                return true;
6069 670a4be2 humkyung
            }
6070
6071 e66f22eb KangIngu
            return false;
6072 670a4be2 humkyung
        }
6073 e66f22eb KangIngu
6074 5b46312f djkim
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6075
        {
6076
            e.Effects = DragDropEffects.Copy;
6077
        }
6078
6079
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6080
        {
6081
            e.Effects = DragDropEffects.Copy;
6082
        }
6083
6084
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6085
        {
6086
            e.Effects = DragDropEffects.None;
6087
        }
6088
6089 92442e4a taeseongkim
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6090 cdfb57ff taeseongkim
        {
6091
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6092
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6093
6094 92442e4a taeseongkim
            ScaleImage(pageWidth, pageHeight);
6095
        }
6096
6097
        /// <summary>
6098
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6099
        /// </summary>
6100
        /// <param name="pageWidth">원본 사이즈</param>
6101
        /// <param name="pageHeight">원본 사이즈</param>
6102
        /// <returns></returns>
6103 233ef333 taeseongkim
        private void ScaleImage(double pageWidth, double pageHeight)
6104 92442e4a taeseongkim
        {
6105 7e2d682c taeseongkim
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6106 cdfb57ff taeseongkim
        }
6107
6108 d0eda156 ljiyeon
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6109
        {
6110
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6111
        }
6112
6113 53deabaf taeseongkim
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6114
        {
6115
            var checkbox = (sender as CheckBox);
6116
6117
            if (checkbox != null)
6118
            {
6119
                if (checkbox.IsChecked.GetValueOrDefault())
6120
                {
6121
                    gridViewMarkup.SelectAll();
6122
                }
6123
                else
6124
                {
6125
                    gridViewMarkup.UnselectAll();
6126
                }
6127
            }
6128
        }
6129 c8dd192f taeseongkim
        
6130 e6a9ddaf humkyung
        /*
6131 5b46312f djkim
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6132
        {
6133 90e7968d ljiyeon
            try
6134 5b46312f djkim
            {
6135 90e7968d ljiyeon
                if (e.Data.GetDataPresent(typeof(string)))
6136
                {
6137
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6138
                    string dragData = e.Data.GetData(typeof(string)) as string;
6139
                    Move_Symbol(sender, dragData);
6140
                }
6141 5b46312f djkim
            }
6142 90e7968d ljiyeon
            catch (Exception ex)
6143
            {
6144 664ea2e1 taeseongkim
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6145 233ef333 taeseongkim
            }
6146 5b46312f djkim
        }
6147 e6a9ddaf humkyung
        */
6148 787a4489 KangIngu
    }
6149 f65e6c02 taeseongkim
6150
    public class testItem
6151
    {
6152
        public string Title { get; set; }
6153
    }
6154 233ef333 taeseongkim
}
클립보드 이미지 추가 (최대 크기: 500 MB)