svnno****@sourc*****
svnno****@sourc*****
2011年 1月 21日 (金) 14:22:21 JST
Revision: 1394 http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1394 Author: kiri_feather Date: 2011-01-21 14:22:21 +0900 (Fri, 21 Jan 2011) Log Message: ----------- 取得が間に合わないときに発言詳細のアイコンが空のままになる問題に対処 Modified Paths: -------------- trunk/Tween/ImageDictionary.vb trunk/Tween/ImageListViewItem.vb trunk/Tween/Tween.vb -------------- next part -------------- Modified: trunk/Tween/ImageDictionary.vb =================================================================== --- trunk/Tween/ImageDictionary.vb 2011-01-20 14:20:03 UTC (rev 1393) +++ trunk/Tween/ImageDictionary.vb 2011-01-21 05:22:21 UTC (rev 1394) @@ -39,18 +39,19 @@ Private cachePolicy As New CacheItemPolicy() Private removedCount As Long = 0 - Public Sub New(ByVal memoryCacheCount As Integer) + Public Sub New(ByVal cacheMemoryLimit As Integer) SyncLock Me.lockObject '10Mb,80% + 'キャッシュチェック間隔はデフォルト値(2分毎) Me.innerDictionary = New MemoryCache("imageCache", New NameValueCollection() From { - {"CacheMemoryLimitMegabytes", "10"}, + {"CacheMemoryLimitMegabytes", cacheMemoryLimit.ToString}, {"PhysicalMemoryLimitPercentage", "80"} }) Me.waitStack = New Stack(Of KeyValuePair(Of String, Action(Of Image))) Me.cachePolicy.RemovedCallback = AddressOf CacheRemoved - Me.cachePolicy.SlidingExpiration = TimeSpan.FromMinutes(30) + Me.cachePolicy.SlidingExpiration = TimeSpan.FromMinutes(30) '30分参照されなかったら削除 End SyncLock End Sub Modified: trunk/Tween/ImageListViewItem.vb =================================================================== --- trunk/Tween/ImageListViewItem.vb 2011-01-20 14:20:03 UTC (rev 1393) +++ trunk/Tween/ImageListViewItem.vb 2011-01-21 05:22:21 UTC (rev 1394) @@ -27,6 +27,7 @@ Inherits ListViewItem Private img As Image = Nothing + Public Event ImageDownloaded(ByVal sender As Object, ByVal e As EventArgs) Public Sub New(ByVal items() As String, ByVal imageKey As String) MyBase.New(items, imageKey) @@ -42,6 +43,7 @@ Me.ListView.Created AndAlso Not Me.ListView.IsDisposed Then Me.ListView.Invoke(Sub() If Me.Index < Me.ListView.VirtualListSize Then Me.ListView.RedrawItems(Me.Index, Me.Index, False) + RaiseEvent ImageDownloaded(Me, EventArgs.Empty) End Sub) End Sub) Modified: trunk/Tween/Tween.vb =================================================================== --- trunk/Tween/Tween.vb 2011-01-20 14:20:03 UTC (rev 1393) +++ trunk/Tween/Tween.vb 2011-01-21 05:22:21 UTC (rev 1394) @@ -208,6 +208,8 @@ Private WithEvents TimerTimeline As New System.Timers.Timer + Private WithEvents displayItem As ImageListViewItem + 'URL短縮のUndo用 Private Structure urlUndo Public Before As String @@ -1017,7 +1019,7 @@ End If 'アイコンリスト作成 - TIconDic = New ImageDictionary(5000) + TIconDic = New ImageDictionary(50) tw.DetailIcon = TIconDic @@ -4620,11 +4622,8 @@ Return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter End Function - Private Sub SetUserPicture() - Thread.Sleep(1000) ' 要調整 - If Not String.IsNullOrEmpty(_curPost.ImageUrl) AndAlso TIconDic.ContainsKey(_curPost.ImageUrl) Then - UserPicture.Image = TIconDic(_curPost.ImageUrl) - End If + Private Sub DisplayItemImage_Downloaded(ByVal sender As Object, ByVal e As EventArgs) Handles displayItem.ImageDownloaded + If sender.Equals(displayItem) AndAlso displayItem.Image IsNot Nothing Then UserPicture.Image = displayItem.Image End Sub Private Overloads Sub DispSelectedPost() @@ -4641,6 +4640,8 @@ End If displaypost = _curPost + displayItem = DirectCast(_curList.Items(_curList.SelectedIndices(0)), ImageListViewItem) + Dim dTxt As String = createDetailHtml(If(_curPost.IsDeleted, "(DELETED)", _curPost.OriginalData)) If _curPost.IsDm Then SourceLinkLabel.Tag = Nothing @@ -4685,11 +4686,6 @@ UserPicture.Image = TIconDic(_curPost.ImageUrl) Else UserPicture.Image = Nothing - - Dim proc As New Thread(New Threading.ThreadStart(Sub() - If Me.IsHandleCreated AndAlso Not Me.IsDisposed Then Invoke(New MethodInvoker(AddressOf SetUserPicture)) - End Sub)) - proc.Start() End If NameLabel.ForeColor = System.Drawing.SystemColors.ControlText