프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ e1c892f7

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

1
using IKCOM;
2
using KCOM.Common;
3
using KCOMDataModel.DataModel;
4
using MarkupToPDF.Common;
5
using MarkupToPDF.Controls.Parsing;
6
using System;
7
using System.Collections.Generic;
8
using System.Collections.ObjectModel;
9
using System.ComponentModel;
10
using System.Diagnostics;
11
using System.Linq;
12
using System.Threading;
13
using System.Threading.Tasks;
14
using System.Windows;
15
using System.Windows.Controls;
16
using System.Windows.Data;
17
using System.Windows.Input;
18
using System.Windows.Media;
19
using Telerik.Windows.Controls;
20
using static MarkupToPDF.Controls.Parsing.MarkupParser;
21

    
22
namespace KCOM.Controls
23
{
24
    /// <summary>
25
    /// Interaction logic for PageNavigator.xaml
26
    /// </summary>
27
    public partial class Sample : UserControl, INotifyPropertyChanged
28
    {
29
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
30
        public event PropertyChangedEventHandler PropertyChanged;
31
        public DelegateCommand SelectCommentCommand { get; private set; }
32

    
33
        //PageManager.PageStorage samplePageStorage;
34

    
35
        public Sample()
36
        {
37
            InitializeComponent();
38

    
39
            if (App.IsDesignMode)
40
            {
41
                return;
42
            }
43

    
44
            //App.splashString(ISplashMessage.SAMPLE);
45
            this.Loaded += Sample_Loaded;
46
            this.Unloaded += Sample_Unloaded;
47
        }
48

    
49
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
50
        {
51
          
52
        }
53

    
54
        private void Sample_Loaded(object sender, RoutedEventArgs e)
55
        {
56
            if(!_Initialize)
57
            {
58
                _Initialize = true;
59

    
60
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
61

    
62
                this.SizeChanged += Sample_SizeChanged;
63
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
64
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
65
            }            
66
        }
67

    
68
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
69
        {
70
            if(e.WidthChanged)
71
            {
72
                ImgListbox.UpdateLayout();
73
            }
74
        }
75

    
76
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample));
77
        public CollectionViewSource FilteredThumbnail
78
        {
79
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
80
            set { SetValue(FilteredThumbnailProperty, value); }
81
        }
82

    
83
        public static readonly DependencyProperty CurrentPageProperty 
84
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
85

    
86
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
87
        {
88
            //var owner = d as Sample;
89

    
90
            //if (owner?.UsersCommentPagesList != null)
91
            //{
92
            //    owner.SetCommentPages();
93
            //}
94
        }
95

    
96
        public ThumbnailItem CurrentPage
97
        {
98
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
99
            set { SetValue(CurrentPageProperty, value); }
100
        }
101

    
102
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
103
        private List<DOCPAGE> _PageList = null;
104
        private string _DefaultUri = null;
105
        public int PageCount = 0;
106
        private bool _Initialize;
107

    
108
        public event EventHandler<EventArgs> ThumbInitialized;
109
        public event EventHandler<PageChangeEventArgs> PageChanged;
110
        public event EventHandler<PageChangeEventArgs> PageChanging;
111

    
112
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
113

    
114
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
115
        {
116
            get {
117
                if(_UsersCommentPagesList == null)
118
                {
119
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
120
                }
121

    
122
                return _UsersCommentPagesList; }
123
            set { _UsersCommentPagesList = value; }
124
        }
125

    
126
        public class PageChangeEventArgs : EventArgs
127
        {
128
            public DOCPAGE CurrentPage { get; set; }
129
            public string PageUri { get; set; }
130
            public int PageNumber { get; set; }
131
        }
132
        private bool _IsFitOn { get; set; }
133
        public bool IsFitOn
134
        {
135
            get
136
            {
137
                return _IsFitOn;
138
            }
139
            set
140
            {
141
                _IsFitOn = value;
142
                RaisePropertyChanged("IsFitOn");
143
            }
144
        }
145

    
146
        public void RaisePropertyChanged(string propName)
147
        {
148
            if (PropertyChanged != null)
149
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
150
        }
151

    
152
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
153
        {
154
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
155
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
156

    
157
            this._PageList = PageList;
158
            this._DefaultUri = DefaultUri;
159

    
160
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
161

    
162
            //samplePageStorage = new PageManager.PageStorage(_DefaultUri, tempStoragePath,"jpg", _PageList.Count(), _PageList.Count());
163

    
164
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
165
            
166
            this.PageCount = PageList.Count();
167

    
168
            //ThumbNmailSet();
169
            
170
        }
171

    
172
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
173
        {
174
            Logger.sendCheckLog("rdoCommented_Checked", 1);
175
            SetCommentPages();
176
        }
177

    
178
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
179
        {
180
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
181
            //if (rdoFavoritePages.IsChecked == true)
182
            //    expCommentPages.IsExpanded = false;
183

    
184
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
185
            //if (_FavoriteSet.Count > 0)
186
            //{
187
            //    SetCommentPages(); //수정    
188
            //}
189
            //else
190
            //{
191
            //    rdoAllPages.IsChecked = true;
192
            //    rdoFavoritePages.IsChecked = false;
193
            //}
194
        }
195

    
196
        private async void ShowPageChange(object sender, RoutedEventArgs e)
197
        {
198
            if (_Initialize)
199
            {
200
                //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
201
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
202
            }
203
        }
204

    
205
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
206
        {
207
            //txtThumbCount.Visibility = Visibility.Collapsed;            
208
        }
209

    
210
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
211
        {
212
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
213
            rdoAllPages.IsChecked = false;
214
            rdoFavoritePages.IsChecked = false;
215
            //txtThumbCount.Visibility = Visibility.Visible;
216
            SetCommentPages();
217
        }
218

    
219
        /// <summary>
220
        /// called when image list box's selection is changed
221
        /// </summary>
222
        /// <param name="sender"></param>
223
        /// <param name="e"></param>
224
        private async void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
225
        {
226
            if(e.AddedItems.Count > 0)
227
            {
228
                await ImgListbox.Dispatcher.InvokeAsync(() =>
229
                {
230
                    var number = (e.AddedItems[0] as KCOM.Common.ThumbnailItem).PageNumber;
231

    
232
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
233

    
234
                    this.CurrentPage = e.AddedItems[0] as KCOM.Common.ThumbnailItem;
235

    
236
                    PageChanging(this, new PageChangeEventArgs
237
                    {
238
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
239
                        PageNumber = number,
240
                        PageUri = null
241
                    });
242

    
243
                });
244
            }
245
            
246

    
247
            //if (ImgListbox.SelectedItem != null)
248
            //{
249
            //    int _CurrentPageNo = -1;
250
            //    if (this.CurrentPage != null)
251
            //    {
252
            //        ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
253

    
254
            //        _CurrentPageNo = this.CurrentPage.PageNumber;
255
            //    }
256

    
257
            //    this.CurrentPage = ImgListbox.SelectedItem as ThumbnailItem;
258
            //    int iPageNo = this.CurrentPage.PageNumber;
259
            //    if(_CurrentPageNo != iPageNo)
260
            //    {
261
            //        PageChanging(this, new PageChangeEventArgs
262
            //        {
263
            //            CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
264
            //            PageNumber = iPageNo,
265
            //            PageUri = null
266
            //        });
267
            //    }
268
            //}
269

    
270
            //var border = VisualTreeHelper.GetChild(ImgListbox, 0);
271
            //if (border != null)
272
            //{
273
            //    IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
274

    
275
            //}
276
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
277

    
278
            
279
            //System.Diagnostics.Debug.WriteLine("page:"+ImgListbox.SelectedIndex);
280
        }
281

    
282
        public bool GotoPageFlag = false;
283

    
284
        /// <summary>
285
        /// 해당 썸네일로 이동
286
        /// </summary>
287
        /// <param name="_pageNumber">이동할 페이지 번호</param>
288
        public void GotoPage(int _pageNumber)
289
        {
290
            try
291
            {
292
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
293

    
294
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
295
                    if (_page.Count() > 0)
296
                    {
297
                        ThumbnailItem thumbnailitem = _page.First();
298
                        if (PageChanging != null)
299
                        {
300

    
301
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
302
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
303
                                ImgListbox.SelectedItem = thumbnailitem;
304
                            });
305
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
306
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
307
                            //    ImgListbox.ScrollIntoView(_itemIndex);
308
                            //else
309
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
310
                        }
311
                    }
312

    
313
                }).ConfigureAwait(true);
314
            }
315
            catch(Exception ex)
316
            {
317
                Logger.sendResLog("GotoPage", ex.Message, 0);
318
            }
319
        }
320

    
321
        /// <summary>
322
        /// 주어진 페이지로 변경한다
323
        /// </summary>
324
        /// <param name="iPageNo">변경할 페이지 번호</param>
325
        public void ChangePage(int iPageNo)
326
        {
327
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
328
            if ((PageChanged != null) && (thumbitem != null))
329
            {
330
                var uri = thumbitem.PageUri.ToString();
331
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
332

    
333
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
334
                if (_DocPages != null)
335
                {
336
                    PageChanged(this, new PageChangeEventArgs
337
                    {
338
                        CurrentPage = _DocPages,
339
                        PageUri = uri,
340
                        PageNumber = thumbitem.PageNumber
341
                    });
342
                    //ImgListbox.SelectedItem = thumbitem;                    
343
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
344
                    
345
                    this.CurrentPage = thumbitem;
346
                }
347
                else
348
                {
349
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
350
                }
351
            }
352
        }
353

    
354
        public void GotoPageTALK(int _pageNumber, int _angle)
355
        {
356
            int _PageNo = -1;
357

    
358
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
359
            {
360
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
361
                if (_page.Count() > 0)
362
                {
363
                    ThumbnailItem _item = _page.First();
364
                    setPageChangeTALK(_item, _angle);
365
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
366
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
367
                }
368
            }
369
        }
370

    
371
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
372
        {
373
            if (thumbnailItem != null)
374
            {
375
                if (PageChanging != null)
376
                {
377
                    ///this.CurrentPage = _NextPage;
378
                    ///_NextPage = thumbnailItem;
379
                    PageChanging(this, new PageChangeEventArgs
380
                    {
381
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
382
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
383
                        PageUri = null
384
                    });
385

    
386
                    var instanceMain = this.ParentOfType<MainWindow>();
387

    
388
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
389

    
390
                    if (rotationNum > 0) // 1, 2, 3
391
                    {
392
                        for (int i = 0; i < rotationNum; i++)
393
                        {
394
                            drawingPannelRotate(true);
395
                        }
396
                    }
397
                    else if (rotationNum < 0)// -1, -2, -3
398
                    {
399
                        for (int i = 0; i < -rotationNum; i++)
400
                        {
401
                            drawingPannelRotate(false);
402
                        }
403
                    }
404
                }
405
            }
406
        }
407

    
408
        public void drawingPannelRotate(bool Flag)
409
        {
410
            var instanceMain = this.ParentOfType<MainWindow>();
411

    
412
            if (Flag)
413
            {
414
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
415
                {
416
                    instanceMain.dzMainMenu.rotate.Angle = 0;
417
                }
418
                else
419
                {
420
                    instanceMain.dzMainMenu.rotate.Angle += 90;
421
                }
422
            }
423
            else
424
            {
425
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
426
                {
427
                    instanceMain.dzMainMenu.rotate.Angle = 270;
428
                }
429
                else
430
                {
431
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
432
                }
433
            }
434

    
435
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
436
            {
437
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
438
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
439
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
440
            }
441

    
442
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
443
            {
444
                instanceMain.dzMainMenu.translate.X = 0;
445
                instanceMain.dzMainMenu.translate.Y = 0;
446
            }
447
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
448
            {
449
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
450
                instanceMain.dzMainMenu.translate.Y = 0;
451
            }
452
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
453
            {
454
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
455
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
456
            }
457
            else
458
            {
459
                instanceMain.dzMainMenu.translate.X = 0;
460
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
461
            }
462

    
463
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
464
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
465
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
466
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
467
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
468
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
469

    
470
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
471
            {
472
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
473

    
474
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
475
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
476
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
477

    
478
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
479
                if (rotationdoc != null)
480
                {
481
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
482
                }
483
                else
484
                {
485
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
486
                }
487
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
488
            });
489
        }
490

    
491
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
492
        {
493
            SetCommentPages();
494
        }
495

    
496
        public async void SetCommentPages(object obj = null)
497
        {
498
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
499
        }
500

    
501
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
502
        {
503
            Logger.sendCheckLog("SetCommentList", 1);
504
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
505
            #region 기존 색상 제거 작업
506

    
507
            foreach (var item in this._thumbnailItems)
508
            {
509
                if (item.DisplayColorItems != null)
510
                {
511
                    item.DisplayColorItems.Clear();
512
                }
513
            }
514
            #endregion
515

    
516
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
517
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
518

    
519
            this.UsersCommentPagesList.ToList().ForEach(item =>
520
            {
521
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
522

    
523
                if (_comm.Count() == 0)
524
                {
525
                    _delItem.Add(item);
526
                }
527
            });
528

    
529
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
530

    
531
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
532
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
533

    
534
            UsersCommentPagesList.ForEach(user =>
535
            {
536
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
537
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
538

    
539
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
540

    
541
                if (_commLst.Count() == 0)
542
                {
543
                    this.UsersCommentPagesList.Add(user);
544
                }
545
                else
546
                {
547
                    if (_commLst.First().PageNumber != user.PageNumber)
548
                        _commLst.First().PageNumber = user.PageNumber;
549
                }
550

    
551
                user.PageNumber.ForEach(page =>
552
                {
553
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
554

    
555
                    if (_items.Count() > 0)
556
                    {
557
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
558
                        
559
                    }
560
                        
561
                });
562
            });
563

    
564
            foreach (var item in this._thumbnailItems)
565
            {
566
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
567
            }
568

    
569
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
570
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
571

    
572
            if (data.Count() != 0)
573
            {
574
                if (Convert.ToBoolean(data.First().isConSolidation))
575
                {
576
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
577
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
578
                    this.lstSelectComment.ItemsSource = data;
579
                }
580
            }
581

    
582
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
583

    
584
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
585

    
586

    
587
            //var template = this.ImgListbox.ItemTemplate;
588
            //this.ImgListbox.ItemTemplate = null;
589
            //this.ImgListbox.ItemTemplate = template;
590

    
591
        }
592

    
593
        List<int> FilterPages = null;
594

    
595
        private void ThumbnailSetAsync()
596
        {
597
            Logger.sendCheckLog("ThumbnailSet", 1);
598

    
599
            if (FilteredThumbnail == null)
600
            {
601
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
602

    
603
                var pageList = ViewerDataModel.Instance.Document_Info;
604

    
605
                var items = from page in pageList
606
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
607
                            select new ThumbnailItem
608
                            {
609
                                ImageUri = new Uri(pageLink),
610
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
611
                                PageNumber = page.PAGE_NUMBER,
612
                                Angle = page.PAGE_ANGLE
613
                            };
614

    
615
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
616
                FilteredThumbnail = new CollectionViewSource();
617
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
618

    
619
                FilteredThumbnail.Source = _thumbnailItems;
620

    
621
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
622

    
623
                FilteredThumbnail.Filter += (snd,evt) =>
624
                {
625
                    if (FilterPages?.Count() > 0 && evt.Item != null)
626
                    {
627
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
628
                    }
629
                    else
630
                    {
631
                        evt.Accepted = false;
632
                    }
633
                };
634

    
635
            }
636

    
637
            FilterPages.Clear();
638

    
639

    
640
            if (rdoAllPages.IsChecked == true)
641
            {
642
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
643
            }
644
            else if (rdoFavoritePages.IsChecked == true)
645
            {
646
                if (_FavoriteSet != null)
647
                {
648
                    FilterPages = (from thumb in _thumbnailItems
649
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
650
                                select thumb.PageNumber).ToList();
651
                }
652
            }
653
            else if (rdoCommentPages.IsChecked == true)
654
            {
655
                if (this.lstSelectComment.ItemsSource != null)
656
                {
657
                    var commentPages = (from commentPage in this.UsersCommentPagesList
658
                                        where commentPage.IsSelected == true
659
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
660

    
661
                    if (commentPages?.Count() > 0)
662
                    {
663
                        FilterPages = (from thumb in _thumbnailItems
664
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
665
                                       select thumb.PageNumber).ToList();
666
                    }
667
                }
668
            }
669

    
670
            if (FilterPages != null)
671
            {
672
                FilteredThumbnail.View.Refresh();
673

    
674
                if (FilterPages.Count() > 0)
675
                {
676
                    ImgListbox.SelectedItem = _thumbnailItems.Where(x=>x.PageNumber == FilterPages.FirstOrDefault()).FirstOrDefault();
677
                    //SetCommentList(UsersCommentPagesList.ToList());
678
                }
679
                else
680
                {
681
                    ImgListbox.SelectedItem = null;
682
                }
683

    
684
                if (ThumbInitialized != null)
685
                {
686
                    ThumbInitialized(this, new EventArgs());
687
                    ThumbInitialized = null;
688
                }
689
            }
690
        }
691

    
692
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
693
        {
694
            if (e.ClickCount >= 2)
695
            {
696
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
697

    
698
                GotoPage(selectItem.PageNumber);
699

    
700
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data);
701

    
702
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
703
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
704
                //bool isGO = false;
705

    
706
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
707
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
708
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
709
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
710
                //{
711
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
712
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
713
                //    {
714
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
715
                //    }
716

    
717
                //};
718
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
719

    
720
                //GotoPage(MarkupList.SelectedItem as MarkupList)
721
            }
722
        }
723

    
724
        public class MarkupInfoItemSmall
725
        {
726
            public string Id { get; set; }
727
            public string UserName { get; set; }
728
            public string UserID { get; set; }
729
            public int PageNumber { get; set; }
730
            public string Data { get; set; }
731
            public int Data_Type { get; set; }
732
            public bool IsConsolidate { get; set; }
733
        }
734

    
735
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
736
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
737
        {
738
            get
739
            {
740
                if (_MarkupInfoSmallList == null)
741
                {
742
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
743
                }
744
                return _MarkupInfoSmallList;
745
            }
746
            set
747
            {
748

    
749
                _MarkupInfoSmallList = value;
750
                RaisePropertyChanged("MarkupInfoSmallList");
751
            }
752
        }
753

    
754
        /// <summary>
755
        /// goto page and select item selected by user
756
        /// </summary>
757
        /// <param name="sender"></param>
758
        /// <param name="e"></param>
759
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
760
        {
761
            var clickButtonItem = sender as RadButton;
762
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
763
            {
764
                try
765
                {
766
                    Rect rect = new Rect();
767
                    Point s_point = new Point();
768
                    Point e_point = new Point();
769

    
770
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
771
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
772

    
773
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString()); //언패킹작업
774
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
775
                    {
776
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
777
                            {
778
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
779
                                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));
780
                            }
781
                            break;
782
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
783
                            {
784
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
785
                                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));
786
                            }
787
                            break;
788
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
789
                            {
790
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
791
                                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));
792
                            }
793
                            break;
794
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
795
                            {
796
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
797

    
798
                                foreach (Point A in instance.PointSet)
799
                                {
800
                                    if (s_point == new Point())
801
                                    {
802
                                        s_point = A;
803
                                        e_point = A;
804
                                    }
805
                                    s_point.X = Math.Min(s_point.X, A.X);
806
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
807
                                    e_point.X = Math.Max(e_point.X, A.X);
808
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
809
                                }
810
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
811
                            }
812
                            break;
813
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
814
                            {
815
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
816

    
817
                                foreach (Point A in instance.PointSet)
818
                                {
819
                                    if (s_point == new Point())
820
                                    {
821
                                        s_point = A;
822
                                        e_point = A;
823
                                    }
824
                                    s_point.X = Math.Min(s_point.X, A.X);
825
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
826
                                    e_point.X = Math.Max(e_point.X, A.X);
827
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
828
                                }
829
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
830
                            }
831
                            break;
832
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
833
                            {
834
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
835

    
836
                                foreach (Point A in instance.PointSet)
837
                                {
838
                                    if (s_point == new Point())
839
                                    {
840
                                        s_point = A;
841
                                        e_point = A;
842
                                    }
843
                                    s_point.X = Math.Min(s_point.X, A.X);
844
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
845
                                    e_point.X = Math.Max(e_point.X, A.X);
846
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
847
                                }
848
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
849
                            }
850
                            break;
851
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
852
                            {
853
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
854

    
855
                                foreach (Point A in instance.PointSet)
856
                                {
857
                                    if (s_point == new Point())
858
                                    {
859
                                        s_point = A;
860
                                        e_point = A;
861
                                    }
862
                                    s_point.X = Math.Min(s_point.X, A.X);
863
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
864
                                    e_point.X = Math.Max(e_point.X, A.X);
865
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
866
                                }
867
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
868
                            }
869
                            break;
870
                        default:
871
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
872
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
873
                            break;
874
                    }
875

    
876
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
877
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
878
                }
879
                catch (Exception ex)
880
                {
881
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
882
                }
883
            }
884
        }
885

    
886

    
887
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
888
        {
889
            var clickButtonItem = sender as RadButton;
890
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
891
            {
892
                try
893
                {
894
             
895

    
896
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
897
                    MarkupList.SelectedItem = gaza;
898

    
899
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
900
                }
901
                catch (Exception ex)
902
                {
903
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
904
                }
905
            }
906
        }
907

    
908
        ///// <summary>
909
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
910
        ///// </summary>
911
        ///// <param name="CommentIdList"></param>
912
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
913
        //{
914
        //    var instance = Common.ViewerDataModel.Instance;
915

    
916
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
917

    
918
        //    var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
919

    
920
        //    if (commentList.Count() > 0)
921
        //    {
922
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
923
        //        #region markup list grid select items
924

    
925
        //        var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
926

    
927
        //        if (infoItem.Count() > 0)
928
        //        {
929

    
930
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
931
        //            gridMarkup.SelectedItems.Clear();
932
        //            gridMarkup.SelectedItems.Add(infoItem.First());
933
        //        }
934

    
935
        //        #endregion
936

    
937
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
938

    
939
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
940
        //        {
941
        //            GotoSelectedMarkup(CommentIdList);
942
        //        }
943
        //        else
944
        //        {
945
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
946

    
947
        //            handler = (snd, evt) =>
948
        //            {
949
        //                GotoSelectedMarkup(CommentIdList);
950
        //                pageNavigator.PageChanged -= handler;
951
        //            };
952

    
953
        //            pageNavigator.PageChanged += handler;
954

    
955
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
956
        //        }
957
        //    }
958
        //}
959

    
960
        ///// <summary>
961
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
962
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
963
        ///// </summary>
964
        ///// <param name="CommentIdList"></param>
965
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
966
        //{
967
        //    var instance = Common.ViewerDataModel.Instance;
968

    
969
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
970
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
971

    
972
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
973
        //    {
974
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
975
        //        commentUserInfo.AddRange(selectOrderComments);
976

    
977
        //        if (commentUserInfo?.Count() > 0)
978
        //        {
979
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
980

    
981
        //            try
982
        //            {
983
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
984
        //                {
985
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
986
        //                    {
987
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
988
        //                    } 
989
                            
990
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
991
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
992
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
993
        //                }
994

    
995
        //                Rect rect = commentUserInfo.First().ItemRect;
996

    
997
        //                foreach (var UserInfo in commentUserInfo)
998
        //                {
999
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1000
        //                }
1001

    
1002
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1003

    
1004
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1005
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1006
        //                //rect.Transform(matrix);
1007

    
1008
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1009
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1010
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1011
        //                double positionX = 0;
1012
        //                double positionY = 0;
1013

    
1014
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1015
        //                {
1016
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1017
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1018
        //                }
1019

    
1020
        //                main.zoomAndPanControl.ContentScale = newScale;
1021
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1022
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1023

    
1024
              
1025
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1026

    
1027
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1028

    
1029
        //                if (pageAngle == 90)
1030
        //                {
1031
        //                    pageAngle = 270;
1032
        //                }
1033
        //                else
1034
        //                {
1035
        //                    pageAngle = 90;
1036
        //                }
1037

    
1038
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1039
        //                {
1040
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1041
        //                    rect.Transform(matrix);
1042

    
1043
        //                    main.zoomAndPanControl.ZoomTo(rect);
1044
        //                }
1045
        //                else
1046
        //                {
1047
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1048

    
1049
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1050
        //                    rect.Transform(matrix);
1051

    
1052

    
1053
        //                    main.zoomAndPanControl.ZoomTo(rect);
1054
        //                }
1055
        //            }
1056
        //            catch (Exception ex)
1057
        //            {
1058
        //                main.DialogMessage_Alert(ex.Message, "Error");
1059
        //            }
1060
        //        }
1061
        //    }
1062
        //}
1063

    
1064
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1065
        {
1066
            if (MarkupInfoSmallList.Count == 0)
1067
            {
1068
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1069
                {
1070
                    if (d.MarkupList != null)
1071
                    {
1072
                        d.MarkupList.ForEach(b =>
1073
                        {
1074
                            bool isConsolidate = false;
1075

    
1076
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1077
                            {
1078
                                isConsolidate = true;
1079
                            }
1080

    
1081
                            System.Diagnostics.Debug.WriteLine($"UserID : {d.UserID} Consolidate : {d.Consolidate}  AvoidConsolidate : {d.AvoidConsolidate}");
1082

    
1083
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1084
                            {
1085
                                Id = b.ID,
1086
                                Data = b.Data,
1087
                                Data_Type = b.Data_Type,
1088
                                PageNumber = b.PageNumber,
1089
                                UserID = d.UserID,
1090
                                UserName = d.UserName,
1091
                                IsConsolidate = isConsolidate
1092

    
1093
                            });
1094
                        });
1095
                    }
1096
                });
1097
                MarkupList.ItemsSource = null;
1098
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1099

    
1100
                FilterUpdate();
1101
            }
1102
        }
1103

    
1104
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1105
        {
1106
            if (MarkupInfoSmallList.Count == 0)
1107
            {
1108
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1109
                {
1110
                    if (d.MarkupList != null)
1111
                    {
1112
                        d.MarkupList.ForEach(b =>
1113
                        {
1114
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1115
                            {
1116
                                Id = b.ID,
1117
                                Data = b.Data,
1118
                                Data_Type = b.Data_Type,
1119
                                PageNumber = b.PageNumber,
1120
                                UserID = d.UserID,
1121
                                UserName = d.UserName,
1122
                            });
1123
                        });
1124
                    }
1125
                });
1126
                MarkupList.ItemsSource = null;
1127
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1128
            }
1129

    
1130
            switch (eventType)
1131
            {
1132
                case Event_Type.Create:
1133
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1134
                    {
1135
                        Id = res.CommentID,
1136
                        Data = res.ConvertData,
1137
                        Data_Type = res.DATA_TYPE,
1138
                        PageNumber = CurrentPage.PageNumber,
1139
                        UserID = App.ViewInfo.UserID,
1140
                        UserName = App.UserName,
1141
                    });
1142
                    break;
1143
                case Event_Type.Delete:
1144
                    if(CommentID == null) //user information list delete btn
1145
                    {
1146
                        foreach (var delItem in item.MarkupList)
1147
                        {
1148
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1149
                        }
1150
                    }
1151
                    else //delete, cut, 
1152
                    {
1153
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1154
                    }                    
1155
                    break;
1156
                case Event_Type.Thumb://이동 회전
1157
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1158
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1159
                    {
1160
                        Id = res.CommentID,
1161
                        Data = res.ConvertData,
1162
                        Data_Type = res.DATA_TYPE,
1163
                        PageNumber = CurrentPage.PageNumber,
1164
                        UserID = App.ViewInfo.UserID,
1165
                        UserName = App.UserName,
1166
                    });
1167
                    break;
1168
                default:
1169
                    break;
1170
            }
1171

    
1172
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1173

    
1174
            bool IsConsolidation = false;
1175
            string UserId = null;
1176

    
1177
            if (commentUser.SelectedValue != null)
1178
            {
1179
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1180
                {
1181
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1182
                }
1183
                else
1184
                {
1185
                    IsConsolidation = true;
1186
                }
1187
            }
1188

    
1189
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1190
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1191
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1192

    
1193
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1194

    
1195
            FilterUpdate();
1196
        }
1197

    
1198
        private void FilterUpdate(string selectUser = null)
1199
        {
1200
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1201

    
1202
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1203
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1204

    
1205

    
1206
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1207
 
1208
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1209
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1210

    
1211
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1212
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1213

    
1214
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1215
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1216

    
1217
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1218
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1219
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1220
        }
1221

    
1222
        
1223

    
1224
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1225
        {
1226
            MarkupList.ItemsSource = null;
1227
            txtSearch.Text = string.Empty;
1228

    
1229
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1230

    
1231
            bool IsConsolidation = false;
1232
            string userName = null;
1233

    
1234
            if (commentUser.SelectedValue != null)
1235
            {
1236
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1237
                {
1238
                    userName = commentUser.SelectedValue.ToString();
1239
                }
1240
                else
1241
                {
1242
                    IsConsolidation = true;
1243
                }
1244
            }
1245

    
1246
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1247
                                   .WhereIf(userName != null, d => d.UserName == userName)
1248
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1249
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1250

    
1251
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1252

    
1253
            FilterUpdate();
1254
        }
1255

    
1256
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1257
        {
1258
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1259
        }
1260

    
1261
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1262
        {
1263
            string search_str = txtSearch.Text;
1264

    
1265
            if(string.IsNullOrWhiteSpace(search_str))
1266
            {
1267
                return;
1268
            }
1269

    
1270
            var sel_type = commentType.SelectedItem;
1271
            var sel_user = commentUser.SelectedItem;
1272
            var sel_page = commentPage.SelectedItem;
1273
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1274
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1275
            if (sel_page != null)
1276
            {
1277
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1278
            }
1279
            if (sel_type != null)
1280
            {
1281
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1282
            }
1283
            if (sel_user != null)
1284
            {
1285
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1286
            }
1287
            foreach (var item in list)
1288
            {
1289
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString());
1290

    
1291
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1292
                {
1293
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1294
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1295
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1296
                        {
1297
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1298

    
1299
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1300
                            {
1301
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1302
                                {
1303
                                    small_list.Add(item);
1304
                                }
1305
                            }
1306
                        }
1307
                        break;
1308
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1309
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1310
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1311
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1312
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1313
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1314
                        {
1315
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1316

    
1317
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1318
                            {
1319
                                if (instance.ArrowText.Contains(search_str))
1320
                                {
1321
                                    small_list.Add(item);
1322
                                }
1323
                            }
1324
                        }
1325
                        break;
1326
                }
1327
            }
1328

    
1329
            MarkupList.ItemsSource = null;
1330
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1331
        }
1332

    
1333
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1334
        {
1335
            if(e.Key == Key.Enter || e.Key == Key.Return)
1336
            {
1337
                btnSearch_Click(sender, new RoutedEventArgs());
1338
            }
1339
        }
1340

    
1341
    }
1342
}
클립보드 이미지 추가 (최대 크기: 500 MB)