프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu

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