OSDN Git Service

画像取得時の画像検証で例外発生時は新規ビットマップを返すよう変更
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Mon, 28 Feb 2011 12:08:36 +0000 (12:08 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:19:10 +0000 (23:19 +0900)
アイコン画像取得失敗時に新規ビットマップで代替するのをやめた
仮想リストビューの選択状態クリアが一度で効かない場合があるので対処
RemovePost整理
LView.Items(Index).Selected = Trueへ戻し。

git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@1475 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Connection/HttpVarious.vb
Tween/HashtagManage.vb
Tween/ImageDictionary.vb
Tween/StatusDictionary.vb
Tween/Tween.vb

index 322108d..accd076 100644 (file)
@@ -193,17 +193,23 @@ Public Class HttpVarious
 
     Public Overloads Function CheckValidImage(ByVal img As Image, ByVal width As Integer, ByVal height As Integer) As Image
         If img Is Nothing Then Return Nothing
-
         Dim bmp As New Bitmap(width, height)
-        Dim tag As Object = img.Tag
-        Using g As Graphics = Graphics.FromImage(bmp)
-            g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
-            g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
-            g.DrawImage(img, 0, 0, width, height)
-        End Using
-        img.Dispose()
-        bmp.Tag = tag
-        Return bmp
+        Try
+            Using g As Graphics = Graphics.FromImage(bmp)
+                g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
+                g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
+                g.DrawImage(img, 0, 0, width, height)
+            End Using
+            bmp.Tag = img.Tag
+            Return bmp
+        Catch ex As Exception
+            bmp.Dispose()
+            bmp = New Bitmap(width, height)
+            bmp.Tag = img.Tag
+            Return bmp
+        Finally
+            img.Dispose()
+        End Try
     End Function
 
 End Class
index 7092399..a398330 100644 (file)
@@ -82,7 +82,9 @@ Public Class HashtagManage
     End Sub
 
     Private Sub UnSelectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnSelectButton.Click
-        HistoryHashList.SelectedIndices.Clear()
+        Do
+            HistoryHashList.SelectedIndices.Clear()
+        Loop While HistoryHashList.SelectedIndices.Count > 0
     End Sub
 
     Private Function GetIndexOf(ByVal list As ListBox.ObjectCollection, ByVal value As String) As Integer
@@ -252,12 +254,16 @@ Public Class HashtagManage
         If Not Me._isAdd AndAlso Me.HistoryHashList.SelectedIndices.Count > 0 Then
             idx = Me.HistoryHashList.SelectedIndices(0)
             Me.HistoryHashList.Items.RemoveAt(idx)
-            Me.HistoryHashList.SelectedIndices.Clear()
+            Do
+                Me.HistoryHashList.SelectedIndices.Clear()
+            Loop While Me.HistoryHashList.SelectedIndices.Count > 0
             Me.HistoryHashList.Items.Insert(idx, hashStr)
             Me.HistoryHashList.SelectedIndex = idx
         Else
             Me.AddHashToHistory(hashStr, False)
-            Me.HistoryHashList.SelectedIndices.Clear()
+            Do
+                Me.HistoryHashList.SelectedIndices.Clear()
+            Loop While Me.HistoryHashList.SelectedIndices.Count > 0
             Me.HistoryHashList.SelectedIndex = Me.HistoryHashList.Items.IndexOf(hashStr)
         End If
 
index 5d927bd..a7cd999 100644 (file)
@@ -275,7 +275,6 @@ Public Class ImageDictionary
         Dim callbackImage As Image = Nothing
         SyncLock lockObject
             If Me.innerDictionary(downloadAsyncInfo.Key) IsNot Nothing Then
-                'callbackImage = New Bitmap(DirectCast(Me.innerDictionary(downloadAsyncInfo.Key), Image))
                 callbackImage = DirectCast(Me.innerDictionary(downloadAsyncInfo.Key), Image)
             End If
         End SyncLock
@@ -290,13 +289,9 @@ Public Class ImageDictionary
             If Me.innerDictionary(downloadAsyncInfo.Key) Is Nothing Then
                 If dlImage IsNot Nothing Then
                     Me.innerDictionary.Add(downloadAsyncInfo.Key, dlImage, Me.cachePolicy)
-                    'callbackImage = New Bitmap(dlImage)
                     callbackImage = dlImage
-                Else
-                    Me.innerDictionary.Add(downloadAsyncInfo.Key, New Bitmap(16, 16), Me.cachePolicy)
                 End If
             Else
-                'callbackImage = New Bitmap(DirectCast(Me.innerDictionary(downloadAsyncInfo.Key), Image))
                 callbackImage = DirectCast(Me.innerDictionary(downloadAsyncInfo.Key), Image)
             End If
         End SyncLock
index 76740b9..13fa19a 100644 (file)
@@ -687,7 +687,7 @@ Public NotInheritable Class TabInformations
                 For Each key As String In _tabs.Keys
                     Dim tab As TabClass = _tabs(key)
                     If tab.Contains(Id) Then
-                        If tab.Posts.Count = 0 Then
+                        If Not tab.IsInnerStorageTabType Then
                             If tab.UnreadManage AndAlso Not post.IsRead Then    '未読管理
                                 SyncLock LockUnread
                                     tab.UnreadCount -= 1
@@ -695,8 +695,7 @@ Public NotInheritable Class TabInformations
                                 End SyncLock
                             End If
                         Else '未読数がずれる可能性があるためtab.Postsの未読も確認する
-                            Dim tabPost As PostClass = tab.Posts(Id)
-                            If tab.UnreadManage AndAlso Not tabPost.IsRead Then    '未読管理
+                            If tab.UnreadManage AndAlso Not tab.Posts(Id).IsRead Then    '未読管理
                                 SyncLock LockUnread
                                     tab.UnreadCount -= 1
                                     Me.SetNextUnreadId(Id, tab)
@@ -708,18 +707,6 @@ Public NotInheritable Class TabInformations
                 Next
                 _statuses.Remove(Id)
             End If
-            For Each tb As TabClass In _tabs.Values
-                If tb.IsInnerStorageTabType AndAlso tb.Contains(Id) Then
-                    post = tb.Posts(Id)
-                    If tb.UnreadManage AndAlso Not post.IsRead Then
-                        SyncLock LockUnread
-                            tb.UnreadCount -= 1
-                            Me.SetNextUnreadId(Id, tb)
-                        End SyncLock
-                    End If
-                    tb.Remove(Id)
-                End If
-            Next
         End SyncLock
     End Sub
 
index 522b953..23b3232 100644 (file)
@@ -2475,7 +2475,9 @@ Public Class TweenMain
             End If
         Next
         If _curTab.Text.Equals(favTabName) Then
-            _curList.SelectedIndices.Clear()
+            Do
+                _curList.SelectedIndices.Clear()
+            Loop While _curList.SelectedIndices.Count > 0
             If _statuses.Tabs(favTabName).AllCount > 0 Then
                 If _statuses.Tabs(favTabName).AllCount - 1 > fidx AndAlso fidx > -1 Then
                     _curList.SelectedIndices.Add(fidx)
@@ -2876,7 +2878,9 @@ Public Class TweenMain
             For Each tb As TabPage In ListTab.TabPages
                 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
                 If _curTab.Equals(tb) Then
-                    _curList.SelectedIndices.Clear()
+                    Do
+                        _curList.SelectedIndices.Clear()
+                    Loop While _curList.SelectedIndices.Count > 0
                     If _statuses.Tabs(tb.Text).AllCount > 0 Then
                         If _statuses.Tabs(tb.Text).AllCount - 1 > fidx AndAlso fidx > -1 Then
                             _curList.SelectedIndices.Add(fidx)
@@ -8230,9 +8234,11 @@ RETRY:
             flg = True
         End If
 
-        LView.SelectedIndices.Clear()
-        'LView.Items(Index).Selected = True
-        LView.SelectedIndices.Add(Index)
+        Do
+            LView.SelectedIndices.Clear()
+        Loop While LView.SelectedIndices.Count > 0
+        LView.Items(Index).Selected = True
+        'LView.SelectedIndices.Add(Index)
         LView.Items(Index).Focused = True
 
         If flg Then LView.Invalidate(bnd)
@@ -8249,7 +8255,9 @@ RETRY:
 
         Dim fIdx As Integer = -1
         If Index IsNot Nothing AndAlso Not (Index.Count = 1 AndAlso Index(0) = -1) Then
-            LView.SelectedIndices.Clear()
+            Do
+                LView.SelectedIndices.Clear()
+            Loop While LView.SelectedIndices.Count > 0
             For Each idx As Integer In Index
                 If idx > -1 AndAlso LView.VirtualListSize > idx Then
                     LView.SelectedIndices.Add(idx)