프로젝트

일반

사용자정보

개정판 d18ea2bd

IDd18ea2bd5a22f2671d8dd8b683008c30c6affcc2
상위 10beebc8
하위 f5c6a3d5

김태성이(가) 약 5년 전에 추가함

ThumbnailItem 중복 호출 방지
ColorList convert로 변경

Change-Id: Idc6bb06d6d84c78875400fc99cf218cd1368c253

차이점 보기:

KCOM/Controls/Sample.xaml.cs
13 13
using System.Threading.Tasks;
14 14
using System.Windows;
15 15
using System.Windows.Controls;
16
using System.Windows.Data;
16 17
using System.Windows.Input;
17 18
using System.Windows.Media;
18 19
using Telerik.Windows.Controls;
......
54 55
            if(!_Initialize)
55 56
            {
56 57
                _Initialize = true;
57

  
58
                this.SizeChanged += Sample_SizeChanged;
58 59
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
59 60
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
60 61
            }            
61 62
        }
62 63

  
64
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
65
        {
66
            if(e.WidthChanged)
67
            {
68
                ImgListbox.UpdateLayout();
69
            }
70
        }
71

  
72
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample));
73
        public CollectionViewSource FilteredThumbnail
74
        {
75
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
76
            set { SetValue(FilteredThumbnailProperty, value); }
77
        }
78

  
79
        public static readonly DependencyProperty CurrentPageProperty 
80
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
81

  
82
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
83
        {
84
            //var owner = d as Sample;
85

  
86
            //if (owner?.UsersCommentPagesList != null)
87
            //{
88
            //    owner.SetCommentPages();
89
            //}
90
        }
91

  
92
        public ThumbnailItem CurrentPage
93
        {
94
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
95
            set { SetValue(CurrentPageProperty, value); }
96
        }
97

  
63 98
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
64 99
        private List<DOCPAGE> _PageList = null;
65 100
        private string _DefaultUri = null;
66
        public ThumbnailItem CurrentPage = null;
67 101
        public int PageCount = 0;
68 102
        private bool _Initialize;
69 103

  
......
115 149
        {
116 150
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
117 151
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
118
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
119
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
120 152

  
121 153
            this._PageList = PageList;
122 154
            this._DefaultUri = DefaultUri;
......
125 157

  
126 158
            //samplePageStorage = new PageManager.PageStorage(_DefaultUri, tempStoragePath,"jpg", _PageList.Count(), _PageList.Count());
127 159

  
128
            if (cts != null)
129
            {
130
                cts.CancelAfter(100);
131
            }
132

  
133
            cts = new CancellationTokenSource();
134

  
135
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync(cts.Token));
160
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
136 161
            
137 162
            this.PageCount = PageList.Count();
138 163

  
......
143 168
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
144 169
        {
145 170
            Logger.sendCheckLog("rdoCommented_Checked", 1);
146
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
147 171
            SetCommentPages();
148 172
        }
149 173

  
150 174
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
151 175
        {
152 176
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
153
            if (rdoFavoritePages.IsChecked == true)
154
                expCommentPages.IsExpanded = false;
177
            //if (rdoFavoritePages.IsChecked == true)
178
            //    expCommentPages.IsExpanded = false;
155 179

  
156
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
157
            if (_FavoriteSet.Count > 0)
158
            {
159
                SetCommentPages(); //수정    
160
            }
161
            else
162
            {
163
                rdoAllPages.IsChecked = true;
164
                rdoFavoritePages.IsChecked = false;
165
            }
180
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
181
            //if (_FavoriteSet.Count > 0)
182
            //{
183
            //    SetCommentPages(); //수정    
184
            //}
185
            //else
186
            //{
187
            //    rdoAllPages.IsChecked = true;
188
            //    rdoFavoritePages.IsChecked = false;
189
            //}
166 190
        }
167 191

  
168 192
        private async void ShowPageChange(object sender, RoutedEventArgs e)
169 193
        {
170
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
171

  
172
            if (cts != null)
194
            if (_Initialize)
173 195
            {
174
                cts.CancelAfter(100);
196
                //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
197
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
175 198
            }
176

  
177
            cts = new CancellationTokenSource();
178

  
179
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync(cts.Token));
180 199
        }
181 200

  
182 201
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
......
448 467
            {
449 468
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
450 469

  
451
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
470
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
452 471
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
453 472
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
454 473

  
......
478 497

  
479 498
        public async void SetCommentPages()
480 499
        {
481
            if (cts != null)
482
            {
483
                cts.CancelAfter(100);
484
            }
485

  
486
            cts = new CancellationTokenSource();
487

  
488
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync(cts.Token));
489
            //SetCommentList(UsersCommentPagesList.ToList());
500
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
490 501
        }
491 502

  
492 503
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
......
556 567
            {
557 568
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
558 569
            }
559
            
570

  
560 571
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
561 572
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
562 573
            if (data.Count() != 0)
......
586 597

  
587 598
        }
588 599

  
589
        CancellationTokenSource cts = null;
600
        List<int> FilterPages = null;
590 601

  
591
        private void ThumbnailSetAsync(CancellationToken ct)
602
        private void ThumbnailSetAsync()
592 603
        {
593 604
            Logger.sendCheckLog("ThumbnailSet", 1);
594 605

  
595
            _thumbnailItems = new ObservableCollection<ThumbnailItem>();
596
            ImgListbox.ItemsSource = null;
597

  
598
            IEnumerable<int> selectComment = null;
599
            IEnumerable<DOCPAGE> pageList = null;
600

  
601
            if (this.lstSelectComment.ItemsSource != null)
606
            if (FilteredThumbnail == null)
602 607
            {
603
                selectComment = (from commentPage in this.UsersCommentPagesList
604
                                 where commentPage.IsSelected == true
605
                                 select commentPage.PageNumber).SelectMany(x => x).Distinct();
606
            }
607

  
608
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
608
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
609 609

  
610
            if (rdoAllPages.IsChecked == true)
611
            {
612
                pageList = ViewerDataModel.Instance.Document_Info;
613
            }
614
            else if (expCommentPages.IsExpanded == true)
615
            {
616
                if (selectComment != null)
617
                {
618
                    pageList = ViewerDataModel.Instance.Document_Info
619
                                .Where(p => selectComment.Where(s => s == p.PAGE_NUMBER).Count() > 0);
620
                }
621
            }
622
            else if (rdoFavoritePages.IsChecked == true)
623
            {
624
                if (_FavoriteSet != null)
625
                {
626
                    pageList = ViewerDataModel.Instance.Document_Info
627
                                .Where(p => _FavoriteSet.Where(data => data.PAGE_NO == p.PAGE_NUMBER).FirstOrDefault() != null);
628
                }
629
            }
610
                var pageList = ViewerDataModel.Instance.Document_Info;
630 611

  
631
            if (pageList?.Count() > 0)
632
            {
633 612
                var items = from page in pageList
634 613
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
635 614
                            orderby page.PAGE_NUMBER
......
641 620
                                Angle = page.PAGE_ANGLE
642 621
                            };
643 622

  
623
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
624
                FilteredThumbnail = new CollectionViewSource();
625
                FilteredThumbnail.Source = _thumbnailItems;
626

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

  
645
                if (items.Count() > 0)
629
                FilteredThumbnail.Filter += (snd,evt) =>
646 630
                {
647
                    try
631
                    if (FilterPages?.Count() > 0 && evt.Item != null)
648 632
                    {
649
                        //await this.Dispatcher.InvokeAsync(() =>
650
                        //{
651
                            foreach (var item in items.ToList())
652
                            {
653
                                if (!ct.IsCancellationRequested)
654
                                {
655
                                    _thumbnailItems.Add(item);
656
                                    System.Diagnostics.Debug.WriteLine("Page Set : " + item.PageNumber);
657
                                }
658
                            }
659
                        //}, System.Windows.Threading.DispatcherPriority.Background, ct);
633
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
660 634
                    }
661
                    catch (OperationCanceledException ex)
635
                    else
662 636
                    {
663

  
637
                        evt.Accepted = false;
664 638
                    }
665
                    
666
                    SetCommentList(UsersCommentPagesList.ToList());
639
                };
667 640

  
668
                    ImgListbox.ItemsSource = _thumbnailItems;
641
            }
669 642

  
670
                    if (_thumbnailItems.Count() > 0)
671
                    {
672
                        ImgListbox.SelectedItem = _thumbnailItems[0];
643
            FilterPages.Clear();
673 644

  
674
                        if (ThumbInitialized != null)
675
                        {
676
                            ThumbInitialized(this, new EventArgs());
677
                        }
645

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

  
667
                    if (commentPages?.Count() > 0)
668
                    {
669
                        FilterPages = (from thumb in _thumbnailItems
670
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
671
                                       select thumb.PageNumber).ToList();
678 672
                    }
679
                    //ImgListbox.UpdateLayout();
673
                }
674
            }
675

  
676
            if (FilterPages != null)
677
            {
678
                FilteredThumbnail.View.Refresh();
679

  
680
                if (FilterPages.Count() > 0)
681
                {
682
                    ImgListbox.SelectedItem = _thumbnailItems.Where(x=>x.PageNumber == FilterPages.FirstOrDefault()).FirstOrDefault();
683
                    //SetCommentList(UsersCommentPagesList.ToList());
684
                }
685
                else
686
                {
687
                    ImgListbox.SelectedItem = null;
688
                }
689

  
690
                if (ThumbInitialized != null)
691
                {
692
                    ThumbInitialized(this, new EventArgs());
693
                    ThumbInitialized = null;
680 694
                }
681 695
            }
682 696
        }

내보내기 Unified diff

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