Changeset 25955

Show
Ignore:
Timestamp:
12/05/08 17:06:51 (4 years ago)
Author:
kiri_feather
Message:

終了時の後片付け
未使用変数削除
using使ってのソース整理

Location:
lang/vb2005/Tween/Tween
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/vb2005/Tween/Tween/MySocket.vb

    r25202 r25955  
    8888            Optional ByVal timeout As Integer = 15000) As Object 
    8989        Dim webReq As HttpWebRequest 
    90         Dim dataB As Byte() 
    91         Dim strm As Stream 
    9290        Dim cpolicy As System.Net.Cache.HttpRequestCachePolicy = New Cache.HttpRequestCachePolicy(Cache.HttpRequestCacheLevel.NoCacheNoStore) 
    9391 
     
    120118                webReq.Method = "POST" 
    121119                webReq.Timeout = timeout 
    122                 dataB = Encoding.ASCII.GetBytes(data) 
     120                Dim dataB As Byte() = Encoding.ASCII.GetBytes(data) 
    123121                webReq.ContentLength = dataB.Length 
    124122                Select Case reqType 
     
    195193                End If 
    196194                resStatus = webRes.StatusCode.ToString() + " " + webRes.ResponseUri.AbsoluteUri 
    197                 strm = webRes.GetResponseStream() 
    198  
    199                 Select Case reqType 
    200                     Case REQ_TYPE.ReqGET, REQ_TYPE.ReqPOST, REQ_TYPE.ReqPOSTEncode, REQ_TYPE.ReqPOSTEncodeProtoVer1, REQ_TYPE.ReqPOSTEncodeProtoVer2, REQ_TYPE.ReqPOSTEncodeProtoVer3, REQ_TYPE.ReqGetNoCache, REQ_TYPE.ReqPOSTAPI, REQ_TYPE.ReqGetAPI 
    201                         Dim rtStr As String 
    202                         Using sr As New StreamReader(strm, _enc) 
    203                             rtStr = sr.ReadToEnd() 
    204                         End Using 
    205                         strm.Close() 
    206                         strm.Dispose() 
    207                         webRes.Close() 
    208                         Return rtStr 
    209                     Case REQ_TYPE.ReqGETBinary 
    210                         Dim readData(1023) As Byte 
    211                         Dim readSize As Integer = 0 
    212                         Dim img As Image 
    213                         Using mem As New MemoryStream 
    214                             While True 
    215                                 readSize = strm.Read(readData, 0, readData.Length) 
    216                                 If readSize = 0 Then 
    217                                     Exit While 
    218                                 End If 
    219                                 mem.Write(readData, 0, readSize) 
    220                             End While 
    221                             img = Image.FromStream(mem, True) 
    222                             strm.Close() 
    223                             strm.Dispose() 
    224                             webRes.Close() 
    225                         End Using 
    226                         Return img 
    227                     Case REQ_TYPE.ReqGETFile 
    228                         Dim fs As New System.IO.FileStream(My.Application.Info.DirectoryPath + "\TweenNew.exe", FileMode.Create, FileAccess.Write) 
    229                         Dim b As Integer 
    230                         Using fs 
    231                             While True 
    232                                 b = strm.ReadByte() 
    233                                 If b = -1 Then Exit While 
    234                                 fs.WriteByte(Convert.ToByte(b)) 
    235                             End While 
    236                         End Using 
    237                         strm.Close() 
    238                         strm.Dispose() 
    239                         webRes.Close() 
    240                     Case REQ_TYPE.ReqGETFileUp 
    241                         Dim fs As New System.IO.FileStream(My.Application.Info.DirectoryPath + "\TweenUp.exe", FileMode.Create, FileAccess.Write) 
    242                         Dim b As Integer 
    243                         Using fs 
    244                             While True 
    245                                 b = strm.ReadByte() 
    246                                 If b = -1 Then Exit While 
    247                                 fs.WriteByte(Convert.ToByte(b)) 
    248                             End While 
    249                         End Using 
    250                         strm.Close() 
    251                         strm.Dispose() 
    252                         webRes.Close() 
    253                     Case REQ_TYPE.ReqGETFileRes 
    254                         If Directory.Exists(My.Application.Info.DirectoryPath + "\en") = False Then 
    255                             Directory.CreateDirectory(My.Application.Info.DirectoryPath + "\en") 
    256                         End If 
    257                         Dim fs As New System.IO.FileStream(My.Application.Info.DirectoryPath + "\en\Tween.resourcesNew.dll", FileMode.Create, FileAccess.Write) 
    258                         Dim b As Integer 
    259                         Using fs 
    260                             While True 
    261                                 b = strm.ReadByte() 
    262                                 If b = -1 Then Exit While 
    263                                 fs.WriteByte(Convert.ToByte(b)) 
    264                             End While 
    265                         End Using 
    266                         strm.Close() 
    267                         strm.Dispose() 
    268                         webRes.Close() 
    269                     Case REQ_TYPE.ReqGETForwardTo 
    270                         strm.Close() 
    271                         strm.Dispose() 
    272                         Dim rtStr As String = "" 
    273                         If webRes.StatusCode = HttpStatusCode.Moved OrElse _ 
    274                            webRes.StatusCode = HttpStatusCode.Found Then 
    275                             rtStr = webRes.Headers.GetValues("Location")(0) 
     195 
     196                Using strm As Stream = webRes.GetResponseStream() 
     197                    Select Case reqType 
     198                        Case REQ_TYPE.ReqGET, REQ_TYPE.ReqPOST, REQ_TYPE.ReqPOSTEncode, REQ_TYPE.ReqPOSTEncodeProtoVer1, REQ_TYPE.ReqPOSTEncodeProtoVer2, REQ_TYPE.ReqPOSTEncodeProtoVer3, REQ_TYPE.ReqGetNoCache, REQ_TYPE.ReqPOSTAPI, REQ_TYPE.ReqGetAPI 
     199                            Dim rtStr As String 
     200                            Using sr As New StreamReader(strm, _enc) 
     201                                rtStr = sr.ReadToEnd() 
     202                            End Using 
    276203                            Return rtStr 
    277                         End If 
    278                         webRes.Close() 
    279                 End Select 
     204                        Case REQ_TYPE.ReqGETBinary 
     205                            Dim readData(1023) As Byte 
     206                            Dim readSize As Integer = 0 
     207                            Dim img As Image 
     208                            Using mem As New MemoryStream 
     209                                While True 
     210                                    readSize = strm.Read(readData, 0, readData.Length) 
     211                                    If readSize = 0 Then 
     212                                        Exit While 
     213                                    End If 
     214                                    mem.Write(readData, 0, readSize) 
     215                                End While 
     216                                img = Image.FromStream(mem, True) 
     217                            End Using 
     218                            Return img 
     219                        Case REQ_TYPE.ReqGETFile 
     220                            Dim fs As New System.IO.FileStream(My.Application.Info.DirectoryPath + "\TweenNew.exe", FileMode.Create, FileAccess.Write) 
     221                            Dim b As Integer 
     222                            Using fs 
     223                                While True 
     224                                    b = strm.ReadByte() 
     225                                    If b = -1 Then Exit While 
     226                                    fs.WriteByte(Convert.ToByte(b)) 
     227                                End While 
     228                            End Using 
     229                        Case REQ_TYPE.ReqGETFileUp 
     230                            Dim fs As New System.IO.FileStream(My.Application.Info.DirectoryPath + "\TweenUp.exe", FileMode.Create, FileAccess.Write) 
     231                            Dim b As Integer 
     232                            Using fs 
     233                                While True 
     234                                    b = strm.ReadByte() 
     235                                    If b = -1 Then Exit While 
     236                                    fs.WriteByte(Convert.ToByte(b)) 
     237                                End While 
     238                            End Using 
     239                        Case REQ_TYPE.ReqGETFileRes 
     240                            If Directory.Exists(My.Application.Info.DirectoryPath + "\en") = False Then 
     241                                Directory.CreateDirectory(My.Application.Info.DirectoryPath + "\en") 
     242                            End If 
     243                            Dim fs As New System.IO.FileStream(My.Application.Info.DirectoryPath + "\en\Tween.resourcesNew.dll", FileMode.Create, FileAccess.Write) 
     244                            Dim b As Integer 
     245                            Using fs 
     246                                While True 
     247                                    b = strm.ReadByte() 
     248                                    If b = -1 Then Exit While 
     249                                    fs.WriteByte(Convert.ToByte(b)) 
     250                                End While 
     251                            End Using 
     252                        Case REQ_TYPE.ReqGETForwardTo 
     253                            Dim rtStr As String = "" 
     254                            If webRes.StatusCode = HttpStatusCode.Moved OrElse _ 
     255                               webRes.StatusCode = HttpStatusCode.Found Then 
     256                                rtStr = webRes.Headers.GetValues("Location")(0) 
     257                                Return rtStr 
     258                            End If 
     259                    End Select 
     260                End Using 
    280261            End Using 
    281  
    282262        Catch ex As System.Net.WebException 
    283263            If ex.Status = WebExceptionStatus.ProtocolError Then 
  • lang/vb2005/Tween/Tween/TwConfig.vb

    r25852 r25955  
    11961196    End Property 
    11971197 
    1198     Private Function EncryptString(ByVal str As String) As String 
     1198    Private Shared Function EncryptString(ByVal str As String) As String 
    11991199        '文字列をバイト型配列にする 
    12001200        Dim bytesIn As Byte() = System.Text.Encoding.UTF8.GetBytes(str) 
     
    12371237    End Function 
    12381238 
    1239     Private Function DecryptString(ByVal str As String) As String 
     1239    Private Shared Function DecryptString(ByVal str As String) As String 
    12401240        'DESCryptoServiceProviderオブジェクトの作成 
    12411241        Dim des As New System.Security.Cryptography.DESCryptoServiceProvider 
  • lang/vb2005/Tween/Tween/Tween.vb

    r25915 r25955  
    6363    Private _clAtTarget As Color          '選択発言中の返信先用背景色 
    6464    Private _clAtFromTarget As Color      '選択発言者への返信発言用背景色 
    65     Private _postCounter As Integer       '取得発言数カウンタ(カウントしているが未使用。タブ別カウンタに変更&未読数カウントとして未読アイコン表示パフォーマンスUPできるように改善したい) 
    6665    Private TIconList As ImageList        '発言詳細部用アイコン画像リスト 
    6766    Private TIconSmallList As ImageList   'リスト表示用アイコン画像リスト 
     
    9493    Private _tlCount As Integer 
    9594    Private ReadOnly _syncObject As New Object()    'ロック用   
    96     Private _StatusSelectionStart As Integer        ' 一時退避用 
    97     Private _StatusSelectionLength As Integer       ' 一時退避用 
    9895 
    9996    ' 以下DrawItem関連 
     
    167164        Public tName As String                      'Fav追加・削除時のタブ名 
    168165    End Structure 
     166 
     167    Private Sub TweenMain_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed 
     168        '後始末 
     169        SettingDialog.Dispose() 
     170        TabDialog.Dispose() 
     171        SearchDialog.Dispose() 
     172        fDialog.Dispose() 
     173        UrlDialog.Dispose() 
     174        If TIconList IsNot Nothing Then TIconList.Dispose() 
     175        If TIconSmallList IsNot Nothing Then TIconSmallList.Dispose() 
     176        If NIconAt IsNot Nothing Then NIconAt.Dispose() 
     177        If NIconAtRed IsNot Nothing Then NIconAtRed.Dispose() 
     178        If NIconAtSmoke IsNot Nothing Then NIconAtSmoke.Dispose() 
     179        If NIconRefresh(0) IsNot Nothing Then NIconRefresh(0).Dispose() 
     180        If NIconRefresh(1) IsNot Nothing Then NIconRefresh(1).Dispose() 
     181        If NIconRefresh(2) IsNot Nothing Then NIconRefresh(2).Dispose() 
     182        If NIconRefresh(3) IsNot Nothing Then NIconRefresh(3).Dispose() 
     183        If TabIcon IsNot Nothing Then TabIcon.Dispose() 
     184        If MainIcon IsNot Nothing Then MainIcon.Dispose() 
     185        _brsHighLight.Dispose() 
     186        _brsHighLightText.Dispose() 
     187        If _brsForeColorUnread IsNot Nothing Then _brsForeColorUnread.Dispose() 
     188        If _brsForeColorReaded IsNot Nothing Then _brsForeColorReaded.Dispose() 
     189        If _brsForeColorFav IsNot Nothing Then _brsForeColorFav.Dispose() 
     190        If _brsForeColorOWL IsNot Nothing Then _brsForeColorOWL.Dispose() 
     191        If _brsBackColorMine IsNot Nothing Then _brsBackColorMine.Dispose() 
     192        If _brsBackColorAt IsNot Nothing Then _brsBackColorAt.Dispose() 
     193        If _brsBackColorYou IsNot Nothing Then _brsBackColorYou.Dispose() 
     194        If _brsBackColorAtYou IsNot Nothing Then _brsBackColorAtYou.Dispose() 
     195        If _brsBackColorAtTo IsNot Nothing Then _brsBackColorAtTo.Dispose() 
     196        If _brsBackColorNone IsNot Nothing Then _brsBackColorNone.Dispose() 
     197        sf.Dispose() 
     198    End Sub 
    169199 
    170200    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     
    19892019 
    19902020    Private Sub FavRemoveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavRemoveToolStripMenuItem.Click 
    1991  
    19922021        Dim cnt As Integer = 0 
    1993         Dim rtn As String = "" 
    1994         Dim msg As String = "" 
    1995         Dim cnt2 As Integer = 0 
    19962022        Dim MyList As DetailsListView = DirectCast(ListTab.SelectedTab.Controls(0), DetailsListView) 
    1997         Dim MyList2 As DetailsListView = Nothing 
    1998         Dim cnt3 As Integer = 0 
    1999         Dim tabName As String = ListTab.SelectedTab.Text 
    2000         Dim idx As Integer = 0 
    2001         Dim flw As Boolean = False 
    20022023 
    20032024        If ListTab.SelectedTab.Text = "Direct" OrElse MyList.SelectedItems.Count = 0 Then Exit Sub 
     
    21192140        Dim lItem As Twitter.MyListItem 
    21202141        Dim cnt As Integer = 0 
    2121         Dim unread As Integer = 0 
    21222142        Dim newCnt As Integer = 0 
    21232143        Dim _pop As String = "" 
     
    26202640 
    26212641    Private Sub RefreshStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshStripMenuItem.Click 
    2622         Dim MyList As DetailsListView = DirectCast(ListTab.SelectedTab.Controls(0), DetailsListView) 
    2623  
    26242642        NotifyIcon1.Icon = NIconRefresh(0) 
    26252643        _refreshIconCnt = 0 
     
    31453163    Private Sub ListTab_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseMove 
    31463164        Dim cpos As New Point(e.X, e.Y) 
    3147         Dim spos As Point = ListTab.PointToClient(cpos) 
    31483165 
    31493166        If e.Button = Windows.Forms.MouseButtons.Left And _tabDrag Then 
     
    38393856        Dim toIdx As Integer 
    38403857        Dim stp As Integer = 1 
    3841         Dim tabIdx As Integer = 0 
    38423858 
    38433859        myList.Focus() 
     
    39964012                        g.DrawImage(TIconList.Images(key), 0, 0, sz, sz) 
    39974013                        TIconSmallList.Images.Add(key, img2) 
    3998                         g.Dispose() 
    3999                         img2.Dispose() 
    40004014                    End Using 
    40014015                End Using 
     
    40104024    Private Sub CheckNewVersion(Optional ByVal startup As Boolean = False) 
    40114025        Dim retMsg As String 
    4012         Dim resStatus As String = "" 
    40134026        Dim strVer As String 
    40144027        Dim forceUpdate As Boolean = My.Computer.Keyboard.ShiftKeyDown 
     
    42894302        If MyList.SelectedItems.Count = 0 Then Exit Sub 
    42904303 
    4291         Dim user As String = MyList.SelectedItems(0).SubItems(4).Text 
    42924304        Dim fIdx As Integer = MyList.SelectedItems(0).Index + 1 
    42934305        If fIdx > MyList.Items.Count - 1 Then Exit Sub 
     
    43134325        If MyList.SelectedItems.Count = 0 Then Exit Sub 
    43144326 
    4315         Dim user As String = MyList.SelectedItems(0).SubItems(4).Text 
    43164327        Dim fIdx As Integer = MyList.SelectedItems(0).Index - 1 
    43174328        If fIdx < 0 Then Exit Sub 
     
    48434854    Private Sub Tabs_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDown 
    48444855        Dim cpos As New Point(e.X, e.Y) 
    4845         Dim spos As Point = ListTab.PointToClient(cpos) 
    48464856        If e.Button = Windows.Forms.MouseButtons.Left Then 
    48474857            For i As Integer = 0 To ListTab.TabPages.Count - 1 
     
    56105620                        For Each itm As ListViewItem In ts2.listCustom.Items 
    56115621                            Dim mv As Boolean = False 
    5612                             Dim nf As Boolean = False 
    56135622                            Dim mk As Boolean = False 
    56145623                            Dim lItem As New Twitter.MyListItem() 
     
    57155724                For Each itm As ListViewItem In itms 
    57165725                    Dim mv As Boolean = False 
    5717                     Dim nf As Boolean = False 
    57185726                    Dim mk As Boolean = False 
    57195727                    Dim lItem As New Twitter.MyListItem() 
     
    61326140                                     "*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?") 
    61336141 
    6134         Dim src As String = "" 
    61356142 
    61366143        If StatusText.SelectionLength > 0 Then 
  • lang/vb2005/Tween/Tween/Twitter.vb

    r25905 r25955  
    432432                            Return "GetTimeline -> Err: Can't get body." 
    433433                        End Try 
     434                        orgData = Regex.Replace(orgData, "<a href=""https://twitter\.com/" + lItem.Name + "/status/[0-9]+"">\.\.\.</a>$", "") 
    434435                        orgData = orgData.Replace("&lt;3", "♡") 
    435436                    End If 
     
    612613        Dim retMsg As String = "" 
    613614        Dim resStatus As String = "" 
    614         Dim moreRead As Boolean = True 
    615         Dim oldID As String = "" 
    616         Dim oldName As String = "" 
    617615 
    618616        endPage = page 
     
    779777                            orgData = strPost.Substring(pos1 + _parseDM11.Length, pos2 - pos1 - _parseDM11.Length).Trim() 
    780778                        End If 
     779                        orgData = Regex.Replace(orgData, "<a href=""https://twitter\.com/" + lItem.Name + "/status/[0-9]+"">\.\.\.</a>$", "") 
    781780                        orgData = orgData.Replace("&lt;3", "♡") 
    782781                    Catch ex As Exception 
     
    923922        Dim resStatus As String = "" 
    924923        Dim img As Image = Nothing 
    925         Dim cnt As Integer = 1 
    926924 
    927925        img = DirectCast(_mySock.GetWebResponse(pathUrl, resStatus, MySocket.REQ_TYPE.ReqGETBinary), System.Drawing.Image)