프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 7bb40d38

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

1 2007ecaa taeseongkim
using IIpc;
2
using IKCOM;
3 787a4489 KangIngu
using KCOM.Common;
4
using KCOMDataModel.DataModel;
5 4eb052e4 ljiyeon
using MarkupToPDF.Common;
6 5529d2a2 humkyung
using MarkupToPDF.Controls.Parsing;
7 787a4489 KangIngu
using System;
8
using System.Collections.Generic;
9
using System.Collections.ObjectModel;
10
using System.ComponentModel;
11 0c997b99 ljiyeon
using System.Diagnostics;
12 787a4489 KangIngu
using System.Linq;
13 6c687be8 taeseongkim
using System.Threading;
14 54a28343 taeseongkim
using System.Threading.Tasks;
15 787a4489 KangIngu
using System.Windows;
16
using System.Windows.Controls;
17 d18ea2bd taeseongkim
using System.Windows.Data;
18 787a4489 KangIngu
using System.Windows.Input;
19 83a98e96 송근호
using System.Windows.Media;
20 787a4489 KangIngu
using Telerik.Windows.Controls;
21 4eb052e4 ljiyeon
using static MarkupToPDF.Controls.Parsing.MarkupParser;
22 787a4489 KangIngu
23
namespace KCOM.Controls
24
{
25
    /// <summary>
26
    /// Interaction logic for PageNavigator.xaml
27
    /// </summary>
28
    public partial class Sample : UserControl, INotifyPropertyChanged
29
    {
30 992a98b4 KangIngu
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
31 787a4489 KangIngu
        public event PropertyChangedEventHandler PropertyChanged;
32 c5519c44 taeseongkim
        public DelegateCommand SelectCommentCommand { get; private set; }
33 54a28343 taeseongkim
34
35 787a4489 KangIngu
        public Sample()
36 f65e6c02 taeseongkim
        {
37
            InitializeComponent();
38
39
            if (App.IsDesignMode)
40 2089959a taeseongkim
            {
41
                return;
42
            }
43
44 2007ecaa taeseongkim
            App.splashString(ISplashMessage.SAMPLE);
45 0c997b99 ljiyeon
            this.Loaded += Sample_Loaded;
46 d97dbc7f taeseongkim
            this.Unloaded += Sample_Unloaded;
47
        }
48
49
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
50
        {
51 6c687be8 taeseongkim
          
52 0c997b99 ljiyeon
        }
53
54
        private void Sample_Loaded(object sender, RoutedEventArgs e)
55
        {
56 afaa7c92 djkim
            if(!_Initialize)
57
            {
58
                _Initialize = true;
59 c5519c44 taeseongkim
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
60
61 24c5e56c taeseongkim
62 d18ea2bd taeseongkim
                this.SizeChanged += Sample_SizeChanged;
63 afaa7c92 djkim
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
64 24c5e56c taeseongkim
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);
65
                this.ImgListbox.PreviewKeyUp += ImgListbox_PreviewKeyUp;
66
67
68 afaa7c92 djkim
            }            
69 787a4489 KangIngu
        }
70
71 d18ea2bd taeseongkim
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
72
        {
73 24c5e56c taeseongkim
            if (e.WidthChanged)
74 d18ea2bd taeseongkim
            {
75
                ImgListbox.UpdateLayout();
76
            }
77
        }
78
79
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample));
80
        public CollectionViewSource FilteredThumbnail
81
        {
82
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
83
            set { SetValue(FilteredThumbnailProperty, value); }
84
        }
85
86
        public static readonly DependencyProperty CurrentPageProperty 
87
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
88
89
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
90
        {
91
            //var owner = d as Sample;
92
93
            //if (owner?.UsersCommentPagesList != null)
94
            //{
95
            //    owner.SetCommentPages();
96
            //}
97
        }
98
99
        public ThumbnailItem CurrentPage
100
        {
101
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
102
            set { SetValue(CurrentPageProperty, value); }
103
        }
104
105 787a4489 KangIngu
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
106
        private List<DOCPAGE> _PageList = null;
107
        private string _DefaultUri = null;
108
        public int PageCount = 0;
109
        private bool _Initialize;
110 54a28343 taeseongkim
111
        public event EventHandler<EventArgs> ThumbInitialized;
112 787a4489 KangIngu
        public event EventHandler<PageChangeEventArgs> PageChanged;
113
        public event EventHandler<PageChangeEventArgs> PageChanging;
114 f65e6c02 taeseongkim
115 c5519c44 taeseongkim
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
116 f65e6c02 taeseongkim
117 c5519c44 taeseongkim
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
118 f65e6c02 taeseongkim
        {
119
            get {
120
                if(_UsersCommentPagesList == null)
121
                {
122 c5519c44 taeseongkim
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
123 f65e6c02 taeseongkim
                }
124
125
                return _UsersCommentPagesList; }
126
            set { _UsersCommentPagesList = value; }
127
        }
128
129 787a4489 KangIngu
        public class PageChangeEventArgs : EventArgs
130
        {
131
            public DOCPAGE CurrentPage { get; set; }
132
            public string PageUri { get; set; }
133
            public int PageNumber { get; set; }
134
        }
135
        private bool _IsFitOn { get; set; }
136
        public bool IsFitOn
137
        {
138
            get
139
            {
140
                return _IsFitOn;
141
            }
142
            set
143
            {
144
                _IsFitOn = value;
145
                RaisePropertyChanged("IsFitOn");
146
            }
147
        }
148
149
        public void RaisePropertyChanged(string propName)
150
        {
151
            if (PropertyChanged != null)
152
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
153
        }
154
155 54a28343 taeseongkim
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
156 787a4489 KangIngu
        {
157 2007ecaa taeseongkim
            App.splashString(ISplashMessage.SAMPLE);
158 6c687be8 taeseongkim
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
159
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
160
161 787a4489 KangIngu
            this._PageList = PageList;
162
            this._DefaultUri = DefaultUri;
163 54a28343 taeseongkim
164
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
165
166
            
167 2007ecaa taeseongkim
            //ThumbnailSetAsync();
168
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
169
170 787a4489 KangIngu
            this.PageCount = PageList.Count();
171 54a28343 taeseongkim
172 9d5b4bc2 taeseongkim
            string endpoint = Common.Commons.shortGuid() + "Thumbnail";
173 2007ecaa taeseongkim
174
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
175
            wcfServer.IpcThumbnailReceived += WcfServer_IpcThumbnailReceived;
176
            wcfServer.Start();
177
178
            DownloadProcess.ThumbnailDownloader(endpoint,ViewerDataModel.Instance.IsAdmin, this._DefaultUri, tempStoragePath, "jpg", this.PageCount);
179 9d5b4bc2 taeseongkim
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath);
180 2007ecaa taeseongkim
181
            App.splashScreen.Close();
182
        }
183
184
        private void WcfServer_IpcThumbnailReceived(object sender, IpcThumbnailEventArgs e)
185
        {
186
            var items = _thumbnailItems.Where(x => x.PageNumber == e.PageNo);
187
188
            if (items.Count() > 0)
189
            {
190
                //Dispatcher.BeginInvoke((Action)delegate ()
191
                //{
192
                    items.First().ImageUri = new Uri(e.Path, UriKind.Absolute);
193
                //});
194
            }
195 787a4489 KangIngu
        }
196 39f0624f ljiyeon
197 787a4489 KangIngu
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
198
        {
199 548c696e ljiyeon
            Logger.sendCheckLog("rdoCommented_Checked", 1);
200 787a4489 KangIngu
            SetCommentPages();
201
        }
202
203
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
204
        {
205 548c696e ljiyeon
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
206 d18ea2bd taeseongkim
            //if (rdoFavoritePages.IsChecked == true)
207
            //    expCommentPages.IsExpanded = false;
208 992a98b4 KangIngu
209 d18ea2bd taeseongkim
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
210
            //if (_FavoriteSet.Count > 0)
211
            //{
212
            //    SetCommentPages(); //수정    
213
            //}
214
            //else
215
            //{
216
            //    rdoAllPages.IsChecked = true;
217
            //    rdoFavoritePages.IsChecked = false;
218
            //}
219 992a98b4 KangIngu
        }
220
221 6c687be8 taeseongkim
        private async void ShowPageChange(object sender, RoutedEventArgs e)
222 992a98b4 KangIngu
        {
223 24c5e56c taeseongkim
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
224
            if (IsInitialized)
225 6c687be8 taeseongkim
            {
226 2007ecaa taeseongkim
                //ThumbnailSetAsync();
227 d18ea2bd taeseongkim
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
228 6c687be8 taeseongkim
            }
229 787a4489 KangIngu
        }
230 992a98b4 KangIngu
231 787a4489 KangIngu
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
232
        {
233
            //txtThumbCount.Visibility = Visibility.Collapsed;            
234
        }
235
236
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
237
        {
238 548c696e ljiyeon
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
239 787a4489 KangIngu
            rdoAllPages.IsChecked = false;
240
            rdoFavoritePages.IsChecked = false;
241
            //txtThumbCount.Visibility = Visibility.Visible;
242
            SetCommentPages();
243
        }
244
245 24c5e56c taeseongkim
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
246
        {
247
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
248
            {
249
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
250
251
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
252
            }
253
        }
254
255 129ca191 humkyung
        /// <summary>
256
        /// called when image list box's selection is changed
257
        /// </summary>
258
        /// <param name="sender"></param>
259
        /// <param name="e"></param>
260 24c5e56c taeseongkim
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
261 eeb0a39c taeseongkim
        {
262 24c5e56c taeseongkim
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
263 787a4489 KangIngu
            {
264 664ea2e1 taeseongkim
                if (ImgListbox.SelectedItem != null)
265
                {
266
                    PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
267
                }
268 24c5e56c taeseongkim
            }
269
        }
270 eeb0a39c taeseongkim
271 24c5e56c taeseongkim
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
272
        { 
273
                var number = selectItem.PageNumber;
274
275
                if (ViewerDataModel.Instance.PageNumber != number)
276
                {
277 ac4f1e13 taeseongkim
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
278 787a4489 KangIngu
279 24c5e56c taeseongkim
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
280 ac4f1e13 taeseongkim
281
                    PageChanging(this, new PageChangeEventArgs
282
                    {
283
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
284
                        PageNumber = number,
285
                        PageUri = null
286
                    });
287 24c5e56c taeseongkim
                }
288 787a4489 KangIngu
        }
289
290
        public bool GotoPageFlag = false;
291
292 b2a6b24a humkyung
        /// <summary>
293
        /// 해당 썸네일로 이동
294
        /// </summary>
295 3908a575 humkyung
        /// <param name="_pageNumber">이동할 페이지 번호</param>
296 787a4489 KangIngu
        public void GotoPage(int _pageNumber)
297
        {
298 90e7968d ljiyeon
            try
299 787a4489 KangIngu
            {
300 a1142a6b taeseongkim
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
301
302
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
303
                    if (_page.Count() > 0)
304 90e7968d ljiyeon
                    {
305 a1142a6b taeseongkim
                        ThumbnailItem thumbnailitem = _page.First();
306
                        if (PageChanging != null)
307
                        {
308
309
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
310
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
311 e13b43de taeseongkim
312 a1142a6b taeseongkim
                                ImgListbox.SelectedItem = thumbnailitem;
313 e13b43de taeseongkim
314
315
                                if (navigationTab.SelectedIndex != 0)
316
                                {
317
                                    PageChange(thumbnailitem);
318
                                }
319
320 a1142a6b taeseongkim
                            });
321
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
322
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
323
                            //    ImgListbox.ScrollIntoView(_itemIndex);
324
                            //else
325
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
326
                        }
327 90e7968d ljiyeon
                    }
328 a1142a6b taeseongkim
329 e13b43de taeseongkim
                }).ConfigureAwait(false);
330 787a4489 KangIngu
            }
331 90e7968d ljiyeon
            catch(Exception ex)
332
            {
333 664ea2e1 taeseongkim
                //Logger.sendResLog("GotoPage", ex.Message, 0);
334 90e7968d ljiyeon
            }
335
        }
336 787a4489 KangIngu
337 3908a575 humkyung
        /// <summary>
338
        /// 주어진 페이지로 변경한다
339
        /// </summary>
340
        /// <param name="iPageNo">변경할 페이지 번호</param>
341
        public void ChangePage(int iPageNo)
342 787a4489 KangIngu
        {
343 3908a575 humkyung
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
344
            if ((PageChanged != null) && (thumbitem != null))
345 787a4489 KangIngu
            {
346 d48260a2 djkim
                var uri = thumbitem.PageUri.ToString();
347
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
348 3908a575 humkyung
349 d48260a2 djkim
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
350
                if (_DocPages != null)
351 3908a575 humkyung
                {
352
                    PageChanged(this, new PageChangeEventArgs
353 787a4489 KangIngu
                    {
354 d48260a2 djkim
                        CurrentPage = _DocPages,
355 3908a575 humkyung
                        PageUri = uri,
356
                        PageNumber = thumbitem.PageNumber
357 787a4489 KangIngu
                    });
358 2d584f1a djkim
                    //ImgListbox.SelectedItem = thumbitem;                    
359
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
360
                    
361 944be2fa djkim
                    this.CurrentPage = thumbitem;
362 3908a575 humkyung
                }
363
                else
364
                {
365
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
366 787a4489 KangIngu
                }
367
            }
368
        }
369 64f6713a humkyung
370 d974f3f8 ljiyeon
        public void GotoPageTALK(int _pageNumber, int _angle)
371
        {
372
            int _PageNo = -1;
373
374
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
375
            {
376
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
377
                if (_page.Count() > 0)
378
                {
379
                    ThumbnailItem _item = _page.First();
380
                    setPageChangeTALK(_item, _angle);
381
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
382 6443ebfe djkim
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
383 d974f3f8 ljiyeon
                }
384
            }
385
        }
386
387
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
388
        {
389
            if (thumbnailItem != null)
390
            {
391
                if (PageChanging != null)
392 90e7968d ljiyeon
                {
393 3908a575 humkyung
                    ///this.CurrentPage = _NextPage;
394
                    ///_NextPage = thumbnailItem;
395 d974f3f8 ljiyeon
                    PageChanging(this, new PageChangeEventArgs
396
                    {
397
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
398
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
399
                        PageUri = null
400
                    });
401
402
                    var instanceMain = this.ParentOfType<MainWindow>();
403
404
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
405
406
                    if (rotationNum > 0) // 1, 2, 3
407
                    {
408 90e7968d ljiyeon
                        for (int i = 0; i < rotationNum; i++)
409 d974f3f8 ljiyeon
                        {
410
                            drawingPannelRotate(true);
411
                        }
412
                    }
413 90e7968d ljiyeon
                    else if (rotationNum < 0)// -1, -2, -3
414 d974f3f8 ljiyeon
                    {
415
                        for (int i = 0; i < -rotationNum; i++)
416
                        {
417
                            drawingPannelRotate(false);
418
                        }
419 90e7968d ljiyeon
                    }
420 d974f3f8 ljiyeon
                }
421
            }
422
        }
423 90e7968d ljiyeon
424 d974f3f8 ljiyeon
        public void drawingPannelRotate(bool Flag)
425
        {
426
            var instanceMain = this.ParentOfType<MainWindow>();
427
428
            if (Flag)
429
            {
430
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
431
                {
432
                    instanceMain.dzMainMenu.rotate.Angle = 0;
433
                }
434
                else
435
                {
436
                    instanceMain.dzMainMenu.rotate.Angle += 90;
437
                }
438
            }
439
            else
440
            {
441
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
442
                {
443
                    instanceMain.dzMainMenu.rotate.Angle = 270;
444
                }
445
                else
446
                {
447
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
448
                }
449
            }
450
451
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
452
            {
453
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
454
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
455
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
456
            }
457 90e7968d ljiyeon
458 d974f3f8 ljiyeon
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
459
            {
460
                instanceMain.dzMainMenu.translate.X = 0;
461
                instanceMain.dzMainMenu.translate.Y = 0;
462
            }
463
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
464
            {
465
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
466
                instanceMain.dzMainMenu.translate.Y = 0;
467
            }
468
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
469
            {
470
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
471
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
472
            }
473
            else
474
            {
475
                instanceMain.dzMainMenu.translate.X = 0;
476
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
477
            }
478
479
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
480
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
481
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
482
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
483
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
484
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
485
486
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
487
            {
488
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
489
490 d18ea2bd taeseongkim
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
491 d974f3f8 ljiyeon
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
492
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
493
494
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
495
                if (rotationdoc != null)
496
                {
497
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
498
                }
499
                else
500
                {
501
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
502
                }
503 3908a575 humkyung
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
504 d974f3f8 ljiyeon
            });
505
        }
506
507 787a4489 KangIngu
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
508
        {
509
            SetCommentPages();
510
        }
511 39f0624f ljiyeon
512 c5519c44 taeseongkim
        public async void SetCommentPages(object obj = null)
513 787a4489 KangIngu
        {
514 2007ecaa taeseongkim
            //ThumbnailSetAsync();
515 d18ea2bd taeseongkim
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
516 787a4489 KangIngu
        }
517
518 24c5e56c taeseongkim
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
519 787a4489 KangIngu
        {
520 548c696e ljiyeon
            Logger.sendCheckLog("SetCommentList", 1);
521 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
522 787a4489 KangIngu
            #region 기존 색상 제거 작업
523 6c687be8 taeseongkim
524 787a4489 KangIngu
            foreach (var item in this._thumbnailItems)
525
            {
526 6c687be8 taeseongkim
                if (item.DisplayColorItems != null)
527
                {
528
                    item.DisplayColorItems.Clear();
529
                }
530 122914ba ljiyeon
            }
531 787a4489 KangIngu
            #endregion
532
533 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
534 787a4489 KangIngu
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
535
536 f65e6c02 taeseongkim
            this.UsersCommentPagesList.ToList().ForEach(item =>
537 787a4489 KangIngu
            {
538
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
539
540
                if (_comm.Count() == 0)
541
                {
542
                    _delItem.Add(item);
543
                }
544 24c5e56c taeseongkim
545
                if (cts != null)
546
                {
547
                    if (cts.Value.IsCancellationRequested)
548
                        return;
549
                }
550 787a4489 KangIngu
            });
551
552 f65e6c02 taeseongkim
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
553 787a4489 KangIngu
554 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
555 81e3a60f 송근호
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
556
557 787a4489 KangIngu
            UsersCommentPagesList.ForEach(user =>
558
            {
559 c5519c44 taeseongkim
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
560
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
561 787a4489 KangIngu
562 f65e6c02 taeseongkim
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
563 787a4489 KangIngu
564
                if (_commLst.Count() == 0)
565
                {
566 f65e6c02 taeseongkim
                    this.UsersCommentPagesList.Add(user);
567 787a4489 KangIngu
                }
568
                else
569
                {
570
                    if (_commLst.First().PageNumber != user.PageNumber)
571
                        _commLst.First().PageNumber = user.PageNumber;
572
                }
573
574
                user.PageNumber.ForEach(page =>
575
                {
576
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
577
578
                    if (_items.Count() > 0)
579 81e3a60f 송근호
                    {
580
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
581
                        
582
                    }
583 24c5e56c taeseongkim
584
                    if (cts != null)
585
                    {
586
                        if (cts.Value.IsCancellationRequested)
587
                            return;
588
                    }
589 787a4489 KangIngu
                });
590
            });
591
592 81e3a60f 송근호
            foreach (var item in this._thumbnailItems)
593
            {
594 8ff1bf3a 송근호
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
595 81e3a60f 송근호
            }
596 d18ea2bd taeseongkim
597 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
598 f65e6c02 taeseongkim
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
599 c5519c44 taeseongkim
600 787a4489 KangIngu
            if (data.Count() != 0)
601
            {
602
                if (Convert.ToBoolean(data.First().isConSolidation))
603
                {
604
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
605
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
606
                    this.lstSelectComment.ItemsSource = data;
607
                }
608
            }
609 f65e6c02 taeseongkim
610 c5519c44 taeseongkim
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
611
612 81e3a60f 송근호
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
613 90e7968d ljiyeon
614 2d584f1a djkim
615 81e3a60f 송근호
            //var template = this.ImgListbox.ItemTemplate;
616
            //this.ImgListbox.ItemTemplate = null;
617
            //this.ImgListbox.ItemTemplate = template;
618 2d584f1a djkim
619 787a4489 KangIngu
        }
620
621 d18ea2bd taeseongkim
        List<int> FilterPages = null;
622 6c687be8 taeseongkim
623 d18ea2bd taeseongkim
        private void ThumbnailSetAsync()
624 787a4489 KangIngu
        {
625 548c696e ljiyeon
            Logger.sendCheckLog("ThumbnailSet", 1);
626 787a4489 KangIngu
627 d18ea2bd taeseongkim
            if (FilteredThumbnail == null)
628 6c687be8 taeseongkim
            {
629 d18ea2bd taeseongkim
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
630 787a4489 KangIngu
631 d18ea2bd taeseongkim
                var pageList = ViewerDataModel.Instance.Document_Info;
632 54a28343 taeseongkim
633 6c687be8 taeseongkim
                var items = from page in pageList
634
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
635
                            select new ThumbnailItem
636
                            {
637 2007ecaa taeseongkim
                                //ImageUri = new Uri(pageLink),
638 6c687be8 taeseongkim
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
639
                                PageNumber = page.PAGE_NUMBER,
640
                                Angle = page.PAGE_ANGLE
641
                            };
642 54a28343 taeseongkim
643 d18ea2bd taeseongkim
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
644
                FilteredThumbnail = new CollectionViewSource();
645 c5519c44 taeseongkim
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
646
647 d18ea2bd taeseongkim
                FilteredThumbnail.Source = _thumbnailItems;
648 787a4489 KangIngu
649 2007ecaa taeseongkim
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
650
                  {
651
                      System.Diagnostics.Debug.WriteLine("ect");
652
                  };
653
654 d18ea2bd taeseongkim
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
655
656 2007ecaa taeseongkim
                FilteredThumbnail.Filter += (snd, evt) =>
657 787a4489 KangIngu
                {
658 d18ea2bd taeseongkim
                    if (FilterPages?.Count() > 0 && evt.Item != null)
659 787a4489 KangIngu
                    {
660 d18ea2bd taeseongkim
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
661 276fdd9b KangIngu
                    }
662 d18ea2bd taeseongkim
                    else
663 787a4489 KangIngu
                    {
664 d18ea2bd taeseongkim
                        evt.Accepted = false;
665 6c687be8 taeseongkim
                    }
666 d18ea2bd taeseongkim
                };
667 54a28343 taeseongkim
668 d18ea2bd taeseongkim
            }
669 787a4489 KangIngu
670 d18ea2bd taeseongkim
            FilterPages.Clear();
671 448c5399 taeseongkim
672 d18ea2bd taeseongkim
            if (rdoAllPages.IsChecked == true)
673
            {
674
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
675
            }
676
            else if (rdoFavoritePages.IsChecked == true)
677
            {
678
                if (_FavoriteSet != null)
679
                {
680
                    FilterPages = (from thumb in _thumbnailItems
681
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
682
                                select thumb.PageNumber).ToList();
683
                }
684
            }
685
            else if (rdoCommentPages.IsChecked == true)
686
            {
687
                if (this.lstSelectComment.ItemsSource != null)
688
                {
689
                    var commentPages = (from commentPage in this.UsersCommentPagesList
690
                                        where commentPage.IsSelected == true
691
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
692
693
                    if (commentPages?.Count() > 0)
694
                    {
695
                        FilterPages = (from thumb in _thumbnailItems
696
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
697
                                       select thumb.PageNumber).ToList();
698 787a4489 KangIngu
                    }
699 d18ea2bd taeseongkim
                }
700
            }
701
702
            if (FilterPages != null)
703
            {
704 664ea2e1 taeseongkim
                if(FilteredThumbnail == null)
705
                {
706
                    System.Diagnostics.Debug.WriteLine("filter null");
707
                }
708
709
                if (FilteredThumbnail.View == null)
710
                {
711
                    System.Diagnostics.Debug.WriteLine("filter null");
712
                }
713
714 d18ea2bd taeseongkim
                FilteredThumbnail.View.Refresh();
715
716
                if (FilterPages.Count() > 0)
717
                {
718 2007ecaa taeseongkim
                    if (_thumbnailItems.Count() > 0)
719
                    {
720
                        ImgListbox.SelectedItem = _thumbnailItems[0];
721
                    }
722
723 d18ea2bd taeseongkim
                    //SetCommentList(UsersCommentPagesList.ToList());
724
                }
725
                else
726
                {
727
                    ImgListbox.SelectedItem = null;
728
                }
729
730
                if (ThumbInitialized != null)
731
                {
732
                    ThumbInitialized(this, new EventArgs());
733
                    ThumbInitialized = null;
734 787a4489 KangIngu
                }
735 54a28343 taeseongkim
            }
736 787a4489 KangIngu
        }
737
738 24c5e56c taeseongkim
739 ac4f1e13 taeseongkim
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
740 787a4489 KangIngu
        {
741
            if (e.ClickCount >= 2)
742
            {
743 39f0624f ljiyeon
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
744 ac4f1e13 taeseongkim
745 787a4489 KangIngu
                GotoPage(selectItem.PageNumber);
746 ac4f1e13 taeseongkim
747 24c5e56c taeseongkim
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data, ViewerDataModel.Instance.CancellationToken());
748 ac4f1e13 taeseongkim
749 90e7968d ljiyeon
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
750 787a4489 KangIngu
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
751
                //bool isGO = false;
752
753
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
754
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
755
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
756
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
757
                //{
758
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
759
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
760
                //    {
761
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
762
                //    }
763
764
                //};
765
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
766
767 39f0624f ljiyeon
                //GotoPage(MarkupList.SelectedItem as MarkupList)
768 787a4489 KangIngu
            }
769
        }
770
771
        public class MarkupInfoItemSmall
772
        {
773
            public string Id { get; set; }
774
            public string UserName { get; set; }
775
            public string UserID { get; set; }
776
            public int PageNumber { get; set; }
777
            public string Data { get; set; }
778
            public int Data_Type { get; set; }
779 eeb0a39c taeseongkim
            public bool IsConsolidate { get; set; }
780 787a4489 KangIngu
        }
781
782
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
783
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
784
        {
785
            get
786
            {
787
                if (_MarkupInfoSmallList == null)
788
                {
789
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
790
                }
791
                return _MarkupInfoSmallList;
792
            }
793
            set
794
            {
795 90e7968d ljiyeon
796 787a4489 KangIngu
                _MarkupInfoSmallList = value;
797
                RaisePropertyChanged("MarkupInfoSmallList");
798
            }
799
        }
800
801 2aaf9645 humkyung
        /// <summary>
802
        /// goto page and select item selected by user
803
        /// </summary>
804
        /// <param name="sender"></param>
805
        /// <param name="e"></param>
806 ac4f1e13 taeseongkim
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
807 787a4489 KangIngu
        {
808
            var clickButtonItem = sender as RadButton;
809
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
810
            {
811
                try
812
                {
813
                    Rect rect = new Rect();
814
                    Point s_point = new Point();
815
                    Point e_point = new Point();
816
817
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
818
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
819 2aaf9645 humkyung
820 24c5e56c taeseongkim
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.CancellationToken()); //언패킹작업
821 787a4489 KangIngu
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
822
                    {
823
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
824
                            {
825
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
826
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
827
                            }
828
                            break;
829
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
830
                            {
831
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
832
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
833
                            }
834
                            break;
835
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
836
                            {
837
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
838
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
839
                            }
840
                            break;
841
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
842
                            {
843
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
844
845
                                foreach (Point A in instance.PointSet)
846
                                {
847
                                    if (s_point == new Point())
848
                                    {
849
                                        s_point = A;
850
                                        e_point = A;
851
                                    }
852
                                    s_point.X = Math.Min(s_point.X, A.X);
853
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
854
                                    e_point.X = Math.Max(e_point.X, A.X);
855
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
856
                                }
857
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
858
                            }
859
                            break;
860
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
861
                            {
862
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
863
864
                                foreach (Point A in instance.PointSet)
865
                                {
866
                                    if (s_point == new Point())
867
                                    {
868
                                        s_point = A;
869
                                        e_point = A;
870
                                    }
871
                                    s_point.X = Math.Min(s_point.X, A.X);
872
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
873
                                    e_point.X = Math.Max(e_point.X, A.X);
874
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
875
                                }
876
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
877
                            }
878
                            break;
879
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
880
                            {
881
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
882
883
                                foreach (Point A in instance.PointSet)
884
                                {
885
                                    if (s_point == new Point())
886
                                    {
887
                                        s_point = A;
888
                                        e_point = A;
889
                                    }
890
                                    s_point.X = Math.Min(s_point.X, A.X);
891
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
892
                                    e_point.X = Math.Max(e_point.X, A.X);
893
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
894
                                }
895
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
896
                            }
897
                            break;
898
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
899
                            {
900
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
901
902
                                foreach (Point A in instance.PointSet)
903
                                {
904
                                    if (s_point == new Point())
905
                                    {
906
                                        s_point = A;
907
                                        e_point = A;
908
                                    }
909
                                    s_point.X = Math.Min(s_point.X, A.X);
910
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
911
                                    e_point.X = Math.Max(e_point.X, A.X);
912
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
913
                                }
914
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
915
                            }
916
                            break;
917
                        default:
918
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
919
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
920
                            break;
921
                    }
922
923 077896be humkyung
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
924 787a4489 KangIngu
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
925
                }
926
                catch (Exception ex)
927
                {
928 2aaf9645 humkyung
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
929 787a4489 KangIngu
                }
930
            }
931
        }
932
933 2089959a taeseongkim
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
934
        {
935
            var clickButtonItem = sender as RadButton;
936
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
937
            {
938
                try
939
                {
940
             
941
942
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
943
                    MarkupList.SelectedItem = gaza;
944
945 c7fde400 taeseongkim
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
946 2089959a taeseongkim
                }
947
                catch (Exception ex)
948
                {
949
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
950
                }
951
            }
952
        }
953
954 c7fde400 taeseongkim
        ///// <summary>
955
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
956
        ///// </summary>
957
        ///// <param name="CommentIdList"></param>
958
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
959
        //{
960
        //    var instance = Common.ViewerDataModel.Instance;
961
962
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
963
964
        //    var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
965
966
        //    if (commentList.Count() > 0)
967
        //    {
968
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
969
        //        #region markup list grid select items
970
971
        //        var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
972
973
        //        if (infoItem.Count() > 0)
974
        //        {
975
976
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
977
        //            gridMarkup.SelectedItems.Clear();
978
        //            gridMarkup.SelectedItems.Add(infoItem.First());
979
        //        }
980
981
        //        #endregion
982
983
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
984
985
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
986
        //        {
987
        //            GotoSelectedMarkup(CommentIdList);
988
        //        }
989
        //        else
990
        //        {
991
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
992
993
        //            handler = (snd, evt) =>
994
        //            {
995
        //                GotoSelectedMarkup(CommentIdList);
996
        //                pageNavigator.PageChanged -= handler;
997
        //            };
998
999
        //            pageNavigator.PageChanged += handler;
1000
1001
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
1002
        //        }
1003
        //    }
1004
        //}
1005
1006
        ///// <summary>
1007
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
1008
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
1009
        ///// </summary>
1010
        ///// <param name="CommentIdList"></param>
1011
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
1012
        //{
1013
        //    var instance = Common.ViewerDataModel.Instance;
1014
1015
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1016
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1017
1018
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
1019
        //    {
1020
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1021
        //        commentUserInfo.AddRange(selectOrderComments);
1022
1023
        //        if (commentUserInfo?.Count() > 0)
1024
        //        {
1025
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1026
1027
        //            try
1028
        //            {
1029
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1030
        //                {
1031
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1032
        //                    {
1033
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1034
        //                    } 
1035 5beaf28e taeseongkim
                            
1036 c7fde400 taeseongkim
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1037
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1038
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1039
        //                }
1040 5beaf28e taeseongkim
1041 c7fde400 taeseongkim
        //                Rect rect = commentUserInfo.First().ItemRect;
1042 2089959a taeseongkim
1043 c7fde400 taeseongkim
        //                foreach (var UserInfo in commentUserInfo)
1044
        //                {
1045
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1046
        //                }
1047 2089959a taeseongkim
1048 c7fde400 taeseongkim
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1049 2089959a taeseongkim
1050 c7fde400 taeseongkim
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1051
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1052
        //                //rect.Transform(matrix);
1053 2089959a taeseongkim
1054 c7fde400 taeseongkim
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1055
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1056
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1057
        //                double positionX = 0;
1058
        //                double positionY = 0;
1059 2089959a taeseongkim
1060 c7fde400 taeseongkim
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1061
        //                {
1062
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1063
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1064
        //                }
1065 2089959a taeseongkim
1066 c7fde400 taeseongkim
        //                main.zoomAndPanControl.ContentScale = newScale;
1067
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1068
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1069 2089959a taeseongkim
1070
              
1071 c7fde400 taeseongkim
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1072
1073
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1074
1075
        //                if (pageAngle == 90)
1076
        //                {
1077
        //                    pageAngle = 270;
1078
        //                }
1079
        //                else
1080
        //                {
1081
        //                    pageAngle = 90;
1082
        //                }
1083
1084
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1085
        //                {
1086
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1087
        //                    rect.Transform(matrix);
1088
1089
        //                    main.zoomAndPanControl.ZoomTo(rect);
1090
        //                }
1091
        //                else
1092
        //                {
1093
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1094
1095
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1096
        //                    rect.Transform(matrix);
1097
1098
1099
        //                    main.zoomAndPanControl.ZoomTo(rect);
1100
        //                }
1101
        //            }
1102
        //            catch (Exception ex)
1103
        //            {
1104
        //                main.DialogMessage_Alert(ex.Message, "Error");
1105
        //            }
1106
        //        }
1107
        //    }
1108
        //}
1109 2089959a taeseongkim
1110 39f0624f ljiyeon
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1111 787a4489 KangIngu
        {
1112
            if (MarkupInfoSmallList.Count == 0)
1113
            {
1114
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1115
                {
1116
                    if (d.MarkupList != null)
1117
                    {
1118
                        d.MarkupList.ForEach(b =>
1119
                        {
1120 eeb0a39c taeseongkim
                            bool isConsolidate = false;
1121
1122
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1123
                            {
1124
                                isConsolidate = true;
1125
                            }
1126
1127
                            System.Diagnostics.Debug.WriteLine($"UserID : {d.UserID} Consolidate : {d.Consolidate}  AvoidConsolidate : {d.AvoidConsolidate}");
1128
1129 787a4489 KangIngu
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1130
                            {
1131
                                Id = b.ID,
1132
                                Data = b.Data,
1133
                                Data_Type = b.Data_Type,
1134
                                PageNumber = b.PageNumber,
1135
                                UserID = d.UserID,
1136
                                UserName = d.UserName,
1137 eeb0a39c taeseongkim
                                IsConsolidate = isConsolidate
1138
1139 787a4489 KangIngu
                            });
1140
                        });
1141
                    }
1142
                });
1143 39f0624f ljiyeon
                MarkupList.ItemsSource = null;
1144
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1145 787a4489 KangIngu
1146 eeb0a39c taeseongkim
                FilterUpdate();
1147 787a4489 KangIngu
            }
1148
        }
1149
1150 39f0624f ljiyeon
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1151 4eb052e4 ljiyeon
        {
1152
            if (MarkupInfoSmallList.Count == 0)
1153
            {
1154
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1155
                {
1156
                    if (d.MarkupList != null)
1157
                    {
1158
                        d.MarkupList.ForEach(b =>
1159
                        {
1160
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1161
                            {
1162
                                Id = b.ID,
1163
                                Data = b.Data,
1164
                                Data_Type = b.Data_Type,
1165
                                PageNumber = b.PageNumber,
1166
                                UserID = d.UserID,
1167
                                UserName = d.UserName,
1168
                            });
1169
                        });
1170
                    }
1171
                });
1172 39f0624f ljiyeon
                MarkupList.ItemsSource = null;
1173
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1174 4eb052e4 ljiyeon
            }
1175
1176
            switch (eventType)
1177
            {
1178
                case Event_Type.Create:
1179
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1180
                    {
1181
                        Id = res.CommentID,
1182
                        Data = res.ConvertData,
1183
                        Data_Type = res.DATA_TYPE,
1184
                        PageNumber = CurrentPage.PageNumber,
1185
                        UserID = App.ViewInfo.UserID,
1186
                        UserName = App.UserName,
1187
                    });
1188
                    break;
1189
                case Event_Type.Delete:
1190
                    if(CommentID == null) //user information list delete btn
1191
                    {
1192
                        foreach (var delItem in item.MarkupList)
1193
                        {
1194
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1195
                        }
1196
                    }
1197
                    else //delete, cut, 
1198
                    {
1199
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1200
                    }                    
1201
                    break;
1202 39f0624f ljiyeon
                case Event_Type.Thumb://이동 회전
1203 4eb052e4 ljiyeon
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1204
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1205
                    {
1206
                        Id = res.CommentID,
1207
                        Data = res.ConvertData,
1208
                        Data_Type = res.DATA_TYPE,
1209
                        PageNumber = CurrentPage.PageNumber,
1210
                        UserID = App.ViewInfo.UserID,
1211
                        UserName = App.UserName,
1212
                    });
1213
                    break;
1214
                default:
1215
                    break;
1216
            }
1217
1218 39f0624f ljiyeon
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1219 4eb052e4 ljiyeon
1220 eeb0a39c taeseongkim
            bool IsConsolidation = false;
1221
            string UserId = null;
1222
1223
            if (commentUser.SelectedValue != null)
1224
            {
1225
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1226
                {
1227
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1228
                }
1229
                else
1230
                {
1231
                    IsConsolidation = true;
1232
                }
1233
            }
1234
1235
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1236
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1237
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1238 4eb052e4 ljiyeon
1239 eeb0a39c taeseongkim
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1240 39f0624f ljiyeon
1241 eeb0a39c taeseongkim
            FilterUpdate();
1242 4eb052e4 ljiyeon
        }
1243
1244 eeb0a39c taeseongkim
        private void FilterUpdate(string selectUser = null)
1245 787a4489 KangIngu
        {
1246 eeb0a39c taeseongkim
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1247 4eb052e4 ljiyeon
1248 eeb0a39c taeseongkim
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1249
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1250 0cda2a88 taeseongkim
1251 b2c6901f swate0609
1252 eeb0a39c taeseongkim
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1253
 
1254
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1255
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1256
1257
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1258
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1259
1260
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1261
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1262
1263
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1264
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1265
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1266 b2c6901f swate0609
        }
1267
1268 eeb0a39c taeseongkim
        
1269
1270
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1271 b2c6901f swate0609
        {
1272
            MarkupList.ItemsSource = null;
1273
            txtSearch.Text = string.Empty;
1274
1275
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1276
1277 eeb0a39c taeseongkim
            bool IsConsolidation = false;
1278
            string userName = null;
1279 4eb052e4 ljiyeon
1280 eeb0a39c taeseongkim
            if (commentUser.SelectedValue != null)
1281
            {
1282
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1283
                {
1284
                    userName = commentUser.SelectedValue.ToString();
1285
                }
1286
                else
1287
                {
1288
                    IsConsolidation = true;
1289
                }
1290
            }
1291 4eb052e4 ljiyeon
1292 eeb0a39c taeseongkim
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1293
                                   .WhereIf(userName != null, d => d.UserName == userName)
1294
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1295
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1296
1297
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1298
1299
            FilterUpdate();
1300 787a4489 KangIngu
        }
1301
1302
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1303
        {
1304
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1305
        }
1306 79f3f21a djkim
1307 ac4f1e13 taeseongkim
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1308 79f3f21a djkim
        {
1309 2089959a taeseongkim
            string search_str = txtSearch.Text;
1310
1311
            if(string.IsNullOrWhiteSpace(search_str))
1312
            {
1313
                return;
1314
            }
1315
1316 79f3f21a djkim
            var sel_type = commentType.SelectedItem;
1317
            var sel_user = commentUser.SelectedItem;
1318
            var sel_page = commentPage.SelectedItem;
1319
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1320
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1321 90e7968d ljiyeon
            if (sel_page != null)
1322 79f3f21a djkim
            {
1323
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1324
            }
1325 90e7968d ljiyeon
            if (sel_type != null)
1326 79f3f21a djkim
            {
1327
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1328
            }
1329
            if (sel_user != null)
1330
            {
1331
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1332
            }
1333
            foreach (var item in list)
1334
            {
1335 24c5e56c taeseongkim
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.CancellationToken());
1336 90e7968d ljiyeon
1337 79f3f21a djkim
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1338 90e7968d ljiyeon
                {
1339 79f3f21a djkim
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1340
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1341
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1342
                        {
1343
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1344 2089959a taeseongkim
1345
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1346 90e7968d ljiyeon
                            {
1347 2089959a taeseongkim
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1348
                                {
1349
                                    small_list.Add(item);
1350
                                }
1351 79f3f21a djkim
                            }
1352
                        }
1353
                        break;
1354
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1355
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1356
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1357
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1358
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1359
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1360
                        {
1361
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1362 2089959a taeseongkim
1363
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1364 79f3f21a djkim
                            {
1365 2089959a taeseongkim
                                if (instance.ArrowText.Contains(search_str))
1366
                                {
1367
                                    small_list.Add(item);
1368
                                }
1369 79f3f21a djkim
                            }
1370
                        }
1371
                        break;
1372
                }
1373
            }
1374 90e7968d ljiyeon
1375 39f0624f ljiyeon
            MarkupList.ItemsSource = null;
1376
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1377 2089959a taeseongkim
        }
1378
1379
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1380
        {
1381
            if(e.Key == Key.Enter || e.Key == Key.Return)
1382
            {
1383
                btnSearch_Click(sender, new RoutedEventArgs());
1384
            }
1385 79f3f21a djkim
        }
1386 6c687be8 taeseongkim
1387 787a4489 KangIngu
    }
1388
}
클립보드 이미지 추가 (최대 크기: 500 MB)