프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu

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