프로젝트

일반

사용자정보

개정판 6c687be8

ID6c687be8b0caaa519ca438da4a187da82a5df815
상위 6c3941a9
하위 10beebc8

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

thumbnail 속도 문제로 되돌림

Change-Id: If873bc60f8159428b34e3df6cedb48f9675e0485

차이점 보기:

KCOM/Controls/Sample.xaml.cs
9 9
using System.ComponentModel;
10 10
using System.Diagnostics;
11 11
using System.Linq;
12
using System.Threading;
12 13
using System.Threading.Tasks;
13 14
using System.Windows;
14 15
using System.Windows.Controls;
......
27 28
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
28 29
        public event PropertyChangedEventHandler PropertyChanged;
29 30

  
30
        PageManager.PageStorage samplePageStorage;
31
        //PageManager.PageStorage samplePageStorage;
31 32

  
32 33
        public Sample()
33 34
        {
......
45 46

  
46 47
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
47 48
        {
48
            if (samplePageStorage != null)
49
            {
50
                samplePageStorage.Clear();
51
            }
49
          
52 50
        }
53 51

  
54 52
        private void Sample_Loaded(object sender, RoutedEventArgs e)
......
115 113

  
116 114
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
117 115
        {
116
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
117
            //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

  
118 121
            this._PageList = PageList;
119 122
            this._DefaultUri = DefaultUri;
120 123

  
121 124
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
122 125

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

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

  
133
            cts = new CancellationTokenSource();
134

  
135
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync(cts.Token));
126 136
            
127 137
            this.PageCount = PageList.Count();
128 138

  
129 139
            //ThumbNmailSet();
130
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
131
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
132
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
133
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
140
            
134 141
        }
135 142

  
136 143
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
......
149 156
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
150 157
            if (_FavoriteSet.Count > 0)
151 158
            {
152
                SetCommentPages_Favorite(); //수정    
159
                SetCommentPages(); //수정    
153 160
            }
154 161
            else
155 162
            {
......
158 165
            }
159 166
        }
160 167

  
161
        private async void SetCommentPages_Favorite()
168
        private async void ShowPageChange(object sender, RoutedEventArgs e)
162 169
        {
163
            await ThumbnailSetAsync();            
164
            SetCommentPages();
170
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
171

  
172
            if (cts != null)
173
            {
174
                cts.CancelAfter(100);
175
            }
176

  
177
            cts = new CancellationTokenSource();
178

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

  
167 182
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
......
463 478

  
464 479
        public async void SetCommentPages()
465 480
        {
466
            await ThumbnailSetAsync();
467
            SetCommentList(UsersCommentPagesList.ToList());
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());
468 490
        }
469 491

  
470 492
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
......
472 494
            Logger.sendCheckLog("SetCommentList", 1);
473 495
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
474 496
            #region 기존 색상 제거 작업
497

  
475 498
            foreach (var item in this._thumbnailItems)
476 499
            {
477
                item.DisplayColorItems.Clear();
500
                if (item.DisplayColorItems != null)
501
                {
502
                    item.DisplayColorItems.Clear();
503
                }
478 504
            }
479 505
            #endregion
480 506

  
......
560 586

  
561 587
        }
562 588

  
563
        private async Task ThumbnailSetAsync()
589
        CancellationTokenSource cts = null;
590

  
591
        private void ThumbnailSetAsync(CancellationToken ct)
564 592
        {
565 593
            Logger.sendCheckLog("ThumbnailSet", 1);
566
      
567
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
568
            List<int> _selectComment = new List<int>();
569
            if (this.lstSelectComment.ItemsSource != null)
570
            {
571
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
572
                             where commentPage.IsSelected == true
573
                             select commentPage.PageNumber;
574 594

  
575
                foreach (var item in _pages)
576
                {
577
                    item.ForEach(pp => _selectComment.Add(pp));
578
                }
595
            _thumbnailItems = new ObservableCollection<ThumbnailItem>();
596
            ImgListbox.ItemsSource = null;
597

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

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

  
583 608
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
584
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
585
            //this._PageList.ForEach(page =>
586 609

  
587
            var items = ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList();
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
            }
588 630

  
589
            foreach (var page in items)
631
            if (pageList?.Count() > 0)
590 632
            {
591
                System.Diagnostics.Debug.WriteLine("thumbnail download process " + page.PAGE_NUMBER);
633
                var items = from page in pageList
634
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
635
                            orderby page.PAGE_NUMBER
636
                            select new ThumbnailItem
637
                            {
638
                                ImageUri = new Uri(pageLink),
639
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
640
                                PageNumber = page.PAGE_NUMBER,
641
                                Angle = page.PAGE_ANGLE
642
                            };
592 643

  
593
            //}
594
            //ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
595
            //{
596
                var _pageNo = page.PAGE_NUMBER;
597
                bool _addFlag = false;
598 644

  
599
                if (rdoFavoritePages.IsChecked == false)
645
                if (items.Count() > 0)
600 646
                {
601
                    if (_selectComment.Count() > 0)
647
                    try
602 648
                    {
603
                        if ((rdoAllPages.IsChecked == true)
604
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
605
                        {
606
                            _addFlag = true;
607
                        }
608
                    }
609
                    else
610
                    {
611
                        //if (App.ViewInfo.IsCustomPage)
612
                        //{
613
                        //    //_addFlag = false;
614

  
615
                        //    //App.ViewInfo.IsCustomPage = false;
616
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
617
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
618
                        //    this.rdoAllPages.IsChecked = false;
619
                        //    this.rdoFavoritePages.IsChecked = true;
620
                        //    //SetCommentPages();                        
621
                        //}
622
                        //else
649
                        //await this.Dispatcher.InvokeAsync(() =>
623 650
                        //{
624
                        _addFlag = true;
625
                        //}
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);
626 660
                    }
627
                }
628

  
629
                var pageUri = await samplePageStorage.GetPageUriAsync(_pageNo);
630

  
631
                if (_addFlag)
632
                {
633
                    
634
                   this._thumbnailItems.Add(new ThumbnailItem
661
                    catch (OperationCanceledException ex)
635 662
                    {
636
                        ImageUri = pageUri,
637
                        PageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString()).Replace("jpg","png")),
638
                        PageNumber = _pageNo,
639
                        Angle = page.PAGE_ANGLE,
640
                    });
641
                }
642
                else
643
                {
644
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
645
                    {
646
                        this._thumbnailItems.Add(new ThumbnailItem
647
                        {
648
                            ImageUri = pageUri,
649
                            PageNumber = _pageNo,
650
                            Angle = page.PAGE_ANGLE,
651
                        });
652
                    }
653
                }
654

  
655
                if (ImgListbox.ItemsSource == null)
656
                {
657
                    ImgListbox.ItemsSource = this._thumbnailItems;
658 663

  
659
                    //this.CurrentPage = this._thumbnailItems.FirstOrDefault();
664
                    }
665
                    
666
                    SetCommentList(UsersCommentPagesList.ToList());
660 667

  
661
                    //this._thumbnailItems.ToList().ForEach(data =>
662
                    //{
663
                    //    data.Width = ImgListbox.ActualWidth;
664
                    //    data.Height = ImgListbox.ActualHeight;
665
                    //});
668
                    ImgListbox.ItemsSource = _thumbnailItems;
666 669

  
667
                    if (ImgListbox.Items.Count > 0)
670
                    if (_thumbnailItems.Count() > 0)
668 671
                    {
669
                        int StartPageIdx = 1;
672
                        ImgListbox.SelectedItem = _thumbnailItems[0];
670 673

  
671
                        if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
674
                        if (ThumbInitialized != null)
672 675
                        {
673
                            ImgListbox.SelectedItem = ImgListbox.Items[0];
676
                            ThumbInitialized(this, new EventArgs());
674 677
                        }
675
                        else
676
                        {
677
                            ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
678
                        }
679
                    }
680

  
681
                    if (ThumbInitialized != null)
682
                    {
683
                        ThumbInitialized(this, new EventArgs());
684 678
                    }
679
                    //ImgListbox.UpdateLayout();
685 680
                }
686
                else
687
                {
688
                    ImgListbox.UpdateLayout();
689
                    ImgListbox.ItemsSource = this._thumbnailItems;
690
                }
691

  
692 681
            }
693

  
694
            //if (ImgListbox.ItemsSource == null)
695
            //{
696
            //    ImgListbox.ItemsSource = this._thumbnailItems;
697

  
698
            //    //this.CurrentPage = this._thumbnailItems.FirstOrDefault();
699

  
700
            //    //this._thumbnailItems.ToList().ForEach(data =>
701
            //    //{
702
            //    //    data.Width = ImgListbox.ActualWidth;
703
            //    //    data.Height = ImgListbox.ActualHeight;
704
            //    //});
705

  
706
            //    if (ImgListbox.Items.Count > 0)
707
            //    {
708
            //        int StartPageIdx = 1;
709
                
710
            //        if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
711
            //        {
712
            //            ImgListbox.SelectedItem = ImgListbox.Items[0];
713
            //        }
714
            //        else
715
            //        {
716
            //            ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
717
            //        }
718
            //    }
719
            //}
720
            //else
721
            //{
722
            //    ImgListbox.UpdateLayout();
723
            //    ImgListbox.ItemsSource = this._thumbnailItems;
724
            //}
725

  
726
            //if(ThumbInitialized != null)
727
            //{
728
            //    ThumbInitialized(this, new EventArgs());
729
            //}
730 682
        }
731 683

  
732 684
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
......
1377 1329
                btnSearch_Click(sender, new RoutedEventArgs());
1378 1330
            }
1379 1331
        }
1332

  
1380 1333
    }
1381 1334
}

내보내기 Unified diff

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