프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 90d1dee0

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