프로젝트

일반

사용자정보

개정판 54a28343

ID54a283437aead516546aa61b4f0e99ea888b1e4c
상위 87d56836
하위 d97dbc7f

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

Thumbnail 로딩 방식 수정

Change-Id: Iad91569fc06e4eecfe9d5a7a9ece9567ad161874

차이점 보기:

ConvertService/ServiceBase/Markus.Service.StationController/Markus.Service.StationController.csproj
351 351
MOVE $(TargetDir)*.dll $(TargetDir)Bin\
352 352
</PostBuildEvent>
353 353
  </PropertyGroup>
354
  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
355
  <Target Name="StationController_ini_AfterBuild" AfterTargets="AfterBuild" Condition="Exists('StationController.$(Configuration).ini')">
356
    <TransformXml Source="StationController.ini" Destination="$(OutputPath)StationController.ini" Transform="StationController.$(Configuration).ini" />
357
  </Target>
354 358
</Project>
KCOM/Controls/PageNavigator.xaml
144 144
                                                 To="180" />
145 145
                                <ColorAnimation d:IsOptimized="True"
146 146
                                                Duration="0"
147
                                                Storyboard.TargetName="OuterCircle"
147
                                                Storyboard.TargetName="OuterCi rcle"
148 148
                                                Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)"
149 149
                                                To="#FF1FA3EB" />
150 150
                            </Storyboard>
......
601 601
            <telerik:RadButton Content="RE" Margin="5,0" Grid.Column="2"/>
602 602
            <telerik:RadButton Content="RR" Margin="5,0" Grid.Column="3"/>
603 603
        </Grid>
604
        <telerik:RadListBox x:Name="ImgListbox"
604
        <ListBox x:Name="ImgListbox"
605 605
                 Grid.Row="3" VirtualizingStackPanel.IsVirtualizing="True"
606 606
                 Background="{DynamicResource KCOMColor_AlternativeBrush}"
607 607
                 BorderBrush="#FFC2C2C2" BorderThickness="0" Margin="5"
608 608
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
609 609
                 SelectionChanged="ImgListbox_SelectionChanged"
610
                 telerik:StyleManager.Theme="Office2016" VirtualizingStackPanel.VirtualizationMode="Recycling">
611
            <telerik:RadListBox.ItemsPanel>
610
                 telerik:StyleManager.Theme="Office2016" VirtualizingStackPanel.VirtualizationMode="Recycling" IsManipulationEnabled="True">
611
            <ListBox.ItemsPanel>
612 612
                <ItemsPanelTemplate>
613 613
                    <!--<StackPanel/>
614 614
                    If StackPanel was used, the memory consumed was over 2GB and dead slow.
615 615
                    -->
616 616
                    <VirtualizingStackPanel/>
617 617
                </ItemsPanelTemplate>
618
            </telerik:RadListBox.ItemsPanel>
619
            <telerik:RadListBox.ItemTemplate>
618
            </ListBox.ItemsPanel>
619
            <ListBox.ItemTemplate>
620 620
                <DataTemplate>
621
                    <Image Stretch="Uniform" Source="{Binding ImageUri,IsAsync=True}" Width="150"/>
621
                    <Image Stretch="Uniform" Source="{Binding ImageUri,IsAsync=False}" Height="150" Width="150"/>
622 622
                </DataTemplate>
623
            </telerik:RadListBox.ItemTemplate>
624
        </telerik:RadListBox>
623
            </ListBox.ItemTemplate>
624
        </ListBox>
625 625
    </Grid>
626 626
</UserControl>
KCOM/Controls/PageNavigator.xaml.cs
23 23
    /// </summary>
24 24
    public partial class PageNavigator : UserControl, INotifyPropertyChanged
25 25
    {
26

  
26 27
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
27 28
        public event PropertyChangedEventHandler PropertyChanged;
28 29
        public PageNavigator()
KCOM/Controls/PrintControl.xaml.cs
442 442
                        //bitmap.EndInit();
443 443

  
444 444
                        printCanvas.Children.Clear();
445
                        var bitmapframe = await  App.PageStorage.GetPageAsync(PageNo);
445
                        var bitmapframe = await  App.PageStorage.GetPageImageAsync(PageNo);
446 446
                        Image bitmap = new Image();
447 447

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

  
30
        PageManager.PageStorage samplePageStorage;
31

  
28 32
        public Sample()
29 33
        {
30 34
            InitializeComponent();
......
55 59
        public ThumbnailItem CurrentPage = null;
56 60
        public int PageCount = 0;
57 61
        private bool _Initialize;
62

  
63
        public event EventHandler<EventArgs> ThumbInitialized;
58 64
        public event EventHandler<PageChangeEventArgs> PageChanged;
59 65
        public event EventHandler<PageChangeEventArgs> PageChanging;
60 66

  
......
98 104
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
99 105
        }
100 106

  
101
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
107
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
102 108
        {
103 109
            this._PageList = PageList;
104 110
            this._DefaultUri = DefaultUri;
105
            ThumbnailSet();
111

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

  
114
            samplePageStorage = new PageManager.PageStorage(_DefaultUri, tempStoragePath,"jpg", _PageList.Count(), _PageList.Count());
115

  
116
            await ThumbnailSetAsync();
117
            
106 118
            this.PageCount = PageList.Count();
119

  
107 120
            //ThumbNmailSet();
108 121
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
109 122
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
......
136 149
            }
137 150
        }
138 151

  
139
        private void SetCommentPages_Favorite()
152
        private async void SetCommentPages_Favorite()
140 153
        {
141
            ThumbnailSet();            
154
            await ThumbnailSetAsync();            
142 155
            SetCommentPages();
143 156
        }
144 157

  
......
439 452
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
440 453
        }
441 454

  
442
        public void SetCommentPages()
455
        public async void SetCommentPages()
443 456
        {
444
            ThumbnailSet();
457
            await ThumbnailSetAsync();
445 458
            SetCommentList(UsersCommentPagesList.ToList());
446 459
        }
447 460

  
......
538 551

  
539 552
        }
540 553

  
541
        private void ThumbnailSet()
554
        private async Task ThumbnailSetAsync()
542 555
        {
543 556
            Logger.sendCheckLog("ThumbnailSet", 1);
544
            if (!_Initialize) return;
545

  
557
      
546 558
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
547 559
            List<int> _selectComment = new List<int>();
548 560
            if (this.lstSelectComment.ItemsSource != null)
......
562 574
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
563 575
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
564 576
            //this._PageList.ForEach(page =>
565
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
577

  
578
            var items = ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList();
579

  
580
            foreach (var page in items)
566 581
            {
582

  
583
            //}
584
            //ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
585
            //{
567 586
                var _pageNo = page.PAGE_NUMBER;
568 587
                bool _addFlag = false;
569 588

  
......
597 616
                    }
598 617
                }
599 618

  
619
                var pageUri = await samplePageStorage.GetPageUriAsync(_pageNo);
600 620

  
601 621
                if (_addFlag)
602 622
                {
603
                    this._thumbnailItems.Add(new ThumbnailItem
623
                    
624
                   this._thumbnailItems.Add(new ThumbnailItem
604 625
                    {
605
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
626
                        ImageUri = pageUri,
606 627
                        PageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString()).Replace("jpg","png")),
607 628
                        PageNumber = _pageNo,
608 629
                        Angle = page.PAGE_ANGLE,
......
614 635
                    {
615 636
                        this._thumbnailItems.Add(new ThumbnailItem
616 637
                        {
617
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
638
                            ImageUri = pageUri,
618 639
                            PageNumber = _pageNo,
619 640
                            Angle = page.PAGE_ANGLE,
620 641
                        });
621 642
                    }
622 643
                }
623

  
624

  
625

  
626
                //this._thumbnailItems.Add(new ThumbnailItem
627
                //{
628
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
629

  
630
                //    //ImageUri = new Uri(@"http://www.honeyhead.net/Pages/000000/111111/11111111/1.cmp"),
631

  
632
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
633
                //    //DisplayColorItems = pageColor,
634
                //    PageNumber = Convert.ToInt32(_pageNo),
635
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
636
                //});
637
            });
638

  
639
            //txtTotPageNo.Text = this._PageList.Count().ToString();
640

  
641
            //txtThumbCount.Text = String.Format("Count : {0}", (this._thumbnailItems.Count).ToString());
644
            }
642 645

  
643 646
            if (ImgListbox.ItemsSource == null)
644 647
            {
645 648
                ImgListbox.ItemsSource = this._thumbnailItems;
646 649

  
650
                this.CurrentPage = this._thumbnailItems.FirstOrDefault();
651

  
647 652
                this._thumbnailItems.ToList().ForEach(data =>
648 653
                {
649 654
                    data.Width = ImgListbox.ActualWidth;
......
652 657

  
653 658
                if (ImgListbox.Items.Count > 0)
654 659
                {
655
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
656 660
                    int StartPageIdx = 1;
657
                    //if (App.ViewInfo.IsCustomPage)
658
                    //{
659
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
660
                    //}
661
                    //else
662
                    //{
663

  
661
                
664 662
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
665 663
                    {
666 664
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
......
669 667
                    {
670 668
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
671 669
                    }
672
                    //}
673 670
                }
674 671
            }
675 672
            else
......
677 674
                ImgListbox.UpdateLayout();
678 675
                ImgListbox.ItemsSource = this._thumbnailItems;
679 676
            }
677

  
678
            if(ThumbInitialized != null)
679
            {
680
                ThumbInitialized(this, new EventArgs());
681
            }
680 682
        }
681 683

  
682 684
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
KCOM/Extensions/TaskExtensions.cs
19 19
            {
20 20
                onException?.Invoke(ex);
21 21
            }
22
            finally
23
            {
24
            }
22 25
        }
23 26
    }
24 27
}
KCOM/PageManager/PageStorage.cs
11 11
    public class PageStorage
12 12
    {
13 13
        private const int DEFUALT_TALK_PAGE_COUNT = 10;
14

  
14
        bool IsRunWork = false;
15 15
        BackgroundWorker backgroundWorker;
16 16
        List<PageItem> fileItems = new List<PageItem>();
17 17
        string _localStorage;
18
        string _fileExt;
18 19
        string _BaseUri;
19 20
        int _TotalPages;
21
        int _TakeCount;
20 22

  
21 23

  
22 24
        BitmapFrame PageImage;
23 25

  
24
        public PageStorage(string BaseUri, string localStoragePath,int totalPages)
26
        public PageStorage(string BaseUri, string localStoragePath,string fileExt,int totalPages,int takeCount = 5)
25 27
        {
26 28
            try
27 29
            {
28 30
                backgroundWorker = new BackgroundWorker {WorkerSupportsCancellation = true };
29 31
                backgroundWorker.DoWork += BackgroundWorker_DoWork;
30 32

  
33
                _fileExt = fileExt;
31 34
                _BaseUri = BaseUri;
32 35
                _localStorage = localStoragePath;
33 36
                _TotalPages = totalPages;
37
                _TakeCount = takeCount;
34 38

  
35 39
                System.IO.Directory.CreateDirectory(_localStorage);
36 40

  
......
74 78

  
75 79
        }
76 80

  
77
        public async Task<BitmapFrame> GetPageAsync(int PageNo,bool IsRestart =false)
81
        public async Task<BitmapFrame> GetPageImageAsync(int PageNo,bool IsRestart =false)
78 82
        {
79 83
            try
80 84
            {
85

  
86
                var localUri = await GetPageUriAsync(PageNo);
87

  
88
                PageImage = BitmapFrame.Create(localUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
89
            }
90
            catch (Exception ex)
91
            {
92
                throw new Exception("GetPageImageAsync(int PageNo,bool IsRestart =false)", ex);
93
            }
94
            finally
95
            {
96
            }
97

  
98
            return PageImage;
99
        }
100

  
101
        public async Task<Uri> GetPageUriAsync(int PageNo, bool IsRestart = false)
102
        {
103
            Uri result = null;
104

  
105
            try
106
            {
81 107
                System.Diagnostics.Debug.WriteLine("GetPageAsync");
108

  
109
                var pageItem = await DownloadPageAsync(PageNo);
82 110
                
83
                while (backgroundWorker.IsBusy)
111
                if (!IsRunWork && pageItem != null)
84 112
                {
85
                    await Task.Delay(100);
113
                    var takePageNoList = Enumerable.Range(PageNo + 1, _TakeCount);
86 114

  
87
                    if (backgroundWorker.IsBusy)
115
                    if (takePageNoList.Any(x => fileItems.Count(y => y.PageNo == x) == 0))
88 116
                    {
89
                        backgroundWorker.CancelAsync();
90
                    }
117
                        while (backgroundWorker.IsBusy)
118
                        {
119
                            if (backgroundWorker.IsBusy)
120
                            {
121
                                backgroundWorker.CancelAsync();
122
                            }
91 123

  
92
                }
124
                            await Task.Delay(100);
125
                        }
93 126

  
94
                var pageItem = await DownloadPageAsync(PageNo);
127
                        backgroundWorker.RunWorkerAsync(new int[] { PageNo + 1, _TakeCount });
95 128

  
96
                backgroundWorker.RunWorkerAsync(new int[] { PageNo + 1, 5 });
97
        
98
                PageImage = BitmapFrame.Create(pageItem.LocalUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
129
                        if (_TotalPages == _TakeCount)
130
                        {
131
                            IsRunWork = true;
132
                        }
133
                    }
134
                }
135

  
136
                result = pageItem.LocalUri;
99 137
            }
100
            catch (Exception)
138
            catch (Exception ex)
101 139
            {
102 140
                if (!IsRestart)
103 141
                {
104 142
                    await Task.Delay(100);
105
                    PageImage = await GetPageAsync(PageNo,true);
143

  
144
                    result = await GetPageUriAsync(PageNo, true);
106 145
                }
107 146
                //throw new Exception("GetPageAsync(string BasePageUri,int PageNo)", ex);
108 147
            }
......
110 149
            {
111 150
            }
112 151

  
113
            return PageImage;
152
            return result;
114 153
        }
115 154

  
116 155
        public void DownloadPagesAsync(int StartPageNo, int TalkCount = 5)
......
129 168
                        try
130 169
                        {
131 170
                            DownloadPageAsync(i).RunAndForget();
171
                            
132 172
                        }
133 173
                        catch (Exception ex)
134 174
                        {
......
138 178
                        {
139 179
                        }
140 180

  
141

  
142 181
                    }
143 182
                }
144 183
            }
......
148 187
            }
149 188
            finally
150 189
            {
151
            
190
                GC.Collect(2);
191
                GC.Collect(2);
152 192
            }
153 193
        }
154 194

  
......
183 223

  
184 224
                    System.Diagnostics.Debug.WriteLine("DownloadPageAsync down");
185 225

  
186
                    string downloadFilePath = System.IO.Path.Combine(_localStorage, PageNo.ToString() + ".png");
226
                    string downloadFilePath = System.IO.Path.Combine(_localStorage, PageNo.ToString() + "." + _fileExt);
187 227

  
188 228
                    Uri originalUri = new Uri(_BaseUri.Replace("{PageNo}", PageNo.ToString()));
189 229

  
......
212 252
                        fileItems.Add(result);
213 253
                    };
214 254

  
215
                    await client.DownloadFileTaskAsync(originalUri, downloadFilePath);
255
                    System.Diagnostics.Debug.WriteLine("Download : " + downloadFilePath);
216 256

  
217
                    GC.Collect();
218
                    GC.WaitForPendingFinalizers();
219
                    GC.Collect();
257
                    await client.DownloadFileTaskAsync(originalUri, downloadFilePath);
220 258

  
221
                    System.Diagnostics.Debug.WriteLine("Download : " + result.LocalFilePath);
259
                    //System.Diagnostics.Debug.WriteLine("Download : " + result.LocalFilePath);
222 260
                }
223 261
            }
224 262
            catch (Exception ex)
KCOM/Services/BaseServices.cs
266 266
                ViewerDataModel.Instance.Document_Info.Add(item);
267 267
            }
268 268
            Logger.sendReqLog("GetMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
269
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
270
            CurrentDoc = new Common.DocumentSet
269
           CurrentDoc = new Common.DocumentSet
271 270
            {
272 271
                docInfo = _DocInfo,
273 272
                Document_Id = _DocInfo.DOCUMENT_ID,
......
295 294
            //.Replace("jpg", "png")을 붙이는 이유는 MainUrl에 확장명이 jpg로 설정한 경우가 있기 때문
296 295

  
297 296
            #endregion
298
            App.PageStorage = new PageManager.PageStorage(MainUrl.Replace("jpg", "png"), tempStoragePath, _DocInfo.PAGE_COUNT);
297
            App.PageStorage = new PageManager.PageStorage(MainUrl.Replace("jpg","png"), tempStoragePath,"png", _DocInfo.PAGE_COUNT);
298
         
299
            await this.pageNavigator.SetPageNaviAsync(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
299 300

  
300
            this.pageNavigator.SetPageNavi(CurrentDoc.docInfo.DOCPAGE.ToList(), MainUrl);
301
        }
301 302

  
302
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
303
        private async void pageNavigator_ThumbInitialized(object sender,EventArgs e)
304
        {
305
            BaseClient.GetMarkupInfoItemsAsync(_ViewInfo.ProjectNO, _DocInfo.ID);
303 306

  
307
            ViewerDataModel.Instance.MarkupControls_USER.Clear();
304 308
            //ViewerDataModel.Instance.SystemMain.dzMainMenu.TempLoad();
305 309

  
306 310
            #region 단어 검색용 파일 다운로드
307 311

  
308 312
            await DownloadOriginalFileAsync();
309
        
310 313

  
311 314
            #endregion
312 315

  
......
315 318

  
316 319
        }
317 320

  
321

  
318 322
        /// <summary>
319 323
        /// get markupinfo and markupitem from database
320 324
        ///  - 1. called when document is loaded
KCOM/Views/MainMenu.xaml.cs
474 474
            if (App.ParameterMode)
475 475
            {
476 476
                App.splashString(ISplashMessage.MAINMENU_1);
477
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
477 478
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
478 479
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
479 480
                imageViewer_Compare = new Image();
......
677 678

  
678 679
            #region 페이지 이미지 로딩 수정
679 680

  
680
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
681
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(changePageNumber);
681 682
       
682 683
            ScaleImage(pageWidth, pageHeight);
683 684

  

내보내기 Unified diff

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