프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 9d5b4bc2

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

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

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

    
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
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
60

    
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
                this.ImgListbox.PreviewKeyUp += ImgListbox_PreviewKeyUp;
66

    
67

    
68
            }            
69
        }
70

    
71
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
72
        {
73
            if (e.WidthChanged)
74
            {
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
        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

    
111
        public event EventHandler<EventArgs> ThumbInitialized;
112
        public event EventHandler<PageChangeEventArgs> PageChanged;
113
        public event EventHandler<PageChangeEventArgs> PageChanging;
114

    
115
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
116

    
117
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
118
        {
119
            get {
120
                if(_UsersCommentPagesList == null)
121
                {
122
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
123
                }
124

    
125
                return _UsersCommentPagesList; }
126
            set { _UsersCommentPagesList = value; }
127
        }
128

    
129
        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
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
156
        {
157
            App.splashString(ISplashMessage.SAMPLE);
158
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
159
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
160

    
161
            this._PageList = PageList;
162
            this._DefaultUri = DefaultUri;
163

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

    
166
            
167
            //ThumbnailSetAsync();
168
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
169

    
170
            this.PageCount = PageList.Count();
171

    
172
            string endpoint = Common.Commons.shortGuid() + "Thumbnail";
173

    
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
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath);
180

    
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
        }
196

    
197
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
198
        {
199
            Logger.sendCheckLog("rdoCommented_Checked", 1);
200
            SetCommentPages();
201
        }
202

    
203
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
204
        {
205
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
206
            //if (rdoFavoritePages.IsChecked == true)
207
            //    expCommentPages.IsExpanded = false;
208

    
209
            //_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
        }
220

    
221
        private async void ShowPageChange(object sender, RoutedEventArgs e)
222
        {
223
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
224
            if (IsInitialized)
225
            {
226
                //ThumbnailSetAsync();
227
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
228
            }
229
        }
230

    
231
        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
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
239
            rdoAllPages.IsChecked = false;
240
            rdoFavoritePages.IsChecked = false;
241
            //txtThumbCount.Visibility = Visibility.Visible;
242
            SetCommentPages();
243
        }
244

    
245
        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
        /// <summary>
256
        /// called when image list box's selection is changed
257
        /// </summary>
258
        /// <param name="sender"></param>
259
        /// <param name="e"></param>
260
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
261
        {
262
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
263
            {
264
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
265
            }
266
        }
267

    
268
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
269
        { 
270
                var number = selectItem.PageNumber;
271

    
272
                if (ViewerDataModel.Instance.PageNumber != number)
273
                {
274
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
275

    
276
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
277

    
278
                    PageChanging(this, new PageChangeEventArgs
279
                    {
280
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
281
                        PageNumber = number,
282
                        PageUri = null
283
                    });
284
                }
285
        }
286

    
287
        public bool GotoPageFlag = false;
288

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

    
299
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
300
                    if (_page.Count() > 0)
301
                    {
302
                        ThumbnailItem thumbnailitem = _page.First();
303
                        if (PageChanging != null)
304
                        {
305

    
306
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
307
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
308
                                ImgListbox.SelectedItem = thumbnailitem;
309
                            });
310
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
311
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
312
                            //    ImgListbox.ScrollIntoView(_itemIndex);
313
                            //else
314
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
315
                        }
316
                    }
317

    
318
                }).ConfigureAwait(true);
319
            }
320
            catch(Exception ex)
321
            {
322
                Logger.sendResLog("GotoPage", ex.Message, 0);
323
            }
324
        }
325

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

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

    
359
        public void GotoPageTALK(int _pageNumber, int _angle)
360
        {
361
            int _PageNo = -1;
362

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

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

    
391
                    var instanceMain = this.ParentOfType<MainWindow>();
392

    
393
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
394

    
395
                    if (rotationNum > 0) // 1, 2, 3
396
                    {
397
                        for (int i = 0; i < rotationNum; i++)
398
                        {
399
                            drawingPannelRotate(true);
400
                        }
401
                    }
402
                    else if (rotationNum < 0)// -1, -2, -3
403
                    {
404
                        for (int i = 0; i < -rotationNum; i++)
405
                        {
406
                            drawingPannelRotate(false);
407
                        }
408
                    }
409
                }
410
            }
411
        }
412

    
413
        public void drawingPannelRotate(bool Flag)
414
        {
415
            var instanceMain = this.ParentOfType<MainWindow>();
416

    
417
            if (Flag)
418
            {
419
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
420
                {
421
                    instanceMain.dzMainMenu.rotate.Angle = 0;
422
                }
423
                else
424
                {
425
                    instanceMain.dzMainMenu.rotate.Angle += 90;
426
                }
427
            }
428
            else
429
            {
430
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
431
                {
432
                    instanceMain.dzMainMenu.rotate.Angle = 270;
433
                }
434
                else
435
                {
436
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
437
                }
438
            }
439

    
440
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
441
            {
442
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
443
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
444
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
445
            }
446

    
447
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
448
            {
449
                instanceMain.dzMainMenu.translate.X = 0;
450
                instanceMain.dzMainMenu.translate.Y = 0;
451
            }
452
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
453
            {
454
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
455
                instanceMain.dzMainMenu.translate.Y = 0;
456
            }
457
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
458
            {
459
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
460
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
461
            }
462
            else
463
            {
464
                instanceMain.dzMainMenu.translate.X = 0;
465
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
466
            }
467

    
468
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
469
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
470
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
471
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
472
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
473
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
474

    
475
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
476
            {
477
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
478

    
479
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
480
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
481
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
482

    
483
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
484
                if (rotationdoc != null)
485
                {
486
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
487
                }
488
                else
489
                {
490
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
491
                }
492
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
493
            });
494
        }
495

    
496
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
497
        {
498
            SetCommentPages();
499
        }
500

    
501
        public async void SetCommentPages(object obj = null)
502
        {
503
            //ThumbnailSetAsync();
504
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
505
        }
506

    
507
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
508
        {
509
            Logger.sendCheckLog("SetCommentList", 1);
510
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
511
            #region 기존 색상 제거 작업
512

    
513
            foreach (var item in this._thumbnailItems)
514
            {
515
                if (item.DisplayColorItems != null)
516
                {
517
                    item.DisplayColorItems.Clear();
518
                }
519
            }
520
            #endregion
521

    
522
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
523
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
524

    
525
            this.UsersCommentPagesList.ToList().ForEach(item =>
526
            {
527
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
528

    
529
                if (_comm.Count() == 0)
530
                {
531
                    _delItem.Add(item);
532
                }
533

    
534
                if (cts != null)
535
                {
536
                    if (cts.Value.IsCancellationRequested)
537
                        return;
538
                }
539
            });
540

    
541
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
542

    
543
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
544
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
545

    
546
            UsersCommentPagesList.ForEach(user =>
547
            {
548
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
549
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
550

    
551
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
552

    
553
                if (_commLst.Count() == 0)
554
                {
555
                    this.UsersCommentPagesList.Add(user);
556
                }
557
                else
558
                {
559
                    if (_commLst.First().PageNumber != user.PageNumber)
560
                        _commLst.First().PageNumber = user.PageNumber;
561
                }
562

    
563
                user.PageNumber.ForEach(page =>
564
                {
565
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
566

    
567
                    if (_items.Count() > 0)
568
                    {
569
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
570
                        
571
                    }
572

    
573
                    if (cts != null)
574
                    {
575
                        if (cts.Value.IsCancellationRequested)
576
                            return;
577
                    }
578
                });
579
            });
580

    
581
            foreach (var item in this._thumbnailItems)
582
            {
583
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
584
            }
585

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

    
589
            if (data.Count() != 0)
590
            {
591
                if (Convert.ToBoolean(data.First().isConSolidation))
592
                {
593
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
594
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
595
                    this.lstSelectComment.ItemsSource = data;
596
                }
597
            }
598

    
599
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
600

    
601
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
602

    
603

    
604
            //var template = this.ImgListbox.ItemTemplate;
605
            //this.ImgListbox.ItemTemplate = null;
606
            //this.ImgListbox.ItemTemplate = template;
607

    
608
        }
609

    
610
        List<int> FilterPages = null;
611

    
612
        private void ThumbnailSetAsync()
613
        {
614
            Logger.sendCheckLog("ThumbnailSet", 1);
615

    
616
            if (FilteredThumbnail == null)
617
            {
618
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
619

    
620
                var pageList = ViewerDataModel.Instance.Document_Info;
621

    
622
                var items = from page in pageList
623
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
624
                            select new ThumbnailItem
625
                            {
626
                                //ImageUri = new Uri(pageLink),
627
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
628
                                PageNumber = page.PAGE_NUMBER,
629
                                Angle = page.PAGE_ANGLE
630
                            };
631

    
632
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
633
                FilteredThumbnail = new CollectionViewSource();
634
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
635

    
636
                FilteredThumbnail.Source = _thumbnailItems;
637

    
638
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
639
                  {
640
                      System.Diagnostics.Debug.WriteLine("ect");
641
                  };
642

    
643
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
644

    
645
                FilteredThumbnail.Filter += (snd, evt) =>
646
                {
647
                    if (FilterPages?.Count() > 0 && evt.Item != null)
648
                    {
649
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
650
                    }
651
                    else
652
                    {
653
                        evt.Accepted = false;
654
                    }
655
                };
656

    
657
            }
658

    
659
            FilterPages.Clear();
660

    
661
            if (rdoAllPages.IsChecked == true)
662
            {
663
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
664
            }
665
            else if (rdoFavoritePages.IsChecked == true)
666
            {
667
                if (_FavoriteSet != null)
668
                {
669
                    FilterPages = (from thumb in _thumbnailItems
670
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
671
                                select thumb.PageNumber).ToList();
672
                }
673
            }
674
            else if (rdoCommentPages.IsChecked == true)
675
            {
676
                if (this.lstSelectComment.ItemsSource != null)
677
                {
678
                    var commentPages = (from commentPage in this.UsersCommentPagesList
679
                                        where commentPage.IsSelected == true
680
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
681

    
682
                    if (commentPages?.Count() > 0)
683
                    {
684
                        FilterPages = (from thumb in _thumbnailItems
685
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
686
                                       select thumb.PageNumber).ToList();
687
                    }
688
                }
689
            }
690

    
691
            if (FilterPages != null)
692
            {
693
                FilteredThumbnail.View.Refresh();
694

    
695
                if (FilterPages.Count() > 0)
696
                {
697
                    if (_thumbnailItems.Count() > 0)
698
                    {
699
                        ImgListbox.SelectedItem = _thumbnailItems[0];
700
                    }
701

    
702
                    //SetCommentList(UsersCommentPagesList.ToList());
703
                }
704
                else
705
                {
706
                    ImgListbox.SelectedItem = null;
707
                }
708

    
709
                if (ThumbInitialized != null)
710
                {
711
                    ThumbInitialized(this, new EventArgs());
712
                    ThumbInitialized = null;
713
                }
714
            }
715
        }
716

    
717

    
718
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
719
        {
720
            if (e.ClickCount >= 2)
721
            {
722
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
723

    
724
                GotoPage(selectItem.PageNumber);
725

    
726
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data, ViewerDataModel.Instance.CancellationToken());
727

    
728
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
729
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
730
                //bool isGO = false;
731

    
732
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
733
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
734
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
735
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
736
                //{
737
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
738
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
739
                //    {
740
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
741
                //    }
742

    
743
                //};
744
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
745

    
746
                //GotoPage(MarkupList.SelectedItem as MarkupList)
747
            }
748
        }
749

    
750
        public class MarkupInfoItemSmall
751
        {
752
            public string Id { get; set; }
753
            public string UserName { get; set; }
754
            public string UserID { get; set; }
755
            public int PageNumber { get; set; }
756
            public string Data { get; set; }
757
            public int Data_Type { get; set; }
758
            public bool IsConsolidate { get; set; }
759
        }
760

    
761
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
762
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
763
        {
764
            get
765
            {
766
                if (_MarkupInfoSmallList == null)
767
                {
768
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
769
                }
770
                return _MarkupInfoSmallList;
771
            }
772
            set
773
            {
774

    
775
                _MarkupInfoSmallList = value;
776
                RaisePropertyChanged("MarkupInfoSmallList");
777
            }
778
        }
779

    
780
        /// <summary>
781
        /// goto page and select item selected by user
782
        /// </summary>
783
        /// <param name="sender"></param>
784
        /// <param name="e"></param>
785
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
786
        {
787
            var clickButtonItem = sender as RadButton;
788
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
789
            {
790
                try
791
                {
792
                    Rect rect = new Rect();
793
                    Point s_point = new Point();
794
                    Point e_point = new Point();
795

    
796
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
797
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
798

    
799
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.CancellationToken()); //언패킹작업
800
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
801
                    {
802
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
803
                            {
804
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
805
                                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));
806
                            }
807
                            break;
808
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
809
                            {
810
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
811
                                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));
812
                            }
813
                            break;
814
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
815
                            {
816
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
817
                                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));
818
                            }
819
                            break;
820
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
821
                            {
822
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
823

    
824
                                foreach (Point A in instance.PointSet)
825
                                {
826
                                    if (s_point == new Point())
827
                                    {
828
                                        s_point = A;
829
                                        e_point = A;
830
                                    }
831
                                    s_point.X = Math.Min(s_point.X, A.X);
832
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
833
                                    e_point.X = Math.Max(e_point.X, A.X);
834
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
835
                                }
836
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
837
                            }
838
                            break;
839
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
840
                            {
841
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
842

    
843
                                foreach (Point A in instance.PointSet)
844
                                {
845
                                    if (s_point == new Point())
846
                                    {
847
                                        s_point = A;
848
                                        e_point = A;
849
                                    }
850
                                    s_point.X = Math.Min(s_point.X, A.X);
851
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
852
                                    e_point.X = Math.Max(e_point.X, A.X);
853
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
854
                                }
855
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
856
                            }
857
                            break;
858
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
859
                            {
860
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
861

    
862
                                foreach (Point A in instance.PointSet)
863
                                {
864
                                    if (s_point == new Point())
865
                                    {
866
                                        s_point = A;
867
                                        e_point = A;
868
                                    }
869
                                    s_point.X = Math.Min(s_point.X, A.X);
870
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
871
                                    e_point.X = Math.Max(e_point.X, A.X);
872
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
873
                                }
874
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
875
                            }
876
                            break;
877
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
878
                            {
879
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
880

    
881
                                foreach (Point A in instance.PointSet)
882
                                {
883
                                    if (s_point == new Point())
884
                                    {
885
                                        s_point = A;
886
                                        e_point = A;
887
                                    }
888
                                    s_point.X = Math.Min(s_point.X, A.X);
889
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
890
                                    e_point.X = Math.Max(e_point.X, A.X);
891
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
892
                                }
893
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
894
                            }
895
                            break;
896
                        default:
897
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
898
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
899
                            break;
900
                    }
901

    
902
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
903
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
904
                }
905
                catch (Exception ex)
906
                {
907
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
908
                }
909
            }
910
        }
911

    
912
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
913
        {
914
            var clickButtonItem = sender as RadButton;
915
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
916
            {
917
                try
918
                {
919
             
920

    
921
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
922
                    MarkupList.SelectedItem = gaza;
923

    
924
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
925
                }
926
                catch (Exception ex)
927
                {
928
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
929
                }
930
            }
931
        }
932

    
933
        ///// <summary>
934
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
935
        ///// </summary>
936
        ///// <param name="CommentIdList"></param>
937
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
938
        //{
939
        //    var instance = Common.ViewerDataModel.Instance;
940

    
941
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
942

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

    
945
        //    if (commentList.Count() > 0)
946
        //    {
947
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
948
        //        #region markup list grid select items
949

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

    
952
        //        if (infoItem.Count() > 0)
953
        //        {
954

    
955
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
956
        //            gridMarkup.SelectedItems.Clear();
957
        //            gridMarkup.SelectedItems.Add(infoItem.First());
958
        //        }
959

    
960
        //        #endregion
961

    
962
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
963

    
964
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
965
        //        {
966
        //            GotoSelectedMarkup(CommentIdList);
967
        //        }
968
        //        else
969
        //        {
970
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
971

    
972
        //            handler = (snd, evt) =>
973
        //            {
974
        //                GotoSelectedMarkup(CommentIdList);
975
        //                pageNavigator.PageChanged -= handler;
976
        //            };
977

    
978
        //            pageNavigator.PageChanged += handler;
979

    
980
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
981
        //        }
982
        //    }
983
        //}
984

    
985
        ///// <summary>
986
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
987
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
988
        ///// </summary>
989
        ///// <param name="CommentIdList"></param>
990
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
991
        //{
992
        //    var instance = Common.ViewerDataModel.Instance;
993

    
994
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
995
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
996

    
997
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
998
        //    {
999
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1000
        //        commentUserInfo.AddRange(selectOrderComments);
1001

    
1002
        //        if (commentUserInfo?.Count() > 0)
1003
        //        {
1004
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1005

    
1006
        //            try
1007
        //            {
1008
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1009
        //                {
1010
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1011
        //                    {
1012
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1013
        //                    } 
1014
                            
1015
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1016
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1017
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1018
        //                }
1019

    
1020
        //                Rect rect = commentUserInfo.First().ItemRect;
1021

    
1022
        //                foreach (var UserInfo in commentUserInfo)
1023
        //                {
1024
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1025
        //                }
1026

    
1027
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1028

    
1029
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1030
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1031
        //                //rect.Transform(matrix);
1032

    
1033
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1034
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1035
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1036
        //                double positionX = 0;
1037
        //                double positionY = 0;
1038

    
1039
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1040
        //                {
1041
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1042
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1043
        //                }
1044

    
1045
        //                main.zoomAndPanControl.ContentScale = newScale;
1046
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1047
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1048

    
1049
              
1050
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1051

    
1052
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1053

    
1054
        //                if (pageAngle == 90)
1055
        //                {
1056
        //                    pageAngle = 270;
1057
        //                }
1058
        //                else
1059
        //                {
1060
        //                    pageAngle = 90;
1061
        //                }
1062

    
1063
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1064
        //                {
1065
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1066
        //                    rect.Transform(matrix);
1067

    
1068
        //                    main.zoomAndPanControl.ZoomTo(rect);
1069
        //                }
1070
        //                else
1071
        //                {
1072
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1073

    
1074
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1075
        //                    rect.Transform(matrix);
1076

    
1077

    
1078
        //                    main.zoomAndPanControl.ZoomTo(rect);
1079
        //                }
1080
        //            }
1081
        //            catch (Exception ex)
1082
        //            {
1083
        //                main.DialogMessage_Alert(ex.Message, "Error");
1084
        //            }
1085
        //        }
1086
        //    }
1087
        //}
1088

    
1089
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1090
        {
1091
            if (MarkupInfoSmallList.Count == 0)
1092
            {
1093
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1094
                {
1095
                    if (d.MarkupList != null)
1096
                    {
1097
                        d.MarkupList.ForEach(b =>
1098
                        {
1099
                            bool isConsolidate = false;
1100

    
1101
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1102
                            {
1103
                                isConsolidate = true;
1104
                            }
1105

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

    
1108
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1109
                            {
1110
                                Id = b.ID,
1111
                                Data = b.Data,
1112
                                Data_Type = b.Data_Type,
1113
                                PageNumber = b.PageNumber,
1114
                                UserID = d.UserID,
1115
                                UserName = d.UserName,
1116
                                IsConsolidate = isConsolidate
1117

    
1118
                            });
1119
                        });
1120
                    }
1121
                });
1122
                MarkupList.ItemsSource = null;
1123
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1124

    
1125
                FilterUpdate();
1126
            }
1127
        }
1128

    
1129
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1130
        {
1131
            if (MarkupInfoSmallList.Count == 0)
1132
            {
1133
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1134
                {
1135
                    if (d.MarkupList != null)
1136
                    {
1137
                        d.MarkupList.ForEach(b =>
1138
                        {
1139
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1140
                            {
1141
                                Id = b.ID,
1142
                                Data = b.Data,
1143
                                Data_Type = b.Data_Type,
1144
                                PageNumber = b.PageNumber,
1145
                                UserID = d.UserID,
1146
                                UserName = d.UserName,
1147
                            });
1148
                        });
1149
                    }
1150
                });
1151
                MarkupList.ItemsSource = null;
1152
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1153
            }
1154

    
1155
            switch (eventType)
1156
            {
1157
                case Event_Type.Create:
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
                case Event_Type.Delete:
1169
                    if(CommentID == null) //user information list delete btn
1170
                    {
1171
                        foreach (var delItem in item.MarkupList)
1172
                        {
1173
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1174
                        }
1175
                    }
1176
                    else //delete, cut, 
1177
                    {
1178
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1179
                    }                    
1180
                    break;
1181
                case Event_Type.Thumb://이동 회전
1182
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1183
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1184
                    {
1185
                        Id = res.CommentID,
1186
                        Data = res.ConvertData,
1187
                        Data_Type = res.DATA_TYPE,
1188
                        PageNumber = CurrentPage.PageNumber,
1189
                        UserID = App.ViewInfo.UserID,
1190
                        UserName = App.UserName,
1191
                    });
1192
                    break;
1193
                default:
1194
                    break;
1195
            }
1196

    
1197
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1198

    
1199
            bool IsConsolidation = false;
1200
            string UserId = null;
1201

    
1202
            if (commentUser.SelectedValue != null)
1203
            {
1204
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1205
                {
1206
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1207
                }
1208
                else
1209
                {
1210
                    IsConsolidation = true;
1211
                }
1212
            }
1213

    
1214
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1215
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1216
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1217

    
1218
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1219

    
1220
            FilterUpdate();
1221
        }
1222

    
1223
        private void FilterUpdate(string selectUser = null)
1224
        {
1225
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1226

    
1227
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1228
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1229

    
1230

    
1231
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1232
 
1233
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1234
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1235

    
1236
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1237
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1238

    
1239
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1240
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1241

    
1242
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1243
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1244
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1245
        }
1246

    
1247
        
1248

    
1249
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1250
        {
1251
            MarkupList.ItemsSource = null;
1252
            txtSearch.Text = string.Empty;
1253

    
1254
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1255

    
1256
            bool IsConsolidation = false;
1257
            string userName = null;
1258

    
1259
            if (commentUser.SelectedValue != null)
1260
            {
1261
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1262
                {
1263
                    userName = commentUser.SelectedValue.ToString();
1264
                }
1265
                else
1266
                {
1267
                    IsConsolidation = true;
1268
                }
1269
            }
1270

    
1271
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1272
                                   .WhereIf(userName != null, d => d.UserName == userName)
1273
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1274
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1275

    
1276
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1277

    
1278
            FilterUpdate();
1279
        }
1280

    
1281
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1282
        {
1283
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1284
        }
1285

    
1286
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1287
        {
1288
            string search_str = txtSearch.Text;
1289

    
1290
            if(string.IsNullOrWhiteSpace(search_str))
1291
            {
1292
                return;
1293
            }
1294

    
1295
            var sel_type = commentType.SelectedItem;
1296
            var sel_user = commentUser.SelectedItem;
1297
            var sel_page = commentPage.SelectedItem;
1298
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1299
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1300
            if (sel_page != null)
1301
            {
1302
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1303
            }
1304
            if (sel_type != null)
1305
            {
1306
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1307
            }
1308
            if (sel_user != null)
1309
            {
1310
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1311
            }
1312
            foreach (var item in list)
1313
            {
1314
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.CancellationToken());
1315

    
1316
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1317
                {
1318
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1319
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1320
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1321
                        {
1322
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1323

    
1324
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1325
                            {
1326
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1327
                                {
1328
                                    small_list.Add(item);
1329
                                }
1330
                            }
1331
                        }
1332
                        break;
1333
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1334
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1335
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1336
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1337
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1338
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1339
                        {
1340
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1341

    
1342
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1343
                            {
1344
                                if (instance.ArrowText.Contains(search_str))
1345
                                {
1346
                                    small_list.Add(item);
1347
                                }
1348
                            }
1349
                        }
1350
                        break;
1351
                }
1352
            }
1353

    
1354
            MarkupList.ItemsSource = null;
1355
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1356
        }
1357

    
1358
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1359
        {
1360
            if(e.Key == Key.Enter || e.Key == Key.Return)
1361
            {
1362
                btnSearch_Click(sender, new RoutedEventArgs());
1363
            }
1364
        }
1365

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