1 ' Tween - Client of Twitter
2 ' Copyright (c) 2007-2010 kiri_feather (@kiri_feather) <kiri_feather@gmail.com>
3 ' (c) 2008-2010 Moz (@syo68k) <http://iddy.jp/profile/moz/>
4 ' (c) 2008-2010 takeshik (@takeshik) <http://www.takeshik.org/>
7 ' This file is part of Tween.
9 ' This program is free software; you can redistribute it and/or modify it
10 ' under the terms of the GNU General Public License as published by the Free
11 ' Software Foundation; either version 3 of the License, or (at your option)
14 ' This program is distributed in the hope that it will be useful, but
15 ' WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ' or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 ' You should have received a copy of the GNU General Public License along
20 ' with this program. If not, see <http://www.gnu.org/licenses/>, or write to
21 ' the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
22 ' Boston, MA 02110-1301, USA.
25 '"c:\Program Files\Microsoft.NET\SDK\v2.0\Bin\sgen.exe" /f /a:"$(TargetPath)"
26 '"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /f /a:"$(TargetPath)"
31 Imports System.Text.RegularExpressions
32 Imports Tween.TweenCustomControl
35 Imports System.Reflection
36 Imports System.ComponentModel
37 Imports System.Diagnostics
38 Imports Microsoft.Win32
41 Imports System.Threading
43 Public Class TweenMain
46 Private _mySize As Size '画面サイズ
47 Private _myLoc As Point '画面位置
48 Private _mySpDis As Integer '区切り位置
49 Private _mySpDis2 As Integer '発言欄区切り位置
50 Private _mySpDis3 As Integer 'プレビュー区切り位置
51 Private _iconSz As Integer 'アイコンサイズ(現在は16、24、48の3種類。将来直接数字指定可能とする 注:24x24の場合に26と指定しているのはMSゴシック系フォントのための仕様)
52 Private _iconCol As Boolean '1列表示の時True(48サイズのとき)
55 Private _initial As Boolean 'True:起動時処理中
56 Private _initialLayout As Boolean = True
57 Private _ignoreConfigSave As Boolean 'True:起動時処理中
58 Private _tabDrag As Boolean 'タブドラッグ中フラグ(DoDragDropを実行するかの判定用)
59 Private _rclickTabName As String '右クリックしたタブの名前(Tabコントロール機能不足対応)
60 Private ReadOnly _syncObject As New Object() 'ロック用
61 Private Const detailHtmlFormatMono1 As String = "<html><head><style type=""text/css""><!-- pre {font-family: """
62 Private Const detailHtmlFormat2 As String = """, sans-serif; font-size: "
63 Private Const detailHtmlFormat3 As String = "pt; word-wrap: break-word; color:rgb("
64 Private Const detailHtmlFormat4 As String = ");} a:link, a:visited, a:active, a:hover {color:rgb("
65 Private Const detailHtmlFormat5 As String = "); } --></style></head><body style=""margin:0px; background-color:rgb("
66 Private Const detailHtmlFormatMono6 As String = ");""><pre>"
67 Private Const detailHtmlFormatMono7 As String = "</pre></body></html>"
68 Private Const detailHtmlFormat1 As String = "<html><head><style type=""text/css""><!-- p {font-family: """
69 Private Const detailHtmlFormat6 As String = ");""><p>"
70 Private Const detailHtmlFormat7 As String = "</p></body></html>"
71 Private detailHtmlFormatHeader As String
72 Private detailHtmlFormatFooter As String
73 Private _myStatusError As Boolean = False
74 Private _myStatusOnline As Boolean = False
75 Private soundfileListup As Boolean = False
76 Private _spaceKeyCanceler As SpaceKeyCanceler
79 'Private _cfg As SettingToConfig '旧
80 Private _cfgLocal As SettingLocal
81 Private _cfgCommon As SettingCommon
82 Private _modifySettingLocal As Boolean = False
83 Private _modifySettingCommon As Boolean = False
84 Private _modifySettingAtId As Boolean = False
87 Private tw As New Twitter
90 Private SettingDialog As Setting = Setting.Instance '設定画面インスタンス
91 Private TabDialog As New TabsDialog 'タブ選択ダイアログインスタンス
92 Private SearchDialog As New SearchWord '検索画面インスタンス
93 Private fDialog As New FilterDialog 'フィルター編集画面
94 Private UrlDialog As New OpenURL
95 Private dialogAsShieldicon As DialogAsShieldIcon ' シールドアイコン付きダイアログ
96 Public AtIdSupl As AtIdSupplement '@id補助
97 Public HashSupl As AtIdSupplement 'Hashtag補助
98 Public HashMgr As HashtagManage
101 Private _fntUnread As Font '未読用フォント
102 Private _clUnread As Color '未読用文字色
103 Private _fntReaded As Font '既読用フォント
104 Private _clReaded As Color '既読用文字色
105 Private _clFav As Color 'Fav用文字色
106 Private _clOWL As Color '片思い用文字色
107 Private _clRetweet As Color 'Retweet用文字色
108 Private _fntDetail As Font '発言詳細部用フォント
109 Private _clDetail As Color '発言詳細部用色
110 Private _clDetailLink As Color '発言詳細部用リンク文字色
111 Private _clDetailBackcolor As Color '発言詳細部用背景色
112 Private _clSelf As Color '自分の発言用背景色
113 Private _clAtSelf As Color '自分宛返信用背景色
114 Private _clTarget As Color '選択発言者の他の発言用背景色
115 Private _clAtTarget As Color '選択発言中の返信先用背景色
116 Private _clAtFromTarget As Color '選択発言者への返信発言用背景色
117 Private _clAtTo As Color '選択発言の唯一@先
118 Private _clListBackcolor As Color 'リスト部通常発言背景色
119 Private _clInputBackcolor As Color '入力欄背景色
120 Private _clInputFont As Color '入力欄文字色
121 Private _fntInputFont As Font '入力欄フォント
122 Private TIconDic As IDictionary(Of String, Image) 'アイコン画像リスト
123 Private NIconAt As Icon 'At.ico タスクトレイアイコン:通常時
124 Private NIconAtRed As Icon 'AtRed.ico タスクトレイアイコン:通信エラー時
125 Private NIconAtSmoke As Icon 'AtSmoke.ico タスクトレイアイコン:オフライン時
126 Private NIconRefresh(3) As Icon 'Refresh.ico タスクトレイアイコン:更新中(アニメーション用に4種類を保持するリスト)
127 Private TabIcon As Icon 'Tab.ico 未読のあるタブ用アイコン
128 Private MainIcon As Icon 'Main.ico 画面左上のアイコン
129 Private ReplyIcon As Icon '5g
130 Private ReplyIconBlink As Icon '6g
132 Private _anchorPost As PostClass
133 Private _anchorFlag As Boolean 'True:関連発言移動中(関連移動以外のオペレーションをするとFalseへ。Trueだとリスト背景色をアンカー発言選択中として描画)
135 Private _history As New List(Of PostingStatus) '発言履歴
136 Private _hisIdx As Integer '発言履歴カレントインデックス
138 '発言投稿時のAPI引数(発言編集時に設定。手書きreplyでは設定されない)
139 Private _reply_to_id As Long ' リプライ先のステータスID 0の場合はリプライではない 注:複数あてのものはリプライではない
140 Private _reply_to_name As String ' リプライ先ステータスの書き込み者の名前
143 Private _postTimestamps As New List(Of Date)
144 Private _favTimestamps As New List(Of Date)
145 Private _tlTimestamps As New Dictionary(Of Date, Integer)
146 Private _tlCount As Integer
149 Private _brsHighLight As New SolidBrush(Color.FromKnownColor(KnownColor.Highlight))
150 Private _brsHighLightText As New SolidBrush(Color.FromKnownColor(KnownColor.HighlightText))
151 Private _brsForeColorUnread As SolidBrush
152 Private _brsForeColorReaded As SolidBrush
153 Private _brsForeColorFav As SolidBrush
154 Private _brsForeColorOWL As SolidBrush
155 Private _brsForeColorRetweet As SolidBrush
156 Private _brsBackColorMine As SolidBrush
157 Private _brsBackColorAt As SolidBrush
158 Private _brsBackColorYou As SolidBrush
159 Private _brsBackColorAtYou As SolidBrush
160 Private _brsBackColorAtFromTarget As SolidBrush
161 Private _brsBackColorAtTo As SolidBrush
162 Private _brsBackColorNone As SolidBrush
163 Private _brsDeactiveSelection As New SolidBrush(Color.FromKnownColor(KnownColor.ButtonFace)) 'Listにフォーカスないときの選択行の背景色
164 'Private sf As New StringFormat()
165 Private sfTab As New StringFormat()
167 '''''''''''''''''''''''''''''''''''''''''''''''''''''
168 Private _apiGauge As New ToolStripAPIGauge()
169 Private _statuses As TabInformations
170 Private _itemCache() As ListViewItem
171 Private _itemCacheIndex As Integer
172 Private _postCache() As PostClass
173 Private _curTab As TabPage
174 Private _curItemIndex As Integer
175 Private _curList As DetailsListView
176 Private _curPost As PostClass
177 Private _isColumnChanged As Boolean = False
178 'Private _waitFollower As Boolean = False
179 Private _waitTimeline As Boolean = False
180 Private _waitReply As Boolean = False
181 Private _waitDm As Boolean = False
182 Private _waitFav As Boolean = False
183 Private _waitPubSearch As Boolean = False
184 Private _waitLists As Boolean = False
185 Private _bw(18) As BackgroundWorker
186 Private _bwFollower As BackgroundWorker
187 Private cMode As Integer
188 Private shield As New ShieldIcon
189 Private SecurityManager As InternetSecurityManager
190 Private Thumbnail As Thumbnail
192 'Private _homeCounter As Integer = 0
193 'Private _homeCounterAdjuster As Integer = 0
194 'Private _mentionCounter As Integer = 0
195 'Private _dmCounter As Integer = 0
196 'Private _pubSearchCounter As Integer = 0
197 'Private _listsCounter As Integer = 0
199 Private UnreadCounter As Integer = -1
200 Private UnreadAtCounter As Integer = -1
202 Private ColumnOrgText(8) As String
203 Private ColumnText(8) As String
205 'Private _UseAdditionalFlags As Boolean = False
206 'Private _FirstRefreshFlags As Boolean = False
207 'Private _FirstListsRefreshFlags As Boolean = False
209 Private _DoFavRetweetFlags As Boolean = False
211 '''''''''''''''''''''''''''''''''''''''''''''''''''''
212 Private _postBrowserStatusText As String = ""
214 Private _colorize As Boolean = False
216 Private WithEvents TimerTimeline As New System.Timers.Timer
219 Private Structure urlUndo
220 Public Before As String
221 Public After As String
224 Private urlUndoBuffer As Generic.List(Of urlUndo) = Nothing
226 Private Structure ReplyChain
227 Public OriginalId As Long
228 Public InReplyToId As Long
229 Public OriginalTab As TabPage
231 Sub New(ByVal originalId As Long, ByVal inReplyToId As Long, ByVal originalTab As TabPage)
232 Me.OriginalId = originalId
233 Me.InReplyToId = inReplyToId
234 Me.OriginalTab = originalTab
238 Private replyChains As Stack(Of ReplyChain)
240 'Backgroundworkerの処理結果通知用引数構造体
241 Private Class GetWorkerResult
242 Public retMsg As String = "" '処理結果詳細メッセージ。エラー時に値がセットされる
243 Public page As Integer '取得対象ページ番号
244 Public endPage As Integer '取得終了ページ番号(継続可能ならインクリメントされて返る。pageと比較して継続判定)
245 Public type As WORKERTYPE '処理種別
246 Public imgs As Dictionary(Of String, Image) '新規取得したアイコンイメージ
247 Public tName As String = "" 'Fav追加・削除時のタブ名
248 Public ids As List(Of Long) 'Fav追加・削除時のID
249 Public sIds As List(Of Long) 'Fav追加・削除成功分のID
250 Public newDM As Boolean
251 Public addCount As Integer
252 Public status As PostingStatus
255 'Backgroundworkerへ処理内容を通知するための引数用構造体
256 Private Class GetWorkerArg
257 Public page As Integer '処理対象ページ番号
258 Public endPage As Integer '処理終了ページ番号(起動時の読み込みページ数。通常時はpageと同じ値をセット)
259 Public type As WORKERTYPE '処理種別
260 Public url As String = "" 'URLをブラウザで開くときのアドレス
261 Public status As New PostingStatus '発言POST時の発言内容
262 Public ids As List(Of Long) 'Fav追加・削除時のItemIndex
263 Public sIds As List(Of Long) 'Fav追加・削除成功分のItemIndex
264 Public tName As String = "" 'Fav追加・削除時のタブ名
268 Private Enum SEARCHTYPE
274 Private Class PostingStatus
275 Public status As String = ""
276 Public inReplyToId As Long = 0
277 Public inReplyToName As String = ""
278 Public imageService As String = "" '画像投稿サービス名
279 Public imagePath As String = ""
283 Public Sub New(ByVal status As String, ByVal replyToId As Long, ByVal replyToName As String)
285 Me.inReplyToId = replyToId
286 Me.inReplyToName = replyToName
290 Private Class SpaceKeyCanceler
291 Inherits NativeWindow
292 Implements IDisposable
294 Dim WM_KEYDOWN As Integer = &H100
295 Dim VK_SPACE As Integer = &H20
297 Public Sub New(ByVal control As Control)
298 Me.AssignHandle(control.Handle)
301 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
302 If (m.Msg = WM_KEYDOWN) AndAlso (CInt(m.WParam) = VK_SPACE) Then
303 RaiseEvent SpaceCancel(Me, EventArgs.Empty)
310 Public Event SpaceCancel As EventHandler
312 Public Sub Dispose() Implements IDisposable.Dispose
317 Private Sub TweenMain_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
318 '画面がアクティブになったら、発言欄の背景色戻す
319 If StatusText.Focused Then
320 Me.StatusText_Enter(Me.StatusText, System.EventArgs.Empty)
324 Private Sub TweenMain_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
326 SettingDialog.Dispose()
328 SearchDialog.Dispose()
331 _spaceKeyCanceler.Dispose()
332 If NIconAt IsNot Nothing Then NIconAt.Dispose()
333 If NIconAtRed IsNot Nothing Then NIconAtRed.Dispose()
334 If NIconAtSmoke IsNot Nothing Then NIconAtSmoke.Dispose()
335 If NIconRefresh(0) IsNot Nothing Then NIconRefresh(0).Dispose()
336 If NIconRefresh(1) IsNot Nothing Then NIconRefresh(1).Dispose()
337 If NIconRefresh(2) IsNot Nothing Then NIconRefresh(2).Dispose()
338 If NIconRefresh(3) IsNot Nothing Then NIconRefresh(3).Dispose()
339 If TabIcon IsNot Nothing Then TabIcon.Dispose()
340 If MainIcon IsNot Nothing Then MainIcon.Dispose()
341 If ReplyIcon IsNot Nothing Then ReplyIcon.Dispose()
342 If ReplyIconBlink IsNot Nothing Then ReplyIconBlink.Dispose()
343 _brsHighLight.Dispose()
344 _brsHighLightText.Dispose()
345 If _brsForeColorUnread IsNot Nothing Then _brsForeColorUnread.Dispose()
346 If _brsForeColorReaded IsNot Nothing Then _brsForeColorReaded.Dispose()
347 If _brsForeColorFav IsNot Nothing Then _brsForeColorFav.Dispose()
348 If _brsForeColorOWL IsNot Nothing Then _brsForeColorOWL.Dispose()
349 If _brsForeColorRetweet IsNot Nothing Then _brsForeColorRetweet.Dispose()
350 If _brsBackColorMine IsNot Nothing Then _brsBackColorMine.Dispose()
351 If _brsBackColorAt IsNot Nothing Then _brsBackColorAt.Dispose()
352 If _brsBackColorYou IsNot Nothing Then _brsBackColorYou.Dispose()
353 If _brsBackColorAtYou IsNot Nothing Then _brsBackColorAtYou.Dispose()
354 If _brsBackColorAtFromTarget IsNot Nothing Then _brsBackColorAtFromTarget.Dispose()
355 If _brsBackColorAtTo IsNot Nothing Then _brsBackColorAtTo.Dispose()
356 If _brsBackColorNone IsNot Nothing Then _brsBackColorNone.Dispose()
357 If _brsDeactiveSelection IsNot Nothing Then _brsDeactiveSelection.Dispose()
361 For Each bw As BackgroundWorker In _bw
362 If bw IsNot Nothing Then
366 If _bwFollower IsNot Nothing Then
367 _bwFollower.Dispose()
369 Me._apiGauge.Dispose()
370 If TIconDic IsNot Nothing Then DirectCast(TIconDic, IDisposable).Dispose()
373 Private Sub LoadIcon(ByRef IconInstance As Icon, ByVal FileName As String)
374 Dim dir As String = Application.StartupPath
375 If File.Exists(Path.Combine(dir, FileName)) Then
377 IconInstance = New Icon(Path.Combine(dir, FileName))
378 Catch ex As Exception
383 Private Sub LoadIcons()
386 Dim dir As String = Application.StartupPath
388 NIconAt = My.Resources.At
389 NIconAtRed = My.Resources.AtRed
390 NIconAtSmoke = My.Resources.AtSmoke
391 NIconRefresh(0) = My.Resources.Refresh
392 NIconRefresh(1) = My.Resources.Refresh2
393 NIconRefresh(2) = My.Resources.Refresh3
394 NIconRefresh(3) = My.Resources.Refresh4
395 TabIcon = My.Resources.TabIcon
396 MainIcon = My.Resources.MIcon
397 ReplyIcon = My.Resources.Reply
398 ReplyIconBlink = My.Resources.ReplyBlink
400 If Not Directory.Exists(Path.Combine(dir, "Icons")) Then
404 LoadIcon(NIconAt, "Icons\At.ico")
407 LoadIcon(NIconAtRed, "Icons\AtRed.ico")
410 LoadIcon(NIconAtSmoke, "Icons\AtSmoke.ico")
414 LoadIcon(NIconRefresh(0), "Icons\Refresh.ico")
415 LoadIcon(NIconRefresh(1), "Icons\Refresh2.ico")
416 LoadIcon(NIconRefresh(2), "Icons\Refresh3.ico")
417 LoadIcon(NIconRefresh(3), "Icons\Refresh4.ico")
420 LoadIcon(TabIcon, "Icons\Tab.ico")
423 LoadIcon(MainIcon, "Icons\MIcon.ico")
426 LoadIcon(ReplyIcon, "Icons\Reply.ico")
429 LoadIcon(ReplyIconBlink, "Icons\ReplyBlink.ico")
432 Private Sub InitColumnText()
435 ColumnText(1) = My.Resources.AddNewTabText2
436 ColumnText(2) = My.Resources.AddNewTabText3
437 ColumnText(3) = My.Resources.AddNewTabText4_2
438 ColumnText(4) = My.Resources.AddNewTabText5
441 ColumnText(7) = "Source"
443 ColumnOrgText(0) = ""
444 ColumnOrgText(1) = My.Resources.AddNewTabText2
445 ColumnOrgText(2) = My.Resources.AddNewTabText3
446 ColumnOrgText(3) = My.Resources.AddNewTabText4_2
447 ColumnOrgText(4) = My.Resources.AddNewTabText5
448 ColumnOrgText(5) = ""
449 ColumnOrgText(6) = ""
450 ColumnOrgText(7) = "Source"
453 Select Case _statuses.SortMode
454 Case IdComparerClass.ComparerMode.Nickname 'ニックネーム
456 Case IdComparerClass.ComparerMode.Data '本文
458 Case IdComparerClass.ComparerMode.Id '時刻=発言Id
460 Case IdComparerClass.ComparerMode.Name '名前
462 Case IdComparerClass.ComparerMode.Source 'Source
467 If _statuses.SortOrder() = SortOrder.Descending Then
468 ' U+25BE BLACK DOWN-POINTING SMALL TRIANGLE
469 ColumnText(2) = ColumnOrgText(2) + "▾"
471 ' U+25B4 BLACK UP-POINTING SMALL TRIANGLE
472 ColumnText(2) = ColumnOrgText(2) + "▴"
475 If _statuses.SortOrder() = SortOrder.Descending Then
476 ' U+25BE BLACK DOWN-POINTING SMALL TRIANGLE
477 ColumnText(c) = ColumnOrgText(c) + "▾"
479 ' U+25B4 BLACK UP-POINTING SMALL TRIANGLE
480 ColumnText(c) = ColumnOrgText(c) + "▴"
485 Private Sub InitializeTraceFrag()
487 TraceOutToolStripMenuItem.Checked = True
490 If Not fileVersion.EndsWith("0") Then
491 TraceOutToolStripMenuItem.Checked = True
496 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
497 _ignoreConfigSave = True
499 SecurityManager = New InternetSecurityManager(PostBrowser)
500 Thumbnail = New Thumbnail(Me)
502 AddHandler TwitterApiInfo.Changed, AddressOf SetStatusLabelApiHandler
504 VerUpMenuItem.Image = shield.Icon
505 If Not My.Application.CommandLineArgs.Count = 0 AndAlso My.Application.CommandLineArgs.Contains("/d") Then TraceFlag = True
507 Me._spaceKeyCanceler = New SpaceKeyCanceler(Me.PostButton)
508 AddHandler Me._spaceKeyCanceler.SpaceCancel, AddressOf spaceKeyCanceler_SpaceCancel
510 Regex.CacheSize = 100
512 fileVersion = DirectCast(Assembly.GetExecutingAssembly().GetCustomAttributes(GetType(AssemblyFileVersionAttribute), False)(0), AssemblyFileVersionAttribute).Version
513 InitializeTraceFrag()
514 LoadIcons() ' アイコン読み込み
517 _statuses = TabInformations.GetInstance()
520 Me.Icon = MainIcon 'メインフォーム(TweenMain)
521 NotifyIcon1.Icon = NIconAt 'タスクトレイ
522 TabImage.Images.Add(TabIcon) 'タブ見出し
524 SettingDialog.Owner = Me
525 SearchDialog.Owner = Me
530 _history.Add(New PostingStatus)
535 '<<<<<<<<<設定関連>>>>>>>>>
542 NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop
543 Me.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked
546 _fntUnread = _cfgLocal.FontUnread
547 _clUnread = _cfgLocal.ColorUnread
548 _fntReaded = _cfgLocal.FontRead
549 _clReaded = _cfgLocal.ColorRead
550 _clFav = _cfgLocal.ColorFav
551 _clOWL = _cfgLocal.ColorOWL
552 _clRetweet = _cfgLocal.ColorRetweet
553 _fntDetail = _cfgLocal.FontDetail
554 _clDetail = _cfgLocal.ColorDetail
555 _clDetailLink = _cfgLocal.ColorDetailLink
556 _clDetailBackcolor = _cfgLocal.ColorDetailBackcolor
557 _clSelf = _cfgLocal.ColorSelf
558 _clAtSelf = _cfgLocal.ColorAtSelf
559 _clTarget = _cfgLocal.ColorTarget
560 _clAtTarget = _cfgLocal.ColorAtTarget
561 _clAtFromTarget = _cfgLocal.ColorAtFromTarget
562 _clAtTo = _cfgLocal.ColorAtTo
563 _clListBackcolor = _cfgLocal.ColorListBackcolor
564 _clInputBackcolor = _cfgLocal.ColorInputBackcolor
565 _clInputFont = _cfgLocal.ColorInputFont
566 _fntInputFont = _cfgLocal.FontInputFont
568 _brsForeColorUnread = New SolidBrush(_clUnread)
569 _brsForeColorReaded = New SolidBrush(_clReaded)
570 _brsForeColorFav = New SolidBrush(_clFav)
571 _brsForeColorOWL = New SolidBrush(_clOWL)
572 _brsForeColorRetweet = New SolidBrush(_clRetweet)
573 _brsBackColorMine = New SolidBrush(_clSelf)
574 _brsBackColorAt = New SolidBrush(_clAtSelf)
575 _brsBackColorYou = New SolidBrush(_clTarget)
576 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
577 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
578 _brsBackColorAtTo = New SolidBrush(_clAtTo)
579 '_brsBackColorNone = New SolidBrush(Color.FromKnownColor(KnownColor.Window))
580 _brsBackColorNone = New SolidBrush(_clListBackcolor)
582 ' StringFormatオブジェクトへの事前設定
583 'sf.Alignment = StringAlignment.Near ' Textを近くへ配置(左から右の場合は左寄せ)
584 'sf.LineAlignment = StringAlignment.Near ' Textを近くへ配置(上寄せ)
585 'sf.FormatFlags = StringFormatFlags.LineLimit '
586 sfTab.Alignment = StringAlignment.Center
587 sfTab.LineAlignment = StringAlignment.Center
590 SettingDialog.IsOAuth = _cfgCommon.IsOAuth
591 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
592 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
593 SettingDialog.TwitterApiUrl = _cfgCommon.TwitterUrl
594 SettingDialog.TwitterSearchApiUrl = _cfgCommon.TwitterSearchUrl
596 If _cfgCommon.IsOAuth Then
597 If _cfgCommon.Token = "" Then _cfgCommon.UserName = ""
598 tw.Initialize(_cfgCommon.Token, _cfgCommon.TokenSecret, _cfgCommon.UserName)
600 tw.Initialize(_cfgCommon.UserName, _cfgCommon.Password)
603 SettingDialog.TimelinePeriodInt = _cfgCommon.TimelinePeriod
604 SettingDialog.ReplyPeriodInt = _cfgCommon.ReplyPeriod
605 SettingDialog.DMPeriodInt = _cfgCommon.DMPeriod
606 SettingDialog.PubSearchPeriodInt = _cfgCommon.PubSearchPeriod
607 SettingDialog.ListsPeriodInt = _cfgCommon.ListsPeriod
609 If Not My.Application.CommandLineArgs.Contains("nolimit") Then
610 If SettingDialog.TimelinePeriodInt < 15 AndAlso SettingDialog.TimelinePeriodInt > 0 Then SettingDialog.TimelinePeriodInt = 15
611 If SettingDialog.ReplyPeriodInt < 15 AndAlso SettingDialog.ReplyPeriodInt > 0 Then SettingDialog.ReplyPeriodInt = 15
612 If SettingDialog.DMPeriodInt < 15 AndAlso SettingDialog.DMPeriodInt > 0 Then SettingDialog.DMPeriodInt = 15
613 If SettingDialog.PubSearchPeriodInt < 30 AndAlso SettingDialog.PubSearchPeriodInt > 0 Then SettingDialog.PubSearchPeriodInt = 30
614 If SettingDialog.ListsPeriodInt < 15 AndAlso SettingDialog.ListsPeriodInt > 0 Then SettingDialog.ListsPeriodInt = 15
617 '起動時読み込み分を既読にするか。Trueなら既読として処理
618 SettingDialog.Readed = _cfgCommon.Read
619 '新着取得時のリストスクロールをするか。Trueならスクロールしない
620 ListLockMenuItem.Checked = _cfgCommon.ListLock
621 Me.LockListFileMenuItem.Checked = _cfgCommon.ListLock
622 SettingDialog.IconSz = _cfgCommon.IconSize
624 SettingDialog.Status = _cfgLocal.StatusText
626 SettingDialog.UnreadManage = _cfgCommon.UnreadManage
628 SettingDialog.PlaySound = _cfgCommon.PlaySound
629 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
630 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
632 SettingDialog.OneWayLove = _cfgCommon.OneWayLove
634 SettingDialog.FontUnread = _fntUnread
635 SettingDialog.ColorUnread = _clUnread
636 SettingDialog.FontReaded = _fntReaded
637 SettingDialog.ColorReaded = _clReaded
638 SettingDialog.ColorFav = _clFav
639 SettingDialog.ColorOWL = _clOWL
640 SettingDialog.ColorRetweet = _clRetweet
641 SettingDialog.FontDetail = _fntDetail
642 SettingDialog.ColorDetail = _clDetail
643 SettingDialog.ColorDetailLink = _clDetailLink
644 SettingDialog.ColorDetailBackcolor = _clDetailBackcolor
645 SettingDialog.ColorSelf = _clSelf
646 SettingDialog.ColorAtSelf = _clAtSelf
647 SettingDialog.ColorTarget = _clTarget
648 SettingDialog.ColorAtTarget = _clAtTarget
649 SettingDialog.ColorAtFromTarget = _clAtFromTarget
650 SettingDialog.ColorAtTo = _clAtTo
651 SettingDialog.ColorListBackcolor = _clListBackcolor
652 SettingDialog.ColorInputBackcolor = _clInputBackcolor
653 SettingDialog.ColorInputFont = _clInputFont
654 SettingDialog.FontInputFont = _fntInputFont
656 SettingDialog.NameBalloon = _cfgCommon.NameBalloon
657 SettingDialog.PostCtrlEnter = _cfgCommon.PostCtrlEnter
658 SettingDialog.PostShiftEnter = _cfgCommon.PostShiftEnter
660 SettingDialog.CountApi = _cfgCommon.CountApi
661 SettingDialog.CountApiReply = _cfgCommon.CountApiReply
662 If SettingDialog.CountApi < 20 OrElse SettingDialog.CountApi > 200 Then SettingDialog.CountApi = 60
663 If SettingDialog.CountApiReply < 20 OrElse SettingDialog.CountApiReply > 200 Then SettingDialog.CountApiReply = 40
665 SettingDialog.BrowserPath = _cfgLocal.BrowserPath
666 SettingDialog.PostAndGet = _cfgCommon.PostAndGet
667 SettingDialog.UseRecommendStatus = _cfgLocal.UseRecommendStatus
668 SettingDialog.DispUsername = _cfgCommon.DispUsername
669 SettingDialog.CloseToExit = _cfgCommon.CloseToExit
670 SettingDialog.MinimizeToTray = _cfgCommon.MinimizeToTray
671 SettingDialog.DispLatestPost = _cfgCommon.DispLatestPost
672 SettingDialog.SortOrderLock = _cfgCommon.SortOrderLock
673 SettingDialog.TinyUrlResolve = _cfgCommon.TinyUrlResolve
675 SettingDialog.SelectedProxyType = _cfgLocal.ProxyType
676 SettingDialog.ProxyAddress = _cfgLocal.ProxyAddress
677 SettingDialog.ProxyPort = _cfgLocal.ProxyPort
678 SettingDialog.ProxyUser = _cfgLocal.ProxyUser
679 SettingDialog.ProxyPassword = _cfgLocal.ProxyPassword
681 SettingDialog.PeriodAdjust = _cfgCommon.PeriodAdjust
682 SettingDialog.StartupVersion = _cfgCommon.StartupVersion
683 SettingDialog.StartupFollowers = _cfgCommon.StartupFollowers
684 SettingDialog.RestrictFavCheck = _cfgCommon.RestrictFavCheck
685 SettingDialog.AlwaysTop = _cfgCommon.AlwaysTop
686 SettingDialog.UrlConvertAuto = _cfgCommon.UrlConvertAuto
688 SettingDialog.OutputzEnabled = _cfgCommon.Outputz
689 SettingDialog.OutputzKey = _cfgCommon.OutputzKey
690 SettingDialog.OutputzUrlmode = _cfgCommon.OutputzUrlMode
692 SettingDialog.UseUnreadStyle = _cfgCommon.UseUnreadStyle
693 SettingDialog.DefaultTimeOut = _cfgCommon.DefaultTimeOut
694 'SettingDialog.ProtectNotInclude = _cfgCommon.ProtectNotInclude
695 SettingDialog.RetweetNoConfirm = _cfgCommon.RetweetNoConfirm
696 SettingDialog.PlaySound = _cfgCommon.PlaySound
697 SettingDialog.DateTimeFormat = _cfgCommon.DateTimeFormat
698 SettingDialog.LimitBalloon = _cfgCommon.LimitBalloon
700 '廃止サービスが選択されていた場合bit.lyへ読み替え
701 If _cfgCommon.AutoShortUrlFirst < 0 Then
702 _cfgCommon.AutoShortUrlFirst = Tween.UrlConverter.Bitly
705 SettingDialog.AutoShortUrlFirst = _cfgCommon.AutoShortUrlFirst
706 SettingDialog.TabIconDisp = _cfgCommon.TabIconDisp
707 SettingDialog.ReplyIconState = _cfgCommon.ReplyIconState
708 SettingDialog.ReadOwnPost = _cfgCommon.ReadOwnPost
709 SettingDialog.GetFav = _cfgCommon.GetFav
710 SettingDialog.ReadOldPosts = _cfgCommon.ReadOldPosts
711 SettingDialog.UseSsl = _cfgCommon.UseSsl
712 SettingDialog.BitlyUser = _cfgCommon.BilyUser
713 SettingDialog.BitlyPwd = _cfgCommon.BitlyPwd
714 SettingDialog.ShowGrid = _cfgCommon.ShowGrid
715 SettingDialog.Language = _cfgCommon.Language
716 SettingDialog.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement
717 SettingDialog.UseHashSupplement = _cfgCommon.UseHashSupplement
718 SettingDialog.PreviewEnable = _cfgCommon.PreviewEnable
719 AtIdSupl = New AtIdSupplement(SettingAtIdList.Load().AtIdList, "@")
721 SettingDialog.IsMonospace = _cfgCommon.IsMonospace
722 If SettingDialog.IsMonospace Then
723 detailHtmlFormatHeader = detailHtmlFormatMono1
724 detailHtmlFormatFooter = detailHtmlFormatMono7
726 detailHtmlFormatHeader = detailHtmlFormat1
727 detailHtmlFormatFooter = detailHtmlFormat7
729 detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString + "," + _clDetail.G.ToString + "," + _clDetail.B.ToString + detailHtmlFormat4 + _clDetailLink.R.ToString + "," + _clDetailLink.G.ToString + "," + _clDetailLink.B.ToString + detailHtmlFormat5 + _clDetailBackcolor.R.ToString + "," + _clDetailBackcolor.G.ToString + "," + _clDetailBackcolor.B.ToString
730 If SettingDialog.IsMonospace Then
731 detailHtmlFormatHeader += detailHtmlFormatMono6
733 detailHtmlFormatHeader += detailHtmlFormat6
735 Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert
736 Me.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText
738 'Dim statregex As New Regex("^0*")
739 SettingDialog.RecommendStatusText = " [TWNv" + Regex.Replace(fileVersion.Replace(".", ""), "^0*", "") + "]"
743 If DateTime.Now.ToString(SettingDialog.DateTimeFormat).Length = 0 Then
745 ' 変換が成功した場合にLengthが0にならない
746 SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"
748 Catch ex As FormatException
749 ' FormatExceptionが発生したら初期値を設定 (=yyyy/MM/dd H:mm:ssとみなされる)
750 SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"
753 SettingDialog.Nicoms = _cfgCommon.Nicoms
754 SettingDialog.HotkeyEnabled = _cfgCommon.HotkeyEnabled
755 SettingDialog.HotkeyMod = _cfgCommon.HotkeyModifier
756 SettingDialog.HotkeyKey = _cfgCommon.HotkeyKey
757 SettingDialog.HotkeyValue = _cfgCommon.HotkeyValue
759 SettingDialog.BlinkNewMentions = _cfgCommon.BlinkNewMentions
761 SettingDialog.UseAdditionalCount = _cfgCommon.UseAdditionalCount
762 SettingDialog.MoreCountApi = _cfgCommon.MoreCountApi
763 SettingDialog.FirstCountApi = _cfgCommon.FirstCountApi
764 SettingDialog.SearchCountApi = _cfgCommon.SearchCountApi
765 SettingDialog.FavoritesCountApi = _cfgCommon.FavoritesCountApi
766 'If _cfgCommon.UseAdditionalCount Then
767 ' _FirstRefreshFlags = True
768 ' _FirstListsRefreshFlags = True
770 SettingDialog.UserstreamStartup = _cfgCommon.UserstreamStartup
771 SettingDialog.UserstreamPeriodInt = _cfgCommon.UserstreamPeriod
774 HashSupl = New AtIdSupplement(_cfgCommon.HashTags, "#")
775 HashMgr = New HashtagManage(HashSupl, _
776 _cfgCommon.HashTags.ToArray, _
777 _cfgCommon.HashSelected, _
778 _cfgCommon.HashIsPermanent, _
779 _cfgCommon.HashIsHead)
780 If HashMgr.UseHash <> "" AndAlso HashMgr.IsPermanent Then HashStripSplitButton.Text = HashMgr.UseHash
784 Dim saveRequired As Boolean = False
785 'ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など)
786 If tw.Username = "" Then
788 '設定せずにキャンセルされた場合はプログラム終了
789 If SettingDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
790 Application.Exit() '強制終了
793 '設定されたが、依然ユーザー名とパスワードが未設定ならプログラム終了
794 If tw.Username = "" Then
795 Application.Exit() '強制終了
800 _fntUnread = SettingDialog.FontUnread
801 _clUnread = SettingDialog.ColorUnread
802 _fntReaded = SettingDialog.FontReaded
803 _clReaded = SettingDialog.ColorReaded
804 _clFav = SettingDialog.ColorFav
805 _clOWL = SettingDialog.ColorOWL
806 _clRetweet = SettingDialog.ColorRetweet
807 _fntDetail = SettingDialog.FontDetail
808 _clDetail = SettingDialog.ColorDetail
809 _clDetailLink = SettingDialog.ColorDetailLink
810 _clDetailBackcolor = SettingDialog.ColorDetailBackcolor
811 _clSelf = SettingDialog.ColorSelf
812 _clAtSelf = SettingDialog.ColorAtSelf
813 _clTarget = SettingDialog.ColorTarget
814 _clAtTarget = SettingDialog.ColorAtTarget
815 _clAtFromTarget = SettingDialog.ColorAtFromTarget
816 _clAtTo = SettingDialog.ColorAtTo
817 _clListBackcolor = SettingDialog.ColorListBackcolor
818 _clInputBackcolor = SettingDialog.ColorInputBackcolor
819 _clInputFont = SettingDialog.ColorInputFont
820 _fntInputFont = SettingDialog.FontInputFont
821 _brsForeColorUnread.Dispose()
822 _brsForeColorReaded.Dispose()
823 _brsForeColorFav.Dispose()
824 _brsForeColorOWL.Dispose()
825 _brsForeColorRetweet.Dispose()
826 _brsForeColorUnread = New SolidBrush(_clUnread)
827 _brsForeColorReaded = New SolidBrush(_clReaded)
828 _brsForeColorFav = New SolidBrush(_clFav)
829 _brsForeColorOWL = New SolidBrush(_clOWL)
830 _brsForeColorRetweet = New SolidBrush(_clRetweet)
831 _brsBackColorMine.Dispose()
832 _brsBackColorAt.Dispose()
833 _brsBackColorYou.Dispose()
834 _brsBackColorAtYou.Dispose()
835 _brsBackColorAtFromTarget.Dispose()
836 _brsBackColorAtTo.Dispose()
837 _brsBackColorNone.Dispose()
838 _brsBackColorMine = New SolidBrush(_clSelf)
839 _brsBackColorAt = New SolidBrush(_clAtSelf)
840 _brsBackColorYou = New SolidBrush(_clTarget)
841 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
842 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
843 _brsBackColorAtTo = New SolidBrush(_clAtTo)
844 _brsBackColorNone = New SolidBrush(_clListBackcolor)
846 If SettingDialog.IsMonospace Then
847 detailHtmlFormatHeader = detailHtmlFormatMono1
848 detailHtmlFormatFooter = detailHtmlFormatMono7
850 detailHtmlFormatHeader = detailHtmlFormat1
851 detailHtmlFormatFooter = detailHtmlFormat7
853 detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString + "," + _clDetail.G.ToString + "," + _clDetail.B.ToString + detailHtmlFormat4 + _clDetailLink.R.ToString + "," + _clDetailLink.G.ToString + "," + _clDetailLink.B.ToString + detailHtmlFormat5 + _clDetailBackcolor.R.ToString + "," + _clDetailBackcolor.G.ToString + "," + _clDetailBackcolor.B.ToString
854 If SettingDialog.IsMonospace Then
855 detailHtmlFormatHeader += detailHtmlFormatMono6
857 detailHtmlFormatHeader += detailHtmlFormat6
859 '他の設定項目は、随時設定画面で保持している値を読み出して使用
862 If SettingDialog.HotkeyEnabled Then
864 Dim modKey As HookGlobalHotkey.ModKeys = HookGlobalHotkey.ModKeys.None
865 If (SettingDialog.HotkeyMod And Keys.Alt) = Keys.Alt Then modKey = modKey Or HookGlobalHotkey.ModKeys.Alt
866 If (SettingDialog.HotkeyMod And Keys.Control) = Keys.Control Then modKey = modKey Or HookGlobalHotkey.ModKeys.Ctrl
867 If (SettingDialog.HotkeyMod And Keys.Shift) = Keys.Shift Then modKey = modKey Or HookGlobalHotkey.ModKeys.Shift
868 If (SettingDialog.HotkeyMod And Keys.LWin) = Keys.LWin Then modKey = modKey Or HookGlobalHotkey.ModKeys.Win
870 _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey)
874 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, _
875 SettingDialog.SelectedProxyType, _
876 SettingDialog.ProxyAddress, _
877 SettingDialog.ProxyPort, _
878 SettingDialog.ProxyUser, _
879 SettingDialog.ProxyPassword)
880 'tw.CountApi = SettingDialog.CountApi
881 'tw.CountApiReply = SettingDialog.CountApiReply
882 tw.RestrictFavCheck = SettingDialog.RestrictFavCheck
883 tw.ReadOwnPost = SettingDialog.ReadOwnPost
884 tw.UseSsl = SettingDialog.UseSsl
885 ShortUrl.IsResolve = SettingDialog.TinyUrlResolve
886 ShortUrl.BitlyId = SettingDialog.BitlyUser
887 ShortUrl.BitlyKey = SettingDialog.BitlyPwd
888 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
889 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
890 tw.TrackWord = _cfgCommon.TrackWord
891 TrackToolStripMenuItem.Checked = Not String.IsNullOrEmpty(tw.TrackWord)
892 tw.AllAtReply = _cfgCommon.AllAtReply
893 AllrepliesToolStripMenuItem.Checked = tw.AllAtReply
895 Outputz.Key = SettingDialog.OutputzKey
896 Outputz.Enabled = SettingDialog.OutputzEnabled
897 Select Case SettingDialog.OutputzUrlmode
898 Case OutputzUrlmode.twittercom
899 Outputz.OutUrl = "http://twitter.com/"
900 Case OutputzUrlmode.twittercomWithUsername
901 Outputz.OutUrl = "http://twitter.com/" + tw.Username
905 SetImageServiceCombo()
906 ImageSelectionPanel.Enabled = False
909 Me.ClientSize = _cfgLocal.FormSize
910 _mySize = _cfgLocal.FormSize 'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
911 _myLoc = _cfgLocal.FormLocation
913 If Me.WindowState <> FormWindowState.Minimized Then
914 Me.DesktopLocation = _cfgLocal.FormLocation
915 Dim tbarRect As New Rectangle(Me.Location, New Size(_mySize.Width, SystemInformation.CaptionHeight))
916 Dim outOfScreen As Boolean = True
917 If Screen.AllScreens.Length = 1 Then 'ハングするとの報告
918 For Each scr As Screen In Screen.AllScreens
919 If Not Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty Then
925 Me.DesktopLocation = New Point(0, 0)
926 _myLoc = Me.DesktopLocation
930 Me.TopMost = SettingDialog.AlwaysTop
931 _mySpDis = _cfgLocal.SplitterDistance
932 _mySpDis2 = _cfgLocal.StatusTextHeight
933 _mySpDis3 = _cfgLocal.PreviewDistance
934 If _mySpDis3 = -1 Then
935 _mySpDis3 = _mySize.Width - 150
936 If _mySpDis3 < 1 Then _mySpDis3 = 50
937 _cfgLocal.PreviewDistance = _mySpDis3
939 MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline
940 'Me.Tween_ClientSizeChanged(Me, Nothing)
941 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
942 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
944 StatusText.Font = _fntInputFont
945 StatusText.ForeColor = _clInputFont
947 '全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定)
948 If SettingDialog.UnreadManage = False Then
949 ReadedStripMenuItem.Enabled = False
950 UnreadStripMenuItem.Enabled = False
954 TimerTimeline.AutoReset = True
955 TimerTimeline.SynchronizingObject = Me
957 TimerTimeline.Interval = 1000
958 TimerTimeline.Enabled = True
961 TimerRefreshIcon.Interval = 200
962 TimerRefreshIcon.Enabled = True
965 StatusLabel.Text = ""
966 StatusLabel.AutoToolTip = False
967 StatusLabel.ToolTipText = ""
969 lblLen.Text = GetRestStatusCount(True, False).ToString()
971 ''''''''''''''''''''''''''''''''''''''''
972 _statuses.SortOrder = DirectCast(_cfgCommon.SortOrder, System.Windows.Forms.SortOrder)
973 Dim mode As IdComparerClass.ComparerMode
974 Select Case _cfgCommon.SortColumn
975 Case 0, 5, 6 '0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
977 mode = IdComparerClass.ComparerMode.Id 'Idソートに読み替え
979 mode = IdComparerClass.ComparerMode.Nickname
981 mode = IdComparerClass.ComparerMode.Data
983 mode = IdComparerClass.ComparerMode.Id
985 mode = IdComparerClass.ComparerMode.Name
987 mode = IdComparerClass.ComparerMode.Source
989 _statuses.SortMode = mode
990 ''''''''''''''''''''''''''''''''''''''''
992 Select Case SettingDialog.IconSz
993 Case IconSizes.IconNone
995 Case IconSizes.Icon16
997 Case IconSizes.Icon24
999 Case IconSizes.Icon48
1001 Case IconSizes.Icon48_2
1009 tw.IconSize = _iconSz
1011 tw.TinyUrlResolve = SettingDialog.TinyUrlResolve
1013 '発言詳細部アイコンをリストアイコンにサイズ変更
1014 Dim sz As Integer = _iconSz
1020 TIconDic = New ImageDictionary(5000)
1022 tw.DetailIcon = TIconDic
1024 StatusLabel.Text = My.Resources.Form1_LoadText1 '画面右下の状態表示を変更
1025 StatusLabelUrl.Text = "" '画面左下のリンク先URL表示部を初期化
1026 NameLabel.Text = "" '発言詳細部名前ラベル初期化
1027 DateTimeLabel.Text = "" '発言詳細部日時ラベル初期化
1028 SourceLinkLabel.Text = "" 'Source部分初期化
1030 '<<<<<<<<タブ関連>>>>>>>
1031 'デフォルトタブの存在チェック、ない場合には追加
1032 If _statuses.GetTabByType(TabUsageType.Home) Is Nothing Then
1033 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.RECENT) Then
1034 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1036 _statuses.Tabs(DEFAULTTAB.RECENT).TabType = TabUsageType.Home
1039 If _statuses.GetTabByType(TabUsageType.Mentions) Is Nothing Then
1040 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.REPLY) Then
1041 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1043 _statuses.Tabs(DEFAULTTAB.REPLY).TabType = TabUsageType.Mentions
1046 If _statuses.GetTabByType(TabUsageType.DirectMessage) Is Nothing Then
1047 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.DM) Then
1048 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1050 _statuses.Tabs(DEFAULTTAB.DM).TabType = TabUsageType.DirectMessage
1053 If _statuses.GetTabByType(TabUsageType.Favorites) Is Nothing Then
1054 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.FAV) Then
1055 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1057 _statuses.Tabs(DEFAULTTAB.FAV).TabType = TabUsageType.Favorites
1060 For Each tn As String In _statuses.Tabs.Keys
1061 If _statuses.Tabs(tn).TabType = TabUsageType.Undefined Then
1062 _statuses.Tabs(tn).TabType = TabUsageType.UserDefined
1064 If Not AddNewTab(tn, True, _statuses.Tabs(tn).TabType) Then Throw New Exception("タブ作成エラー")
1067 Me.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space"
1068 CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C"
1069 CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C"
1070 CopyUserIdStripMenuItem.ShortcutKeyDisplayString = "Shift+Alt+C"
1072 If SettingDialog.MinimizeToTray = False OrElse Me.WindowState <> FormWindowState.Minimized Then
1075 _curTab = ListTab.SelectedTab
1077 _curList = DirectCast(_curTab.Tag, DetailsListView)
1078 SetMainWindowTitle()
1081 If SettingDialog.TabIconDisp Then
1082 ListTab.DrawMode = TabDrawMode.Normal
1084 ListTab.DrawMode = TabDrawMode.OwnerDrawFixed
1085 AddHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
1086 ListTab.ImageList = Nothing
1089 _ignoreConfigSave = False
1090 Me.TweenMain_Resize(Nothing, Nothing)
1091 If saveRequired Then SaveConfigsAll(False)
1094 Private Sub spaceKeyCanceler_SpaceCancel(ByVal sender As Object, ByVal e As EventArgs)
1095 JumpUnreadMenuItem_Click(Nothing, Nothing)
1098 Private Sub ListTab_DrawItem( _
1099 ByVal sender As Object, ByVal e As DrawItemEventArgs)
1102 txt = ListTab.TabPages(e.Index).Text
1103 Catch ex As Exception
1107 e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.Bounds)
1108 If e.State = DrawItemState.Selected Then
1109 e.DrawFocusRectangle()
1113 If _statuses.Tabs(txt).UnreadCount > 0 Then
1116 fore = System.Drawing.SystemBrushes.ControlText
1118 Catch ex As Exception
1119 fore = System.Drawing.SystemBrushes.ControlText
1121 e.Graphics.DrawString(txt, e.Font, fore, e.Bounds, sfTab)
1124 Private Function LoadOldConfig() As Boolean
1125 Dim needToSave As Boolean = False
1126 _cfgCommon = SettingCommon.Load()
1127 _cfgLocal = SettingLocal.Load()
1128 If _cfgCommon.TabList.Count > 0 Then
1129 For Each tabName As String In _cfgCommon.TabList
1130 _statuses.Tabs.Add(tabName, SettingTab.Load(tabName).Tab)
1131 If tabName <> ReplaceInvalidFilename(tabName) Then
1132 Dim tb As TabClass = _statuses.Tabs(tabName)
1133 _statuses.RemoveTab(tabName)
1134 tb.TabName = ReplaceInvalidFilename(tabName)
1135 _statuses.Tabs.Add(ReplaceInvalidFilename(tabName), tb)
1136 Dim tabSetting As New SettingTab
1143 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1144 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1145 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1146 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1149 _cfgCommon.TabList.Clear()
1150 For Each tabName As String In _statuses.Tabs.Keys
1151 _cfgCommon.TabList.Add(tabName)
1156 If System.IO.File.Exists(SettingCommon.GetSettingFilePath("")) Then
1163 Private Sub LoadConfig()
1164 Dim needToSave As Boolean = False
1165 _cfgCommon = SettingCommon.Load()
1166 _cfgLocal = SettingLocal.Load()
1167 Dim tabs As List(Of TabClass) = SettingTabs.Load().Tabs
1168 For Each tb As TabClass In tabs
1169 _statuses.Tabs.Add(tb.TabName, tb)
1171 If _statuses.Tabs.Count = 0 Then
1172 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1173 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1174 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1175 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1179 Private Sub ConvertConfig()
1181 If System.IO.File.Exists(SettingTabs.GetSettingFilePath("")) Then
1188 Private Sub TimerTimeline_Elapsed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerTimeline.Elapsed
1190 Dim sw As Stopwatch = Stopwatch.StartNew()
1192 Static homeCounter As Integer = 0
1193 Static mentionCounter As Integer = 0
1194 Static dmCounter As Integer = 0
1195 Static pubSearchCounter As Integer = 0
1196 Static listsCounter As Integer = 0
1197 Static usCounter As Integer = 0
1199 If homeCounter > 0 Then Interlocked.Decrement(homeCounter)
1200 If mentionCounter > 0 Then Interlocked.Decrement(mentionCounter)
1201 If dmCounter > 0 Then Interlocked.Decrement(dmCounter)
1202 If pubSearchCounter > 0 Then Interlocked.Decrement(pubSearchCounter)
1203 If listsCounter > 0 Then Interlocked.Decrement(listsCounter)
1204 If usCounter > 0 Then Interlocked.Decrement(usCounter)
1207 If homeCounter <= 0 AndAlso SettingDialog.TimelinePeriodInt > 0 Then
1208 'Dim period As Integer
1209 'Interlocked.Exchange(period, 0)
1210 'Interlocked.Add(period, SettingDialog.TimelinePeriodInt)
1211 'Interlocked.Add(period, -_homeCounterAdjuster)
1212 'Interlocked.Exchange(_homeCounter, period)
1213 Interlocked.Exchange(homeCounter, SettingDialog.TimelinePeriodInt)
1214 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
1216 If mentionCounter <= 0 AndAlso SettingDialog.ReplyPeriodInt > 0 Then
1217 Interlocked.Exchange(mentionCounter, SettingDialog.ReplyPeriodInt)
1218 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
1220 If dmCounter <= 0 AndAlso SettingDialog.DMPeriodInt > 0 Then
1221 Interlocked.Exchange(dmCounter, SettingDialog.DMPeriodInt)
1222 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
1224 If pubSearchCounter <= 0 AndAlso SettingDialog.PubSearchPeriodInt > 0 Then
1225 Interlocked.Exchange(pubSearchCounter, SettingDialog.PubSearchPeriodInt)
1226 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, "")
1228 If listsCounter <= 0 AndAlso SettingDialog.ListsPeriodInt > 0 Then
1229 Interlocked.Exchange(listsCounter, SettingDialog.ListsPeriodInt)
1230 GetTimeline(WORKERTYPE.List, 1, 0, "")
1232 If usCounter <= 0 AndAlso SettingDialog.UserstreamPeriodInt > 0 Then
1233 Interlocked.Exchange(usCounter, SettingDialog.UserstreamPeriodInt)
1234 RefreshTimeline(True)
1239 Console.WriteLine("Counter: Home {0} Reply {1} Dm {2} Search {3} Lists {4}", homeCounter, mentionCounter, dmCounter, pubSearchCounter, listsCounter)
1240 Console.WriteLine(sw.Elapsed)
1244 Private Sub RefreshTimeline(ByVal isUserStream As Boolean)
1246 Dim smode As Integer = -1 '-1:制御しない,-2:最新へ,その他:topitem使用
1247 Dim topId As Long = GetScrollPos(smode)
1248 Dim befCnt As Integer = _curList.VirtualListSize
1251 Dim selId As New Dictionary(Of String, Long())
1252 Dim focusedId As New Dictionary(Of String, Long)
1253 SaveSelectedStatus(selId, focusedId)
1256 Dim dmCount As Integer = _statuses.GetTabByType(TabUsageType.DirectMessage).AllCount
1259 Dim notifyPosts() As PostClass = Nothing
1260 Dim soundFile As String = ""
1261 Dim addCount As Integer = 0
1262 Dim isMention As Boolean = False
1263 addCount = _statuses.SubmitUpdate(soundFile, notifyPosts, isMention, isUserStream)
1265 If _endingFlag Then Exit Sub
1269 For Each tab As TabPage In ListTab.TabPages
1270 Dim lst As DetailsListView = DirectCast(tab.Tag, DetailsListView)
1271 Dim tabInfo As TabClass = _statuses.Tabs(tab.Text)
1273 If lst.VirtualListSize <> tabInfo.AllCount Then
1274 If lst.Equals(_curList) Then
1275 _itemCache = Nothing
1276 _postCache = Nothing
1279 lst.VirtualListSize = tabInfo.AllCount 'リスト件数更新
1280 Catch ex As Exception
1283 Me.SelectListItem(lst, _
1284 _statuses.IndexOf(tab.Text, selId(tab.Text)), _
1285 _statuses.IndexOf(tab.Text, focusedId(tab.Text)))
1288 If tabInfo.UnreadCount > 0 Then
1289 If SettingDialog.TabIconDisp Then
1290 If tab.ImageIndex = -1 Then tab.ImageIndex = 0 'タブアイコン
1294 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
1295 Catch ex As Exception
1296 'ex.Data("Msg") = "Ref1, UseAPI=" + SettingDialog.UseAPI.ToString
1302 If befCnt <> _curList.VirtualListSize Then
1306 _curList.EnsureVisible(0)
1309 If _curList.VirtualListSize > 0 Then _curList.EnsureVisible(_curList.VirtualListSize - 1)
1314 If _curList.VirtualListSize > 0 AndAlso _statuses.IndexOf(_curTab.Text, topId) > -1 Then
1315 _curList.EnsureVisible(_curList.VirtualListSize - 1)
1316 _curList.EnsureVisible(_statuses.IndexOf(_curTab.Text, topId))
1320 Catch ex As Exception
1321 ex.Data("Msg") = "Ref2"
1326 NotifyNewPosts(notifyPosts,
1329 isMention OrElse dmCount <> _statuses.GetTabByType(TabUsageType.DirectMessage).AllCount)
1331 SetMainWindowTitle()
1332 If Not StatusLabelUrl.Text.StartsWith("http") Then SetStatusLabelUrl()
1334 HashSupl.AddRangeItem(tw.GetHashList)
1338 Private Function GetScrollPos(ByRef smode As Integer) As Long
1339 Dim topId As Long = -1
1340 If _curList IsNot Nothing AndAlso _curTab IsNot Nothing AndAlso _curList.VirtualListSize > 0 Then
1341 If _statuses.SortMode = IdComparerClass.ComparerMode.Id Then
1342 If _statuses.SortOrder = SortOrder.Ascending Then
1344 If ListLockMenuItem.Checked Then
1348 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1351 '最下行が表示されていたら、最下行へ強制スクロール。最下行が表示されていなかったら制御しない
1352 Dim _item As ListViewItem
1353 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1) '一番下
1354 If _item Is Nothing Then _item = _curList.Items(_curList.Items.Count - 1)
1355 If _item.Index = _curList.Items.Count - 1 Then
1359 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1365 If ListLockMenuItem.Checked Then
1367 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1370 '最上行が表示されていたら、制御しない。最上行が表示されていなかったら、現在表示位置へ強制スクロール
1371 Dim _item As ListViewItem
1373 _item = _curList.GetItemAt(0, 10) '一番上
1374 If _item Is Nothing Then _item = _curList.Items(0)
1375 If _item.Index = 0 Then
1378 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1385 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1394 Private Sub SaveSelectedStatus(ByVal selId As Dictionary(Of String, Long()), ByVal focusedId As Dictionary(Of String, Long))
1395 If _endingFlag Then Exit Sub
1396 For Each tab As TabPage In ListTab.TabPages
1397 Dim lst As DetailsListView = DirectCast(tab.Tag, DetailsListView)
1398 If lst.SelectedIndices.Count > 0 AndAlso lst.SelectedIndices.Count < 31 Then
1399 selId.Add(tab.Text, _statuses.GetId(tab.Text, lst.SelectedIndices))
1401 selId.Add(tab.Text, New Long(0) {-1})
1403 If lst.FocusedItem IsNot Nothing Then
1404 focusedId.Add(tab.Text, _statuses.GetId(tab.Text, lst.FocusedItem.Index))
1406 focusedId.Add(tab.Text, -1)
1412 Private Sub NotifyNewPosts(ByVal notifyPosts() As PostClass, ByVal soundFile As String, ByVal addCount As Integer, ByVal newMentions As Boolean)
1415 NewPostPopMenuItem.Checked AndAlso _
1416 notifyPosts IsNot Nothing AndAlso _
1417 notifyPosts.Length > 0 AndAlso _
1418 Not _initial AndAlso _
1421 SettingDialog.LimitBalloon AndAlso _
1423 Me.WindowState = FormWindowState.Minimized OrElse _
1424 Not Me.Visible OrElse _
1425 Form.ActiveForm Is Nothing _
1428 Not SettingDialog.LimitBalloon _
1431 Not IsScreenSaverRunning() Then
1432 Dim sb As New StringBuilder
1433 Dim reply As Boolean = False
1434 Dim dm As Boolean = False
1435 For Each post As PostClass In notifyPosts
1436 If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True
1437 If post.IsDm Then dm = True
1438 If sb.Length > 0 Then sb.Append(System.Environment.NewLine)
1439 Select Case SettingDialog.NameBalloon
1440 Case NameBalloonEnum.UserID
1441 sb.Append(post.Name).Append(" : ")
1442 Case NameBalloonEnum.NickName
1443 sb.Append(post.Nickname).Append(" : ")
1445 sb.Append(post.Data)
1447 If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = ""
1449 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
1450 NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2
1452 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
1453 NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
1455 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
1456 NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
1458 Dim bText As String = sb.ToString
1459 If String.IsNullOrEmpty(bText) Then Exit Sub
1460 NotifyIcon1.BalloonTipText = sb.ToString()
1461 NotifyIcon1.ShowBalloonTip(500)
1465 If Not _initial AndAlso SettingDialog.PlaySound AndAlso soundFile <> "" Then
1467 Dim dir As String = My.Application.Info.DirectoryPath
1468 If Directory.Exists(Path.Combine(dir, "Sounds")) Then
1469 dir = Path.Combine(dir, "Sounds")
1471 My.Computer.Audio.Play(Path.Combine(dir, soundFile), AudioPlayMode.Background)
1472 Catch ex As Exception
1478 If Not _initial AndAlso SettingDialog.BlinkNewMentions AndAlso newMentions AndAlso Form.ActiveForm Is Nothing Then
1479 FlashMyWindow(Me.Handle, FlashSpecification.FlashTray, 3)
1484 Private Sub MyList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
1485 If _curList.SelectedIndices.Count <> 1 Then Exit Sub
1486 'If _curList.SelectedIndices.Count = 0 Then Exit Sub
1488 _curItemIndex = _curList.SelectedIndices(0)
1489 'If _curPost Is GetCurTabPost(_curItemIndex) Then Exit Sub 'refreshで既読化されるのを防ぐため追加
1490 _curPost = GetCurTabPost(_curItemIndex)
1491 If SettingDialog.UnreadManage Then _statuses.SetRead(True, _curTab.Text, _curItemIndex)
1492 'MyList.RedrawItems(MyList.SelectedIndices(0), MyList.SelectedIndices(0), False) 'RetrieveVirtualItemが発生することを期待
1494 ChangeCacheStyleRead(True, _curItemIndex, _curTab) '既読へ(フォント、文字色)
1496 'ColorizeList(-1) '全キャッシュ更新(背景色)
1502 Private Sub ChangeCacheStyleRead(ByVal Read As Boolean, ByVal Index As Integer, ByVal Tab As TabPage)
1503 'Read:True=既読 False=未読
1504 '未読管理していなかったら既読として扱う
1505 If Not _statuses.Tabs(_curTab.Text).UnreadManage OrElse _
1506 Not SettingDialog.UnreadManage Then Read = True
1509 Dim itm As ListViewItem
1510 Dim post As PostClass
1511 If Tab.Equals(_curTab) AndAlso _itemCache IsNot Nothing AndAlso Index >= _itemCacheIndex AndAlso Index < _itemCacheIndex + _itemCache.Length Then
1512 itm = _itemCache(Index - _itemCacheIndex)
1513 post = _postCache(Index - _itemCacheIndex)
1515 itm = DirectCast(Tab.Tag, DetailsListView).Items(Index)
1516 post = _statuses.Item(Tab.Text, Index)
1519 ChangeItemStyleRead(Read, itm, post, DirectCast(Tab.Tag, DetailsListView))
1522 Private Sub ChangeItemStyleRead(ByVal Read As Boolean, ByVal Item As ListViewItem, ByVal Post As PostClass, ByVal DList As DetailsListView)
1527 Item.SubItems(5).Text = ""
1530 Item.SubItems(5).Text = "★"
1536 ElseIf Post.RetweetedId > 0 Then
1538 ElseIf Post.IsOwl AndAlso (Post.IsDm OrElse SettingDialog.OneWayLove) Then
1540 ElseIf Read OrElse Not SettingDialog.UseUnreadStyle Then
1545 If DList Is Nothing OrElse Item.Index = -1 Then
1547 If SettingDialog.UseUnreadStyle Then
1552 If SettingDialog.UseUnreadStyle Then
1553 DList.ChangeItemFontAndColor(Item.Index, cl, fnt)
1555 DList.ChangeItemForeColor(Item.Index, cl)
1557 'If _itemCache IsNot Nothing Then DList.RedrawItems(_itemCacheIndex, _itemCacheIndex + _itemCache.Length - 1, False)
1561 Private Sub ColorizeList()
1562 'Index:更新対象のListviewItem.Index。Colorを返す。
1563 '-1は全キャッシュ。Colorは返さない(ダミーを戻す)
1564 Dim _post As PostClass
1571 If _itemCache Is Nothing Then Exit Sub
1573 If _post Is Nothing Then Exit Sub
1576 For cnt As Integer = 0 To _itemCache.Length - 1
1577 _curList.ChangeItemBackColor(_itemCacheIndex + cnt, JudgeColor(_post, _postCache(cnt)))
1579 Catch ex As Exception
1583 Private Sub ColorizeList(ByVal Item As ListViewItem, ByVal Index As Integer)
1584 'Index:更新対象のListviewItem.Index。Colorを返す。
1585 '-1は全キャッシュ。Colorは返さない(ダミーを戻す)
1586 Dim _post As PostClass
1593 Dim tPost As PostClass = GetCurTabPost(Index)
1595 If _post Is Nothing Then Exit Sub
1597 If Item.Index = -1 Then
1598 Item.BackColor = JudgeColor(_post, tPost)
1600 _curList.ChangeItemBackColor(Item.Index, JudgeColor(_post, tPost))
1604 Private Function JudgeColor(ByVal BasePost As PostClass, ByVal TargetPost As PostClass) As Color
1606 If TargetPost.Id = BasePost.InReplyToId Then
1609 ElseIf TargetPost.IsMe Then
1612 ElseIf TargetPost.IsReply Then
1615 ElseIf BasePost.ReplyToList.Contains(TargetPost.Name.ToLower()) Then
1617 cl = _clAtFromTarget
1618 ElseIf TargetPost.ReplyToList.Contains(BasePost.Name.ToLower()) Then
1621 ElseIf TargetPost.Name.Equals(BasePost.Name, StringComparison.OrdinalIgnoreCase) Then
1626 cl = _clListBackcolor
1631 Private Sub PostButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostButton.Click
1632 If StatusText.Text.Trim.Length = 0 Then
1633 If Not ImageSelectionPanel.Enabled Then
1639 If _curPost IsNot Nothing AndAlso StatusText.Text.Trim() = String.Format("RT @{0}: {1}", _curPost.Name, _curPost.Data) Then
1640 Dim rtResult As DialogResult = MessageBox.Show(String.Format(My.Resources.PostButton_Click1, Environment.NewLine),
1642 MessageBoxButtons.YesNoCancel,
1643 MessageBoxIcon.Question)
1644 Select Case rtResult
1645 Case Windows.Forms.DialogResult.Yes
1646 doReTweetOfficial(False)
1647 StatusText.Text = ""
1649 Case Windows.Forms.DialogResult.Cancel
1654 _history(_history.Count - 1) = New PostingStatus(StatusText.Text.Trim, _reply_to_id, _reply_to_name)
1656 If SettingDialog.UrlConvertAuto Then
1657 StatusText.SelectionStart = StatusText.Text.Length
1658 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
1659 ElseIf SettingDialog.Nicoms Then
1660 StatusText.SelectionStart = StatusText.Text.Length
1661 UrlConvert(UrlConverter.Nicoms)
1663 StatusText.SelectionStart = StatusText.Text.Length
1664 Dim args As New GetWorkerArg()
1667 args.type = WORKERTYPE.PostMessage
1668 CheckReplyTo(StatusText.Text)
1671 Dim adjustCount As Integer = 0
1672 Dim tmpStatus As String = StatusText.Text.Trim
1673 If ToolStripMenuItemApiCommandEvasion.Checked Then
1675 If Regex.IsMatch(tmpStatus, _
1676 "^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", _
1677 RegexOptions.IgnoreCase) _
1678 AndAlso tmpStatus.EndsWith(" .") = False Then adjustCount += 2
1681 If ToolStripMenuItemUrlMultibyteSplit.Checked Then
1683 adjustCount += Regex.Matches(tmpStatus, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+").Count
1686 Dim isCutOff As Boolean = False
1687 Dim isRemoveFooter As Boolean = My.Computer.Keyboard.ShiftKeyDown
1688 If StatusText.Multiline AndAlso Not SettingDialog.PostCtrlEnter Then
1689 '複数行でEnter投稿の場合、Ctrlも押されていたらフッタ付加しない
1690 isRemoveFooter = My.Computer.Keyboard.CtrlKeyDown
1692 If SettingDialog.PostShiftEnter Then
1693 isRemoveFooter = My.Computer.Keyboard.CtrlKeyDown
1695 If Not isRemoveFooter AndAlso (StatusText.Text.Contains("RT @") OrElse StatusText.Text.Contains("QT @")) Then
1696 isRemoveFooter = True
1698 If GetRestStatusCount(False, Not isRemoveFooter) - adjustCount < 0 Then
1699 If MessageBox.Show(My.Resources.PostLengthOverMessage1, My.Resources.PostLengthOverMessage2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
1701 If Not SettingDialog.UrlConvertAuto Then UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
1702 If GetRestStatusCount(False, Not isRemoveFooter) - adjustCount < 0 Then
1703 isRemoveFooter = True
1710 Dim footer As String = ""
1711 Dim header As String = ""
1712 If StatusText.Text.StartsWith("D ") OrElse StatusText.Text.StartsWith("d ") Then
1717 If HashMgr.UseHash <> "" Then
1718 If HashMgr.IsHead Then
1719 header = HashMgr.UseHash + " "
1721 footer = " " + HashMgr.UseHash
1724 If Not isRemoveFooter Then
1725 If SettingDialog.UseRecommendStatus Then
1727 footer += SettingDialog.RecommendStatusText
1729 ' テキストボックスに入力されている文字列を使用する
1730 footer += " " + SettingDialog.Status.Trim
1734 args.status.status = header + StatusText.Text.Trim + footer
1736 If ToolStripMenuItemApiCommandEvasion.Checked Then
1738 If Regex.IsMatch(args.status.status, _
1739 "^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", _
1740 RegexOptions.IgnoreCase) _
1741 AndAlso args.status.status.EndsWith(" .") = False Then args.status.status += " ."
1744 If ToolStripMenuItemUrlMultibyteSplit.Checked Then
1746 Dim mc2 As Match = Regex.Match(args.status.status, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+")
1747 If mc2.Success Then args.status.status = Regex.Replace(args.status.status, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+", "$& ")
1750 If IdeographicSpaceToSpaceToolStripMenuItem.Checked Then
1751 ' 文中の全角スペースを半角スペース1個にする
1752 args.status.status = args.status.status.Replace(" ", " ")
1755 If isCutOff AndAlso args.status.status.Length > 140 Then
1756 args.status.status = args.status.status.Substring(0, 140)
1757 Dim AtId As String = "(@|@)[a-z0-9_/]+$"
1758 Dim HashTag As String = "(^|[^0-9A-Z&\/\?]+)(#|#)([0-9A-Z_]*[A-Z_]+)$"
1759 Dim Url As String = "https?:\/\/[a-z0-9!\*'\(\);:&=\+\$\/%#\[\]\-_\.,~?]+$" '簡易判定
1760 Dim pattern As String = String.Format("({0})|({1})|({2})", AtId, HashTag, Url)
1761 Dim mc As Match = Regex.Match(args.status.status, pattern, RegexOptions.IgnoreCase)
1763 'さらに@ID、ハッシュタグ、URLと推測される文字列をカットする
1764 args.status.status = args.status.status.Substring(0, 140 - mc.Value.Length)
1766 If MessageBox.Show(args.status.status, "Post or Cancel?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then Exit Sub
1769 args.status.inReplyToId = _reply_to_id
1770 args.status.inReplyToName = _reply_to_name
1771 If ImageSelectionPanel.Visible Then
1773 If ImageSelectedPicture.Image IsNot ImageSelectedPicture.InitialImage AndAlso _
1774 ImageServiceCombo.SelectedIndex > -1 AndAlso _
1775 ImagefilePathText.Text <> "" Then
1776 If MessageBox.Show(My.Resources.PostPictureConfirm1, _
1777 My.Resources.PostPictureConfirm2, _
1778 MessageBoxButtons.OKCancel, _
1779 MessageBoxIcon.Question, _
1780 MessageBoxDefaultButton.Button1) _
1781 = Windows.Forms.DialogResult.Cancel Then
1782 TimelinePanel.Visible = True
1783 TimelinePanel.Enabled = True
1784 ImageSelectionPanel.Visible = False
1785 ImageSelectionPanel.Enabled = False
1786 If _curList IsNot Nothing Then
1791 args.status.imageService = ImageServiceCombo.Text
1792 args.status.imagePath = ImagefilePathText.Text
1793 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
1794 ImagefilePathText.Text = ""
1795 TimelinePanel.Visible = True
1796 TimelinePanel.Enabled = True
1797 ImageSelectionPanel.Visible = False
1798 ImageSelectionPanel.Enabled = False
1799 If _curList IsNot Nothing Then
1803 MessageBox.Show(My.Resources.PostPictureWarn1, My.Resources.PostPictureWarn2)
1811 If StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) AndAlso StatusText.Text.Trim.Length > 7 Then
1812 Dim tmp As String = String.Format(My.Resources.SearchItem2Url, HttpUtility.UrlEncode(StatusText.Text.Substring(7)))
1818 StatusText.Text = ""
1819 _history.Add(New PostingStatus)
1820 _hisIdx = _history.Count - 1
1821 If Not ToolStripFocusLockMenuItem.Checked Then
1822 DirectCast(ListTab.SelectedTab.Tag, Control).Focus()
1824 urlUndoBuffer = Nothing
1825 UrlUndoToolStripMenuItem.Enabled = False 'Undoをできないように設定
1828 Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click, EndFileMenuItem.Click
1833 Private Sub Tween_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
1834 If Not SettingDialog.CloseToExit AndAlso e.CloseReason = CloseReason.UserClosing AndAlso _endingFlag = False Then
1835 '_endingFlag=False:フォームの×ボタン
1839 _hookGlobalHotkey.UnregisterAllOriginalHotkey()
1840 _ignoreConfigSave = True
1842 TimerTimeline.Enabled = False
1843 TimerRefreshIcon.Enabled = False
1847 Private Sub NotifyIcon1_BalloonTipClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyIcon1.BalloonTipClicked
1849 If Me.WindowState = FormWindowState.Minimized Then
1850 Me.WindowState = FormWindowState.Normal
1855 Private Shared Function CheckAccountValid() As Boolean
1856 Static errorCount As Integer = 0
1857 If Twitter.AccountState <> ACCOUNT_STATE.Valid Then
1859 If errorCount > 5 Then
1861 Twitter.AccountState = ACCOUNT_STATE.Valid
1870 Private Sub GetTimelineWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
1871 Dim bw As BackgroundWorker = DirectCast(sender, BackgroundWorker)
1872 If bw.CancellationPending OrElse _endingFlag Then
1877 Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.BelowNormal
1879 My.Application.InitCulture()
1881 Dim ret As String = ""
1882 Dim rslt As New GetWorkerResult()
1884 Dim read As Boolean = Not SettingDialog.UnreadManage
1885 If _initial AndAlso SettingDialog.UnreadManage Then read = SettingDialog.Readed
1887 Dim args As GetWorkerArg = DirectCast(e.Argument, GetWorkerArg)
1889 If Not CheckAccountValid() Then
1890 rslt.retMsg = "Auth error. Check your account"
1891 rslt.type = WORKERTYPE.ErrorState 'エラー表示のみ行ない、後処理キャンセル
1892 rslt.tName = args.tName
1897 If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(0, "") 'Notifyアイコンアニメーション開始
1898 Select Case args.type
1899 Case WORKERTYPE.Timeline, WORKERTYPE.Reply
1900 bw.ReportProgress(50, MakeStatusMessage(args, False))
1901 ret = tw.GetTimelineApi(read, args.type, args.page = -1, _initial)
1903 If ret = "" AndAlso args.type = WORKERTYPE.Timeline AndAlso SettingDialog.ReadOldPosts Then
1907 rslt.addCount = _statuses.DistributePosts()
1908 Case WORKERTYPE.DirectMessegeRcv '送信分もまとめて取得
1909 bw.ReportProgress(50, MakeStatusMessage(args, False))
1910 ret = tw.GetDirectMessageApi(read, WORKERTYPE.DirectMessegeRcv, args.page = -1)
1911 If ret = "" Then ret = tw.GetDirectMessageApi(read, WORKERTYPE.DirectMessegeSnt, args.page = -1)
1912 rslt.addCount = _statuses.DistributePosts()
1913 Case WORKERTYPE.FavAdd
1915 If _statuses.Tabs.ContainsKey(args.tName) Then
1916 Dim tbc As TabClass = _statuses.Tabs(args.tName)
1917 For i As Integer = 0 To args.ids.Count - 1
1918 Dim post As PostClass = Nothing
1919 If tbc.TabType = TabUsageType.Lists OrElse tbc.TabType = TabUsageType.PublicSearch Then
1920 post = tbc.Posts(args.ids(i))
1922 post = _statuses.Item(args.ids(i))
1925 bw.ReportProgress(50, MakeStatusMessage(args, False))
1926 If Not post.IsFav Then
1927 If post.RetweetedId = 0 Then
1928 ret = tw.PostFavAdd(post.Id)
1930 ret = tw.PostFavAdd(post.RetweetedId)
1932 If ret.Length = 0 Then
1933 args.sIds.Add(post.Id)
1934 post.IsFav = True 'リスト再描画必要
1935 _favTimestamps.Add(Now)
1936 If post.RelTabName = "" Then
1937 '検索,リストタブからのfavは、favタブへ追加せず。それ以外は追加
1938 _statuses.GetTabByType(TabUsageType.Favorites).Add(post.Id, post.IsRead, False)
1940 '検索・リストタブからのfavで、TLでも取得済みならfav反映
1941 If _statuses.ContainsKey(post.Id) Then
1942 Dim postTl As PostClass = _statuses.Item(post.Id)
1944 _statuses.GetTabByType(TabUsageType.Favorites).Add(postTl.Id, postTl.IsRead, False)
1948 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch Or TabUsageType.Lists)
1949 If tb.Contains(post.Id) Then tb.Posts(post.Id).IsFav = True
1955 rslt.sIds = args.sIds
1956 Case WORKERTYPE.FavRemove
1958 If _statuses.Tabs.ContainsKey(args.tName) Then
1959 Dim tbc As TabClass = _statuses.Tabs(args.tName)
1960 For i As Integer = 0 To args.ids.Count - 1
1961 Dim post As PostClass = Nothing
1962 If tbc.TabType = TabUsageType.Lists OrElse tbc.TabType = TabUsageType.PublicSearch Then
1963 post = tbc.Posts(args.ids(i))
1965 post = _statuses.Item(args.ids(i))
1968 bw.ReportProgress(50, MakeStatusMessage(args, False))
1970 If post.RetweetedId = 0 Then
1971 ret = tw.PostFavRemove(post.Id)
1973 ret = tw.PostFavRemove(post.RetweetedId)
1975 If ret.Length = 0 Then
1976 args.sIds.Add(post.Id)
1977 post.IsFav = False 'リスト再描画必要
1978 If _statuses.ContainsKey(post.Id) Then _statuses.Item(post.Id).IsFav = False
1980 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch Or TabUsageType.Lists)
1981 If tb.Contains(post.Id) Then tb.Posts(post.Id).IsFav = False
1987 rslt.sIds = args.sIds
1988 Case WORKERTYPE.PostMessage
1989 bw.ReportProgress(200)
1990 If String.IsNullOrEmpty(args.status.imagePath) Then
1991 For i As Integer = 0 To 1
1992 ret = tw.PostStatus(args.status.status, args.status.inReplyToId)
1993 If ret = "" OrElse _
1994 ret.StartsWith("OK:") OrElse _
1995 ret.StartsWith("Outputz:") OrElse _
1996 ret.StartsWith("Warn:") OrElse _
1997 ret = "Err:Status is a duplicate." OrElse _
1998 args.status.status.StartsWith("D", StringComparison.OrdinalIgnoreCase) OrElse _
1999 args.status.status.StartsWith("DM", StringComparison.OrdinalIgnoreCase) Then
2004 Dim picSvc As New PictureService(tw)
2005 If String.IsNullOrEmpty(args.status.status) Then args.status.status = ""
2006 ret = picSvc.Upload(args.status.imagePath, args.status.status, args.status.imageService)
2008 bw.ReportProgress(300)
2009 rslt.status = args.status
2010 Case WORKERTYPE.Retweet
2011 bw.ReportProgress(200)
2012 For i As Integer = 0 To args.ids.Count - 1
2013 ret = tw.PostRetweet(args.ids(i), read)
2015 bw.ReportProgress(300)
2016 Case WORKERTYPE.Follower
2017 bw.ReportProgress(50, My.Resources.UpdateFollowersMenuItem1_ClickText1)
2018 ret = tw.GetFollowersApi()
2019 Case WORKERTYPE.OpenUri
2020 Dim myPath As String = Convert.ToString(args.url)
2023 If SettingDialog.BrowserPath <> "" Then
2024 If SettingDialog.BrowserPath.StartsWith("""") AndAlso SettingDialog.BrowserPath.Length > 2 AndAlso SettingDialog.BrowserPath.IndexOf("""", 2) > -1 Then
2025 Dim sep As Integer = SettingDialog.BrowserPath.IndexOf("""", 2)
2026 Dim browserPath As String = SettingDialog.BrowserPath.Substring(1, sep - 1)
2027 Dim arg As String = ""
2028 If sep < SettingDialog.BrowserPath.Length - 1 Then
2029 arg = SettingDialog.BrowserPath.Substring(sep + 1)
2031 myPath = arg + " " + myPath
2032 System.Diagnostics.Process.Start(browserPath, myPath)
2034 System.Diagnostics.Process.Start(SettingDialog.BrowserPath, myPath)
2037 System.Diagnostics.Process.Start(myPath)
2039 Catch ex As Exception
2040 ' MessageBox.Show("ブラウザの起動に失敗、またはタイムアウトしました。" + ex.ToString())
2042 Case WORKERTYPE.Favorites
2043 bw.ReportProgress(50, MakeStatusMessage(args, False))
2044 ret = tw.GetFavoritesApi(read, args.type)
2045 rslt.addCount = _statuses.DistributePosts()
2046 Case WORKERTYPE.PublicSearch
2047 bw.ReportProgress(50, MakeStatusMessage(args, False))
2048 If args.tName = "" Then
2049 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch)
2050 If tb.SearchWords <> "" Then ret = tw.GetSearch(read, tb, False)
2053 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2054 If tb IsNot Nothing Then
2055 ret = tw.GetSearch(read, tb, False)
2056 If ret = "" AndAlso args.page = -1 Then
2057 ret = tw.GetSearch(read, tb, True)
2062 rslt.addCount = _statuses.DistributePosts()
2063 Case WORKERTYPE.List
2064 bw.ReportProgress(50, MakeStatusMessage(args, False))
2065 If args.tName = "" Then
2067 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.Lists)
2068 If tb.ListInfo IsNot Nothing AndAlso tb.ListInfo.Id <> 0 Then ret = tw.GetListStatus(read, tb, False, _initial)
2072 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2073 If tb IsNot Nothing Then
2074 ret = tw.GetListStatus(read, tb, args.page = -1, _initial)
2078 rslt.addCount = _statuses.DistributePosts()
2079 Case WORKERTYPE.Related
2080 bw.ReportProgress(50, MakeStatusMessage(args, False))
2081 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2082 ret = tw.GetRelatedResultsApi(read, tb)
2083 rslt.addCount = _statuses.DistributePosts()
2086 If bw.CancellationPending Then
2092 If args.type = WORKERTYPE.FavAdd Then
2093 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2094 For i As Integer = _favTimestamps.Count - 1 To 0 Step -1
2095 If _favTimestamps(i).CompareTo(oneHour) < 0 Then
2096 _favTimestamps.RemoveAt(i)
2100 If args.type = WORKERTYPE.Timeline AndAlso Not _initial Then
2101 SyncLock _syncObject
2102 Dim tm As Date = Now
2103 If _tlTimestamps.ContainsKey(tm) Then
2104 _tlTimestamps(tm) += rslt.addCount
2106 _tlTimestamps.Add(Now, rslt.addCount)
2108 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2109 Dim keys As New List(Of Date)
2111 For Each key As Date In _tlTimestamps.Keys
2112 If key.CompareTo(oneHour) < 0 Then
2115 _tlCount += _tlTimestamps(key)
2118 For Each key As Date In keys
2119 _tlTimestamps.Remove(key)
2126 If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(100, MakeStatusMessage(args, True)) 'ステータス書き換え、Notifyアイコンアニメーション開始
2129 rslt.type = args.type
2130 rslt.tName = args.tName
2131 If args.type = WORKERTYPE.DirectMessegeRcv OrElse _
2132 args.type = WORKERTYPE.DirectMessegeSnt OrElse _
2133 args.type = WORKERTYPE.Reply OrElse _
2134 args.type = WORKERTYPE.Timeline OrElse _
2135 args.type = WORKERTYPE.Favorites Then
2136 rslt.page = args.page - 1 '値が正しいか後でチェック。10ページ毎の継続確認
2142 Private Function MakeStatusMessage(ByVal AsyncArg As GetWorkerArg, ByVal Finish As Boolean) As String
2143 Dim smsg As String = ""
2146 Select Case AsyncArg.type
2147 Case WORKERTYPE.Timeline
2148 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText5 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2149 Case WORKERTYPE.Reply
2150 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText4 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2151 Case WORKERTYPE.DirectMessegeRcv
2152 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText8 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2153 Case WORKERTYPE.FavAdd
2154 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText15 + AsyncArg.page.ToString() + "/" + AsyncArg.ids.Count.ToString() + _
2155 My.Resources.GetTimelineWorker_RunWorkerCompletedText16 + (AsyncArg.page - AsyncArg.sIds.Count - 1).ToString()
2156 Case WORKERTYPE.FavRemove
2157 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText17 + AsyncArg.page.ToString() + "/" + AsyncArg.ids.Count.ToString() + _
2158 My.Resources.GetTimelineWorker_RunWorkerCompletedText18 + (AsyncArg.page - AsyncArg.sIds.Count - 1).ToString()
2159 Case WORKERTYPE.Favorites
2160 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText19
2161 Case WORKERTYPE.PublicSearch
2162 smsg = "Search refreshing..."
2163 Case WORKERTYPE.List
2164 smsg = "List refreshing..."
2165 Case WORKERTYPE.Related
2166 smsg = "Related refreshing..."
2170 Select Case AsyncArg.type
2171 Case WORKERTYPE.Timeline
2172 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText1
2173 Case WORKERTYPE.Reply
2174 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText9
2175 Case WORKERTYPE.DirectMessegeRcv
2176 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText11
2177 Case WORKERTYPE.DirectMessegeSnt
2178 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText13
2179 Case WORKERTYPE.FavAdd
2181 Case WORKERTYPE.FavRemove
2183 Case WORKERTYPE.Favorites
2184 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText20
2185 Case WORKERTYPE.Follower
2186 smsg = My.Resources.UpdateFollowersMenuItem1_ClickText3
2187 Case WORKERTYPE.PublicSearch
2188 smsg = "Search refreshed"
2189 Case WORKERTYPE.List
2190 smsg = "List refreshed"
2191 Case WORKERTYPE.Related
2192 smsg = "Related refreshed"
2198 Private Sub GetTimelineWorker_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
2199 If _endingFlag Then Exit Sub
2200 If e.ProgressPercentage > 100 Then
2202 If e.ProgressPercentage = 200 Then '開始
2203 StatusLabel.Text = "Posting..."
2205 If e.ProgressPercentage = 300 Then '終了
2206 StatusLabel.Text = My.Resources.PostWorker_RunWorkerCompletedText4
2209 Dim smsg As String = DirectCast(e.UserState, String)
2210 If smsg.Length > 0 Then StatusLabel.Text = smsg
2214 Private Sub GetTimelineWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
2216 If _endingFlag OrElse e.Cancelled Then Exit Sub 'キャンセル
2218 If e.Error IsNot Nothing Then
2219 _myStatusError = True
2220 _waitTimeline = False
2224 _waitPubSearch = False
2226 Throw New Exception("BackgroundWorker Exception", e.Error)
2230 Dim rslt As GetWorkerResult = DirectCast(e.Result, GetWorkerResult)
2232 If rslt.type = WORKERTYPE.OpenUri Then Exit Sub
2235 If rslt.retMsg.Length > 0 Then
2236 _myStatusError = True
2237 StatusLabel.Text = rslt.retMsg
2240 If rslt.type = WORKERTYPE.ErrorState Then Exit Sub
2242 If rslt.type = WORKERTYPE.FavRemove Then
2243 DispSelectedPost() ' 詳細画面書き直し
2244 Dim favTabName As String = _statuses.GetTabByType(TabUsageType.Favorites).TabName
2246 If _curTab.Text.Equals(favTabName) Then
2247 If _curList.FocusedItem IsNot Nothing Then
2248 fidx = _curList.FocusedItem.Index
2249 ElseIf _curList.TopItem IsNot Nothing Then
2250 fidx = _curList.TopItem.Index
2256 For Each i As Long In rslt.sIds
2257 _statuses.RemoveFavPost(i)
2259 If _curTab IsNot Nothing AndAlso _curTab.Text.Equals(favTabName) Then
2260 _itemCache = Nothing 'キャッシュ破棄
2261 _postCache = Nothing
2265 For Each tp As TabPage In ListTab.TabPages
2266 If tp.Text = favTabName Then
2267 DirectCast(tp.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(favTabName).AllCount
2271 If _curTab.Text.Equals(favTabName) Then
2272 _curList.SelectedIndices.Clear()
2273 If _statuses.Tabs(favTabName).AllCount > 0 Then
2274 If _statuses.Tabs(favTabName).AllCount - 1 > fidx AndAlso fidx > -1 Then
2275 _curList.SelectedIndices.Add(fidx)
2277 _curList.SelectedIndices.Add(_statuses.Tabs(favTabName).AllCount - 1)
2279 If _curList.SelectedIndices.Count > 0 Then
2280 _curList.EnsureVisible(_curList.SelectedIndices(0))
2281 _curList.FocusedItem = _curList.Items(_curList.SelectedIndices(0))
2288 'Dim busy As Boolean = False
2289 'For Each bw As BackgroundWorker In _bw
2290 ' If bw IsNot Nothing AndAlso bw.IsBusy Then
2295 'If Not busy Then RefreshTimeline() 'background処理なければ、リスト反映
2296 If rslt.type = WORKERTYPE.Timeline OrElse _
2297 rslt.type = WORKERTYPE.Reply OrElse _
2298 rslt.type = WORKERTYPE.List OrElse _
2299 rslt.type = WORKERTYPE.PublicSearch OrElse _
2300 rslt.type = WORKERTYPE.DirectMessegeRcv OrElse _
2301 rslt.type = WORKERTYPE.DirectMessegeSnt OrElse _
2302 rslt.type = WORKERTYPE.Favorites OrElse _
2303 rslt.type = WORKERTYPE.Follower OrElse _
2304 rslt.type = WORKERTYPE.FavAdd OrElse _
2305 rslt.type = WORKERTYPE.FavRemove OrElse _
2306 rslt.type = WORKERTYPE.Related Then
2307 RefreshTimeline(False) 'リスト反映
2310 Select Case rslt.type
2311 Case WORKERTYPE.Timeline
2312 _waitTimeline = False
2313 If Not _initial Then
2314 ' 'API使用時の取得調整は別途考える(カウント調整?)
2316 Case WORKERTYPE.Reply
2318 If rslt.newDM AndAlso Not _initial Then
2319 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
2321 Case WORKERTYPE.Favorites
2323 Case WORKERTYPE.DirectMessegeRcv
2325 Case WORKERTYPE.FavAdd, WORKERTYPE.FavRemove
2326 If _curList IsNot Nothing AndAlso _curTab IsNot Nothing Then
2327 _curList.BeginUpdate()
2328 If rslt.type = WORKERTYPE.FavRemove AndAlso _statuses.Tabs(_curTab.Text).TabType = TabUsageType.Favorites Then
2331 For i As Integer = 0 To rslt.sIds.Count - 1
2332 If _curTab.Text.Equals(rslt.tName) Then
2333 Dim idx As Integer = _statuses.Tabs(rslt.tName).IndexOf(rslt.sIds(i))
2335 Dim post As PostClass = Nothing
2336 Dim tb As TabClass = _statuses.Tabs(rslt.tName)
2337 If tb IsNot Nothing Then
2338 If tb.TabType = TabUsageType.Lists OrElse tb.TabType = TabUsageType.PublicSearch Then
2339 post = tb.Posts(rslt.sIds(i))
2341 post = _statuses.Item(rslt.sIds(i))
2343 ChangeCacheStyleRead(post.IsRead, idx, _curTab)
2345 If idx = _curItemIndex Then DispSelectedPost() '選択アイテム再表示
2350 _curList.EndUpdate()
2352 Case WORKERTYPE.PostMessage
2353 If rslt.retMsg = "" OrElse _
2354 rslt.retMsg.StartsWith("Outputz") OrElse _
2355 rslt.retMsg.StartsWith("OK:") OrElse _
2356 rslt.retMsg = "Warn:Status is a duplicate." Then
2357 _postTimestamps.Add(Now)
2358 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2359 For i As Integer = _postTimestamps.Count - 1 To 0 Step -1
2360 If _postTimestamps(i).CompareTo(oneHour) < 0 Then
2361 _postTimestamps.RemoveAt(i)
2365 If Not HashMgr.IsPermanent AndAlso HashMgr.UseHash <> "" Then
2366 HashMgr.ClearHashtag()
2367 Me.HashStripSplitButton.Text = "#[-]"
2368 Me.HashToggleMenuItem.Checked = False
2369 Me.HashToggleToolStripMenuItem.Checked = False
2371 SetMainWindowTitle()
2374 If MessageBox.Show(String.Format("{0} ---> [ " & rslt.retMsg & " ]" & Environment.NewLine & """" & rslt.status.status & """" & Environment.NewLine & "{1}", My.Resources.StatusUpdateFailed1, My.Resources.StatusUpdateFailed2), "Failed to update status", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Retry Then
2375 Dim args As New GetWorkerArg()
2378 args.type = WORKERTYPE.PostMessage
2379 args.status = rslt.status
2382 If ToolStripFocusLockMenuItem.Checked Then
2383 '連投モードのときだけEnterイベントが起きないので強制的に背景色を戻す
2384 StatusText_Enter(StatusText, New EventArgs)
2388 If rslt.retMsg.Length = 0 AndAlso SettingDialog.PostAndGet Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2389 Case WORKERTYPE.Retweet
2390 If rslt.retMsg.Length = 0 Then
2391 _postTimestamps.Add(Now)
2392 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2393 For i As Integer = _postTimestamps.Count - 1 To 0 Step -1
2394 If _postTimestamps(i).CompareTo(oneHour) < 0 Then
2395 _postTimestamps.RemoveAt(i)
2398 If SettingDialog.PostAndGet Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2400 Case WORKERTYPE.Follower
2401 '_waitFollower = False
2402 _itemCache = Nothing
2403 _postCache = Nothing
2404 If _curList IsNot Nothing Then _curList.Refresh()
2405 Case WORKERTYPE.PublicSearch
2406 _waitPubSearch = False
2407 Case WORKERTYPE.List
2413 Private Sub GetTimeline(ByVal WkType As WORKERTYPE, ByVal fromPage As Integer, ByVal toPage As Integer, ByVal tabName As String)
2415 If Not IsNetworkAvailable() Then Exit Sub
2418 Dim args As New GetWorkerArg
2419 args.page = fromPage
2420 args.endPage = toPage
2422 args.tName = tabName
2424 Static lastTime As New Dictionary(Of WORKERTYPE, DateTime)
2425 If Not lastTime.ContainsKey(WkType) Then lastTime.Add(WkType, New DateTime)
2426 Dim period As Double = Now.Subtract(lastTime(WkType)).TotalSeconds
2427 If period > 1 OrElse period < -1 Then
2428 lastTime(WkType) = Now
2432 'Timeline取得モードの場合はReplyも同時に取得
2433 'If Not SettingDialog.UseAPI AndAlso _
2434 ' Not _initial AndAlso _
2435 ' WkType = WORKERTYPE.Timeline AndAlso _
2436 ' SettingDialog.CheckReply Then
2437 ' 'TimerReply.Enabled = False
2438 ' _mentionCounter = SettingDialog.ReplyPeriodInt
2439 ' Dim _args As New GetWorkerArg
2440 ' _args.page = fromPage
2441 ' _args.endPage = toPage
2442 ' _args.type = WORKERTYPE.Reply
2447 Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
2448 If e.Button = Windows.Forms.MouseButtons.Left Then
2450 If Me.WindowState = FormWindowState.Minimized Then
2451 Me.WindowState = FormWindowState.Normal
2457 Private Sub MyList_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
2458 MakeReplyOrDirectStatus()
2461 Private Sub FavAddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavAddToolStripMenuItem.Click, FavOpMenuItem.Click
2462 FavoriteChange(True)
2465 Private Sub FavRemoveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavRemoveToolStripMenuItem.Click, UnFavOpMenuItem.Click
2466 FavoriteChange(False)
2470 Private Sub FavoriteRetweetMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavoriteRetweetMenuItem.Click, FavoriteRetweetContextMenu.Click
2471 FavoritesRetweetOriginal()
2474 Private Sub FavoriteRetweetUnofficialMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavoriteRetweetUnofficialMenuItem.Click, FavoriteRetweetUnofficialContextMenu.Click
2475 FavoritesRetweetUnofficial()
2478 Private Sub FavoriteChange(ByVal FavAdd As Boolean, Optional ByVal multiFavoriteChangeDialogEnable As Boolean = True)
2479 'TrueでFavAdd,FalseでFavRemove
2480 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage OrElse _curList.SelectedIndices.Count = 0 Then Exit Sub
2483 If _curList.SelectedIndices.Count > 250 AndAlso FavAdd Then
2484 MessageBox.Show(My.Resources.FavoriteLimitCountText)
2485 _DoFavRetweetFlags = False
2487 ElseIf multiFavoriteChangeDialogEnable AndAlso _curList.SelectedIndices.Count > 1 Then
2489 Dim QuestionText As String = My.Resources.FavAddToolStripMenuItem_ClickText1
2490 If _DoFavRetweetFlags Then QuestionText = My.Resources.FavoriteRetweetQuestionText3
2491 If MessageBox.Show(QuestionText, My.Resources.FavAddToolStripMenuItem_ClickText2, _
2492 MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
2493 _DoFavRetweetFlags = False
2497 If MessageBox.Show(My.Resources.FavRemoveToolStripMenuItem_ClickText1, My.Resources.FavRemoveToolStripMenuItem_ClickText2, _
2498 MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
2504 Dim args As New GetWorkerArg
2505 args.ids = New List(Of Long)
2506 args.sIds = New List(Of Long)
2507 args.tName = _curTab.Text
2509 args.type = WORKERTYPE.FavAdd
2511 args.type = WORKERTYPE.FavRemove
2513 For Each idx As Integer In _curList.SelectedIndices
2514 Dim post As PostClass = GetCurTabPost(idx)
2516 If Not post.IsFav Then args.ids.Add(post.Id)
2518 If post.IsFav Then args.ids.Add(post.Id)
2521 If args.ids.Count = 0 Then
2523 StatusLabel.Text = My.Resources.FavAddToolStripMenuItem_ClickText4
2525 StatusLabel.Text = My.Resources.FavRemoveToolStripMenuItem_ClickText4
2533 Private Function GetCurTabPost(ByVal Index As Integer) As PostClass
2534 If _postCache IsNot Nothing AndAlso Index >= _itemCacheIndex AndAlso Index < _itemCacheIndex + _postCache.Length Then
2535 Return _postCache(Index - _itemCacheIndex)
2537 Return _statuses.Item(_curTab.Text, Index)
2542 Private Sub MoveToHomeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToHomeToolStripMenuItem.Click, OpenHomeOpMenuItem.Click
2543 If _curList.SelectedIndices.Count > 0 Then
2544 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
2545 ElseIf _curList.SelectedIndices.Count = 0 Then
2546 OpenUriAsync("http://twitter.com/")
2550 Private Sub MoveToFavToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToFavToolStripMenuItem.Click, OpenFavOpMenuItem.Click
2551 If _curList.SelectedIndices.Count > 0 Then
2552 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
2556 Private Sub Tween_ClientSizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ClientSizeChanged
2557 If Me.WindowState <> FormWindowState.Minimized Then
2558 If Not _initialLayout AndAlso Me.Visible = True Then
2559 If Me.WindowState = FormWindowState.Normal Then
2560 _mySize = Me.ClientSize
2561 _mySpDis = Me.SplitContainer1.SplitterDistance
2562 _mySpDis3 = Me.SplitContainer3.SplitterDistance
2563 If StatusText.Multiline Then _mySpDis2 = Me.StatusText.Height
2564 _modifySettingLocal = True
2570 Private Sub MyList_ColumnClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs)
2571 If SettingDialog.SortOrderLock Then Exit Sub
2572 Dim mode As IdComparerClass.ComparerMode
2574 mode = IdComparerClass.ComparerMode.Id
2576 Select Case e.Column
2577 Case 0, 5, 6 '0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
2581 mode = IdComparerClass.ComparerMode.Nickname
2583 mode = IdComparerClass.ComparerMode.Data
2585 mode = IdComparerClass.ComparerMode.Id
2587 mode = IdComparerClass.ComparerMode.Name
2589 mode = IdComparerClass.ComparerMode.Source
2592 _statuses.ToggleSortOrder(mode)
2596 DirectCast(sender, DetailsListView).Columns.Item(0).Text = ColumnOrgText(0)
2597 DirectCast(sender, DetailsListView).Columns.Item(1).Text = ColumnText(2)
2599 For i As Integer = 0 To 7
2600 DirectCast(sender, DetailsListView).Columns.Item(i).Text = ColumnOrgText(i)
2602 DirectCast(sender, DetailsListView).Columns.Item(e.Column).Text = ColumnText(e.Column)
2605 _itemCache = Nothing
2606 _postCache = Nothing
2608 If _statuses.Tabs(_curTab.Text).AllCount > 0 AndAlso _curPost IsNot Nothing Then
2609 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.Id)
2610 SelectListItem(_curList, idx)
2611 _curList.EnsureVisible(idx)
2614 _modifySettingCommon = True
2617 Private Sub Tween_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
2618 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
2619 _myLoc = Me.DesktopLocation
2620 _modifySettingLocal = True
2624 Private Sub ContextMenuOperate_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuOperate.Opening
2625 If ListTab.SelectedTab Is Nothing Then Exit Sub
2626 If _statuses Is Nothing OrElse _statuses.Tabs Is Nothing OrElse Not _statuses.Tabs.ContainsKey(ListTab.SelectedTab.Text) Then Exit Sub
2627 If _curPost Is Nothing Then
2628 ReplyStripMenuItem.Enabled = False
2629 ReplyAllStripMenuItem.Enabled = False
2630 DMStripMenuItem.Enabled = False
2631 ShowProfileMenuItem.Enabled = False
2632 ListManageUserContextToolStripMenuItem2.Enabled = False
2633 MoveToFavToolStripMenuItem.Enabled = False
2634 TabMenuItem.Enabled = False
2635 IDRuleMenuItem.Enabled = False
2636 ReadedStripMenuItem.Enabled = False
2637 UnreadStripMenuItem.Enabled = False
2639 ShowProfileMenuItem.Enabled = True
2640 ListManageUserContextToolStripMenuItem2.Enabled = True
2641 ReplyStripMenuItem.Enabled = True
2642 ReplyAllStripMenuItem.Enabled = True
2643 DMStripMenuItem.Enabled = True
2644 MoveToFavToolStripMenuItem.Enabled = True
2645 TabMenuItem.Enabled = True
2646 IDRuleMenuItem.Enabled = True
2647 ReadedStripMenuItem.Enabled = True
2648 UnreadStripMenuItem.Enabled = True
2650 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage OrElse _curPost Is Nothing OrElse _curPost.IsDm Then
2651 FavAddToolStripMenuItem.Enabled = False
2652 FavRemoveToolStripMenuItem.Enabled = False
2653 StatusOpenMenuItem.Enabled = False
2654 FavorareMenuItem.Enabled = False
2655 ShowRelatedStatusesMenuItem.Enabled = False
2657 ReTweetStripMenuItem.Enabled = False
2658 ReTweetOriginalStripMenuItem.Enabled = False
2659 QuoteStripMenuItem.Enabled = False
2660 FavoriteRetweetContextMenu.Enabled = False
2661 FavoriteRetweetUnofficialContextMenu.Enabled = False
2662 If _curPost IsNot Nothing AndAlso _curPost.IsDm Then DeleteStripMenuItem.Enabled = True
2664 FavAddToolStripMenuItem.Enabled = True
2665 FavRemoveToolStripMenuItem.Enabled = True
2666 StatusOpenMenuItem.Enabled = True
2667 FavorareMenuItem.Enabled = True
2668 ShowRelatedStatusesMenuItem.Enabled = True 'PublicSearchの時問題出るかも
2670 If _curPost.IsMe Then
2671 ReTweetOriginalStripMenuItem.Enabled = False
2672 FavoriteRetweetContextMenu.Enabled = False
2673 DeleteStripMenuItem.Enabled = True
2675 DeleteStripMenuItem.Enabled = False
2676 If _curPost.IsProtect Then
2677 ReTweetOriginalStripMenuItem.Enabled = False
2678 ReTweetStripMenuItem.Enabled = False
2679 QuoteStripMenuItem.Enabled = False
2680 FavoriteRetweetContextMenu.Enabled = False
2681 FavoriteRetweetUnofficialContextMenu.Enabled = False
2683 ReTweetOriginalStripMenuItem.Enabled = True
2684 ReTweetStripMenuItem.Enabled = True
2685 QuoteStripMenuItem.Enabled = True
2686 FavoriteRetweetContextMenu.Enabled = True
2687 FavoriteRetweetUnofficialContextMenu.Enabled = True
2691 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.Favorites Then
2692 RefreshMoreStripMenuItem.Enabled = True
2694 RefreshMoreStripMenuItem.Enabled = False
2696 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch _
2697 OrElse _curPost Is Nothing _
2698 OrElse Not _curPost.InReplyToId > 0 Then
2699 RepliedStatusOpenMenuItem.Enabled = False
2701 RepliedStatusOpenMenuItem.Enabled = True
2703 If _curPost Is Nothing OrElse _curPost.RetweetedBy = "" Then
2704 MoveToRTHomeMenuItem.Enabled = False
2706 MoveToRTHomeMenuItem.Enabled = True
2710 Private Sub ReplyStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReplyStripMenuItem.Click, ReplyOpMenuItem.Click
2711 MakeReplyOrDirectStatus(False, True)
2714 Private Sub DMStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DMStripMenuItem.Click, DmOpMenuItem.Click
2715 MakeReplyOrDirectStatus(False, False)
2718 Private Sub doStatusDelete()
2719 If _curTab Is Nothing OrElse _curList Is Nothing Then Exit Sub
2720 If _statuses.Tabs(_curTab.Text).TabType <> TabUsageType.DirectMessage Then
2721 Dim myPost As Boolean = False
2722 For Each idx As Integer In _curList.SelectedIndices
2723 If GetCurTabPost(idx).IsMe OrElse _
2724 GetCurTabPost(idx).RetweetedBy.ToLower = tw.Username.ToLower Then
2729 If Not myPost Then Exit Sub
2731 If _curList.SelectedIndices.Count = 0 Then
2736 Dim tmp As String = String.Format(My.Resources.DeleteStripMenuItem_ClickText1, Environment.NewLine)
2738 If MessageBox.Show(tmp, My.Resources.DeleteStripMenuItem_ClickText2, _
2739 MessageBoxButtons.OKCancel, _
2740 MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then Exit Sub
2743 If _curList.FocusedItem IsNot Nothing Then
2744 fidx = _curList.FocusedItem.Index
2745 ElseIf _curList.TopItem IsNot Nothing Then
2746 fidx = _curList.TopItem.Index
2752 Me.Cursor = Cursors.WaitCursor
2754 Dim rslt As Boolean = True
2755 For Each Id As Long In _statuses.GetId(_curTab.Text, _curList.SelectedIndices)
2756 Dim rtn As String = ""
2757 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then
2758 rtn = tw.RemoveDirectMessage(Id)
2760 If _statuses.Item(Id).IsMe OrElse _statuses.Item(Id).RetweetedBy.ToLower = tw.Username.ToLower Then
2761 rtn = tw.RemoveStatus(Id)
2766 If rtn.Length > 0 Then
2770 _statuses.RemovePost(Id)
2775 StatusLabel.Text = My.Resources.DeleteStripMenuItem_ClickText3 '失敗
2777 StatusLabel.Text = My.Resources.DeleteStripMenuItem_ClickText4 '成功
2780 _itemCache = Nothing 'キャッシュ破棄
2781 _postCache = Nothing
2784 For Each tb As TabPage In ListTab.TabPages
2785 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
2786 If _curTab.Equals(tb) Then
2787 _curList.SelectedIndices.Clear()
2788 If _statuses.Tabs(tb.Text).AllCount > 0 Then
2789 If _statuses.Tabs(tb.Text).AllCount - 1 > fidx AndAlso fidx > -1 Then
2790 _curList.SelectedIndices.Add(fidx)
2792 _curList.SelectedIndices.Add(_statuses.Tabs(tb.Text).AllCount - 1)
2794 If _curList.SelectedIndices.Count > 0 Then
2795 _curList.EnsureVisible(_curList.SelectedIndices(0))
2796 _curList.FocusedItem = _curList.Items(_curList.SelectedIndices(0))
2800 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2801 If SettingDialog.TabIconDisp Then
2802 If tb.ImageIndex = 0 Then tb.ImageIndex = -1 'タブアイコン
2806 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2808 Me.Cursor = Cursors.Default
2812 Private Sub DeleteStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteStripMenuItem.Click, DelOpMenuItem.Click
2816 Private Sub ReadedStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadedStripMenuItem.Click, ReadOpMenuItem.Click
2817 _curList.BeginUpdate()
2818 If SettingDialog.UnreadManage Then
2819 For Each idx As Integer In _curList.SelectedIndices
2820 _statuses.SetRead(True, _curTab.Text, idx)
2823 For Each idx As Integer In _curList.SelectedIndices
2824 ChangeCacheStyleRead(True, idx, _curTab)
2827 _curList.EndUpdate()
2828 For Each tb As TabPage In ListTab.TabPages
2829 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2830 If SettingDialog.TabIconDisp Then
2831 If tb.ImageIndex = 0 Then tb.ImageIndex = -1 'タブアイコン
2835 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2838 Private Sub UnreadStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnreadStripMenuItem.Click, UnreadOpMenuItem.Click
2839 _curList.BeginUpdate()
2840 If SettingDialog.UnreadManage Then
2841 For Each idx As Integer In _curList.SelectedIndices
2842 _statuses.SetRead(False, _curTab.Text, idx)
2845 For Each idx As Integer In _curList.SelectedIndices
2846 ChangeCacheStyleRead(False, idx, _curTab)
2849 _curList.EndUpdate()
2850 For Each tb As TabPage In ListTab.TabPages
2851 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
2852 If SettingDialog.TabIconDisp Then
2853 If tb.ImageIndex = -1 Then tb.ImageIndex = 0 'タブアイコン
2857 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2860 Private Sub RefreshStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshStripMenuItem.Click, RefreshOpMenuItem.Click
2864 Private Sub DoRefresh()
2865 If _curTab IsNot Nothing Then
2866 Select Case _statuses.Tabs(_curTab.Text).TabType
2867 Case TabUsageType.Mentions
2868 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
2869 Case TabUsageType.DirectMessage
2870 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
2871 Case TabUsageType.Favorites
2872 GetTimeline(WORKERTYPE.Favorites, 1, 0, "")
2873 'Case TabUsageType.Profile
2875 Case TabUsageType.PublicSearch
2877 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2878 If tb.SearchWords = "" Then Exit Sub
2879 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, _curTab.Text)
2880 Case TabUsageType.Lists
2882 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2883 If tb.ListInfo Is Nothing OrElse tb.ListInfo.Id = 0 Then Exit Sub
2884 GetTimeline(WORKERTYPE.List, 1, 0, _curTab.Text)
2886 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2889 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2893 Private Sub DoRefreshMore()
2895 If _curTab IsNot Nothing Then
2896 Select Case _statuses.Tabs(_curTab.Text).TabType
2897 Case TabUsageType.Mentions
2898 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
2899 Case TabUsageType.DirectMessage
2900 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
2901 Case TabUsageType.Favorites
2902 ' GetTimeline(WORKERTYPE.Favorites, -1, 0, "")
2903 Case TabUsageType.Profile
2905 Case TabUsageType.PublicSearch
2907 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2908 If tb.SearchWords = "" Then Exit Sub
2909 GetTimeline(WORKERTYPE.PublicSearch, -1, 0, _curTab.Text)
2910 Case TabUsageType.Lists
2912 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2913 If tb.ListInfo Is Nothing OrElse tb.ListInfo.Id = 0 Then Exit Sub
2914 GetTimeline(WORKERTYPE.List, -1, 0, _curTab.Text)
2916 GetTimeline(WORKERTYPE.Timeline, -1, 0, "")
2919 GetTimeline(WORKERTYPE.Timeline, -1, 0, "")
2923 Private Sub SettingStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingStripMenuItem.Click, SettingFileMenuItem.Click
2924 Dim result As DialogResult
2925 Dim uid As String = tw.Username.ToLower
2928 result = SettingDialog.ShowDialog()
2929 Catch ex As Exception
2933 If result = Windows.Forms.DialogResult.OK Then
2934 SyncLock _syncObject
2936 ' If SettingDialog.TimelinePeriodInt > 0 Then
2937 ' _homeCounterAdjuster = 0
2939 'Catch ex As Exception
2940 ' ex.Data("Instance") = "Set Timers"
2941 ' ex.Data("IsTerminatePermission") = False
2944 'tw.CountApi = SettingDialog.CountApi
2945 'tw.CountApiReply = SettingDialog.CountApiReply
2946 tw.TinyUrlResolve = SettingDialog.TinyUrlResolve
2947 tw.RestrictFavCheck = SettingDialog.RestrictFavCheck
2948 tw.ReadOwnPost = SettingDialog.ReadOwnPost
2949 tw.UseSsl = SettingDialog.UseSsl
2950 ShortUrl.IsResolve = SettingDialog.TinyUrlResolve
2951 ShortUrl.BitlyId = SettingDialog.BitlyUser
2952 ShortUrl.BitlyKey = SettingDialog.BitlyPwd
2953 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
2954 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
2956 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, _
2957 SettingDialog.SelectedProxyType, _
2958 SettingDialog.ProxyAddress, _
2959 SettingDialog.ProxyPort, _
2960 SettingDialog.ProxyUser, _
2961 SettingDialog.ProxyPassword)
2963 If SettingDialog.TabIconDisp Then
2964 RemoveHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
2965 ListTab.DrawMode = TabDrawMode.Normal
2966 ListTab.ImageList = Me.TabImage
2968 RemoveHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
2969 AddHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
2970 ListTab.DrawMode = TabDrawMode.OwnerDrawFixed
2971 ListTab.ImageList = Nothing
2973 Catch ex As Exception
2974 ex.Data("Instance") = "ListTab(TabIconDisp)"
2975 ex.Data("IsTerminatePermission") = False
2980 If Not SettingDialog.UnreadManage Then
2981 ReadedStripMenuItem.Enabled = False
2982 UnreadStripMenuItem.Enabled = False
2983 If SettingDialog.TabIconDisp Then
2984 For Each myTab As TabPage In ListTab.TabPages
2985 myTab.ImageIndex = -1
2989 ReadedStripMenuItem.Enabled = True
2990 UnreadStripMenuItem.Enabled = True
2992 Catch ex As Exception
2993 ex.Data("Instance") = "ListTab(UnreadManage)"
2994 ex.Data("IsTerminatePermission") = False
2999 For Each mytab As TabPage In ListTab.TabPages
3000 Dim lst As DetailsListView = DirectCast(mytab.Tag, DetailsListView)
3001 lst.GridLines = SettingDialog.ShowGrid
3003 Catch ex As Exception
3004 ex.Data("Instance") = "ListTab(ShowGrid)"
3005 ex.Data("IsTerminatePermission") = False
3009 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
3010 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
3011 _fntUnread = SettingDialog.FontUnread
3012 _clUnread = SettingDialog.ColorUnread
3013 _fntReaded = SettingDialog.FontReaded
3014 _clReaded = SettingDialog.ColorReaded
3015 _clFav = SettingDialog.ColorFav
3016 _clOWL = SettingDialog.ColorOWL
3017 _clRetweet = SettingDialog.ColorRetweet
3018 _fntDetail = SettingDialog.FontDetail
3019 _clDetail = SettingDialog.ColorDetail
3020 _clDetailLink = SettingDialog.ColorDetailLink
3021 _clDetailBackcolor = SettingDialog.ColorDetailBackcolor
3022 _clSelf = SettingDialog.ColorSelf
3023 _clAtSelf = SettingDialog.ColorAtSelf
3024 _clTarget = SettingDialog.ColorTarget
3025 _clAtTarget = SettingDialog.ColorAtTarget
3026 _clAtFromTarget = SettingDialog.ColorAtFromTarget
3027 _clAtTo = SettingDialog.ColorAtTo
3028 _clListBackcolor = SettingDialog.ColorListBackcolor
3029 _clInputBackcolor = SettingDialog.ColorInputBackcolor
3030 _clInputFont = SettingDialog.ColorInputFont
3031 _fntInputFont = SettingDialog.FontInputFont
3033 If StatusText.Focused Then StatusText.BackColor = _clInputBackcolor
3034 StatusText.Font = _fntInputFont
3035 StatusText.ForeColor = _clInputFont
3036 Catch ex As Exception
3037 MessageBox.Show(ex.Message)
3040 _brsForeColorUnread.Dispose()
3041 _brsForeColorReaded.Dispose()
3042 _brsForeColorFav.Dispose()
3043 _brsForeColorOWL.Dispose()
3044 _brsForeColorRetweet.Dispose()
3045 _brsForeColorUnread = New SolidBrush(_clUnread)
3046 _brsForeColorReaded = New SolidBrush(_clReaded)
3047 _brsForeColorFav = New SolidBrush(_clFav)
3048 _brsForeColorOWL = New SolidBrush(_clOWL)
3049 _brsForeColorRetweet = New SolidBrush(_clRetweet)
3050 _brsBackColorMine.Dispose()
3051 _brsBackColorAt.Dispose()
3052 _brsBackColorYou.Dispose()
3053 _brsBackColorAtYou.Dispose()
3054 _brsBackColorAtFromTarget.Dispose()
3055 _brsBackColorAtTo.Dispose()
3056 _brsBackColorNone.Dispose()
3057 _brsBackColorMine = New SolidBrush(_clSelf)
3058 _brsBackColorAt = New SolidBrush(_clAtSelf)
3059 _brsBackColorYou = New SolidBrush(_clTarget)
3060 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
3061 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
3062 _brsBackColorAtTo = New SolidBrush(_clAtTo)
3063 _brsBackColorNone = New SolidBrush(_clListBackcolor)
3065 If SettingDialog.IsMonospace Then
3066 detailHtmlFormatHeader = detailHtmlFormatMono1
3067 detailHtmlFormatFooter = detailHtmlFormatMono7
3069 detailHtmlFormatHeader = detailHtmlFormat1
3070 detailHtmlFormatFooter = detailHtmlFormat7
3072 detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString + "," + _clDetail.G.ToString + "," + _clDetail.B.ToString + detailHtmlFormat4 + _clDetailLink.R.ToString + "," + _clDetailLink.G.ToString + "," + _clDetailLink.B.ToString + detailHtmlFormat5 + _clDetailBackcolor.R.ToString + "," + _clDetailBackcolor.G.ToString + "," + _clDetailBackcolor.B.ToString
3073 If SettingDialog.IsMonospace Then
3074 detailHtmlFormatHeader += detailHtmlFormatMono6
3076 detailHtmlFormatHeader += detailHtmlFormat6
3078 Catch ex As Exception
3079 ex.Data("Instance") = "Font"
3080 ex.Data("IsTerminatePermission") = False
3084 _statuses.SetUnreadManage(SettingDialog.UnreadManage)
3085 Catch ex As Exception
3086 ex.Data("Instance") = "_statuses"
3087 ex.Data("IsTerminatePermission") = False
3092 For Each tb As TabPage In ListTab.TabPages
3093 If SettingDialog.TabIconDisp Then
3094 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
3100 If tb.Tag IsNot Nothing AndAlso tb.Controls.Count > 0 Then
3101 DirectCast(tb.Tag, DetailsListView).Font = _fntReaded
3102 DirectCast(tb.Tag, DetailsListView).BackColor = _clListBackcolor
3105 Catch ex As Exception
3106 ex.Data("Instance") = "ListTab(TabIconDisp no2)"
3107 ex.Data("IsTerminatePermission") = False
3110 SetMainWindowTitle()
3113 _itemCache = Nothing
3114 _postCache = Nothing
3115 If _curList IsNot Nothing Then _curList.Refresh()
3118 Outputz.Key = SettingDialog.OutputzKey
3119 Outputz.Enabled = SettingDialog.OutputzEnabled
3120 Select Case SettingDialog.OutputzUrlmode
3121 Case OutputzUrlmode.twittercom
3122 Outputz.OutUrl = "http://twitter.com/"
3123 Case OutputzUrlmode.twittercomWithUsername
3124 Outputz.OutUrl = "http://twitter.com/" + tw.Username
3127 _hookGlobalHotkey.UnregisterAllOriginalHotkey()
3128 If SettingDialog.HotkeyEnabled Then
3129 '''グローバルホットキーの登録。設定で変更可能にするかも
3130 Dim modKey As HookGlobalHotkey.ModKeys = HookGlobalHotkey.ModKeys.None
3131 If (SettingDialog.HotkeyMod And Keys.Alt) = Keys.Alt Then modKey = modKey Or HookGlobalHotkey.ModKeys.Alt
3132 If (SettingDialog.HotkeyMod And Keys.Control) = Keys.Control Then modKey = modKey Or HookGlobalHotkey.ModKeys.Ctrl
3133 If (SettingDialog.HotkeyMod And Keys.Shift) = Keys.Shift Then modKey = modKey Or HookGlobalHotkey.ModKeys.Shift
3134 If (SettingDialog.HotkeyMod And Keys.LWin) = Keys.LWin Then modKey = modKey Or HookGlobalHotkey.ModKeys.Win
3136 _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey)
3139 If uid <> tw.Username Then Me.doGetFollowersMenu()
3141 SetImageServiceCombo()
3144 StatusText_TextChanged(Nothing, Nothing)
3145 Catch ex As Exception
3151 Twitter.AccountState = ACCOUNT_STATE.Valid
3153 Me.TopMost = SettingDialog.AlwaysTop
3154 SaveConfigsAll(False)
3157 Private Sub PostBrowser_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles PostBrowser.Navigated
3158 If e.Url.AbsoluteUri <> "about:blank" Then
3160 OpenUriAsync(e.Url.OriginalString)
3164 Private Sub PostBrowser_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles PostBrowser.Navigating
3165 If e.Url.Scheme = "data" Then
3166 StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&")
3167 ElseIf e.Url.AbsoluteUri <> "about:blank" Then
3170 If e.Url.AbsoluteUri.StartsWith("http://twitter.com/search?q=%23") OrElse _
3171 e.Url.AbsoluteUri.StartsWith("https://twitter.com/search?q=%23") Then
3173 Dim urlStr As String = HttpUtility.UrlDecode(e.Url.AbsoluteUri)
3174 Dim hash As String = urlStr.Substring(urlStr.IndexOf("#"))
3175 HashSupl.AddItem(hash)
3176 HashMgr.AddHashToHistory(hash.Trim, False)
3177 AddNewTabForSearch(hash)
3180 OpenUriAsync(e.Url.OriginalString)
3185 Public Sub AddNewTabForSearch(ByVal searchWord As String)
3186 '同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了
3187 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch)
3188 If tb.SearchWords = searchWord AndAlso tb.SearchLang = "" Then
3189 For Each tp As TabPage In ListTab.TabPages
3190 If tb.TabName = tp.Text Then
3191 ListTab.SelectedTab = tp
3198 Dim tabName As String = searchWord
3199 For i As Integer = 0 To 100
3200 If _statuses.ContainsTab(tabName) Then
3207 AddNewTab(tabName, False, TabUsageType.PublicSearch)
3208 _statuses.AddTab(tabName, TabUsageType.PublicSearch, Nothing)
3210 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
3212 Dim cmb As ComboBox = DirectCast(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), ComboBox)
3213 cmb.Items.Add(searchWord)
3214 cmb.Text = searchWord
3217 Me.SearchButton_Click(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), Nothing)
3220 Public Function AddNewTab(ByVal tabName As String, ByVal startup As Boolean, ByVal tabType As TabUsageType) As Boolean
3222 For Each tb As TabPage In ListTab.TabPages
3223 If tb.Text = tabName Then Return False
3227 If tabName = My.Resources.AddNewTabText1 Then Return False
3231 If tabType = TabUsageType.DirectMessage OrElse _
3232 tabType = TabUsageType.Favorites OrElse _
3233 tabType = TabUsageType.Home OrElse _
3234 tabType = TabUsageType.Mentions OrElse _
3235 tabType = TabUsageType.Related Then
3236 If _statuses.GetTabByType(tabType) IsNot Nothing Then Return False
3240 Dim _tabPage As TabPage = New TabPage
3241 Dim _listCustom As DetailsListView = New DetailsListView
3242 Dim _colHd1 As ColumnHeader = New ColumnHeader() 'アイコン
3243 Dim _colHd2 As ColumnHeader = New ColumnHeader() 'ニックネーム
3244 Dim _colHd3 As ColumnHeader = New ColumnHeader() '本文
3245 Dim _colHd4 As ColumnHeader = New ColumnHeader() '日付
3246 Dim _colHd5 As ColumnHeader = New ColumnHeader() 'ユーザID
3247 Dim _colHd6 As ColumnHeader = New ColumnHeader() '未読
3248 Dim _colHd7 As ColumnHeader = New ColumnHeader() 'マーク&プロテクト
3249 Dim _colHd8 As ColumnHeader = New ColumnHeader() 'ソース
3251 Dim cnt As Integer = ListTab.TabPages.Count
3253 '''ToDo:Create and set controls follow tabtypes
3255 Me.SplitContainer1.Panel1.SuspendLayout()
3256 Me.SplitContainer1.Panel2.SuspendLayout()
3257 Me.SplitContainer1.SuspendLayout()
3258 Me.ListTab.SuspendLayout()
3261 _tabPage.SuspendLayout()
3266 Dim pnl As Panel = Nothing
3267 If tabType = TabUsageType.PublicSearch Then
3270 Dim lbl As New Label
3271 Dim cmb As New ComboBox
3272 Dim btn As New Button
3273 Dim cmbLang As New ComboBox
3277 pnl.Controls.Add(cmb)
3278 pnl.Controls.Add(cmbLang)
3279 pnl.Controls.Add(btn)
3280 pnl.Controls.Add(lbl)
3281 pnl.Name = "panelSearch"
3282 pnl.Dock = DockStyle.Top
3283 pnl.Height = cmb.Height
3284 AddHandler pnl.Enter, AddressOf SearchControls_Enter
3285 AddHandler pnl.Leave, AddressOf SearchControls_Leave
3288 cmb.Anchor = AnchorStyles.Left Or AnchorStyles.Right
3289 cmb.Dock = DockStyle.Fill
3290 cmb.Name = "comboSearch"
3291 cmb.DropDownStyle = ComboBoxStyle.DropDown
3292 cmb.ImeMode = Windows.Forms.ImeMode.NoControl
3294 cmb.AutoCompleteMode = AutoCompleteMode.None
3296 If _statuses.ContainsTab(tabName) Then
3297 cmb.Items.Add(_statuses.Tabs(tabName).SearchWords)
3298 cmb.Text = _statuses.Tabs(tabName).SearchWords
3302 cmbLang.Anchor = AnchorStyles.Left Or AnchorStyles.Right
3303 cmbLang.Dock = DockStyle.Right
3305 cmbLang.Name = "comboLang"
3306 cmbLang.DropDownStyle = ComboBoxStyle.DropDownList
3307 cmbLang.TabStop = False
3308 cmbLang.Items.Add("")
3309 cmbLang.Items.Add("ja")
3310 cmbLang.Items.Add("en")
3311 cmbLang.Items.Add("ar")
3312 cmbLang.Items.Add("da")
3313 cmbLang.Items.Add("nl")
3314 cmbLang.Items.Add("fa")
3315 cmbLang.Items.Add("fi")
3316 cmbLang.Items.Add("fr")
3317 cmbLang.Items.Add("de")
3318 cmbLang.Items.Add("hu")
3319 cmbLang.Items.Add("is")
3320 cmbLang.Items.Add("it")
3321 cmbLang.Items.Add("no")
3322 cmbLang.Items.Add("pl")
3323 cmbLang.Items.Add("pt")
3324 cmbLang.Items.Add("ru")
3325 cmbLang.Items.Add("es")
3326 cmbLang.Items.Add("sv")
3327 cmbLang.Items.Add("th")
3328 If _statuses.ContainsTab(tabName) Then cmbLang.Text = _statuses.Tabs(tabName).SearchLang
3330 lbl.Text = "Search(C-S-f)"
3332 lbl.Dock = DockStyle.Left
3334 lbl.Height = cmb.Height
3335 lbl.TextAlign = ContentAlignment.MiddleLeft
3338 btn.Name = "buttonSearch"
3339 btn.UseVisualStyleBackColor = True
3340 btn.Dock = DockStyle.Right
3342 AddHandler btn.Click, AddressOf SearchButton_Click
3346 Me.ListTab.Controls.Add(_tabPage)
3347 _tabPage.Controls.Add(_listCustom)
3349 If tabType = TabUsageType.PublicSearch Then _tabPage.Controls.Add(pnl)
3351 _tabPage.Location = New Point(4, 4)
3352 _tabPage.Name = "CTab" + cnt.ToString()
3353 _tabPage.Size = New Size(380, 260)
3354 _tabPage.TabIndex = 2 + cnt
3355 _tabPage.Text = tabName
3356 _tabPage.UseVisualStyleBackColor = True
3358 _listCustom.AllowColumnReorder = True
3359 If Not _iconCol Then
3360 _listCustom.Columns.AddRange(New ColumnHeader() {_colHd1, _colHd2, _colHd3, _colHd4, _colHd5, _colHd6, _colHd7, _colHd8})
3362 _listCustom.Columns.AddRange(New ColumnHeader() {_colHd1, _colHd3})
3364 _listCustom.ContextMenuStrip = Me.ContextMenuOperate
3365 _listCustom.Dock = DockStyle.Fill
3366 _listCustom.FullRowSelect = True
3367 _listCustom.HideSelection = False
3368 _listCustom.Location = New Point(0, 0)
3369 _listCustom.Margin = New Padding(0)
3370 _listCustom.Name = "CList" + Environment.TickCount.ToString()
3371 _listCustom.ShowItemToolTips = True
3372 _listCustom.Size = New Size(380, 260)
3373 _listCustom.UseCompatibleStateImageBehavior = False
3374 _listCustom.View = View.Details
3375 _listCustom.OwnerDraw = True
3376 _listCustom.VirtualMode = True
3377 _listCustom.Font = _fntReaded
3378 _listCustom.BackColor = _clListBackcolor
3380 _listCustom.GridLines = SettingDialog.ShowGrid
3381 _listCustom.AllowDrop = True
3383 AddHandler _listCustom.SelectedIndexChanged, AddressOf MyList_SelectedIndexChanged
3384 AddHandler _listCustom.MouseDoubleClick, AddressOf MyList_MouseDoubleClick
3385 AddHandler _listCustom.ColumnClick, AddressOf MyList_ColumnClick
3386 AddHandler _listCustom.DrawColumnHeader, AddressOf MyList_DrawColumnHeader
3387 AddHandler _listCustom.DragDrop, AddressOf TweenMain_DragDrop
3388 AddHandler _listCustom.DragOver, AddressOf TweenMain_DragOver
3389 AddHandler _listCustom.DrawItem, AddressOf MyList_DrawItem
3390 AddHandler _listCustom.MouseClick, AddressOf MyList_MouseClick
3391 AddHandler _listCustom.ColumnReordered, AddressOf MyList_ColumnReordered
3392 AddHandler _listCustom.ColumnWidthChanged, AddressOf MyList_ColumnWidthChanged
3393 AddHandler _listCustom.CacheVirtualItems, AddressOf MyList_CacheVirtualItems
3394 AddHandler _listCustom.RetrieveVirtualItem, AddressOf MyList_RetrieveVirtualItem
3395 AddHandler _listCustom.DrawSubItem, AddressOf MyList_DrawSubItem
3396 AddHandler _listCustom.HScrolled, AddressOf MyList_HScrolled
3399 _colHd1.Text = ColumnText(0)
3401 _colHd2.Text = ColumnText(1)
3403 _colHd3.Text = ColumnText(2)
3405 _colHd4.Text = ColumnText(3)
3407 _colHd5.Text = ColumnText(4)
3409 _colHd6.Text = ColumnText(5)
3411 _colHd7.Text = ColumnText(6)
3413 _colHd8.Text = ColumnText(7)
3416 If (_statuses.Tabs.ContainsKey(tabName) AndAlso _statuses.Tabs(tabName).TabType = TabUsageType.Mentions) _
3417 OrElse (Not _statuses.IsDefaultTab(tabName) AndAlso tabType <> TabUsageType.PublicSearch AndAlso tabType <> TabUsageType.Lists AndAlso tabType <> TabUsageType.Related) Then
3418 TabDialog.AddTab(tabName)
3421 _listCustom.SmallImageList = New ImageList()
3423 _listCustom.SmallImageList.ImageSize = New Size(_iconSz, _iconSz)
3426 Dim dispOrder(7) As Integer
3428 For i As Integer = 0 To _curList.Columns.Count - 1
3429 For j As Integer = 0 To _curList.Columns.Count - 1
3430 If _curList.Columns(j).DisplayIndex = i Then
3436 For i As Integer = 0 To _curList.Columns.Count - 1
3437 _listCustom.Columns(i).Width = _curList.Columns(i).Width
3438 _listCustom.Columns(dispOrder(i)).DisplayIndex = i
3442 _listCustom.Columns(0).Width = _cfgLocal.Width1
3443 _listCustom.Columns(1).Width = _cfgLocal.Width3
3444 _listCustom.Columns(0).DisplayIndex = 0
3445 _listCustom.Columns(1).DisplayIndex = 1
3447 For i As Integer = 0 To 7
3448 If _cfgLocal.DisplayIndex1 = i Then
3450 ElseIf _cfgLocal.DisplayIndex2 = i Then
3452 ElseIf _cfgLocal.DisplayIndex3 = i Then
3454 ElseIf _cfgLocal.DisplayIndex4 = i Then
3456 ElseIf _cfgLocal.DisplayIndex5 = i Then
3458 ElseIf _cfgLocal.DisplayIndex6 = i Then
3460 ElseIf _cfgLocal.DisplayIndex7 = i Then
3462 ElseIf _cfgLocal.DisplayIndex8 = i Then
3466 _listCustom.Columns(0).Width = _cfgLocal.Width1
3467 _listCustom.Columns(1).Width = _cfgLocal.Width2
3468 _listCustom.Columns(2).Width = _cfgLocal.Width3
3469 _listCustom.Columns(3).Width = _cfgLocal.Width4
3470 _listCustom.Columns(4).Width = _cfgLocal.Width5
3471 _listCustom.Columns(5).Width = _cfgLocal.Width6
3472 _listCustom.Columns(6).Width = _cfgLocal.Width7
3473 _listCustom.Columns(7).Width = _cfgLocal.Width8
3474 For i As Integer = 0 To 7
3475 _listCustom.Columns(dispOrder(i)).DisplayIndex = i
3480 If tabType = TabUsageType.PublicSearch Then pnl.ResumeLayout(False)
3482 _tabPage.ResumeLayout(False)
3484 Me.SplitContainer1.Panel1.ResumeLayout(False)
3485 Me.SplitContainer1.Panel2.ResumeLayout(False)
3486 Me.SplitContainer1.ResumeLayout(False)
3487 Me.ListTab.ResumeLayout(False)
3488 Me.ResumeLayout(False)
3490 _tabPage.Tag = _listCustom
3494 Public Function RemoveSpecifiedTab(ByVal TabName As String) As Boolean
3495 Dim idx As Integer = 0
3496 For idx = 0 To ListTab.TabPages.Count - 1
3497 If ListTab.TabPages(idx).Text = TabName Then Exit For
3500 If _statuses.IsDefaultTab(TabName) Then Return False
3502 Dim tmp As String = String.Format(My.Resources.RemoveSpecifiedTabText1, Environment.NewLine)
3503 If MessageBox.Show(tmp, TabName + " " + My.Resources.RemoveSpecifiedTabText2, _
3504 MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Cancel Then
3508 SetListProperty() '他のタブに列幅等を反映
3510 Dim tabType As TabUsageType = _statuses.Tabs(TabName).TabType
3513 Me.SplitContainer1.Panel1.SuspendLayout()
3514 Me.SplitContainer1.Panel2.SuspendLayout()
3515 Me.SplitContainer1.SuspendLayout()
3516 Me.ListTab.SuspendLayout()
3519 Dim _tabPage As TabPage = ListTab.TabPages(idx)
3520 Dim _listCustom As DetailsListView = DirectCast(_tabPage.Tag, DetailsListView)
3521 _tabPage.Tag = Nothing
3523 _tabPage.SuspendLayout()
3525 Me.ListTab.Controls.Remove(_tabPage)
3527 Dim pnl As Control = Nothing
3528 If tabType = TabUsageType.PublicSearch Then
3529 pnl = _tabPage.Controls("panelSearch")
3530 For Each ctrl As Control In pnl.Controls
3531 If ctrl.Name = "buttonSearch" Then
3532 RemoveHandler ctrl.Click, AddressOf SearchButton_Click
3534 RemoveHandler ctrl.Enter, AddressOf SearchControls_Enter
3535 RemoveHandler ctrl.Leave, AddressOf SearchControls_Leave
3536 pnl.Controls.Remove(ctrl)
3539 _tabPage.Controls.Remove(pnl)
3542 _tabPage.Controls.Remove(_listCustom)
3543 _listCustom.Columns.Clear()
3544 _listCustom.ContextMenuStrip = Nothing
3546 RemoveHandler _listCustom.SelectedIndexChanged, AddressOf MyList_SelectedIndexChanged
3547 RemoveHandler _listCustom.MouseDoubleClick, AddressOf MyList_MouseDoubleClick
3548 RemoveHandler _listCustom.ColumnClick, AddressOf MyList_ColumnClick
3549 RemoveHandler _listCustom.DrawColumnHeader, AddressOf MyList_DrawColumnHeader
3550 RemoveHandler _listCustom.DragDrop, AddressOf TweenMain_DragDrop
3551 RemoveHandler _listCustom.DragOver, AddressOf TweenMain_DragOver
3552 RemoveHandler _listCustom.DrawItem, AddressOf MyList_DrawItem
3553 RemoveHandler _listCustom.MouseClick, AddressOf MyList_MouseClick
3554 RemoveHandler _listCustom.ColumnReordered, AddressOf MyList_ColumnReordered
3555 RemoveHandler _listCustom.ColumnWidthChanged, AddressOf MyList_ColumnWidthChanged
3556 RemoveHandler _listCustom.CacheVirtualItems, AddressOf MyList_CacheVirtualItems
3557 RemoveHandler _listCustom.RetrieveVirtualItem, AddressOf MyList_RetrieveVirtualItem
3558 RemoveHandler _listCustom.DrawSubItem, AddressOf MyList_DrawSubItem
3559 RemoveHandler _listCustom.HScrolled, AddressOf MyList_HScrolled
3561 TabDialog.RemoveTab(TabName)
3563 _listCustom.SmallImageList = Nothing
3564 _listCustom.ListViewItemSorter = Nothing
3567 If _curTab.Equals(_tabPage) Then
3573 _itemCache = Nothing
3574 _itemCacheIndex = -1
3575 _postCache = Nothing
3577 _tabPage.ResumeLayout(False)
3579 Me.SplitContainer1.Panel1.ResumeLayout(False)
3580 Me.SplitContainer1.Panel2.ResumeLayout(False)
3581 Me.SplitContainer1.ResumeLayout(False)
3582 Me.ListTab.ResumeLayout(False)
3583 Me.ResumeLayout(False)
3587 _listCustom.Dispose()
3588 _statuses.RemoveTab(TabName)
3590 For Each tp As TabPage In ListTab.TabPages
3591 Dim lst As DetailsListView = DirectCast(tp.Tag, DetailsListView)
3592 If lst.VirtualListSize <> _statuses.Tabs(tp.Text).AllCount Then
3593 lst.VirtualListSize = _statuses.Tabs(tp.Text).AllCount
3599 Private Sub ListTab_Deselected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles ListTab.Deselected
3600 _itemCache = Nothing
3601 _itemCacheIndex = -1
3602 _postCache = Nothing
3605 Private Sub ListTab_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseMove
3607 Dim cpos As New Point(e.X, e.Y)
3609 If e.Button = Windows.Forms.MouseButtons.Left AndAlso _tabDrag Then
3610 Dim tn As String = ""
3611 For i As Integer = 0 To ListTab.TabPages.Count - 1
3612 Dim rect As Rectangle = ListTab.GetTabRect(i)
3613 If rect.Left <= cpos.X AndAlso cpos.X <= rect.Right AndAlso _
3614 rect.Top <= cpos.Y AndAlso cpos.Y <= rect.Bottom Then
3615 tn = ListTab.TabPages(i).Text
3620 If tn = "" Then Exit Sub
3622 For Each tb As TabPage In ListTab.TabPages
3623 If tb.Text = tn Then
3624 ListTab.DoDragDrop(tb, DragDropEffects.All)
3632 For i As Integer = 0 To ListTab.TabPages.Count - 1
3633 Dim rect As Rectangle = ListTab.GetTabRect(i)
3634 If rect.Left <= cpos.X And cpos.X <= rect.Right And _
3635 rect.Top <= cpos.Y And cpos.Y <= rect.Bottom Then
3636 _rclickTabName = ListTab.TabPages(i).Text
3642 Private Sub ListTab_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListTab.SelectedIndexChanged
3645 SetMainWindowTitle()
3647 If ListTab.Focused OrElse DirectCast(ListTab.SelectedTab.Tag, Control).Focused Then Me.Tag = ListTab.Tag
3648 TabMenuControl(ListTab.SelectedTab.Text)
3651 Private Sub SetListProperty()
3653 If _curList Is Nothing Then Exit Sub
3654 If Not _isColumnChanged Then Exit Sub
3656 Dim dispOrder(_curList.Columns.Count - 1) As Integer
3657 For i As Integer = 0 To _curList.Columns.Count - 1
3658 For j As Integer = 0 To _curList.Columns.Count - 1
3659 If _curList.Columns(j).DisplayIndex = i Then
3667 For Each tb As TabPage In ListTab.TabPages
3668 If Not tb.Equals(_curTab) Then
3669 If tb.Tag IsNot Nothing AndAlso tb.Controls.Count > 0 Then
3670 Dim lst As DetailsListView = DirectCast(tb.Tag, DetailsListView)
3671 For i As Integer = 0 To lst.Columns.Count - 1
3672 lst.Columns(dispOrder(i)).DisplayIndex = i
3673 lst.Columns(i).Width = _curList.Columns(i).Width
3679 _isColumnChanged = False
3682 Private Sub PostBrowser_StatusTextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles PostBrowser.StatusTextChanged
3683 If PostBrowser.StatusText.StartsWith("http") OrElse PostBrowser.StatusText.StartsWith("ftp") _
3684 OrElse PostBrowser.StatusText.StartsWith("data") Then
3685 StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&")
3687 If PostBrowser.StatusText = "" Then
3692 Private Sub StatusText_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles StatusText.KeyPress
3693 If e.KeyChar = "@" Then
3694 If Not SettingDialog.UseAtIdSupplement Then Exit Sub
3696 ShowSuplDialog(StatusText, AtIdSupl)
3698 ElseIf e.KeyChar = "#" Then
3699 If Not SettingDialog.UseHashSupplement Then Exit Sub
3700 ShowSuplDialog(StatusText, HashSupl)
3705 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement)
3706 ShowSuplDialog(owner, dialog, 0, "")
3709 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement, ByVal offset As Integer)
3710 ShowSuplDialog(owner, dialog, offset, "")
3713 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement, ByVal offset As Integer, ByVal startswith As String)
3714 dialog.StartsWith = startswith
3715 If dialog.Visible Then
3720 Me.TopMost = SettingDialog.AlwaysTop
3721 Dim selStart As Integer = owner.SelectionStart
3722 Dim fHalf As String = ""
3723 Dim eHalf As String = ""
3724 If dialog.DialogResult = Windows.Forms.DialogResult.OK Then
3725 If dialog.inputText <> "" Then
3726 If selStart > 0 Then
3727 fHalf = owner.Text.Substring(0, selStart - offset)
3729 If selStart < owner.Text.Length Then
3730 eHalf = owner.Text.Substring(selStart)
3732 owner.Text = fHalf + dialog.inputText + eHalf
3733 owner.SelectionStart = selStart + dialog.inputText.Length
3736 If selStart > 0 Then
3737 fHalf = owner.Text.Substring(0, selStart)
3739 If selStart < owner.Text.Length Then
3740 eHalf = owner.Text.Substring(selStart)
3742 owner.Text = fHalf + eHalf
3743 If selStart > 0 Then
3744 owner.SelectionStart = selStart
3750 Private Sub StatusText_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StatusText.KeyUp
3752 If Not e.Alt AndAlso Not e.Control AndAlso Not e.Shift Then
3753 If e.KeyCode = Keys.Space OrElse e.KeyCode = Keys.ProcessKey Then
3754 Dim isSpace As Boolean = False
3755 For Each c As Char In StatusText.Text.ToCharArray
3756 If c = " " OrElse c = " " Then
3765 StatusText.Text = ""
3766 JumpUnreadMenuItem_Click(Nothing, Nothing)
3770 Me.StatusText_TextChanged(Nothing, Nothing)
3773 Private Sub StatusText_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.TextChanged
3775 Dim pLen As Integer = GetRestStatusCount(True, False)
3776 lblLen.Text = pLen.ToString()
3778 StatusText.ForeColor = Color.Red
3780 StatusText.ForeColor = _clInputFont
3782 If StatusText.Text = "" Then
3788 Private Function GetRestStatusCount(ByVal isAuto As Boolean, ByVal isAddFooter As Boolean) As Integer
3790 Dim pLen As Integer = 140 - StatusText.Text.Length
3791 If (isAuto AndAlso Not My.Computer.Keyboard.CtrlKeyDown AndAlso SettingDialog.PostShiftEnter) OrElse _
3792 (isAuto AndAlso Not My.Computer.Keyboard.ShiftKeyDown AndAlso Not SettingDialog.PostShiftEnter) OrElse _
3793 (Not isAuto AndAlso isAddFooter) Then
3794 If SettingDialog.UseRecommendStatus Then
3795 pLen -= SettingDialog.RecommendStatusText.Length
3796 ElseIf SettingDialog.Status.Length > 0 Then
3797 pLen -= SettingDialog.Status.Length + 1
3800 If HashMgr.UseHash <> "" Then
3801 pLen -= HashMgr.UseHash.Length + 1
3806 Private Sub MyList_CacheVirtualItems(ByVal sender As System.Object, ByVal e As System.Windows.Forms.CacheVirtualItemsEventArgs)
3807 If _itemCache IsNot Nothing AndAlso _
3808 e.StartIndex >= _itemCacheIndex AndAlso _
3809 e.EndIndex < _itemCacheIndex + _itemCache.Length AndAlso _
3810 _curList.Equals(sender) Then
3811 'If the newly requested cache is a subset of the old cache,
3812 'no need to rebuild everything, so do nothing.
3816 'Now we need to rebuild the cache.
3817 If _curList.Equals(sender) Then CreateCache(e.StartIndex, e.EndIndex)
3820 Private Sub MyList_RetrieveVirtualItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.RetrieveVirtualItemEventArgs)
3821 If _itemCache IsNot Nothing AndAlso e.ItemIndex >= _itemCacheIndex AndAlso e.ItemIndex < _itemCacheIndex + _itemCache.Length AndAlso _curList.Equals(sender) Then
3822 'A cache hit, so get the ListViewItem from the cache instead of making a new one.
3823 e.Item = _itemCache(e.ItemIndex - _itemCacheIndex)
3825 'A cache miss, so create a new ListViewItem and pass it back.
3826 Dim tb As TabPage = DirectCast(DirectCast(sender, Tween.TweenCustomControl.DetailsListView).Parent, TabPage)
3828 e.Item = CreateItem(tb, _
3829 _statuses.Item(tb.Text, e.ItemIndex), _
3831 Catch ex As Exception
3833 Dim sitem() As String = {"", "", "", "", "", "", "", ""}
3834 e.Item = New ImageListViewItem(sitem, "")
3839 Private Sub CreateCache(ByVal StartIndex As Integer, ByVal EndIndex As Integer)
3841 'キャッシュ要求(要求範囲±30を作成)
3843 If StartIndex < 0 Then StartIndex = 0
3845 If EndIndex >= _statuses.Tabs(_curTab.Text).AllCount Then EndIndex = _statuses.Tabs(_curTab.Text).AllCount - 1
3846 _postCache = _statuses.Item(_curTab.Text, StartIndex, EndIndex) '配列で取得
3847 _itemCacheIndex = StartIndex
3849 _itemCache = New ListViewItem(_postCache.Length - 1) {}
3850 For i As Integer = 0 To _postCache.Length - 1
3851 _itemCache(i) = CreateItem(_curTab, _postCache(i), StartIndex + i)
3853 Catch ex As Exception
3854 'キャッシュ要求が実データとずれるため(イベントの遅延?)
3855 _postCache = Nothing
3856 _itemCache = Nothing
3860 Private Function CreateItem(ByVal Tab As TabPage, ByVal Post As PostClass, ByVal Index As Integer) As ListViewItem
3861 Dim mk As String = ""
3862 If Post.IsMark Then mk += "♪"
3863 If Post.IsProtect Then mk += "Ю"
3864 If Post.InReplyToId > 0 Then mk += "⇒"
3865 Dim itm As ImageListViewItem
3866 If Post.RetweetedId = 0 Then
3867 Dim sitem() As String = {"", Post.Nickname, Post.Data, Post.PDate.ToString(SettingDialog.DateTimeFormat), Post.Name, "", mk, Post.Source}
3868 itm = New ImageListViewItem(sitem, DirectCast(Me.TIconDic, ImageDictionary), Post.ImageUrl)
3870 Dim sitem() As String = {"", Post.Nickname, Post.Data, Post.PDate.ToString(SettingDialog.DateTimeFormat), Post.Name + Environment.NewLine + "(RT:" + Post.RetweetedBy + ")", "", mk, Post.Source}
3871 itm = New ImageListViewItem(sitem, DirectCast(Me.TIconDic, ImageDictionary), Post.ImageUrl)
3874 Dim read As Boolean = Post.IsRead
3875 '未読管理していなかったら既読として扱う
3876 If Not _statuses.Tabs(Tab.Text).UnreadManage OrElse _
3877 Not SettingDialog.UnreadManage Then read = True
3878 ChangeItemStyleRead(read, itm, Post, Nothing)
3879 If Tab.Equals(_curTab) Then ColorizeList(itm, Index)
3883 Private Sub MyList_DrawColumnHeader(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewColumnHeaderEventArgs)
3884 e.DrawDefault = True
3887 Private Sub MyList_HScrolled(ByVal sender As Object, ByVal e As EventArgs)
3888 Dim listView As DetailsListView = DirectCast(sender, DetailsListView)
3892 Private Sub MyList_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewItemEventArgs)
3893 If e.State = 0 Then Exit Sub
3894 e.DrawDefault = False
3895 If Not e.Item.Selected Then 'e.ItemStateでうまく判定できない???
3896 Dim brs2 As SolidBrush = Nothing
3897 Select Case e.Item.BackColor
3899 brs2 = _brsBackColorMine
3901 brs2 = _brsBackColorAt
3903 brs2 = _brsBackColorYou
3905 brs2 = _brsBackColorAtYou
3906 Case _clAtFromTarget
3907 brs2 = _brsBackColorAtFromTarget
3909 brs2 = _brsBackColorAtTo
3911 brs2 = _brsBackColorNone
3913 e.Graphics.FillRectangle(brs2, e.Bounds)
3916 If DirectCast(sender, Windows.Forms.Control).Focused Then
3917 e.Graphics.FillRectangle(_brsHighLight, e.Bounds)
3919 e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds)
3922 If (e.State And ListViewItemStates.Focused) = ListViewItemStates.Focused Then e.DrawFocusRectangle()
3925 Private Sub MyList_DrawSubItem(ByVal sender As Object, ByVal e As DrawListViewSubItemEventArgs)
3926 If e.ItemState = 0 Then Exit Sub
3928 If e.ColumnIndex = 0 Then
3929 Me.DrawListViewItemIcon(e)
3932 Dim rct As RectangleF = e.Bounds
3933 Dim rctB As RectangleF = e.Bounds
3934 rct.Width = e.Header.Width
3935 rctB.Width = e.Header.Width
3937 rct.Y += e.Item.Font.Height
3938 rct.Height -= e.Item.Font.Height
3939 rctB.Height = e.Item.Font.Height
3943 Dim heightDiff As Integer
3944 Dim drawLineCount As Integer = Math.Max(1, Math.DivRem(CType(rct.Height, Integer), e.Item.Font.Height, heightDiff))
3946 'If heightDiff > e.Item.Font.Height * 0.7 Then
3947 ' rct.Height += e.Item.Font.Height
3948 ' drawLineCount += 1
3951 'フォントの高さの半分を足してるのは保険。無くてもいいかも。
3952 If Not _iconCol AndAlso drawLineCount <= 1 Then
3953 'rct.Inflate(0, CType(heightDiff / -2, Integer))
3954 'rct.Height += CType(e.Item.Font.Height / 2, Integer)
3955 ElseIf heightDiff < e.Item.Font.Height * 0.7 Then
3956 '最終行が70%以上欠けていたら、最終行は表示しない
3957 'rct.Height = CType((e.Item.Font.Height * drawLineCount) + (e.Item.Font.Height / 2), Single)
3958 rct.Height = CType((e.Item.Font.Height * drawLineCount), Single) - 1
3963 'If Not _iconCol AndAlso drawLineCount > 1 Then
3964 ' rct.Y += CType(e.Item.Font.Height * 0.2, Single)
3965 ' If heightDiff >= e.Item.Font.Height * 0.8 Then rct.Height -= CType(e.Item.Font.Height * 0.2, Single)
3967 If Not e.Item.Selected Then 'e.ItemStateでうまく判定できない???
3970 Dim brs As SolidBrush = Nothing
3971 Dim flg As Boolean = False
3972 Select Case e.Item.ForeColor
3974 brs = _brsForeColorUnread
3976 brs = _brsForeColorReaded
3978 brs = _brsForeColorFav
3980 brs = _brsForeColorOWL
3982 brs = _brsForeColorRetweet
3984 brs = New SolidBrush(e.Item.ForeColor)
3987 If rct.Width > 0 Then
3989 Dim fnt As New Font(e.Item.Font, FontStyle.Bold)
3990 'e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, brs, rct, sf)
3991 'e.Graphics.DrawString(e.Item.SubItems(4).Text + " / " + e.Item.SubItems(1).Text + " (" + e.Item.SubItems(3).Text + ") " + e.Item.SubItems(5).Text + e.Item.SubItems(6).Text + " [" + e.Item.SubItems(7).Text + "]", fnt, brs, rctB, sf)
3992 TextRenderer.DrawText(e.Graphics,
3993 e.Item.SubItems(2).Text,
3995 Rectangle.Round(rct),
3997 TextFormatFlags.WordBreak Or
3998 TextFormatFlags.EndEllipsis Or
3999 TextFormatFlags.GlyphOverhangPadding Or
4000 TextFormatFlags.NoPrefix)
4001 TextRenderer.DrawText(e.Graphics,
4002 e.Item.SubItems(4).Text + " / " + e.Item.SubItems(1).Text + " (" + e.Item.SubItems(3).Text + ") " + e.Item.SubItems(5).Text + e.Item.SubItems(6).Text + " [" + e.Item.SubItems(7).Text + "]",
4004 Rectangle.Round(rctB),
4006 TextFormatFlags.SingleLine Or
4007 TextFormatFlags.EndEllipsis Or
4008 TextFormatFlags.GlyphOverhangPadding Or
4009 TextFormatFlags.NoPrefix)
4011 ElseIf drawLineCount = 1 Then
4012 TextRenderer.DrawText(e.Graphics,
4015 Rectangle.Round(rct),
4017 TextFormatFlags.SingleLine Or
4018 TextFormatFlags.EndEllipsis Or
4019 TextFormatFlags.GlyphOverhangPadding Or
4020 TextFormatFlags.NoPrefix Or
4021 TextFormatFlags.VerticalCenter)
4023 'e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, brs, rct, sf)
4024 TextRenderer.DrawText(e.Graphics,
4027 Rectangle.Round(rct),
4029 TextFormatFlags.WordBreak Or
4030 TextFormatFlags.EndEllipsis Or
4031 TextFormatFlags.GlyphOverhangPadding Or
4032 TextFormatFlags.NoPrefix)
4035 If flg Then brs.Dispose()
4037 If rct.Width > 0 Then
4039 Dim fnt As New Font(e.Item.Font, FontStyle.Bold)
4040 If DirectCast(sender, Windows.Forms.Control).Focused Then
4042 'e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, _brsHighLightText, rct, sf)
4043 'e.Graphics.DrawString(e.Item.SubItems(4).Text + " / " + e.Item.SubItems(1).Text + " (" + e.Item.SubItems(3).Text + ") " + e.Item.SubItems(5).Text + e.Item.SubItems(6).Text + " [" + e.Item.SubItems(7).Text + "]", fnt, _brsHighLightText, rctB, sf)
4044 TextRenderer.DrawText(e.Graphics,
4045 e.Item.SubItems(2).Text,
4047 Rectangle.Round(rct),
4048 _brsHighLightText.Color,
4049 TextFormatFlags.WordBreak Or
4050 TextFormatFlags.EndEllipsis Or
4051 TextFormatFlags.GlyphOverhangPadding Or
4052 TextFormatFlags.NoPrefix)
4053 TextRenderer.DrawText(e.Graphics,
4054 e.Item.SubItems(4).Text + " / " + e.Item.SubItems(1).Text + " (" + e.Item.SubItems(3).Text + ") " + e.Item.SubItems(5).Text + e.Item.SubItems(6).Text + " [" + e.Item.SubItems(7).Text + "]",
4056 Rectangle.Round(rctB),
4057 _brsHighLightText.Color,
4058 TextFormatFlags.SingleLine Or
4059 TextFormatFlags.EndEllipsis Or
4060 TextFormatFlags.GlyphOverhangPadding Or
4061 TextFormatFlags.NoPrefix)
4062 ElseIf drawLineCount = 1 Then
4063 TextRenderer.DrawText(e.Graphics,
4066 Rectangle.Round(rct),
4067 _brsHighLightText.Color,
4068 TextFormatFlags.SingleLine Or
4069 TextFormatFlags.EndEllipsis Or
4070 TextFormatFlags.GlyphOverhangPadding Or
4071 TextFormatFlags.NoPrefix Or
4072 TextFormatFlags.VerticalCenter)
4074 'e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsHighLightText, rct, sf)
4075 TextRenderer.DrawText(e.Graphics,
4078 Rectangle.Round(rct),
4079 _brsHighLightText.Color,
4080 TextFormatFlags.WordBreak Or
4081 TextFormatFlags.EndEllipsis Or
4082 TextFormatFlags.GlyphOverhangPadding Or
4083 TextFormatFlags.NoPrefix)
4087 'e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, _brsForeColorUnread, rct, sf)
4088 'e.Graphics.DrawString(e.Item.SubItems(4).Text + " / " + e.Item.SubItems(1).Text + " (" + e.Item.SubItems(3).Text + ") " + e.Item.SubItems(5).Text + e.Item.SubItems(6).Text + " [" + e.Item.SubItems(7).Text + "]", fnt, _brsForeColorUnread, rctB, sf)
4089 TextRenderer.DrawText(e.Graphics,
4090 e.Item.SubItems(2).Text,
4092 Rectangle.Round(rct),
4093 _brsForeColorUnread.Color,
4094 TextFormatFlags.WordBreak Or
4095 TextFormatFlags.EndEllipsis Or
4096 TextFormatFlags.GlyphOverhangPadding Or
4097 TextFormatFlags.NoPrefix)
4098 TextRenderer.DrawText(e.Graphics,
4099 e.Item.SubItems(4).Text + " / " + e.Item.SubItems(1).Text + " (" + e.Item.SubItems(3).Text + ") " + e.Item.SubItems(5).Text + e.Item.SubItems(6).Text + " [" + e.Item.SubItems(7).Text + "]",
4101 Rectangle.Round(rctB),
4102 _brsForeColorUnread.Color,
4103 TextFormatFlags.SingleLine Or
4104 TextFormatFlags.EndEllipsis Or
4105 TextFormatFlags.GlyphOverhangPadding Or
4106 TextFormatFlags.NoPrefix)
4107 ElseIf drawLineCount = 1 Then
4108 TextRenderer.DrawText(e.Graphics,
4111 Rectangle.Round(rct),
4112 _brsForeColorUnread.Color,
4113 TextFormatFlags.SingleLine Or
4114 TextFormatFlags.EndEllipsis Or
4115 TextFormatFlags.GlyphOverhangPadding Or
4116 TextFormatFlags.NoPrefix Or
4117 TextFormatFlags.VerticalCenter)
4119 'e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsForeColorUnread, rct, sf)
4120 TextRenderer.DrawText(e.Graphics,
4123 Rectangle.Round(rct),
4124 _brsForeColorUnread.Color,
4125 TextFormatFlags.WordBreak Or
4126 TextFormatFlags.EndEllipsis Or
4127 TextFormatFlags.GlyphOverhangPadding Or
4128 TextFormatFlags.NoPrefix)
4137 Private Sub DrawListViewItemIcon(ByVal e As DrawListViewSubItemEventArgs)
4138 Dim item As ImageListViewItem = DirectCast(e.Item, ImageListViewItem)
4139 If item.Image IsNot Nothing Then
4140 'e.Bounds.Leftが常に0を指すから自前で計算
4141 Dim itemRect As Rectangle = item.Bounds
4142 itemRect.Width = e.Item.ListView.Columns(0).Width
4144 For Each clm As ColumnHeader In e.Item.ListView.Columns
4145 If clm.DisplayIndex < e.Item.ListView.Columns(0).DisplayIndex Then
4146 itemRect.X += clm.Width
4150 Dim iconRect As Rectangle = Rectangle.Intersect(New Rectangle(e.Item.GetBounds(ItemBoundsPortion.Icon).Location, New Size(_iconSz, _iconSz)), itemRect)
4151 iconRect.Offset(0, CType(Math.Max(0, (itemRect.Height - _iconSz) / 2), Integer))
4153 If iconRect.Width > 0 Then
4154 e.Graphics.FillRectangle(Brushes.White, iconRect)
4155 e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.High
4156 e.Graphics.DrawImage(item.Image, iconRect)
4161 Private Sub DoTabSearch(ByVal _word As String, _
4162 ByVal CaseSensitive As Boolean, _
4163 ByVal UseRegex As Boolean, _
4164 ByVal SType As SEARCHTYPE)
4165 Dim cidx As Integer = 0
4166 Dim fnd As Boolean = False
4167 Dim toIdx As Integer
4168 Dim stp As Integer = 1
4170 If _curList.VirtualListSize = 0 Then
4171 MessageBox.Show(My.Resources.DoTabSearchText2, My.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information)
4174 If _curList.SelectedIndices.Count > 0 Then
4175 cidx = _curList.SelectedIndices(0)
4177 toIdx = _curList.VirtualListSize - 1
4180 Case SEARCHTYPE.DialogSearch 'ダイアログからの検索
4181 If _curList.SelectedIndices.Count > 0 Then
4182 cidx = _curList.SelectedIndices(0)
4186 Case SEARCHTYPE.NextSearch '次を検索
4187 If _curList.SelectedIndices.Count > 0 Then
4188 cidx = _curList.SelectedIndices(0) + 1
4189 If cidx > toIdx Then cidx = toIdx
4193 Case SEARCHTYPE.PrevSearch '前を検索
4194 If _curList.SelectedIndices.Count > 0 Then
4195 cidx = _curList.SelectedIndices(0) - 1
4196 If cidx < 0 Then cidx = 0
4204 Dim regOpt As RegexOptions = RegexOptions.None
4205 Dim fndOpt As StringComparison = StringComparison.Ordinal
4206 If Not CaseSensitive Then
4207 regOpt = RegexOptions.IgnoreCase
4208 fndOpt = StringComparison.OrdinalIgnoreCase
4214 Dim _search As Regex
4216 _search = New Regex(_word)
4217 For idx As Integer = cidx To toIdx Step stp
4218 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4219 If _search.IsMatch(post.Nickname, regOpt) _
4220 OrElse _search.IsMatch(post.Data, regOpt) _
4221 OrElse _search.IsMatch(post.Name, regOpt) _
4223 SelectListItem(_curList, idx)
4224 _curList.EnsureVisible(idx)
4228 Catch ex As ArgumentException
4229 MsgBox(My.Resources.DoTabSearchText1, MsgBoxStyle.Critical)
4234 For idx As Integer = cidx To toIdx Step stp
4235 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4236 If post.Nickname.IndexOf(_word, fndOpt) > -1 _
4237 OrElse post.Data.IndexOf(_word, fndOpt) > -1 _
4238 OrElse post.Name.IndexOf(_word, fndOpt) > -1 _
4240 SelectListItem(_curList, idx)
4241 _curList.EnsureVisible(idx)
4249 Case SEARCHTYPE.DialogSearch, SEARCHTYPE.NextSearch
4252 Case SEARCHTYPE.PrevSearch
4254 cidx = _curList.Items.Count - 1
4259 Catch ex As ArgumentOutOfRangeException
4262 MessageBox.Show(My.Resources.DoTabSearchText2, My.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information)
4265 Private Sub MenuItemSubSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSubSearch.Click
4267 SearchDialog.Owner = Me
4268 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4269 Me.TopMost = SettingDialog.AlwaysTop
4272 Me.TopMost = SettingDialog.AlwaysTop
4274 If SearchDialog.SWord <> "" Then
4275 DoTabSearch(SearchDialog.SWord, _
4276 SearchDialog.CheckCaseSensitive, _
4277 SearchDialog.CheckRegex, _
4278 SEARCHTYPE.DialogSearch)
4282 Private Sub MenuItemSearchNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSearchNext.Click
4284 If SearchDialog.SWord = "" Then
4285 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4286 Me.TopMost = SettingDialog.AlwaysTop
4289 Me.TopMost = SettingDialog.AlwaysTop
4290 If SearchDialog.SWord = "" Then Exit Sub
4292 DoTabSearch(SearchDialog.SWord, _
4293 SearchDialog.CheckCaseSensitive, _
4294 SearchDialog.CheckRegex, _
4295 SEARCHTYPE.DialogSearch)
4297 DoTabSearch(SearchDialog.SWord, _
4298 SearchDialog.CheckCaseSensitive, _
4299 SearchDialog.CheckRegex, _
4300 SEARCHTYPE.NextSearch)
4304 Private Sub MenuItemSearchPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSearchPrev.Click
4306 If SearchDialog.SWord = "" Then
4307 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4308 Me.TopMost = SettingDialog.AlwaysTop
4311 Me.TopMost = SettingDialog.AlwaysTop
4312 If SearchDialog.SWord = "" Then Exit Sub
4315 DoTabSearch(SearchDialog.SWord, _
4316 SearchDialog.CheckCaseSensitive, _
4317 SearchDialog.CheckRegex, _
4318 SEARCHTYPE.PrevSearch)
4321 Private Sub AboutMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutMenuItem.Click
4322 TweenAboutBox.ShowDialog()
4323 Me.TopMost = SettingDialog.AlwaysTop
4326 Private Sub JumpUnreadMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JumpUnreadMenuItem.Click, JumpReadOpMenuItem.Click
4327 Dim bgnIdx As Integer = ListTab.TabPages.IndexOf(_curTab)
4328 Dim idx As Integer = -1
4329 Dim lst As DetailsListView = Nothing
4331 If ImageSelectionPanel.Enabled Then
4336 For i As Integer = bgnIdx To ListTab.TabPages.Count - 1
4338 idx = _statuses.GetOldestUnreadId(ListTab.TabPages(i).Text)
4340 ListTab.SelectedIndex = i
4341 lst = DirectCast(ListTab.TabPages(i).Tag, DetailsListView)
4342 '_curTab = ListTab.TabPages(i)
4347 '未読みつからず&現在タブが先頭ではなかったら、先頭タブから現在タブの手前まで探索
4348 If idx = -1 AndAlso bgnIdx > 0 Then
4349 For i As Integer = 0 To bgnIdx - 1
4350 idx = _statuses.GetOldestUnreadId(ListTab.TabPages(i).Text)
4352 ListTab.SelectedIndex = i
4353 lst = DirectCast(ListTab.TabPages(i).Tag, DetailsListView)
4354 '_curTab = ListTab.TabPages(i)
4360 '全部調べたが未読見つからず→先頭タブの最新発言へ
4362 ListTab.SelectedIndex = 0
4363 lst = DirectCast(ListTab.TabPages(0).Tag, DetailsListView)
4364 '_curTab = ListTab.TabPages(0)
4365 If _statuses.SortOrder = SortOrder.Ascending Then
4366 idx = lst.VirtualListSize - 1
4372 If lst.VirtualListSize > 0 AndAlso idx > -1 AndAlso lst.VirtualListSize > idx Then
4373 SelectListItem(lst, idx)
4374 If _statuses.SortMode = IdComparerClass.ComparerMode.Id Then
4375 If _statuses.SortOrder = SortOrder.Ascending AndAlso lst.Items(idx).Position.Y > lst.ClientSize.Height - _iconSz - 10 OrElse _
4376 _statuses.SortOrder = SortOrder.Descending AndAlso lst.Items(idx).Position.Y < _iconSz + 10 Then
4379 lst.EnsureVisible(idx)
4382 lst.EnsureVisible(idx)
4388 Private Sub StatusOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusOpenMenuItem.Click, OpenStatusOpMenuItem.Click
4389 If _curList.SelectedIndices.Count > 0 AndAlso _statuses.Tabs(_curTab.Text).TabType <> TabUsageType.DirectMessage Then
4390 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(0))
4391 If post.RetweetedId = 0 Then
4392 OpenUriAsync("http://twitter.com/" + post.Name + "/status/" + post.Id.ToString)
4394 OpenUriAsync("http://twitter.com/" + post.Name + "/status/" + post.RetweetedId.ToString)
4399 Private Sub FavorareMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FavorareMenuItem.Click, OpenFavotterOpMenuItem.Click
4400 If _curList.SelectedIndices.Count > 0 Then
4401 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(0))
4402 OpenUriAsync(My.Resources.FavstarUrl + "users/" + post.Name + "/recent")
4406 Private Sub VerUpMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VerUpMenuItem.Click
4410 Private Sub RunTweenUp()
4412 Dim pinfo As New ProcessStartInfo
4413 pinfo.UseShellExecute = True
4414 pinfo.WorkingDirectory = Application.StartupPath
4415 pinfo.FileName = Path.Combine(Application.StartupPath(), "TweenUp.exe")
4417 Process.Start(pinfo)
4418 Catch ex As Exception
4419 MessageBox.Show("Failed to execute TweenUp.exe.")
4423 Private Sub CheckNewVersion(Optional ByVal startup As Boolean = False)
4424 Dim retMsg As String = ""
4425 Dim strVer As String = ""
4426 Dim strDetail As String = ""
4427 Dim forceUpdate As Boolean = My.Computer.Keyboard.ShiftKeyDown
4430 retMsg = tw.GetVersionInfo()
4431 Catch ex As Exception
4432 StatusLabel.Text = My.Resources.CheckNewVersionText9
4433 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText10, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
4436 If retMsg.Length > 0 Then
4437 strVer = retMsg.Substring(0, 4)
4438 If retMsg.Length > 4 Then
4439 strDetail = retMsg.Substring(5).Trim
4441 If fileVersion <> "" AndAlso strVer.CompareTo(fileVersion.Replace(".", "")) > 0 Then
4442 Dim tmp As String = String.Format(My.Resources.CheckNewVersionText3, strVer)
4443 Using dialogAsShieldicon As New DialogAsShieldIcon
4444 If dialogAsShieldicon.Show(tmp, strDetail, My.Resources.CheckNewVersionText1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
4445 retMsg = tw.GetTweenBinary(strVer)
4446 If retMsg.Length = 0 Then
4449 dialogAsShieldicon.Dispose()
4453 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText5 + System.Environment.NewLine + retMsg, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4456 dialogAsShieldicon.Dispose()
4460 Dim tmp As String = String.Format(My.Resources.CheckNewVersionText6, strVer)
4461 Using dialogAsShieldicon As New DialogAsShieldIcon
4462 If dialogAsShieldicon.Show(tmp, strDetail, My.Resources.CheckNewVersionText1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
4463 retMsg = tw.GetTweenBinary(strVer)
4464 If retMsg.Length = 0 Then
4467 dialogAsShieldicon.Dispose()
4471 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText5 + System.Environment.NewLine + retMsg, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4474 dialogAsShieldicon.Dispose()
4476 ElseIf Not startup Then
4477 MessageBox.Show(My.Resources.CheckNewVersionText7 + fileVersion.Replace(".", "") + My.Resources.CheckNewVersionText8 + strVer, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Information)
4481 StatusLabel.Text = My.Resources.CheckNewVersionText9
4482 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText10, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4486 Private Sub Colorize()
4490 If SettingDialog.DispLatestPost <> DispTitleEnum.None AndAlso _
4491 SettingDialog.DispLatestPost <> DispTitleEnum.Post AndAlso _
4492 SettingDialog.DispLatestPost <> DispTitleEnum.Ver AndAlso _
4493 SettingDialog.DispLatestPost <> DispTitleEnum.OwnStatus Then
4494 SetMainWindowTitle()
4496 If Not StatusLabelUrl.Text.StartsWith("http") Then SetStatusLabelUrl()
4497 For Each tb As TabPage In ListTab.TabPages
4498 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
4499 If SettingDialog.TabIconDisp Then
4500 If tb.ImageIndex = 0 Then tb.ImageIndex = -1
4504 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
4507 Public Function createDetailHtml(ByVal orgdata As String) As String
4508 Return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter
4511 Private Sub DispSelectedPost()
4513 If _curList.SelectedIndices.Count = 0 OrElse _curPost Is Nothing Then Exit Sub
4515 Dim dTxt As String = createDetailHtml(_curPost.OriginalData)
4516 If _curPost.IsDm Then
4517 SourceLinkLabel.Tag = Nothing
4518 SourceLinkLabel.Text = ""
4519 'SourceLinkLabel.Visible = False
4521 Dim mc As Match = Regex.Match(_curPost.SourceHtml, "<a href=""(?<sourceurl>.+?)""")
4523 Dim src As String = mc.Groups("sourceurl").Value
4524 SourceLinkLabel.Tag = mc.Groups("sourceurl").Value
4525 mc = Regex.Match(src, "^https?://")
4526 If Not mc.Success Then
4527 src = src.Insert(0, "http://twitter.com")
4529 SourceLinkLabel.Tag = src
4531 SourceLinkLabel.Tag = Nothing
4533 If String.IsNullOrEmpty(_curPost.Source) Then
4534 SourceLinkLabel.Text = ""
4535 'SourceLinkLabel.Visible = False
4537 SourceLinkLabel.Text = "via " + _curPost.Source
4538 'SourceLinkLabel.Visible = True
4542 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage AndAlso Not _curPost.IsOwl Then
4543 NameLabel.Text = "DM TO -> "
4544 ElseIf _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then
4545 NameLabel.Text = "DM FROM <- "
4549 NameLabel.Text += _curPost.Name + "/" + _curPost.Nickname
4550 NameLabel.Tag = _curPost.Name
4551 If Not String.IsNullOrEmpty(_curPost.RetweetedBy) Then
4552 NameLabel.Text += " (RT:" + _curPost.RetweetedBy + ")"
4554 If UserPicture.Image IsNot Nothing Then UserPicture.Image.Dispose()
4555 If Not String.IsNullOrEmpty(_curPost.ImageUrl) AndAlso TIconDic.ContainsKey(_curPost.ImageUrl) Then
4556 UserPicture.Image = TIconDic(_curPost.ImageUrl)
4558 'Dim dummy As Image = DirectCast(TIconDic, ImageDictionary)(_curPost.ImageUrl, Sub(getImg)
4559 ' If img IsNot Nothing Then img.Dispose()
4560 ' If getImg Is Nothing Then Exit Sub
4561 ' img = DirectCast(getImg.Clone(), Image)
4563 ' Me.UserPicture.Image = img
4567 UserPicture.Image = Nothing
4570 NameLabel.ForeColor = System.Drawing.SystemColors.ControlText
4571 DateTimeLabel.Text = _curPost.PDate.ToString()
4572 If _curPost.IsOwl AndAlso (SettingDialog.OneWayLove OrElse _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage) Then NameLabel.ForeColor = _clOWL
4573 If _curPost.RetweetedId > 0 Then NameLabel.ForeColor = _clRetweet
4574 If _curPost.IsFav Then NameLabel.ForeColor = _clFav
4576 If DumpPostClassToolStripMenuItem.Checked Then
4577 Dim sb As New StringBuilder(512)
4579 sb.Append("-----Start PostClass Dump<br>")
4580 sb.AppendFormat("Data : {0}<br>", _curPost.Data)
4581 sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.Data)
4582 sb.AppendFormat("Id : {0}<br>", _curPost.Id.ToString)
4583 'sb.AppendFormat("ImageIndex : {0}<br>", _curPost.ImageIndex.ToString)
4584 sb.AppendFormat("ImageUrl : {0}<br>", _curPost.ImageUrl)
4585 sb.AppendFormat("InReplyToId : {0}<br>", _curPost.InReplyToId.ToString)
4586 sb.AppendFormat("InReplyToUser : {0}<br>", _curPost.InReplyToUser)
4587 sb.AppendFormat("IsDM : {0}<br>", _curPost.IsDm.ToString)
4588 sb.AppendFormat("IsFav : {0}<br>", _curPost.IsFav.ToString)
4589 sb.AppendFormat("IsMark : {0}<br>", _curPost.IsMark.ToString)
4590 sb.AppendFormat("IsMe : {0}<br>", _curPost.IsMe.ToString)
4591 sb.AppendFormat("IsOwl : {0}<br>", _curPost.IsOwl.ToString)
4592 sb.AppendFormat("IsProtect : {0}<br>", _curPost.IsProtect.ToString)
4593 sb.AppendFormat("IsRead : {0}<br>", _curPost.IsRead.ToString)
4594 sb.AppendFormat("IsReply : {0}<br>", _curPost.IsReply.ToString)
4596 For Each nm As String In _curPost.ReplyToList
4597 sb.AppendFormat("ReplyToList : {0}<br>", nm)
4600 sb.AppendFormat("Name : {0}<br>", _curPost.Name)
4601 sb.AppendFormat("NickName : {0}<br>", _curPost.Nickname)
4602 sb.AppendFormat("OriginalData : {0}<br>", _curPost.OriginalData)
4603 sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.OriginalData)
4604 sb.AppendFormat("PDate : {0}<br>", _curPost.PDate.ToString)
4605 sb.AppendFormat("Source : {0}<br>", _curPost.Source)
4606 sb.AppendFormat("Uid : {0}<br>", _curPost.Uid)
4607 sb.AppendFormat("FilterHit : {0}<br>", _curPost.FilterHit)
4608 sb.AppendFormat("RetweetedBy : {0}<br>", _curPost.RetweetedBy)
4609 sb.AppendFormat("RetweetedId : {0}<br>", _curPost.RetweetedId)
4610 sb.AppendFormat("SearchTabName : {0}<br>", _curPost.RelTabName)
4611 sb.Append("-----End PostClass Dump<br>")
4613 PostBrowser.Visible = False
4614 PostBrowser.DocumentText = detailHtmlFormatHeader + sb.ToString + detailHtmlFormatFooter
4615 PostBrowser.Visible = True
4618 If PostBrowser.DocumentText <> dTxt Then
4619 PostBrowser.Visible = False
4620 PostBrowser.DocumentText = dTxt
4621 Dim lnks As New List(Of String)
4622 For Each lnk As Match In Regex.Matches(dTxt, "<a target=""_self"" href=""(?<url>http[^""]+)""", RegexOptions.IgnoreCase)
4623 lnks.Add(lnk.Result("${url}"))
4625 Thumbnail.thumbnail(_curPost.Id, lnks)
4627 Catch ex As System.Runtime.InteropServices.COMException
4630 PostBrowser.Visible = True
4635 Private Sub MatomeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MatomeMenuItem.Click
4636 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
4639 Private Sub ShortcutKeyListMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShortcutKeyListMenuItem.Click
4640 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/%E3%82%B7%E3%83%A7%E3%83%BC%E3%83%88%E3%82%AB%E3%83%83%E3%83%88%E3%82%AD%E3%83%BC")
4643 Private Sub ListTab_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListTab.KeyDown
4644 If ListTab.SelectedTab IsNot Nothing Then
4645 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch Then
4646 Dim pnl As Control = ListTab.SelectedTab.Controls("panelSearch")
4647 If pnl.Controls("comboSearch").Focused OrElse _
4648 pnl.Controls("comboLang").Focused OrElse _
4649 pnl.Controls("buttonSearch").Focused Then Exit Sub
4653 If e.Modifiers = Keys.None Then
4654 ' ModifierKeyが押されていない場合
4655 If e.KeyCode = Keys.N OrElse e.KeyCode = Keys.Right Then
4657 e.SuppressKeyPress = True
4660 ElseIf e.KeyCode = Keys.P OrElse e.KeyCode = Keys.Left Then
4662 e.SuppressKeyPress = True
4665 ElseIf e.KeyCode = Keys.OemPeriod Then
4667 e.SuppressKeyPress = True
4672 If e.KeyCode = Keys.Space OrElse e.KeyCode = Keys.ProcessKey Then
4674 e.SuppressKeyPress = True
4675 JumpUnreadMenuItem_Click(Nothing, Nothing)
4676 ElseIf e.KeyCode = Keys.Enter OrElse e.KeyCode = Keys.Return Then
4678 e.SuppressKeyPress = True
4679 MakeReplyOrDirectStatus()
4680 ElseIf e.KeyCode = Keys.L Then
4682 e.SuppressKeyPress = True
4684 ElseIf e.KeyCode = Keys.H Then
4686 e.SuppressKeyPress = True
4688 ElseIf e.KeyCode = Keys.J AndAlso Not e.Alt Then
4690 e.SuppressKeyPress = True
4691 SendKeys.Send("{DOWN}")
4692 ElseIf e.KeyCode = Keys.K AndAlso Not e.Alt Then
4694 e.SuppressKeyPress = True
4695 SendKeys.Send("{UP}")
4697 If e.KeyCode = Keys.Z Or e.KeyCode = Keys.Oemcomma Then
4699 e.SuppressKeyPress = True
4701 ElseIf e.KeyCode = Keys.R OrElse e.KeyCode = Keys.F5 Then
4703 e.SuppressKeyPress = True
4705 ElseIf e.KeyCode = Keys.S Then
4707 e.SuppressKeyPress = True
4709 ElseIf e.KeyCode = Keys.A Then
4711 e.SuppressKeyPress = True
4714 'If e.KeyCode = Keys.OemQuestion Then
4716 ' e.SuppressKeyPress = True
4717 ' MenuItemSubSearch_Click(Nothing, Nothing) '/検索
4719 If e.KeyCode = Keys.F Then
4721 e.SuppressKeyPress = True
4722 SendKeys.Send("{PGDN}")
4724 If e.KeyCode = Keys.B Then
4726 e.SuppressKeyPress = True
4727 SendKeys.Send("{PGUP}")
4729 If e.KeyCode = Keys.I Then
4731 e.SuppressKeyPress = True
4732 SendKeys.Send("{TAB}")
4734 If e.KeyCode = Keys.G Then
4736 e.SuppressKeyPress = True
4737 ShowRelatedStatusesMenuItem_Click(Nothing, Nothing)
4739 ' ] in_reply_to参照元へ戻る
4740 If e.KeyCode = Keys.Oem4 Then
4742 e.SuppressKeyPress = True
4745 ' [ in_reply_toへジャンプ
4746 If e.KeyCode = Keys.Oem6 Then
4748 e.SuppressKeyPress = True
4749 GoBackInReplyToPost()
4751 If e.KeyCode = Keys.F1 Then
4753 e.SuppressKeyPress = True
4754 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
4755 ElseIf e.KeyCode = Keys.F3 Then
4757 e.SuppressKeyPress = True
4758 MenuItemSearchNext_Click(Nothing, Nothing)
4759 ElseIf e.KeyCode = Keys.F6 Then
4761 e.SuppressKeyPress = True
4762 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
4763 ElseIf e.KeyCode = Keys.F7 Then
4765 e.SuppressKeyPress = True
4766 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
4772 If e.Control AndAlso Not e.Alt AndAlso Not e.Shift Then
4774 If e.KeyCode = Keys.Home OrElse e.KeyCode = Keys.End Then
4777 If e.KeyCode = Keys.N Then
4779 e.SuppressKeyPress = True
4781 ElseIf e.KeyCode = Keys.P Then
4783 e.SuppressKeyPress = True
4785 ElseIf e.KeyCode = Keys.R Then
4787 e.SuppressKeyPress = True
4788 MakeReplyOrDirectStatus(False, True)
4789 ElseIf e.KeyCode = Keys.M Then
4791 e.SuppressKeyPress = True
4792 MakeReplyOrDirectStatus(False, False)
4793 ElseIf e.KeyCode = Keys.S Then
4795 e.SuppressKeyPress = True
4796 FavoriteChange(True)
4797 ElseIf e.KeyCode = Keys.I Then
4799 e.SuppressKeyPress = True
4800 doRepliedStatusOpen()
4801 ElseIf e.KeyCode = Keys.D Then
4803 e.SuppressKeyPress = True
4805 ElseIf e.KeyCode = Keys.Q Then
4807 e.SuppressKeyPress = True
4809 ElseIf e.KeyCode = Keys.B Then
4811 e.SuppressKeyPress = True
4812 ReadedStripMenuItem_Click(Nothing, Nothing)
4813 ElseIf e.KeyCode = Keys.T Then
4815 e.SuppressKeyPress = True
4816 HashManageMenuItem_Click(Nothing, Nothing)
4817 ElseIf e.KeyCode = Keys.L Then
4819 e.SuppressKeyPress = True
4820 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
4821 ElseIf e.KeyCode = Keys.Y Then
4823 e.SuppressKeyPress = True
4824 MultiLineMenuItem_Click(Nothing, Nothing)
4825 ElseIf e.KeyCode = Keys.F Then
4827 e.SuppressKeyPress = True
4828 MenuItemSubSearch_Click(Nothing, Nothing)
4829 ElseIf e.KeyCode = Keys.C Then
4830 Dim clstr As String = ""
4832 e.SuppressKeyPress = True
4834 ElseIf e.KeyCode = Keys.J AndAlso Not e.Alt Then
4836 e.SuppressKeyPress = True
4837 SendKeys.Send("{DOWN}")
4838 ElseIf e.KeyCode = Keys.K AndAlso Not e.Alt Then
4840 e.SuppressKeyPress = True
4841 SendKeys.Send("{UP}")
4846 Select Case e.KeyCode
4848 If _curList.SelectedIndices.Count > 0 Then
4849 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
4850 ElseIf _curList.SelectedIndices.Count = 0 Then
4851 OpenUriAsync("http://twitter.com/")
4854 If _curList.SelectedIndices.Count > 0 Then
4855 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
4858 StatusOpenMenuItem_Click(Nothing, Nothing)
4860 OpenURLMenuItem_Click(Nothing, Nothing)
4863 ' タブダイレクト選択(Ctrl+1~8,Ctrl+9)
4865 Select Case e.KeyCode
4866 Case Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8
4867 Dim tabNo As Integer = e.KeyCode - Keys.D1
4868 If ListTab.TabPages.Count < tabNo Then
4871 ListTab.SelectedIndex = tabNo
4872 ListTabSelect(ListTab.TabPages(tabNo))
4874 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
4875 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
4881 If Not e.Control AndAlso e.Alt AndAlso Not e.Shift Then
4883 ' 別タブの同じ書き込みへ(ALT+←/→)
4884 If e.KeyCode = Keys.Right Then
4886 e.SuppressKeyPress = True
4887 GoSamePostToAnotherTab(False)
4888 ElseIf e.KeyCode = Keys.Left Then
4890 e.SuppressKeyPress = True
4891 GoSamePostToAnotherTab(True)
4892 ElseIf e.KeyCode = Keys.R Then
4894 e.SuppressKeyPress = True
4895 doReTweetOfficial(True)
4896 ElseIf e.KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
4898 e.SuppressKeyPress = True
4899 doShowUserStatus(_curPost.Name, False)
4901 If e.KeyCode = Keys.Up Then
4902 ScrollDownPostBrowser(False)
4903 ElseIf e.KeyCode = Keys.Down Then
4904 ScrollDownPostBrowser(True)
4905 ElseIf e.KeyCode = Keys.PageUp Then
4906 PageDownPostBrowser(False)
4907 ElseIf e.KeyCode = Keys.PageDown Then
4908 PageDownPostBrowser(True)
4912 If e.Shift AndAlso Not e.Control AndAlso Not e.Alt Then
4914 If e.KeyCode = Keys.H Then
4916 e.SuppressKeyPress = True
4918 ElseIf e.KeyCode = Keys.L Then
4920 e.SuppressKeyPress = True
4922 ElseIf e.KeyCode = Keys.M Then
4924 e.SuppressKeyPress = True
4926 ElseIf e.KeyCode = Keys.G Then
4928 e.SuppressKeyPress = True
4930 ElseIf e.KeyCode = Keys.Z Then
4932 e.SuppressKeyPress = True
4934 ElseIf e.KeyCode = Keys.J AndAlso Not e.Alt Then
4936 e.SuppressKeyPress = True
4937 SendKeys.Send("{DOWN}")
4938 ElseIf e.KeyCode = Keys.K AndAlso Not e.Alt Then
4940 e.SuppressKeyPress = True
4941 SendKeys.Send("{UP}")
4944 ' お気に入り前後ジャンプ(SHIFT+N←/P→)
4945 If e.KeyCode = Keys.N OrElse e.KeyCode = Keys.Right Then
4947 e.SuppressKeyPress = True
4949 ElseIf e.KeyCode = Keys.P OrElse e.KeyCode = Keys.Left Then
4951 e.SuppressKeyPress = True
4953 ElseIf e.KeyCode = Keys.R OrElse e.KeyCode = Keys.F5 Then
4955 e.SuppressKeyPress = True
4958 If e.KeyCode = Keys.F3 Then
4960 e.SuppressKeyPress = True
4961 MenuItemSearchPrev_Click(Nothing, Nothing)
4962 ElseIf e.KeyCode = Keys.F6 Then
4964 e.SuppressKeyPress = True
4965 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
4966 ElseIf e.KeyCode = Keys.F7 Then
4968 e.SuppressKeyPress = True
4969 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
4973 If e.Control AndAlso Not e.Alt AndAlso e.Shift Then
4974 ' CTRL+SHIFTキーが押されている場合
4975 If e.KeyCode = Keys.R Then
4977 e.SuppressKeyPress = True
4978 MakeReplyOrDirectStatus(False, True, True)
4979 ElseIf e.KeyCode = Keys.C Then
4980 Dim clstr As String = ""
4982 e.SuppressKeyPress = True
4984 ElseIf e.KeyCode = Keys.F Then
4986 e.SuppressKeyPress = True
4987 If ListTab.SelectedTab IsNot Nothing Then
4988 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
4989 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
4991 ElseIf e.KeyCode = Keys.S Then
4993 e.SuppressKeyPress = True
4994 FavoriteChange(False)
4995 ElseIf e.KeyCode = Keys.B Then
4997 e.SuppressKeyPress = True
4998 UnreadStripMenuItem_Click(Nothing, Nothing)
5000 If e.KeyCode = Keys.T Then
5002 e.SuppressKeyPress = True
5003 HashToggleMenuItem_Click(Nothing, Nothing)
5004 ElseIf e.KeyCode = Keys.P Then
5006 e.SuppressKeyPress = True
5007 ImageSelectMenuItem_Click(Nothing, Nothing)
5008 ElseIf e.KeyCode = Keys.H Then
5010 e.SuppressKeyPress = True
5012 ElseIf e.KeyCode = Keys.O Then
5014 e.SuppressKeyPress = True
5015 FavorareMenuItem_Click(Nothing, Nothing)
5019 If Not e.Control AndAlso e.Alt AndAlso e.Shift Then
5020 ' ALT+SHIFTキーが押されている場合
5021 If e.KeyCode = Keys.R Then
5023 e.SuppressKeyPress = True
5024 doReTweetUnofficial()
5025 ElseIf e.KeyCode = Keys.C Then
5027 e.SuppressKeyPress = True
5029 ElseIf e.KeyCode = Keys.Up Then
5030 Thumbnail.ScrollThumbnail(False)
5031 ElseIf e.KeyCode = Keys.Down Then
5032 Thumbnail.ScrollThumbnail(True)
5034 If e.KeyCode = Keys.Enter Then
5035 If Not Me.SplitContainer3.Panel2Collapsed Then
5036 Thumbnail.OpenPicture()
5039 e.SuppressKeyPress = True
5043 If e.Alt AndAlso e.Control Then
5044 ' CTRL+ALTキーが押されている場合
5045 If e.KeyCode = Keys.S Then
5047 e.SuppressKeyPress = True
5048 FavoritesRetweetOriginal()
5049 ElseIf e.KeyCode = Keys.R Then
5051 e.SuppressKeyPress = True
5052 FavoritesRetweetUnofficial()
5058 Private Sub ScrollDownPostBrowser(ByVal forward As Boolean)
5059 Dim doc As HtmlDocument = PostBrowser.Document
5060 If doc Is Nothing Then Exit Sub
5061 If doc.Body Is Nothing Then Exit Sub
5064 doc.Body.ScrollTop += SettingDialog.FontDetail.Height
5066 doc.Body.ScrollTop -= SettingDialog.FontDetail.Height
5070 Private Sub PageDownPostBrowser(ByVal forward As Boolean)
5071 Dim doc As HtmlDocument = PostBrowser.Document
5072 If doc Is Nothing Then Exit Sub
5073 If doc.Body Is Nothing Then Exit Sub
5076 doc.Body.ScrollTop += PostBrowser.ClientRectangle.Height - SettingDialog.FontDetail.Height
5078 doc.Body.ScrollTop -= PostBrowser.ClientRectangle.Height - SettingDialog.FontDetail.Height
5082 Private Sub GoNextTab(ByVal forward As Boolean)
5083 Dim idx As Integer = ListTab.SelectedIndex
5086 If idx > ListTab.TabPages.Count - 1 Then idx = 0
5089 If idx < 0 Then idx = ListTab.TabPages.Count - 1
5091 ListTab.SelectedIndex = idx
5092 ListTabSelect(ListTab.TabPages(idx))
5095 Private Sub CopyStot()
5096 Dim clstr As String = ""
5097 Dim sb As New StringBuilder()
5098 Dim IsProtected As Boolean = False
5099 For Each idx As Integer In _curList.SelectedIndices
5100 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5101 If post.IsProtect Then
5105 If post.RetweetedId > 0 Then
5106 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.Name, post.Data, post.RetweetedId, Environment.NewLine)
5108 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.Name, post.Data, post.Id, Environment.NewLine)
5112 MessageBox.Show(My.Resources.CopyStotText1)
5114 If sb.Length > 0 Then
5115 clstr = sb.ToString()
5117 Clipboard.SetDataObject(clstr, False, 5, 100)
5118 Catch ex As Exception
5119 MessageBox.Show(ex.Message)
5122 ' Dim proc As New Action(Of String)(Sub(text)
5123 ' Me.Invoke(New Action(Of String)(AddressOf Clipboard.SetText), text)
5125 ' proc.BeginInvoke(clstr, Nothing, Nothing)
5126 'Catch ex As Exception
5127 ' MessageBox.Show(ex.Message)
5132 Private Sub CopyIdUri()
5133 Dim clstr As String = ""
5134 Dim sb As New StringBuilder()
5135 For Each idx As Integer In _curList.SelectedIndices
5136 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5137 If post.RetweetedId > 0 Then
5138 sb.AppendFormat("http://twitter.com/{0}/status/{1}{2}", post.Name, post.RetweetedId, Environment.NewLine)
5140 sb.AppendFormat("http://twitter.com/{0}/status/{1}{2}", post.Name, post.Id, Environment.NewLine)
5143 If sb.Length > 0 Then
5144 clstr = sb.ToString()
5146 Clipboard.SetDataObject(clstr, False, 5, 100)
5147 Catch ex As Exception
5148 MessageBox.Show(ex.Message)
5153 Private Sub GoFav(ByVal forward As Boolean)
5154 If _curList.VirtualListSize = 0 Then Exit Sub
5155 Dim fIdx As Integer = 0
5156 Dim toIdx As Integer = 0
5157 Dim stp As Integer = 1
5160 If _curList.SelectedIndices.Count = 0 Then
5163 fIdx = _curList.SelectedIndices(0) + 1
5164 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
5166 toIdx = _curList.VirtualListSize - 1
5169 If _curList.SelectedIndices.Count = 0 Then
5170 fIdx = _curList.VirtualListSize - 1
5172 fIdx = _curList.SelectedIndices(0) - 1
5173 If fIdx < 0 Then Exit Sub
5179 For idx As Integer = fIdx To toIdx Step stp
5180 If _statuses.Item(_curTab.Text, idx).IsFav Then
5181 SelectListItem(_curList, idx)
5182 _curList.EnsureVisible(idx)
5188 Private Sub GoSamePostToAnotherTab(ByVal left As Boolean)
5189 If _curList.VirtualListSize = 0 Then Exit Sub
5190 Dim fIdx As Integer = 0
5191 Dim toIdx As Integer = 0
5192 Dim stp As Integer = 1
5193 Dim targetId As Long = 0
5195 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then Exit Sub ' Directタブは対象外(見つかるはずがない)
5196 If _curList.SelectedIndices.Count = 0 Then Exit Sub '未選択も処理しない
5198 targetId = GetCurTabPost(_curList.SelectedIndices(0)).Id
5202 If ListTab.SelectedIndex = 0 Then
5205 fIdx = ListTab.SelectedIndex - 1
5211 If ListTab.SelectedIndex = ListTab.TabCount - 1 Then
5214 fIdx = ListTab.SelectedIndex + 1
5216 toIdx = ListTab.TabCount - 1
5220 Dim found As Boolean = False
5221 For tabidx As Integer = fIdx To toIdx Step stp
5222 If _statuses.Tabs(ListTab.TabPages(tabidx).Text).TabType = TabUsageType.DirectMessage Then Continue For ' Directタブは対象外
5223 For idx As Integer = 0 To DirectCast(ListTab.TabPages(tabidx).Tag, DetailsListView).VirtualListSize - 1
5224 If _statuses.Item(ListTab.TabPages(tabidx).Text, idx).Id = targetId Then
5225 ListTab.SelectedIndex = tabidx
5226 ListTabSelect(ListTab.TabPages(tabidx))
5227 SelectListItem(_curList, idx)
5228 _curList.EnsureVisible(idx)
5233 If found Then Exit For
5237 Private Sub GoPost(ByVal forward As Boolean)
5238 If _curList.SelectedIndices.Count = 0 OrElse _curPost Is Nothing Then Exit Sub
5239 Dim fIdx As Integer = 0
5240 Dim toIdx As Integer = 0
5241 Dim stp As Integer = 1
5244 fIdx = _curList.SelectedIndices(0) + 1
5245 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
5246 toIdx = _curList.VirtualListSize - 1
5249 fIdx = _curList.SelectedIndices(0) - 1
5250 If fIdx < 0 Then Exit Sub
5255 Dim name As String = ""
5256 If _curPost.RetweetedId = 0 Then
5257 name = _curPost.Name
5259 name = _curPost.RetweetedBy
5261 For idx As Integer = fIdx To toIdx Step stp
5262 If _statuses.Item(_curTab.Text, idx).RetweetedId = 0 Then
5263 If _statuses.Item(_curTab.Text, idx).Name = name Then
5264 SelectListItem(_curList, idx)
5265 _curList.EnsureVisible(idx)
5269 If _statuses.Item(_curTab.Text, idx).RetweetedBy = name Then
5270 SelectListItem(_curList, idx)
5271 _curList.EnsureVisible(idx)
5278 Private Sub GoRelPost(ByVal forward As Boolean)
5279 If _curList.SelectedIndices.Count = 0 Then Exit Sub
5281 Dim fIdx As Integer = 0
5282 Dim toIdx As Integer = 0
5283 Dim stp As Integer = 1
5285 fIdx = _curList.SelectedIndices(0) + 1
5286 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
5287 toIdx = _curList.VirtualListSize - 1
5290 fIdx = _curList.SelectedIndices(0) - 1
5291 If fIdx < 0 Then Exit Sub
5296 If Not _anchorFlag Then
5297 If _curPost Is Nothing Then Exit Sub
5298 _anchorPost = _curPost
5301 If _anchorPost Is Nothing Then Exit Sub
5304 For idx As Integer = fIdx To toIdx Step stp
5305 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5306 If post.Name = _anchorPost.Name OrElse _
5307 post.RetweetedBy = _anchorPost.Name OrElse _
5308 post.Name = _anchorPost.RetweetedBy OrElse _
5309 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso post.RetweetedBy = _anchorPost.RetweetedBy) OrElse _
5310 _anchorPost.ReplyToList.Contains(post.Name.ToLower()) OrElse _
5311 _anchorPost.ReplyToList.Contains(post.RetweetedBy.ToLower()) OrElse _
5312 post.ReplyToList.Contains(_anchorPost.Name.ToLower()) OrElse _
5313 post.ReplyToList.Contains(_anchorPost.RetweetedBy.ToLower()) Then
5314 SelectListItem(_curList, idx)
5315 _curList.EnsureVisible(idx)
5321 Private Sub GoAnchor()
5322 If _anchorPost Is Nothing Then Exit Sub
5323 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_anchorPost.Id)
5324 If idx = -1 Then Exit Sub
5326 SelectListItem(_curList, idx)
5327 _curList.EnsureVisible(idx)
5330 Private Sub GoTopEnd(ByVal GoTop As Boolean)
5331 Dim _item As ListViewItem
5335 _item = _curList.GetItemAt(0, 25)
5336 If _item Is Nothing Then
5342 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
5343 If _item Is Nothing Then
5344 idx = _curList.VirtualListSize - 1
5349 SelectListItem(_curList, idx)
5352 Private Sub GoMiddle()
5353 Dim _item As ListViewItem
5358 _item = _curList.GetItemAt(0, 0)
5359 If _item Is Nothing Then
5364 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
5365 If _item Is Nothing Then
5366 idx2 = _curList.VirtualListSize - 1
5370 idx3 = (idx1 + idx2) \ 2
5372 SelectListItem(_curList, idx3)
5375 Private Sub GoLast()
5376 If _curList.VirtualListSize = 0 Then Exit Sub
5378 If _statuses.SortOrder = SortOrder.Ascending Then
5379 SelectListItem(_curList, _curList.VirtualListSize - 1)
5380 _curList.EnsureVisible(_curList.VirtualListSize - 1)
5382 SelectListItem(_curList, 0)
5383 _curList.EnsureVisible(0)
5387 Private Sub MoveTop()
5388 If _curList.SelectedIndices.Count = 0 Then Exit Sub
5389 Dim idx As Integer = _curList.SelectedIndices(0)
5390 If _statuses.SortOrder = SortOrder.Ascending Then
5391 _curList.EnsureVisible(_curList.VirtualListSize - 1)
5393 _curList.EnsureVisible(0)
5395 _curList.EnsureVisible(idx)
5398 Private Sub GoInReplyToPost()
5399 If _curPost IsNot Nothing AndAlso _curPost.InReplyToUser IsNot Nothing AndAlso _curPost.InReplyToId > 0 Then
5400 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.Lists Then
5401 If _statuses.Tabs(_curTab.Text).Posts.ContainsKey(_curPost.InReplyToId) Then
5402 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.InReplyToId)
5404 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
5405 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
5407 If replyChains Is Nothing OrElse (replyChains.Count > 0 AndAlso replyChains.Peek().InReplyToId <> _curPost.Id) Then
5408 replyChains = New Stack(Of ReplyChain)
5410 replyChains.Push(New ReplyChain(_curPost.Id, _curPost.InReplyToId, _curTab))
5411 SelectListItem(_curList, idx)
5412 _curList.EnsureVisible(idx)
5415 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/statuses/" + _curPost.InReplyToId.ToString())
5418 If _statuses.ContainsKey(_curPost.InReplyToId) Then
5419 Dim tab As TabPage = _curTab
5420 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.InReplyToId)
5422 For Each tab In ListTab.TabPages
5423 idx = _statuses.Tabs(tab.Text).IndexOf(_curPost.InReplyToId)
5430 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
5431 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
5433 If replyChains Is Nothing OrElse (replyChains.Count > 0 AndAlso replyChains.Peek().InReplyToId <> _curPost.Id) Then
5434 replyChains = New Stack(Of ReplyChain)
5436 replyChains.Push(New ReplyChain(_curPost.Id, _curPost.InReplyToId, _curTab))
5438 If tab IsNot _curTab Then
5439 ListTab.SelectTab(tab)
5441 SelectListItem(_curList, idx)
5442 _curList.EnsureVisible(idx)
5445 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/statuses/" + _curPost.InReplyToId.ToString())
5451 Private Sub GoBackInReplyToPost()
5452 If replyChains Is Nothing OrElse replyChains.Count < 1 Then
5456 Dim chainHead As ReplyChain = replyChains.Pop()
5457 If chainHead.InReplyToId = _curPost.Id Then
5458 Dim idx As Integer = _statuses.Tabs(chainHead.OriginalTab.Text).IndexOf(chainHead.OriginalId)
5460 replyChains = Nothing
5463 ListTab.SelectTab(chainHead.OriginalTab)
5464 Catch ex As Exception
5465 replyChains = Nothing
5467 SelectListItem(_curList, idx)
5468 _curList.EnsureVisible(idx)
5471 replyChains = Nothing
5475 Private Sub MyList_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
5479 Private Sub StatusText_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.Enter
5480 ' フォーカスの戻り先を StatusText に設定
5482 StatusText.BackColor = _clInputBackcolor
5485 Public Property InputBackColor() As System.Drawing.Color
5487 Return _clInputBackcolor
5489 Set(ByVal value As System.Drawing.Color)
5490 _clInputBackcolor = value
5494 Private Sub StatusText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.Leave
5495 ' フォーカスがメニューに遷移しないならばフォーカスはタブに移ることを期待
5496 If ListTab.SelectedTab IsNot Nothing AndAlso MenuStrip1.Tag Is Nothing Then Me.Tag = ListTab.SelectedTab.Tag
5497 StatusText.BackColor = Color.FromKnownColor(KnownColor.Window)
5500 Private Sub StatusText_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StatusText.KeyDown
5502 If e.Modifiers = Keys.None Then
5503 If e.KeyCode = Keys.F1 Then
5505 e.SuppressKeyPress = True
5506 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
5507 ElseIf e.KeyCode = Keys.F3 Then
5509 e.SuppressKeyPress = True
5510 MenuItemSearchNext_Click(Nothing, Nothing)
5511 ElseIf e.KeyCode = Keys.F5 Then
5513 e.SuppressKeyPress = True
5515 ElseIf e.KeyCode = Keys.F6 Then
5517 e.SuppressKeyPress = True
5518 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
5519 ElseIf e.KeyCode = Keys.F7 Then
5521 e.SuppressKeyPress = True
5522 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
5527 If e.Control AndAlso Not e.Alt AndAlso Not e.Shift Then
5528 If e.KeyCode = Keys.A Then
5529 StatusText.SelectAll()
5530 ElseIf e.KeyCode = Keys.Up OrElse e.KeyCode = Keys.Down Then
5531 If StatusText.Text.Trim() <> "" Then
5532 _history(_hisIdx) = New PostingStatus(StatusText.Text, _reply_to_id, _reply_to_name)
5534 If e.KeyCode = Keys.Up Then
5536 If _hisIdx < 0 Then _hisIdx = 0
5539 If _hisIdx > _history.Count - 1 Then _hisIdx = _history.Count - 1
5541 StatusText.Text = _history(_hisIdx).status
5542 _reply_to_id = _history(_hisIdx).inReplyToId
5543 _reply_to_name = _history(_hisIdx).inReplyToName
5544 StatusText.SelectionStart = StatusText.Text.Length
5546 e.SuppressKeyPress = True
5547 ElseIf e.KeyCode = Keys.PageUp OrElse e.KeyCode = Keys.P Then
5548 If ListTab.SelectedIndex = 0 Then
5549 ListTab.SelectedIndex = ListTab.TabCount - 1
5551 ListTab.SelectedIndex -= 1
5554 e.SuppressKeyPress = True
5556 ElseIf e.KeyCode = Keys.PageDown OrElse e.KeyCode = Keys.N Then
5557 If ListTab.SelectedIndex = ListTab.TabCount - 1 Then
5558 ListTab.SelectedIndex = 0
5560 ListTab.SelectedIndex += 1
5563 e.SuppressKeyPress = True
5565 ElseIf e.KeyCode = Keys.R Then
5567 e.SuppressKeyPress = True
5568 MakeReplyOrDirectStatus(False, True)
5569 ElseIf e.KeyCode = Keys.M Then
5571 e.SuppressKeyPress = True
5572 MakeReplyOrDirectStatus(False, False)
5573 ElseIf e.KeyCode = Keys.S Then
5575 e.SuppressKeyPress = True
5576 FavoriteChange(True)
5577 ElseIf e.KeyCode = Keys.I Then
5579 e.SuppressKeyPress = True
5580 doRepliedStatusOpen()
5581 ElseIf e.KeyCode = Keys.Q Then
5583 e.SuppressKeyPress = True
5585 ElseIf e.KeyCode = Keys.B Then
5587 e.SuppressKeyPress = True
5588 ReadedStripMenuItem_Click(Nothing, Nothing)
5589 ElseIf e.KeyCode = Keys.T Then
5591 e.SuppressKeyPress = True
5592 HashManageMenuItem_Click(Nothing, Nothing)
5593 ElseIf e.KeyCode = Keys.L Then
5595 e.SuppressKeyPress = True
5596 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
5597 ElseIf e.KeyCode = Keys.Y Then
5599 e.SuppressKeyPress = True
5600 MultiLineMenuItem_Click(Nothing, Nothing)
5601 ElseIf e.KeyCode = Keys.F Then
5603 e.SuppressKeyPress = True
5604 MenuItemSubSearch_Click(Nothing, Nothing)
5607 Select Case e.KeyCode
5609 If _curList.SelectedIndices.Count > 0 Then
5610 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
5611 ElseIf _curList.SelectedIndices.Count = 0 Then
5612 OpenUriAsync("http://twitter.com/")
5615 If _curList.SelectedIndices.Count > 0 Then
5616 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
5619 OpenURLMenuItem_Click(Nothing, Nothing)
5621 StatusOpenMenuItem_Click(Nothing, Nothing)
5627 If e.KeyCode = Keys.F3 Then
5629 e.SuppressKeyPress = True
5630 MenuItemSearchPrev_Click(Nothing, Nothing)
5631 ElseIf e.KeyCode = Keys.F5 Then
5633 e.SuppressKeyPress = True
5635 ElseIf e.KeyCode = Keys.F6 Then
5637 e.SuppressKeyPress = True
5638 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
5639 ElseIf e.KeyCode = Keys.F7 Then
5641 e.SuppressKeyPress = True
5642 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
5647 If e.Alt AndAlso Not e.Control AndAlso e.Shift Then
5648 If e.KeyCode = Keys.R Then
5650 e.SuppressKeyPress = True
5651 doReTweetOfficial(True)
5652 ElseIf e.KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
5654 e.SuppressKeyPress = True
5655 doShowUserStatus(_curPost.Name, False)
5657 If e.KeyCode = Keys.Up Then
5658 ScrollDownPostBrowser(False)
5659 ElseIf e.KeyCode = Keys.Down Then
5660 ScrollDownPostBrowser(True)
5661 ElseIf e.KeyCode = Keys.PageUp Then
5662 PageDownPostBrowser(False)
5663 ElseIf e.KeyCode = Keys.PageDown Then
5664 PageDownPostBrowser(True)
5668 If e.KeyCode = Keys.Space AndAlso e.Modifiers = (Keys.Shift Or Keys.Control) Then
5669 If StatusText.SelectionStart > 0 Then
5670 Dim endidx As Integer = StatusText.SelectionStart - 1
5671 Dim startstr As String = ""
5672 For i As Integer = StatusText.SelectionStart - 1 To 0 Step -1
5673 Dim c As Char = StatusText.Text.Chars(i)
5674 If Char.IsLetterOrDigit(c) OrElse c = "_" Then
5678 startstr = StatusText.Text.Substring(i + 1, endidx - i)
5679 ShowSuplDialog(StatusText, AtIdSupl, startstr.Length + 1, startstr)
5681 startstr = StatusText.Text.Substring(i + 1, endidx - i)
5682 ShowSuplDialog(StatusText, HashSupl, startstr.Length + 1, startstr)
5692 If e.Shift AndAlso e.Control Then
5693 If e.KeyCode = Keys.Up Then
5695 e.SuppressKeyPress = True
5696 Dim idx As Integer = 0
5697 If _curList IsNot Nothing AndAlso _curList.Items.Count <> 0 AndAlso _
5698 _curList.SelectedIndices.Count > 0 AndAlso _curList.SelectedIndices(0) > 0 Then
5699 idx = _curList.SelectedIndices(0) - 1
5700 SelectListItem(_curList, idx)
5701 _curList.EnsureVisible(idx)
5703 ElseIf e.KeyCode = Keys.Down Then
5705 e.SuppressKeyPress = True
5706 Dim idx As Integer = 0
5707 If _curList IsNot Nothing AndAlso _curList.Items.Count <> 0 AndAlso _curList.SelectedIndices.Count > 0 _
5708 AndAlso _curList.SelectedIndices(0) < _curList.Items.Count - 1 Then
5709 idx = _curList.SelectedIndices(0) + 1
5710 SelectListItem(_curList, idx)
5711 _curList.EnsureVisible(idx)
5714 If e.KeyCode = Keys.R Then
5716 e.SuppressKeyPress = True
5717 MakeReplyOrDirectStatus(False, True, True)
5718 ElseIf e.KeyCode = Keys.H Then
5720 e.SuppressKeyPress = True
5722 ElseIf e.KeyCode = Keys.T Then
5724 e.SuppressKeyPress = True
5725 HashToggleMenuItem_Click(Nothing, Nothing)
5726 ElseIf e.KeyCode = Keys.S Then
5728 e.SuppressKeyPress = True
5729 FavoriteChange(False)
5730 ElseIf e.KeyCode = Keys.B Then
5732 e.SuppressKeyPress = True
5733 UnreadStripMenuItem_Click(Nothing, Nothing)
5734 ElseIf e.KeyCode = Keys.G Then
5736 e.SuppressKeyPress = True
5737 FavorareMenuItem_Click(Nothing, Nothing)
5738 ElseIf e.KeyCode = Keys.C Then
5739 Dim clstr As String = ""
5741 e.SuppressKeyPress = True
5743 ElseIf e.KeyCode = Keys.O Then
5745 e.SuppressKeyPress = True
5746 FavorareMenuItem_Click(Nothing, Nothing)
5747 ElseIf e.KeyCode = Keys.P Then
5749 e.SuppressKeyPress = True
5750 ImageSelectMenuItem_Click(Nothing, Nothing)
5751 ElseIf e.KeyCode = Keys.F Then
5753 e.SuppressKeyPress = True
5754 If ListTab.SelectedTab IsNot Nothing Then
5755 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
5756 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
5762 If e.Alt AndAlso e.Shift Then
5763 If e.KeyCode = Keys.R Then
5765 e.SuppressKeyPress = True
5766 doReTweetUnofficial()
5767 ElseIf e.KeyCode = Keys.C Then
5769 e.SuppressKeyPress = True
5771 ElseIf e.KeyCode = Keys.Up Then
5772 Thumbnail.ScrollThumbnail(False)
5773 ElseIf e.KeyCode = Keys.Down Then
5774 Thumbnail.ScrollThumbnail(True)
5779 If e.Alt AndAlso e.Control Then
5780 If e.KeyCode = Keys.S Then
5782 e.SuppressKeyPress = True
5783 FavoritesRetweetOriginal()
5784 ElseIf e.KeyCode = Keys.R Then
5786 e.SuppressKeyPress = True
5787 FavoritesRetweetUnofficial()
5791 Me.StatusText_TextChanged(Nothing, Nothing)
5794 Private Sub SaveConfigsAll(ByVal ifModified As Boolean)
5795 If Not ifModified Then
5798 'SaveConfigsTab(True) 'True:事前に設定ファイル削除
5801 If _modifySettingCommon Then SaveConfigsCommon()
5802 If _modifySettingLocal Then SaveConfigsLocal()
5803 If _modifySettingAtId AndAlso SettingDialog.UseAtIdSupplement AndAlso AtIdSupl IsNot Nothing Then
5804 _modifySettingAtId = False
5805 Dim cfgAtId As New SettingAtIdList(AtIdSupl.GetItemList)
5811 Private Sub SaveConfigsCommon()
5812 If _ignoreConfigSave Then Exit Sub
5814 _modifySettingCommon = False
5815 SyncLock _syncObject
5816 _cfgCommon.UserName = tw.Username
5817 _cfgCommon.Password = tw.Password
5818 _cfgCommon.IsOAuth = SettingDialog.IsOAuth
5819 _cfgCommon.Token = tw.AccessToken
5820 _cfgCommon.TokenSecret = tw.AccessTokenSecret
5821 _cfgCommon.UserstreamStartup = SettingDialog.UserstreamStartup
5822 _cfgCommon.UserstreamPeriod = SettingDialog.UserstreamPeriodInt
5823 _cfgCommon.TimelinePeriod = SettingDialog.TimelinePeriodInt
5824 _cfgCommon.ReplyPeriod = SettingDialog.ReplyPeriodInt
5825 _cfgCommon.DMPeriod = SettingDialog.DMPeriodInt
5826 _cfgCommon.PubSearchPeriod = SettingDialog.PubSearchPeriodInt
5827 _cfgCommon.ListsPeriod = SettingDialog.ListsPeriodInt
5828 _cfgCommon.Read = SettingDialog.Readed
5829 _cfgCommon.IconSize = SettingDialog.IconSz
5830 _cfgCommon.UnreadManage = SettingDialog.UnreadManage
5831 _cfgCommon.PlaySound = SettingDialog.PlaySound
5832 _cfgCommon.OneWayLove = SettingDialog.OneWayLove
5834 _cfgCommon.NameBalloon = SettingDialog.NameBalloon
5835 _cfgCommon.PostCtrlEnter = SettingDialog.PostCtrlEnter
5836 _cfgCommon.PostShiftEnter = SettingDialog.PostShiftEnter
5837 _cfgCommon.CountApi = SettingDialog.CountApi
5838 _cfgCommon.CountApiReply = SettingDialog.CountApiReply
5839 '_cfgCommon.CheckReply = SettingDialog.CheckReply
5840 _cfgCommon.PostAndGet = SettingDialog.PostAndGet
5841 _cfgCommon.DispUsername = SettingDialog.DispUsername
5842 _cfgCommon.MinimizeToTray = SettingDialog.MinimizeToTray
5843 _cfgCommon.CloseToExit = SettingDialog.CloseToExit
5844 _cfgCommon.DispLatestPost = SettingDialog.DispLatestPost
5845 _cfgCommon.SortOrderLock = SettingDialog.SortOrderLock
5846 _cfgCommon.TinyUrlResolve = SettingDialog.TinyUrlResolve
5847 _cfgCommon.PeriodAdjust = SettingDialog.PeriodAdjust
5848 _cfgCommon.StartupVersion = SettingDialog.StartupVersion
5849 _cfgCommon.StartupFollowers = SettingDialog.StartupFollowers
5850 _cfgCommon.RestrictFavCheck = SettingDialog.RestrictFavCheck
5851 _cfgCommon.AlwaysTop = SettingDialog.AlwaysTop
5852 _cfgCommon.UrlConvertAuto = SettingDialog.UrlConvertAuto
5853 _cfgCommon.Outputz = SettingDialog.OutputzEnabled
5854 _cfgCommon.OutputzKey = SettingDialog.OutputzKey
5855 _cfgCommon.OutputzUrlMode = SettingDialog.OutputzUrlmode
5856 _cfgCommon.UseUnreadStyle = SettingDialog.UseUnreadStyle
5857 _cfgCommon.DateTimeFormat = SettingDialog.DateTimeFormat
5858 _cfgCommon.DefaultTimeOut = SettingDialog.DefaultTimeOut
5859 '_cfgCommon.ProtectNotInclude = SettingDialog.ProtectNotInclude
5860 _cfgCommon.RetweetNoConfirm = SettingDialog.RetweetNoConfirm
5861 _cfgCommon.LimitBalloon = SettingDialog.LimitBalloon
5862 _cfgCommon.AutoShortUrlFirst = SettingDialog.AutoShortUrlFirst
5863 _cfgCommon.TabIconDisp = SettingDialog.TabIconDisp
5864 _cfgCommon.ReplyIconState = SettingDialog.ReplyIconState
5865 _cfgCommon.ReadOwnPost = SettingDialog.ReadOwnPost
5866 _cfgCommon.GetFav = SettingDialog.GetFav
5867 _cfgCommon.IsMonospace = SettingDialog.IsMonospace
5868 If IdeographicSpaceToSpaceToolStripMenuItem IsNot Nothing AndAlso _
5869 IdeographicSpaceToSpaceToolStripMenuItem.IsDisposed = False Then
5870 _cfgCommon.WideSpaceConvert = Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked
5872 _cfgCommon.ReadOldPosts = SettingDialog.ReadOldPosts
5873 _cfgCommon.UseSsl = SettingDialog.UseSsl
5874 _cfgCommon.BilyUser = SettingDialog.BitlyUser
5875 _cfgCommon.BitlyPwd = SettingDialog.BitlyPwd
5876 _cfgCommon.ShowGrid = SettingDialog.ShowGrid
5877 _cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement
5878 _cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement
5879 _cfgCommon.PreviewEnable = SettingDialog.PreviewEnable
5880 _cfgCommon.Language = SettingDialog.Language
5882 _cfgCommon.SortOrder = _statuses.SortOrder
5883 Select Case _statuses.SortMode
5884 Case IdComparerClass.ComparerMode.Nickname 'ニックネーム
5885 _cfgCommon.SortColumn = 1
5886 Case IdComparerClass.ComparerMode.Data '本文
5887 _cfgCommon.SortColumn = 2
5888 Case IdComparerClass.ComparerMode.Id '時刻=発言Id
5889 _cfgCommon.SortColumn = 3
5890 Case IdComparerClass.ComparerMode.Name '名前
5891 _cfgCommon.SortColumn = 4
5892 Case IdComparerClass.ComparerMode.Source 'Source
5893 _cfgCommon.SortColumn = 7
5896 _cfgCommon.Nicoms = SettingDialog.Nicoms
5897 _cfgCommon.HashTags = HashMgr.HashHistories
5898 If HashMgr.IsPermanent Then
5899 _cfgCommon.HashSelected = HashMgr.UseHash
5901 _cfgCommon.HashSelected = ""
5903 _cfgCommon.HashIsHead = HashMgr.IsHead
5904 _cfgCommon.HashIsPermanent = HashMgr.IsPermanent
5905 _cfgCommon.TwitterUrl = SettingDialog.TwitterApiUrl
5906 _cfgCommon.TwitterSearchUrl = SettingDialog.TwitterSearchApiUrl
5907 _cfgCommon.HotkeyEnabled = SettingDialog.HotkeyEnabled
5908 _cfgCommon.HotkeyModifier = SettingDialog.HotkeyMod
5909 _cfgCommon.HotkeyKey = SettingDialog.HotkeyKey
5910 _cfgCommon.HotkeyValue = SettingDialog.HotkeyValue
5911 _cfgCommon.BlinkNewMentions = SettingDialog.BlinkNewMentions
5912 If ToolStripFocusLockMenuItem IsNot Nothing AndAlso _
5913 ToolStripFocusLockMenuItem.IsDisposed = False Then
5914 _cfgCommon.FocusLockToStatusText = Me.ToolStripFocusLockMenuItem.Checked
5916 _cfgCommon.UseAdditionalCount = SettingDialog.UseAdditionalCount
5917 _cfgCommon.MoreCountApi = SettingDialog.MoreCountApi
5918 _cfgCommon.FirstCountApi = SettingDialog.FirstCountApi
5919 _cfgCommon.SearchCountApi = SettingDialog.SearchCountApi
5920 _cfgCommon.FavoritesCountApi = SettingDialog.FavoritesCountApi
5921 _cfgCommon.TrackWord = tw.TrackWord
5922 _cfgCommon.AllAtReply = tw.AllAtReply
5928 Private Sub SaveConfigsLocal()
5929 If _ignoreConfigSave Then Exit Sub
5930 SyncLock _syncObject
5931 _modifySettingLocal = False
5932 _cfgLocal.FormSize = _mySize
5933 _cfgLocal.FormLocation = _myLoc
5934 _cfgLocal.SplitterDistance = _mySpDis
5935 _cfgLocal.PreviewDistance = _mySpDis3
5936 _cfgLocal.StatusMultiline = StatusText.Multiline
5937 _cfgLocal.StatusTextHeight = _mySpDis2
5938 _cfgLocal.StatusText = SettingDialog.Status
5940 _cfgLocal.FontUnread = _fntUnread
5941 _cfgLocal.ColorUnread = _clUnread
5942 _cfgLocal.FontRead = _fntReaded
5943 _cfgLocal.ColorRead = _clReaded
5944 _cfgLocal.FontDetail = _fntDetail
5945 _cfgLocal.ColorDetail = _clDetail
5946 _cfgLocal.ColorDetailBackcolor = _clDetailBackcolor
5947 _cfgLocal.ColorDetailLink = _clDetailLink
5948 _cfgLocal.ColorFav = _clFav
5949 _cfgLocal.ColorOWL = _clOWL
5950 _cfgLocal.ColorRetweet = _clRetweet
5951 _cfgLocal.ColorSelf = _clSelf
5952 _cfgLocal.ColorAtSelf = _clAtSelf
5953 _cfgLocal.ColorTarget = _clTarget
5954 _cfgLocal.ColorAtTarget = _clAtTarget
5955 _cfgLocal.ColorAtFromTarget = _clAtFromTarget
5956 _cfgLocal.ColorAtTo = _clAtTo
5957 _cfgLocal.ColorListBackcolor = _clListBackcolor
5958 _cfgLocal.ColorInputBackcolor = _clInputBackcolor
5959 _cfgLocal.ColorInputFont = _clInputFont
5960 _cfgLocal.FontInputFont = _fntInputFont
5962 _cfgLocal.BrowserPath = SettingDialog.BrowserPath
5963 _cfgLocal.UseRecommendStatus = SettingDialog.UseRecommendStatus
5964 _cfgLocal.ProxyType = SettingDialog.SelectedProxyType
5965 _cfgLocal.ProxyAddress = SettingDialog.ProxyAddress
5966 _cfgLocal.ProxyPort = SettingDialog.ProxyPort
5967 _cfgLocal.ProxyUser = SettingDialog.ProxyUser
5968 _cfgLocal.ProxyPassword = SettingDialog.ProxyPassword
5969 If _ignoreConfigSave Then Exit Sub
5974 Private Sub SaveConfigsTabs()
5975 Dim tabSetting As New SettingTabs
5976 For i As Integer = 0 To ListTab.TabPages.Count - 1
5977 If _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.Related Then tabSetting.Tabs.Add(_statuses.Tabs(ListTab.TabPages(i).Text))
5982 Private Sub SaveLogMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveLogMenuItem.Click, SaveFileMenuItem.Click
5983 Dim rslt As DialogResult = MessageBox.Show(String.Format(My.Resources.SaveLogMenuItem_ClickText1, Environment.NewLine), _
5984 My.Resources.SaveLogMenuItem_ClickText2, _
5985 MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
5986 If rslt = Windows.Forms.DialogResult.Cancel Then Exit Sub
5988 SaveFileDialog1.FileName = "TweenPosts" + Format(Now, "yyMMdd-HHmmss") + ".tsv"
5989 SaveFileDialog1.InitialDirectory = My.Application.Info.DirectoryPath
5990 SaveFileDialog1.Filter = My.Resources.SaveLogMenuItem_ClickText3
5991 SaveFileDialog1.FilterIndex = 0
5992 SaveFileDialog1.Title = My.Resources.SaveLogMenuItem_ClickText4
5993 SaveFileDialog1.RestoreDirectory = True
5995 If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
5996 If Not SaveFileDialog1.ValidateNames Then Exit Sub
5997 Using sw As StreamWriter = New StreamWriter(SaveFileDialog1.FileName, False, Encoding.UTF8)
5998 If rslt = Windows.Forms.DialogResult.Yes Then
6000 For idx As Integer = 0 To _curList.VirtualListSize - 1
6001 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
6002 Dim protect As String = ""
6003 If post.IsProtect Then protect = "Protect"
6004 sw.WriteLine(post.Nickname & vbTab & _
6005 """" & post.Data.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6006 post.PDate.ToString() & vbTab & _
6007 post.Name & vbTab & _
6008 post.Id.ToString() & vbTab & _
6009 post.ImageUrl & vbTab & _
6010 """" & post.OriginalData.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6014 For Each idx As Integer In _curList.SelectedIndices
6015 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
6016 Dim protect As String = ""
6017 If post.IsProtect Then protect = "Protect"
6018 sw.WriteLine(post.Nickname & vbTab & _
6019 """" & post.Data.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6020 post.PDate.ToString() & vbTab & _
6021 post.Name & vbTab & _
6022 post.Id.ToString() & vbTab & _
6023 post.ImageUrl & vbTab & _
6024 """" & post.OriginalData.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6032 Me.TopMost = SettingDialog.AlwaysTop
6035 Private Sub PostBrowser_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles PostBrowser.PreviewKeyDown
6037 If e.Modifiers = Keys.None Then
6038 Select Case e.KeyCode
6042 JumpUnreadMenuItem_Click(Nothing, Nothing)
6045 ShowRelatedStatusesMenuItem_Click(Nothing, Nothing)
6048 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
6051 MenuItemSearchNext_Click(Nothing, Nothing)
6058 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
6061 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
6068 If e.Modifiers = Keys.Shift Then
6069 Select Case e.KeyCode
6072 MenuItemSearchPrev_Click(Nothing, Nothing)
6079 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
6082 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
6088 If e.Modifiers = Keys.Control Then
6089 Select Case e.KeyCode
6092 PostBrowser.Document.ExecCommand("SelectAll", False, Nothing)
6093 Case Keys.C, Keys.Insert
6095 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
6096 If Not String.IsNullOrEmpty(_selText) Then
6098 Clipboard.SetDataObject(_selText, False, 5, 100)
6099 Catch ex As Exception
6100 MessageBox.Show(ex.Message)
6105 MakeReplyOrDirectStatus(False, True)
6108 MakeReplyOrDirectStatus(False, False)
6111 doReTweetOfficial(True)
6117 FavoriteChange(True)
6120 ReadedStripMenuItem_Click(Nothing, Nothing)
6123 MultiLineMenuItem.Checked = Not MultiLineMenuItem.Checked
6124 MultiLineMenuItem_Click(Nothing, Nothing)
6130 MenuItemSubSearch_Click(Nothing, Nothing)
6133 If _curList.SelectedIndices.Count > 0 Then
6134 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
6135 ElseIf _curList.SelectedIndices.Count = 0 Then
6136 OpenUriAsync("http://twitter.com/")
6140 If _curList.SelectedIndices.Count > 0 Then
6141 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
6145 MoveToFavToolStripMenuItem_Click(Nothing, Nothing)
6148 OpenURLMenuItem_Click(Nothing, Nothing)
6153 If e.Modifiers = Keys.Alt Then
6154 If e.KeyCode = Keys.R Then
6156 doReTweetOfficial(True)
6157 ElseIf e.KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
6159 doShowUserStatus(_curPost.Name, False)
6163 ' ControlKey + ShiftKey + 何か
6164 If e.Modifiers = (Keys.Control Or Keys.Shift) Then
6165 Select Case e.KeyCode
6168 MakeReplyOrDirectStatus(False, True, True)
6171 If ListTab.SelectedTab IsNot Nothing Then
6172 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
6173 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
6177 FavoriteChange(False)
6180 UnreadStripMenuItem_Click(Nothing, Nothing)
6183 HashToggleMenuItem_Click(Nothing, Nothing)
6186 ImageSelectMenuItem_Click(Nothing, Nothing)
6189 FavorareMenuItem_Click(Nothing, Nothing)
6198 'AltKey + ShiftKey + 何か
6199 If e.Modifiers = (Keys.Alt Or Keys.Shift) Then
6200 Select Case e.KeyCode
6202 e.IsInputKey = False
6203 doReTweetUnofficial()
6205 e.IsInputKey = False
6211 'CtrlKey + AltKey + 何か
6212 If e.Modifiers = (Keys.Control Or Keys.Alt) Then
6213 Select Case e.KeyCode
6216 FavoritesRetweetUnofficial()
6219 FavoritesRetweetOriginal()
6224 Public Function TabRename(ByRef tabName As String) As Boolean
6226 Dim newTabText As String = Nothing
6227 Using inputName As New InputTabName()
6228 inputName.TabName = tabName
6229 inputName.ShowDialog()
6230 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Return False
6231 newTabText = inputName.TabName
6234 Me.TopMost = SettingDialog.AlwaysTop
6235 If Not String.IsNullOrEmpty(newTabText) Then
6237 For i As Integer = 0 To ListTab.TabCount - 1
6238 If ListTab.TabPages(i).Text = newTabText Then
6239 Dim tmp As String = String.Format(My.Resources.Tabs_DoubleClickText1, newTabText)
6240 MessageBox.Show(tmp, My.Resources.Tabs_DoubleClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
6244 'タブ名のリスト作り直し(デフォルトタブ以外は再作成)
6245 For i As Integer = 0 To ListTab.TabCount - 1
6246 If _statuses.Tabs(ListTab.TabPages(i).Text).TabType = TabUsageType.Mentions OrElse _
6247 (Not _statuses.IsDefaultTab(ListTab.TabPages(i).Text) AndAlso _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.PublicSearch AndAlso _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.Lists AndAlso _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.Related) Then
6248 TabDialog.RemoveTab(ListTab.TabPages(i).Text)
6250 If ListTab.TabPages(i).Text = tabName Then
6251 ListTab.TabPages(i).Text = newTabText
6254 _statuses.RenameTab(tabName, newTabText)
6256 For i As Integer = 0 To ListTab.TabCount - 1
6257 If _statuses.Tabs(ListTab.TabPages(i).Text).TabType = TabUsageType.Mentions OrElse _
6258 (Not _statuses.IsDefaultTab(ListTab.TabPages(i).Text) AndAlso _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.PublicSearch AndAlso _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.Lists AndAlso _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.Related) Then
6259 If ListTab.TabPages(i).Text = tabName Then
6260 ListTab.TabPages(i).Text = newTabText
6262 TabDialog.AddTab(ListTab.TabPages(i).Text)
6267 _rclickTabName = newTabText
6268 tabName = newTabText
6275 Private Sub Tabs_DoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDoubleClick
6276 Dim tn As String = ListTab.SelectedTab.Text
6280 Private Sub Tabs_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDown
6281 Dim cpos As New Point(e.X, e.Y)
6282 If e.Button = Windows.Forms.MouseButtons.Left Then
6283 For i As Integer = 0 To ListTab.TabPages.Count - 1
6284 Dim rect As Rectangle = ListTab.GetTabRect(i)
6285 If rect.Left <= cpos.X AndAlso cpos.X <= rect.Right AndAlso _
6286 rect.Top <= cpos.Y AndAlso cpos.Y <= rect.Bottom Then
6296 Private Sub Tabs_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListTab.DragEnter
6297 If e.Data.GetDataPresent(GetType(TabPage)) Then
6298 e.Effect = DragDropEffects.Move
6300 e.Effect = DragDropEffects.None
6304 Private Sub Tabs_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListTab.DragDrop
6305 If Not e.Data.GetDataPresent(GetType(TabPage)) Then Exit Sub
6308 Dim tn As String = ""
6310 Dim cpos As New Point(e.X, e.Y)
6311 Dim spos As Point = ListTab.PointToClient(cpos)
6313 For i = 0 To ListTab.TabPages.Count - 1
6314 Dim rect As Rectangle = ListTab.GetTabRect(i)
6315 If rect.Left <= spos.X AndAlso spos.X <= rect.Right AndAlso _
6316 rect.Top <= spos.Y AndAlso spos.Y <= rect.Bottom Then
6317 tn = ListTab.TabPages(i).Text
6318 If spos.X <= (rect.Left + rect.Right) / 2 Then
6327 'タブのないところにドロップ->最後尾へ移動
6328 If String.IsNullOrEmpty(tn) Then
6329 tn = ListTab.TabPages(ListTab.TabPages.Count - 1).Text
6331 i = ListTab.TabPages.Count - 1
6334 Dim tp As TabPage = DirectCast(e.Data.GetData(GetType(TabPage)), TabPage)
6335 If tp.Text = tn Then Exit Sub
6337 ReOrderTab(tp.Text, tn, bef)
6340 Public Sub ReOrderTab(ByVal targetTabText As String, ByVal baseTabText As String, ByVal isBeforeBaseTab As Boolean)
6341 Dim baseIndex As Integer = 0
6342 For baseIndex = 0 To ListTab.TabPages.Count - 1
6343 If ListTab.TabPages(baseIndex).Text = baseTabText Then Exit For
6346 ListTab.SuspendLayout()
6348 Dim mTp As TabPage = Nothing
6349 For j As Integer = 0 To ListTab.TabPages.Count - 1
6350 If ListTab.TabPages(j).Text = targetTabText Then
6351 mTp = ListTab.TabPages(j)
6352 ListTab.TabPages.Remove(mTp)
6353 If j < baseIndex Then baseIndex -= 1
6357 If isBeforeBaseTab Then
6358 ListTab.TabPages.Insert(baseIndex, mTp)
6360 ListTab.TabPages.Insert(baseIndex + 1, mTp)
6363 ListTab.ResumeLayout()
6368 Private Sub MakeReplyOrDirectStatus(Optional ByVal isAuto As Boolean = True, Optional ByVal isReply As Boolean = True, Optional ByVal isAll As Boolean = False)
6369 'isAuto:True=先頭に挿入、False=カーソル位置に挿入
6370 'isReply:True=@,False=DM
6371 If Not StatusText.Enabled Then Exit Sub
6372 If _curList Is Nothing Then Exit Sub
6373 If _curTab Is Nothing Then Exit Sub
6374 If _curPost Is Nothing Then Exit Sub
6376 ' 複数あてリプライはReplyではなく通常ポスト
6377 '↑仕様変更で全部リプライ扱いでOK(先頭ドット付加しない)
6378 '090403暫定でドットを付加しないようにだけ修正。単独と複数の処理は統合できると思われる。
6379 '090513 all @ replies 廃止の仕様変更によりドット付加に戻し(syo68k)
6381 If _curList.SelectedIndices.Count > 0 Then
6383 If _curList.SelectedIndices.Count = 1 AndAlso Not isAll AndAlso _curPost IsNot Nothing Then
6385 If (_statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage AndAlso isAuto) OrElse (Not isAuto AndAlso Not isReply) Then
6387 StatusText.Text = "D " + _curPost.Name + " " + StatusText.Text
6388 StatusText.SelectionStart = StatusText.Text.Length
6394 If String.IsNullOrEmpty(StatusText.Text) Then
6397 ' ステータステキストが入力されていない場合先頭に@ユーザー名を追加する
6398 StatusText.Text = "@" + _curPost.Name + " "
6399 If _curPost.RetweetedId > 0 Then
6400 _reply_to_id = _curPost.RetweetedId
6402 _reply_to_id = _curPost.Id
6404 _reply_to_name = _curPost.Name
6409 '1件選んでEnter or DoubleClick
6410 If StatusText.Text.Contains("@" + _curPost.Name + " ") Then
6411 If _reply_to_id > 0 AndAlso _reply_to_name = _curPost.Name Then
6413 If _curPost.RetweetedId > 0 Then
6414 _reply_to_id = _curPost.RetweetedId
6416 _reply_to_id = _curPost.Id
6418 _reply_to_name = _curPost.Name
6422 If Not StatusText.Text.StartsWith("@") Then
6424 If StatusText.Text.StartsWith(". ") Then
6426 StatusText.Text = StatusText.Text.Insert(2, "@" + _curPost.Name + " ")
6431 StatusText.Text = "@" + _curPost.Name + " " + StatusText.Text
6432 If _curPost.RetweetedId > 0 Then
6433 _reply_to_id = _curPost.RetweetedId
6435 _reply_to_id = _curPost.Id
6437 _reply_to_name = _curPost.Name
6442 StatusText.Text = ". @" + _curPost.Name + " " + StatusText.Text
6443 'StatusText.Text = "@" + _curPost.Name + " " + StatusText.Text
6448 '1件選んでCtrl-Rの場合(返信先操作せず)
6449 Dim sidx As Integer = StatusText.SelectionStart
6450 Dim id As String = "@" + _curPost.Name + " "
6452 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6456 StatusText.Text = StatusText.Text.Insert(sidx, id)
6458 'If StatusText.Text.StartsWith("@") Then
6460 ' StatusText.Text = ". " + StatusText.Text.Insert(sidx, " @" + _curPost.Name + " ")
6461 ' sidx += 5 + _curPost.Name.Length
6464 ' StatusText.Text = StatusText.Text.Insert(sidx, " @" + _curPost.Name + " ")
6465 ' sidx += 3 + _curPost.Name.Length
6467 StatusText.SelectionStart = sidx
6470 '_reply_to_name = Nothing
6476 If Not isAuto AndAlso Not isReply Then Exit Sub
6478 'C-S-rか、複数の宛先を選択中にEnter/DoubleClick/C-r/C-S-r
6481 'Enter or DoubleClick
6483 Dim sTxt As String = StatusText.Text
6484 If Not sTxt.StartsWith(". ") Then
6489 For cnt As Integer = 0 To _curList.SelectedIndices.Count - 1
6490 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(cnt))
6491 If Not sTxt.Contains("@" + post.Name + " ") Then
6492 sTxt = sTxt.Insert(2, "@" + post.Name + " ")
6493 'sTxt = "@" + post.Name + " " + sTxt
6496 StatusText.Text = sTxt
6499 If _curList.SelectedIndices.Count > 1 Then
6502 Dim ids As String = ""
6503 Dim sidx As Integer = StatusText.SelectionStart
6504 For cnt As Integer = 0 To _curList.SelectedIndices.Count - 1
6505 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(cnt))
6506 If Not ids.Contains("@" + post.Name + " ") AndAlso _
6507 Not post.Name.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6508 ids += "@" + post.Name + " "
6511 For Each nm As String In post.ReplyToList
6512 If Not ids.Contains("@" + nm + " ") AndAlso _
6513 Not nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6514 Dim m As Match = Regex.Match(post.Data, "[@@](?<id>" + nm + ")([^a-zA-Z0-9]|$)", RegexOptions.IgnoreCase)
6516 ids += "@" + m.Result("${id}") + " "
6518 ids += "@" + nm + " "
6524 If ids.Length = 0 Then Exit Sub
6525 If Not StatusText.Text.StartsWith(". ") Then
6526 StatusText.Text = ". " + StatusText.Text
6532 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6536 StatusText.Text = StatusText.Text.Insert(sidx, ids)
6538 'If StatusText.Text.StartsWith("@") Then
6539 ' StatusText.Text = ". " + StatusText.Text.Insert(sidx, ids)
6540 ' sidx += 2 + ids.Length
6542 ' StatusText.Text = StatusText.Text.Insert(sidx, ids)
6543 ' sidx += 1 + ids.Length
6545 StatusText.SelectionStart = sidx
6549 '1件のみ選択のC-S-r(返信元付加する可能性あり)
6551 Dim ids As String = ""
6552 Dim sidx As Integer = StatusText.SelectionStart
6553 Dim post As PostClass = _curPost
6554 If Not ids.Contains("@" + post.Name + " ") AndAlso _
6555 Not post.Name.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6556 ids += "@" + post.Name + " "
6558 For Each nm As String In post.ReplyToList
6559 If Not ids.Contains("@" + nm + " ") AndAlso _
6560 Not nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6561 Dim m As Match = Regex.Match(post.Data, "[@@](?<id>" + nm + ")([^a-zA-Z0-9]|$)", RegexOptions.IgnoreCase)
6563 ids += "@" + m.Result("${id}") + " "
6565 ids += "@" + nm + " "
6569 If Not String.IsNullOrEmpty(post.RetweetedBy) Then
6570 If Not ids.Contains("@" + post.RetweetedBy + " ") AndAlso _
6571 Not post.RetweetedBy.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6572 ids += "@" + post.RetweetedBy + " "
6575 If ids.Length = 0 Then Exit Sub
6576 If String.IsNullOrEmpty(StatusText.Text) Then
6578 StatusText.Text = ids
6579 StatusText.SelectionStart = ids.Length
6581 If post.RetweetedId > 0 Then
6582 _reply_to_id = post.RetweetedId
6584 _reply_to_id = post.Id
6586 _reply_to_name = post.Name
6591 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6595 StatusText.Text = StatusText.Text.Insert(sidx, ids)
6597 StatusText.SelectionStart = sidx
6603 StatusText.SelectionStart = StatusText.Text.Length
6608 Private Sub ListTab_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseUp
6612 Private Sub TimerRefreshIcon_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerRefreshIcon.Tick
6614 If _colorize Then Colorize()
6615 If Not TimerRefreshIcon.Enabled Then Exit Sub
6616 Static iconCnt As Integer = 0
6617 Static blinkCnt As Integer = 0
6618 Static blink As Boolean = False
6619 Static idle As Boolean = False
6620 'Static usCheckCnt As Integer = 0
6622 Static iconDlListTopItem As ListViewItem = Nothing
6623 If DirectCast(ListTab.SelectedTab.Tag, ListView).TopItem Is iconDlListTopItem Then
6624 DirectCast(Me.TIconDic, ImageDictionary).PauseGetImage = False
6626 DirectCast(Me.TIconDic, ImageDictionary).PauseGetImage = True
6628 iconDlListTopItem = DirectCast(ListTab.SelectedTab.Tag, ListView).TopItem
6634 'If usCheckCnt > 300 Then '1min
6636 ' If Not Me.IsReceivedUserStream Then
6637 ' TraceOut("ReconnectUserStream")
6638 ' tw.ReconnectUserStream()
6642 Dim busy As Boolean = False
6643 For Each bw As BackgroundWorker In Me._bw
6644 If bw IsNot Nothing AndAlso bw.IsBusy Then
6653 If blinkCnt > 10 Then
6656 SaveConfigsAll(True)
6660 NotifyIcon1.Icon = NIconRefresh(iconCnt)
6662 _myStatusError = False
6666 Dim tb As TabClass = _statuses.GetTabByType(TabUsageType.Mentions)
6667 If SettingDialog.ReplyIconState <> REPLY_ICONSTATE.None AndAlso tb IsNot Nothing AndAlso tb.UnreadCount > 0 Then
6668 If blinkCnt > 0 Then Exit Sub
6670 If blink OrElse SettingDialog.ReplyIconState = REPLY_ICONSTATE.StaticIcon Then
6671 NotifyIcon1.Icon = ReplyIcon
6673 NotifyIcon1.Icon = ReplyIconBlink
6679 If idle Then Exit Sub
6683 If _myStatusError Then
6684 NotifyIcon1.Icon = NIconAtRed
6687 If _myStatusOnline Then
6688 NotifyIcon1.Icon = NIconAt
6690 NotifyIcon1.Icon = NIconAtSmoke
6694 Private Sub ContextMenuTabProperty_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuTabProperty.Opening
6695 '右クリックの場合はタブ名が設定済。アプリケーションキーの場合は現在のタブを対象とする
6696 If String.IsNullOrEmpty(_rclickTabName) OrElse sender IsNot ContextMenuTabProperty Then
6697 If ListTab IsNot Nothing AndAlso ListTab.SelectedTab IsNot Nothing Then
6698 _rclickTabName = ListTab.SelectedTab.Text
6704 If _statuses Is Nothing Then Exit Sub
6705 If _statuses.Tabs Is Nothing Then Exit Sub
6707 Dim tb As TabClass = _statuses.Tabs(_rclickTabName)
6708 If tb Is Nothing Then Exit Sub
6710 NotifyDispMenuItem.Checked = tb.Notify
6711 Me.NotifyTbMenuItem.Checked = tb.Notify
6713 soundfileListup = True
6714 SoundFileComboBox.Items.Clear()
6715 Me.SoundFileTbComboBox.Items.Clear()
6716 SoundFileComboBox.Items.Add("")
6717 Me.SoundFileTbComboBox.Items.Add("")
6718 Dim oDir As IO.DirectoryInfo = New IO.DirectoryInfo(My.Application.Info.DirectoryPath + IO.Path.DirectorySeparatorChar)
6719 If IO.Directory.Exists(IO.Path.Combine(My.Application.Info.DirectoryPath, "Sounds")) Then
6720 oDir = oDir.GetDirectories("Sounds")(0)
6722 For Each oFile As IO.FileInfo In oDir.GetFiles("*.wav")
6723 SoundFileComboBox.Items.Add(oFile.Name)
6724 Me.SoundFileTbComboBox.Items.Add(oFile.Name)
6726 Dim idx As Integer = SoundFileComboBox.Items.IndexOf(tb.SoundFile)
6727 If idx = -1 Then idx = 0
6728 SoundFileComboBox.SelectedIndex = idx
6729 Me.SoundFileTbComboBox.SelectedIndex = idx
6730 soundfileListup = False
6731 UreadManageMenuItem.Checked = tb.UnreadManage
6732 Me.UnreadMngTbMenuItem.Checked = tb.UnreadManage
6734 TabMenuControl(_rclickTabName)
6737 Private Sub TabMenuControl(ByVal tabName As String)
6738 If _statuses.Tabs(tabName).TabType <> TabUsageType.Mentions AndAlso _statuses.IsDefaultTab(tabName) Then
6739 FilterEditMenuItem.Enabled = True
6740 Me.EditRuleTbMenuItem.Enabled = True
6741 DeleteTabMenuItem.Enabled = False
6742 Me.DeleteTbMenuItem.Enabled = False
6743 ElseIf _statuses.Tabs(tabName).TabType = TabUsageType.Mentions Then
6744 FilterEditMenuItem.Enabled = True
6745 Me.EditRuleTbMenuItem.Enabled = True
6746 DeleteTabMenuItem.Enabled = False
6747 Me.DeleteTbMenuItem.Enabled = False
6749 FilterEditMenuItem.Enabled = True
6750 Me.EditRuleTbMenuItem.Enabled = True
6751 DeleteTabMenuItem.Enabled = True
6752 Me.DeleteTbMenuItem.Enabled = True
6756 Private Sub UreadManageMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UreadManageMenuItem.Click, UnreadMngTbMenuItem.Click
6757 UreadManageMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
6758 Me.UnreadMngTbMenuItem.Checked = UreadManageMenuItem.Checked
6760 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6761 ChangeTabUnreadManage(_rclickTabName, UreadManageMenuItem.Checked)
6766 Public Sub ChangeTabUnreadManage(ByVal tabName As String, ByVal isManage As Boolean)
6769 For idx = 0 To ListTab.TabCount
6770 If ListTab.TabPages(idx).Text = tabName Then Exit For
6773 _statuses.SetTabUnreadManage(tabName, isManage)
6774 If SettingDialog.TabIconDisp Then
6775 If _statuses.Tabs(tabName).UnreadCount > 0 Then
6776 ListTab.TabPages(idx).ImageIndex = 0
6778 ListTab.TabPages(idx).ImageIndex = -1
6782 If _curTab.Text = tabName Then
6783 _itemCache = Nothing
6784 _postCache = Nothing
6788 SetMainWindowTitle()
6790 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6793 Private Sub NotifyDispMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyDispMenuItem.Click, NotifyTbMenuItem.Click
6794 NotifyDispMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
6795 Me.NotifyTbMenuItem.Checked = NotifyDispMenuItem.Checked
6797 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6799 _statuses.Tabs(_rclickTabName).Notify = NotifyDispMenuItem.Checked
6804 Private Sub SoundFileComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SoundFileComboBox.SelectedIndexChanged, SoundFileTbComboBox.SelectedIndexChanged
6805 If soundfileListup OrElse _rclickTabName = "" Then Exit Sub
6807 _statuses.Tabs(_rclickTabName).SoundFile = DirectCast(DirectCast(sender, ToolStripComboBox).SelectedItem, String)
6812 Private Sub DeleteTabMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteTabMenuItem.Click, DeleteTbMenuItem.Click
6813 If String.IsNullOrEmpty(_rclickTabName) OrElse sender Is Me.DeleteTbMenuItem Then _rclickTabName = ListTab.SelectedTab.Text
6815 RemoveSpecifiedTab(_rclickTabName)
6819 Private Sub FilterEditMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilterEditMenuItem.Click, EditRuleTbMenuItem.Click
6821 If String.IsNullOrEmpty(_rclickTabName) Then _rclickTabName = _statuses.GetTabByType(TabUsageType.Home).TabName
6822 fDialog.SetCurrent(_rclickTabName)
6823 fDialog.ShowDialog()
6824 Me.TopMost = SettingDialog.AlwaysTop
6827 Me.Cursor = Cursors.WaitCursor
6828 _itemCache = Nothing
6829 _postCache = Nothing
6832 _statuses.FilterAll()
6833 For Each tb As TabPage In ListTab.TabPages
6834 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6835 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6836 If SettingDialog.TabIconDisp Then
6840 If SettingDialog.TabIconDisp Then
6845 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6847 Me.Cursor = Cursors.Default
6852 Private Sub AddTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabMenuItem.Click, CreateTbMenuItem.Click
6853 Dim tabName As String = Nothing
6854 Dim tabUsage As TabUsageType
6855 Using inputName As New InputTabName()
6856 inputName.TabName = _statuses.GetUniqueTabName
6857 inputName.IsShowUsage = True
6858 inputName.ShowDialog()
6859 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Exit Sub
6860 tabName = inputName.TabName
6861 tabUsage = inputName.Usage
6864 Me.TopMost = SettingDialog.AlwaysTop
6865 If Not String.IsNullOrEmpty(tabName) Then
6867 Dim list As ListElement = Nothing
6868 If tabUsage = TabUsageType.Lists Then
6869 Using listAvail As New ListAvailable
6870 If listAvail.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then Exit Sub
6871 If listAvail.SelectedList Is Nothing Then Exit Sub
6872 list = listAvail.SelectedList
6875 If Not AddNewTab(tabName, False, tabUsage) Then
6876 Dim tmp As String = String.Format(My.Resources.AddTabMenuItem_ClickText1, tabName)
6877 MessageBox.Show(tmp, My.Resources.AddTabMenuItem_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
6880 _statuses.AddTab(tabName, tabUsage, list)
6882 If tabUsage = TabUsageType.PublicSearch Then
6883 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
6884 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
6885 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
6887 If tabUsage = TabUsageType.Lists Then
6888 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
6889 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
6890 GetTimeline(WORKERTYPE.List, 1, 0, tabName)
6896 Private Sub TabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabMenuItem.Click, CreateTabRuleOpMenuItem.Click
6898 For Each idx As Integer In _curList.SelectedIndices
6899 Dim tabName As String = ""
6901 If Not SelectTab(tabName) Then Exit Sub
6903 fDialog.SetCurrent(tabName)
6904 If _statuses.Item(_curTab.Text, idx).RetweetedId = 0 Then
6905 fDialog.AddNewFilter(_statuses.Item(_curTab.Text, idx).Name, _statuses.Item(_curTab.Text, idx).Data)
6907 fDialog.AddNewFilter(_statuses.Item(_curTab.Text, idx).RetweetedBy, _statuses.Item(_curTab.Text, idx).Data)
6909 fDialog.ShowDialog()
6910 Me.TopMost = SettingDialog.AlwaysTop
6914 Me.Cursor = Cursors.WaitCursor
6915 _itemCache = Nothing
6916 _postCache = Nothing
6919 _statuses.FilterAll()
6920 For Each tb As TabPage In ListTab.TabPages
6921 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6922 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6923 If SettingDialog.TabIconDisp Then
6927 If SettingDialog.TabIconDisp Then
6932 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6934 Me.Cursor = Cursors.Default
6937 If Me.ListTab.SelectedTab IsNot Nothing AndAlso
6938 DirectCast(Me.ListTab.SelectedTab.Tag, DetailsListView).SelectedIndices.Count > 0 Then
6939 _curPost = _statuses.Item(Me.ListTab.SelectedTab.Text, DirectCast(Me.ListTab.SelectedTab.Tag, DetailsListView).SelectedIndices(0))
6943 Protected Overrides Function ProcessDialogKey( _
6944 ByVal keyData As Keys) As Boolean
6945 'TextBox1でEnterを押してもビープ音が鳴らないようにする
6946 If (keyData And Keys.KeyCode) = Keys.Enter Then
6947 If StatusText.Focused Then
6949 If StatusText.Multiline AndAlso _
6950 (Not SettingDialog.PostShiftEnter AndAlso (keyData And Keys.Shift) = Keys.Shift AndAlso _
6951 (keyData And Keys.Control) <> Keys.Control) OrElse _
6952 (SettingDialog.PostShiftEnter AndAlso (keyData And Keys.Control) = Keys.Control AndAlso _
6953 (keyData And Keys.Shift) <> Keys.Shift) Then
6954 Dim pos1 As Integer = StatusText.SelectionStart
6955 If StatusText.SelectionLength > 0 Then
6956 StatusText.Text = StatusText.Text.Remove(pos1, StatusText.SelectionLength) '選択状態文字列削除
6958 StatusText.Text = StatusText.Text.Insert(pos1, Environment.NewLine) '改行挿入
6959 StatusText.SelectionStart = pos1 + Environment.NewLine.Length 'カーソルを改行の次の文字へ移動
6963 If (Not StatusText.Multiline AndAlso _
6964 ((keyData And Keys.Control) = Keys.Control AndAlso SettingDialog.PostCtrlEnter) OrElse _
6965 ((keyData And Keys.Shift) = Keys.Shift AndAlso SettingDialog.PostShiftEnter) OrElse _
6966 (((keyData And Keys.Control) <> Keys.Control AndAlso Not SettingDialog.PostCtrlEnter) AndAlso _
6967 ((keyData And Keys.Shift) <> Keys.Shift AndAlso Not SettingDialog.PostShiftEnter))) OrElse _
6968 (StatusText.Multiline AndAlso _
6969 (Not SettingDialog.PostCtrlEnter AndAlso Not SettingDialog.PostShiftEnter AndAlso _
6970 ((keyData And Keys.Control) <> Keys.Control AndAlso (keyData And Keys.Shift) <> Keys.Shift) OrElse _
6971 ((keyData And Keys.Control) = Keys.Control AndAlso (keyData And Keys.Shift) = Keys.Shift)) OrElse _
6972 (SettingDialog.PostCtrlEnter AndAlso (keyData And Keys.Control) = Keys.Control) OrElse _
6973 (SettingDialog.PostShiftEnter AndAlso (keyData And Keys.Shift) = Keys.Shift)) Then
6974 PostButton_Click(Nothing, Nothing)
6977 ElseIf _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch AndAlso _
6978 (ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focused OrElse _
6979 ListTab.SelectedTab.Controls("panelSearch").Controls("comboLang").Focused) Then
6980 Me.SearchButton_Click(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), Nothing)
6985 Return MyBase.ProcessDialogKey(keyData)
6988 Private Sub ReplyAllStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReplyAllStripMenuItem.Click, ReplyAllOpMenuItem.Click
6989 MakeReplyOrDirectStatus(False, True, True)
6992 Private Sub IDRuleMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IDRuleMenuItem.Click, CreateIdRuleOpMenuItem.Click
6993 Dim tabName As String = ""
6996 If _curList.SelectedIndices.Count = 0 Then Exit Sub
6999 If Not SelectTab(tabName) Then Exit Sub
7001 Dim mv As Boolean = False
7002 Dim mk As Boolean = False
7005 Dim ids As New List(Of String)
7006 For Each idx As Integer In _curList.SelectedIndices
7007 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
7008 If Not ids.Contains(post.Name) Then
7009 Dim fc As New FiltersClass
7011 If post.RetweetedId = 0 Then
7012 fc.NameFilter = post.Name
7014 fc.NameFilter = post.RetweetedBy
7016 fc.SearchBoth = True
7020 fc.SearchUrl = False
7021 _statuses.Tabs(tabName).AddFilter(fc)
7024 If ids.Count <> 0 Then
7025 Dim atids As New List(Of String)
7026 For Each id As String In ids
7029 Dim cnt As Integer = AtIdSupl.ItemCount
7030 AtIdSupl.AddRangeItem(atids.ToArray)
7031 If AtIdSupl.ItemCount <> cnt Then _modifySettingAtId = True
7035 Me.Cursor = Cursors.WaitCursor
7036 _itemCache = Nothing
7037 _postCache = Nothing
7040 _statuses.FilterAll()
7041 For Each tb As TabPage In ListTab.TabPages
7042 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
7043 If _statuses.ContainsTab(tb.Text) Then
7044 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
7045 If SettingDialog.TabIconDisp Then
7049 If SettingDialog.TabIconDisp Then
7055 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
7057 Me.Cursor = Cursors.Default
7062 Private Function SelectTab(ByRef tabName As String) As Boolean
7065 If TabDialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
7066 Me.TopMost = SettingDialog.AlwaysTop
7069 Me.TopMost = SettingDialog.AlwaysTop
7070 tabName = TabDialog.SelectedTabName
7072 ListTab.SelectedTab.Focus()
7074 If tabName = My.Resources.IDRuleMenuItem_ClickText1 Then
7075 Using inputName As New InputTabName()
7076 inputName.TabName = _statuses.GetUniqueTabName
7077 inputName.ShowDialog()
7078 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Return False
7079 tabName = inputName.TabName
7082 Me.TopMost = SettingDialog.AlwaysTop
7083 If Not String.IsNullOrEmpty(tabName) Then
7084 If Not AddNewTab(tabName, False, TabUsageType.UserDefined) Then
7085 Dim tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText2, tabName)
7086 MessageBox.Show(tmp, My.Resources.IDRuleMenuItem_ClickText3, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
7089 _statuses.AddTab(tabName, TabUsageType.UserDefined, Nothing)
7101 Private Sub MoveOrCopy(ByRef move As Boolean, ByRef mark As Boolean)
7104 Dim _tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText4, Environment.NewLine)
7105 If MessageBox.Show(_tmp, My.Resources.IDRuleMenuItem_ClickText5, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
7113 Dim _tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText6, vbCrLf)
7114 If MessageBox.Show(_tmp, My.Resources.IDRuleMenuItem_ClickText7, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
7121 Private Sub CopySTOTMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopySTOTMenuItem.Click
7125 Private Sub CopyURLMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyURLMenuItem.Click
7129 Private Sub SelectAllMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllMenuItem.Click, SelAllOpMenuItem.Click
7130 If StatusText.Focused Then
7132 StatusText.SelectAll()
7135 For i As Integer = 0 To _curList.VirtualListSize - 1
7136 _curList.SelectedIndices.Add(i)
7141 Private Sub MoveMiddle()
7142 Dim _item As ListViewItem
7146 If _curList.SelectedIndices.Count = 0 Then Exit Sub
7148 Dim idx As Integer = _curList.SelectedIndices(0)
7150 _item = _curList.GetItemAt(0, 25)
7151 If _item Is Nothing Then
7156 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
7157 If _item Is Nothing Then
7158 idx2 = _curList.VirtualListSize - 1
7163 idx -= Math.Abs(idx1 - idx2) \ 2
7164 If idx < 0 Then idx = 0
7166 _curList.EnsureVisible(_curList.VirtualListSize - 1)
7167 _curList.EnsureVisible(idx)
7170 Private Sub OpenURLMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenURLMenuItem.Click, OpenUrlOpMenuItem.Click
7171 If PostBrowser.Document.Links.Count > 0 Then
7172 UrlDialog.ClearUrl()
7174 Dim openUrlStr As String = ""
7176 If PostBrowser.Document.Links.Count = 1 Then
7177 Dim urlStr As String = ""
7179 urlStr = IDNDecode(PostBrowser.Document.Links(0).GetAttribute("href"))
7180 Catch ex As ArgumentException
7184 If String.IsNullOrEmpty(urlStr) Then Exit Sub
7185 openUrlStr = urlEncodeMultibyteChar(urlStr)
7187 For Each linkElm As HtmlElement In PostBrowser.Document.Links
7188 Dim urlStr As String = ""
7189 Dim linkText As String = ""
7191 urlStr = IDNDecode(linkElm.GetAttribute("href"))
7192 linkText = linkElm.InnerText
7193 If Not linkText.StartsWith("http") AndAlso Not linkText.StartsWith("#") Then
7194 linkText = "@" + linkText
7196 Catch ex As ArgumentException
7200 If String.IsNullOrEmpty(urlStr) Then Continue For
7201 UrlDialog.AddUrl(New OpenUrlItem(linkText, urlEncodeMultibyteChar(urlStr)))
7204 If UrlDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
7205 openUrlStr = UrlDialog.SelectedUrl
7207 Catch ex As Exception
7210 Me.TopMost = SettingDialog.AlwaysTop
7212 If String.IsNullOrEmpty(openUrlStr) Then Exit Sub
7214 If openUrlStr.StartsWith("http://twitter.com/search?q=%23") OrElse _
7215 openUrlStr.StartsWith("https://twitter.com/search?q=%23") Then
7217 Dim urlStr As String = HttpUtility.UrlDecode(openUrlStr)
7218 Dim hash As String = urlStr.Substring(urlStr.IndexOf("#"))
7219 HashSupl.AddItem(hash)
7220 HashMgr.AddHashToHistory(hash.Trim, False)
7221 AddNewTabForSearch(hash)
7225 openUrlStr = openUrlStr.Replace("://twitter.com/search?q=#", "://twitter.com/search?q=%23")
7226 OpenUriAsync(openUrlStr)
7230 Private Sub ClearTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearTabMenuItem.Click, ClearTbMenuItem.Click
7231 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
7232 ClearTab(_rclickTabName, True)
7235 Private Sub ClearTab(ByVal tabName As String, ByVal showWarning As Boolean)
7237 Dim tmp As String = String.Format(My.Resources.ClearTabMenuItem_ClickText1, Environment.NewLine)
7238 If MessageBox.Show(tmp, tabName + " " + My.Resources.ClearTabMenuItem_ClickText2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
7243 _statuses.ClearTabIds(tabName)
7244 If ListTab.SelectedTab.Text = tabName Then
7245 _anchorPost = Nothing
7247 _itemCache = Nothing
7248 _postCache = Nothing
7249 _itemCacheIndex = -1
7253 For Each tb As TabPage In ListTab.TabPages
7254 If tb.Text = tabName Then
7256 DirectCast(tb.Tag, DetailsListView).VirtualListSize = 0
7260 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
7262 SetMainWindowTitle()
7266 Private Sub SetMainWindowTitle()
7268 Dim ttl As New StringBuilder(256)
7269 Dim ur As Integer = 0
7270 Dim al As Integer = 0
7271 Static myVer As String = fileVersion
7272 Static followers As Long = 0
7273 If SettingDialog.DispLatestPost <> DispTitleEnum.None AndAlso _
7274 SettingDialog.DispLatestPost <> DispTitleEnum.Post AndAlso _
7275 SettingDialog.DispLatestPost <> DispTitleEnum.Ver AndAlso _
7276 SettingDialog.DispLatestPost <> DispTitleEnum.OwnStatus Then
7277 For Each key As String In _statuses.Tabs.Keys
7278 ur += _statuses.Tabs(key).UnreadCount
7279 al += _statuses.Tabs(key).AllCount
7283 If SettingDialog.DispUsername Then ttl.Append(tw.Username).Append(" - ")
7284 ttl.Append("Tween ")
7285 Select Case SettingDialog.DispLatestPost
7286 Case DispTitleEnum.Ver
7287 ttl.Append("Ver:").Append(myVer)
7288 Case DispTitleEnum.Post
7289 If _history IsNot Nothing AndAlso _history.Count > 1 Then
7290 ttl.Append(_history(_history.Count - 2).status.Replace(vbCrLf, ""))
7292 Case DispTitleEnum.UnreadRepCount
7293 ttl.AppendFormat(My.Resources.SetMainWindowTitleText1, _statuses.GetTabByType(TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(TabUsageType.DirectMessage).UnreadCount)
7294 Case DispTitleEnum.UnreadAllCount
7295 ttl.AppendFormat(My.Resources.SetMainWindowTitleText2, ur)
7296 Case DispTitleEnum.UnreadAllRepCount
7297 ttl.AppendFormat(My.Resources.SetMainWindowTitleText3, ur, _statuses.GetTabByType(TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(TabUsageType.DirectMessage).UnreadCount)
7298 Case DispTitleEnum.UnreadCountAllCount
7299 ttl.AppendFormat(My.Resources.SetMainWindowTitleText4, ur, al)
7300 Case DispTitleEnum.OwnStatus
7301 If followers = 0 AndAlso tw.FollowersCount > 0 Then followers = tw.FollowersCount
7302 ttl.AppendFormat(My.Resources.OwnStatusTitle, tw.StatusesCount, tw.FriendsCount, tw.FollowersCount, tw.FollowersCount - followers)
7306 Me.Text = ttl.ToString()
7307 Catch ex As AccessViolationException
7308 '原因不明。ポスト内容に依存か?たまーに発生するが再現せず。
7312 Private Function GetStatusLabelText() As String
7314 'タブ未読数/タブ発言数 全未読数/総発言数 (未読@+未読DM数)
7315 If _statuses Is Nothing Then Return ""
7316 Dim tbRep As TabClass = _statuses.GetTabByType(TabUsageType.Mentions)
7317 Dim tbDm As TabClass = _statuses.GetTabByType(TabUsageType.DirectMessage)
7318 If tbRep Is Nothing OrElse tbDm Is Nothing Then Return ""
7319 Dim urat As Integer = tbRep.UnreadCount + tbDm.UnreadCount
7320 Dim ur As Integer = 0
7321 Dim al As Integer = 0
7322 Dim tur As Integer = 0
7323 Dim tal As Integer = 0
7324 Dim slbl As StringBuilder = New StringBuilder(256)
7326 For Each key As String In _statuses.Tabs.Keys
7327 ur += _statuses.Tabs(key).UnreadCount
7328 al += _statuses.Tabs(key).AllCount
7329 If key.Equals(_curTab.Text) Then
7330 tur = _statuses.Tabs(key).UnreadCount
7331 tal = _statuses.Tabs(key).AllCount
7334 Catch ex As Exception
7339 UnreadAtCounter = urat
7341 slbl.AppendFormat(My.Resources.SetStatusLabelText1, tur, tal, ur, al, urat, _postTimestamps.Count, _favTimestamps.Count, _tlCount)
7342 If SettingDialog.TimelinePeriodInt = 0 Then
7343 slbl.Append(My.Resources.SetStatusLabelText2)
7345 slbl.Append(SettingDialog.TimelinePeriodInt.ToString() + My.Resources.SetStatusLabelText3)
7347 Return slbl.ToString()
7350 Delegate Sub SetStatusLabelApiDelegate()
7352 Private Sub SetStatusLabelApiHandler(ByVal sender As Object, ByVal e As ApiInformationChangedEventArgs)
7353 If InvokeRequired Then
7354 Invoke(New SetStatusLabelApiDelegate(AddressOf SetStatusLabelApi))
7360 Private Sub SetStatusLabelApi()
7361 Me._apiGauge.RemainCount = TwitterApiInfo.RemainCount
7362 Me._apiGauge.MaxCount = TwitterApiInfo.MaxCount
7363 Me._apiGauge.ResetTime = TwitterApiInfo.ResetTime
7366 Private Sub SetStatusLabelUrl()
7367 StatusLabelUrl.Text = GetStatusLabelText()
7370 Public Sub SetStatusLabel(ByVal text As String)
7371 StatusLabel.Text = text
7374 Private Sub SetNotifyIconText()
7375 ' タスクトレイアイコンのツールチップテキスト書き換え
7377 Static ur As New StringBuilder(64)
7378 ur.Remove(0, ur.Length)
7379 If SettingDialog.DispUsername Then
7380 ur.Append(tw.Username)
7385 ur.Append("(Debug Build)")
7387 If UnreadCounter <> -1 AndAlso UnreadAtCounter <> -1 Then
7389 ur.Append(UnreadCounter)
7391 ur.Append(UnreadAtCounter)
7394 NotifyIcon1.Text = ur.ToString()
7397 Friend Sub CheckReplyTo(ByVal StatusText As String)
7398 Dim m As MatchCollection
7400 m = Regex.Matches(StatusText, "(^|[^a-zA-Z0-9_/])(#|#)(?<hash>[a-zA-Z0-9_]+)")
7401 Dim hstr As String = ""
7402 For Each hm As Match In m
7403 If Not IsNumeric(hm.Result("${hash}")) Then
7404 If Not hstr.Contains("#" + hm.Result("${hash}") + " ") Then
7405 hstr += "#" + hm.Result("${hash}") + " "
7406 HashSupl.AddItem("#" + hm.Result("${hash}"))
7410 If Not String.IsNullOrEmpty(HashMgr.UseHash) AndAlso Not hstr.Contains(HashMgr.UseHash + " ") Then
7411 hstr += HashMgr.UseHash
7413 If Not String.IsNullOrEmpty(hstr) Then HashMgr.AddHashToHistory(hstr.Trim, False)
7415 ' 本当にリプライ先指定すべきかどうかの判定
7416 m = Regex.Matches(StatusText, "(^|[ -/:-@[-^`{-~])(?<id>@[a-zA-Z0-9_]+)")
7418 If SettingDialog.UseAtIdSupplement Then
7419 Dim bCnt As Integer = AtIdSupl.ItemCount
7420 For Each mid As Match In m
7421 AtIdSupl.AddItem(mid.Result("${id}"))
7423 If bCnt <> AtIdSupl.ItemCount Then _modifySettingAtId = True
7426 ' リプライ先ステータスIDの指定がない場合は指定しない
7427 If _reply_to_id = 0 Then Exit Sub
7429 ' リプライ先ユーザー名がない場合も指定しない
7430 If String.IsNullOrEmpty(_reply_to_name) Then
7436 ' 次の条件を満たす場合に in_reply_to_status_id 指定
7437 ' 1. Twitterによりリンクと判定される @idが文中に1つ含まれる (2009/5/28 リンク化される@IDのみカウントするように修正)
7438 ' 2. リプライ先ステータスIDが設定されている(リストをダブルクリックで返信している)
7439 ' 3. 文中に含まれた@idがリプライ先のポスト者のIDと一致する
7441 If m IsNot Nothing Then
7442 If StatusText.StartsWith("@") Then
7443 If StatusText.StartsWith("@" + _reply_to_name) Then Exit Sub
7445 For Each mid As Match In m
7446 If StatusText.Contains("QT " + mid.Result("${id}") + ":") AndAlso mid.Result("${id}") = "@" + _reply_to_name Then Exit Sub
7456 Private Sub TweenMain_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
7457 If Not _initialLayout AndAlso SettingDialog.MinimizeToTray AndAlso WindowState = FormWindowState.Minimized Then
7460 If _initialLayout AndAlso _cfgLocal IsNot Nothing AndAlso Me.WindowState = FormWindowState.Normal AndAlso Me.Visible Then
7461 Me.ClientSize = _cfgLocal.FormSize
7462 '_mySize = Me.ClientSize 'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
7463 Me.DesktopLocation = _cfgLocal.FormLocation
7464 '_myLoc = Me.DesktopLocation '位置保持(最小化・最大化されたまま終了した場合の対応用)
7465 If _cfgLocal.SplitterDistance > Me.SplitContainer1.Panel1MinSize AndAlso _cfgLocal.SplitterDistance < Me.SplitContainer1.Height - Me.SplitContainer1.Panel2MinSize - Me.SplitContainer1.SplitterWidth Then
7466 Me.SplitContainer1.SplitterDistance = _cfgLocal.SplitterDistance 'Splitterの位置設定
7469 StatusText.Multiline = _cfgLocal.StatusMultiline
7470 If StatusText.Multiline Then
7471 Dim dis As Integer = SplitContainer2.Height - _cfgLocal.StatusTextHeight - SplitContainer2.SplitterWidth
7472 If dis > SplitContainer2.Panel1MinSize AndAlso dis < SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth Then
7473 SplitContainer2.SplitterDistance = SplitContainer2.Height - _cfgLocal.StatusTextHeight - SplitContainer2.SplitterWidth
7475 StatusText.Height = _cfgLocal.StatusTextHeight
7477 If SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth > 0 Then
7478 SplitContainer2.SplitterDistance = SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth
7481 If _cfgLocal.PreviewDistance > Me.SplitContainer3.Panel1MinSize AndAlso _cfgLocal.PreviewDistance < Me.SplitContainer3.Width - Me.SplitContainer3.Panel2MinSize - Me.SplitContainer3.SplitterWidth Then
7482 Me.SplitContainer3.SplitterDistance = _cfgLocal.PreviewDistance
7484 _initialLayout = False
7488 Private Sub PlaySoundMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlaySoundMenuItem.CheckedChanged, PlaySoundFileMenuItem.CheckStateChanged
7489 PlaySoundMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7490 Me.PlaySoundFileMenuItem.Checked = PlaySoundMenuItem.Checked
7491 If PlaySoundMenuItem.Checked Then
7492 SettingDialog.PlaySound = True
7494 SettingDialog.PlaySound = False
7496 _modifySettingCommon = True
7499 Private Sub SplitContainer1_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved
7500 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
7501 _mySpDis = SplitContainer1.SplitterDistance
7502 If StatusText.Multiline Then _mySpDis2 = StatusText.Height
7503 _modifySettingLocal = True
7507 Private Sub doRepliedStatusOpen()
7508 If _curPost IsNot Nothing AndAlso _curPost.InReplyToUser IsNot Nothing AndAlso _curPost.InReplyToId > 0 Then
7509 If My.Computer.Keyboard.ShiftKeyDown Then
7510 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/status/" + _curPost.InReplyToId.ToString())
7513 If _statuses.ContainsKey(_curPost.InReplyToId) Then
7514 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
7515 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
7517 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.Lists Or TabUsageType.PublicSearch)
7518 If tb Is Nothing OrElse Not tb.Contains(_curPost.InReplyToId) Then Exit For
7519 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
7520 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
7523 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/status/" + _curPost.InReplyToId.ToString())
7528 Private Sub RepliedStatusOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RepliedStatusOpenMenuItem.Click, OpenRepSourceOpMenuItem.Click
7529 doRepliedStatusOpen()
7532 Private Sub ContextMenuUserPicture_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuUserPicture.Opening
7533 '発言詳細のアイコン右クリック時のメニュー制御
7534 If _curList.SelectedIndices.Count > 0 AndAlso _curPost IsNot Nothing Then
7535 Dim name As String = _curPost.ImageUrl
7536 If name IsNot Nothing AndAlso name.Length > 0 Then
7537 Dim idx As Integer = name.LastIndexOf("/"c)
7539 name = IO.Path.GetFileNameWithoutExtension(name.Substring(idx))
7540 If name.EndsWith("_normal", StringComparison.OrdinalIgnoreCase) Then
7541 name = name.Substring(0, name.Length - 7) ' "_normal".Length
7542 Me.IconNameToolStripMenuItem.Text = name
7543 Me.IconNameToolStripMenuItem.Enabled = True
7545 Me.IconNameToolStripMenuItem.Enabled = False
7546 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7549 Me.IconNameToolStripMenuItem.Enabled = False
7550 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7552 If Me.TIconDic.ContainsKey(_curPost.ImageUrl) AndAlso Me.TIconDic(_curPost.ImageUrl) IsNot Nothing Then
7553 Me.SaveIconPictureToolStripMenuItem.Enabled = True
7555 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7558 Me.IconNameToolStripMenuItem.Enabled = False
7559 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7560 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7563 Me.IconNameToolStripMenuItem.Enabled = False
7564 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7565 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText2
7567 If NameLabel.Tag IsNot Nothing Then
7568 Dim id As String = DirectCast(NameLabel.Tag, String)
7569 If id = tw.Username Then
7570 FollowToolStripMenuItem.Enabled = False
7571 UnFollowToolStripMenuItem.Enabled = False
7572 ShowFriendShipToolStripMenuItem.Enabled = False
7573 ShowUserStatusToolStripMenuItem.Enabled = True
7574 SearchAtPostsDetailNameToolStripMenuItem.Enabled = False
7575 ListManageUserContextToolStripMenuItem3.Enabled = True
7577 FollowToolStripMenuItem.Enabled = True
7578 UnFollowToolStripMenuItem.Enabled = True
7579 ShowFriendShipToolStripMenuItem.Enabled = True
7580 ShowUserStatusToolStripMenuItem.Enabled = True
7581 SearchAtPostsDetailNameToolStripMenuItem.Enabled = True
7582 ListManageUserContextToolStripMenuItem3.Enabled = True
7585 FollowToolStripMenuItem.Enabled = False
7586 UnFollowToolStripMenuItem.Enabled = False
7587 ShowFriendShipToolStripMenuItem.Enabled = False
7588 ShowUserStatusToolStripMenuItem.Enabled = False
7589 SearchAtPostsDetailNameToolStripMenuItem.Enabled = False
7590 ListManageUserContextToolStripMenuItem3.Enabled = False
7594 Private Sub IconNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IconNameToolStripMenuItem.Click
7595 If _curPost Is Nothing Then Exit Sub
7596 Dim name As String = _curPost.ImageUrl
7597 OpenUriAsync(name.Remove(name.LastIndexOf("_normal"), 7)) ' "_normal".Length
7600 Private Sub SaveOriginalSizeIconPictureToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
7601 If _curPost Is Nothing Then Exit Sub
7602 Dim name As String = _curPost.ImageUrl
7603 name = IO.Path.GetFileNameWithoutExtension(name.Substring(name.LastIndexOf("/"c)))
7605 Me.SaveFileDialog1.FileName = name.Substring(0, name.Length - 8) ' "_normal".Length + 1
7607 If Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
7612 Private Sub SaveIconPictureToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveIconPictureToolStripMenuItem.Click
7613 If _curPost Is Nothing Then Exit Sub
7614 Dim name As String = _curPost.ImageUrl
7616 Me.SaveFileDialog1.FileName = name.Substring(name.LastIndexOf("/"c) + 1)
7618 If Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
7619 Using bmp2 As New Bitmap(TIconDic(name).Size.Width, TIconDic(name).Size.Height)
7620 Using g As Graphics = Graphics.FromImage(bmp2)
7621 g.InterpolationMode = Drawing2D.InterpolationMode.High
7622 g.DrawImage(TIconDic(name), 0, 0, TIconDic(name).Size.Width, TIconDic(name).Size.Height)
7625 bmp2.Save(Me.SaveFileDialog1.FileName)
7631 Private Sub SplitContainer2_Panel2_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitContainer2.Panel2.Resize
7632 Me.StatusText.Multiline = Me.SplitContainer2.Panel2.Height > Me.SplitContainer2.Panel2MinSize + 2
7633 MultiLineMenuItem.Checked = Me.StatusText.Multiline
7634 _modifySettingLocal = True
7637 Private Sub StatusText_MultilineChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.MultilineChanged
7638 If Me.StatusText.Multiline Then
7639 Me.StatusText.ScrollBars = ScrollBars.Vertical
7641 Me.StatusText.ScrollBars = ScrollBars.None
7643 _modifySettingLocal = True
7646 Private Sub MultiLineMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MultiLineMenuItem.Click
7648 StatusText.Multiline = MultiLineMenuItem.Checked
7649 _cfgLocal.StatusMultiline = MultiLineMenuItem.Checked
7650 If MultiLineMenuItem.Checked Then
7651 If SplitContainer2.Height - _mySpDis2 - SplitContainer2.SplitterWidth < 0 Then
7652 SplitContainer2.SplitterDistance = 0
7654 SplitContainer2.SplitterDistance = SplitContainer2.Height - _mySpDis2 - SplitContainer2.SplitterWidth
7657 SplitContainer2.SplitterDistance = SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth
7659 _modifySettingLocal = True
7662 Private Function UrlConvert(ByVal Converter_Type As UrlConverter) As Boolean
7663 'Converter_Type=Nicomsの場合は、nicovideoのみ短縮する
7664 '参考資料 RFC3986 Uniform Resource Identifier (URI): Generic Syntax
7665 'Appendix A. Collected ABNF for URI
7666 'http://www.ietf.org/rfc/rfc3986.txt
7668 Dim result As String = ""
7669 Const url As String = "(?<before>(?:[^\""':!=]|^|\:))" + _
7670 "(?<url>(?<protocol>https?://)" + _
7671 "(?<domain>(?:[\.-]|[^\p{P}\s])+\.[a-z]{2,}(?::[0-9]+)?)" + _
7672 "(?<path>/[a-z0-9!*'();:&=+$/%#\-_.,~@]*[a-z0-9)=#/]?)?" + _
7673 "(?<query>\?[a-z0-9!*'();:&=+$/%#\-_.,~@?]*[a-z0-9_&=#/])?)"
7675 Const nico As String = "^https?://[a-z]+\.(nicovideo|niconicommons|nicolive)\.jp/[a-z]+/[a-z0-9]+$"
7677 If StatusText.SelectionLength > 0 Then
7678 Dim tmp As String = StatusText.SelectedText
7679 ' httpから始まらない場合、ExcludeStringで指定された文字列で始まる場合は対象としない
7680 If tmp.StartsWith("http") Then
7681 ' 文字列が選択されている場合はその文字列について処理
7683 'nico.ms使用、nicovideoにマッチしたら変換
7684 If SettingDialog.Nicoms AndAlso Regex.IsMatch(tmp, nico) Then
7685 result = nicoms.Shorten(tmp)
7686 ElseIf Converter_Type <> UrlConverter.Nicoms Then
7687 '短縮URL変換 日本語を含むかもしれないのでURLエンコードする
7688 result = ShortUrl.Make(Converter_Type, tmp)
7689 If result.Equals("Can't convert") Then
7690 StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":")
7697 If Not String.IsNullOrEmpty(result) Then
7698 Dim undotmp As New urlUndo
7700 StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length)
7701 StatusText.SelectedText = result
7704 undotmp.Before = tmp
7705 undotmp.After = result
7707 If urlUndoBuffer Is Nothing Then
7708 urlUndoBuffer = New List(Of urlUndo)
7709 UrlUndoToolStripMenuItem.Enabled = True
7712 urlUndoBuffer.Add(undotmp)
7716 ' 正規表現にマッチしたURL文字列をtinyurl化
7717 For Each mt As Match In Regex.Matches(StatusText.Text, url, RegexOptions.IgnoreCase)
7718 If StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal) = -1 Then Continue For
7719 Dim tmp As String = mt.Result("${url}")
7720 If tmp.StartsWith("w", StringComparison.OrdinalIgnoreCase) Then tmp = "http://" + tmp
7721 Dim undotmp As New urlUndo
7724 StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length)
7726 'nico.ms使用、nicovideoにマッチしたら変換
7727 If SettingDialog.Nicoms AndAlso Regex.IsMatch(tmp, nico) Then
7728 result = nicoms.Shorten(tmp)
7729 ElseIf Converter_Type <> UrlConverter.Nicoms Then
7730 '短縮URL変換 日本語を含むかもしれないのでURLエンコードする
7731 result = ShortUrl.Make(Converter_Type, tmp)
7732 If result.Equals("Can't convert") Then
7733 StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":")
7740 If Not String.IsNullOrEmpty(result) Then
7741 StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length)
7742 StatusText.SelectedText = result
7744 undotmp.Before = mt.Result("${url}")
7745 undotmp.After = result
7747 If urlUndoBuffer Is Nothing Then
7748 urlUndoBuffer = New List(Of urlUndo)
7749 UrlUndoToolStripMenuItem.Enabled = True
7752 urlUndoBuffer.Add(undotmp)
7761 Private Sub doUrlUndo()
7762 If urlUndoBuffer IsNot Nothing Then
7763 Dim tmp As String = StatusText.Text
7764 For Each data As urlUndo In urlUndoBuffer
7765 tmp = tmp.Replace(data.After, data.Before)
7767 StatusText.Text = tmp
7768 urlUndoBuffer = Nothing
7769 UrlUndoToolStripMenuItem.Enabled = False
7773 Private Sub TinyURLToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TinyURLToolStripMenuItem.Click
7774 UrlConvert(UrlConverter.TinyUrl)
7777 Private Sub IsgdToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IsgdToolStripMenuItem.Click
7778 UrlConvert(UrlConverter.Isgd)
7781 Private Sub TwurlnlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TwurlnlToolStripMenuItem.Click
7782 UrlConvert(UrlConverter.Twurl)
7785 Private Sub UrlConvertAutoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlConvertAutoToolStripMenuItem.Click
7786 If Not UrlConvert(SettingDialog.AutoShortUrlFirst) Then
7787 Dim svc As UrlConverter = SettingDialog.AutoShortUrlFirst
7788 Dim rnd As New Random()
7789 ' 前回使用した短縮URLサービス以外を選択する
7791 svc = CType(rnd.Next(System.Enum.GetNames(GetType(UrlConverter)).Length), UrlConverter)
7792 Loop Until svc <> SettingDialog.AutoShortUrlFirst
7797 Private Sub UrlUndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlUndoToolStripMenuItem.Click
7801 Private Sub NewPostPopMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewPostPopMenuItem.CheckStateChanged, NotifyFileMenuItem.CheckStateChanged
7802 Me.NotifyFileMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7803 Me.NewPostPopMenuItem.Checked = Me.NotifyFileMenuItem.Checked
7804 _cfgCommon.NewAllPop = NewPostPopMenuItem.Checked
7805 _modifySettingCommon = True
7808 Private Sub ListLockMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListLockMenuItem.CheckStateChanged, LockListFileMenuItem.CheckStateChanged
7809 ListLockMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7810 Me.LockListFileMenuItem.Checked = ListLockMenuItem.Checked
7811 _cfgCommon.ListLock = ListLockMenuItem.Checked
7812 _modifySettingCommon = True
7815 Private Sub MenuStrip1_MenuActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuStrip1.MenuActivate
7816 ' フォーカスがメニューに移る (MenuStrip1.Tag フラグを立てる)
7817 MenuStrip1.Tag = New Object()
7818 MenuStrip1.Select() ' StatusText がフォーカスを持っている場合 Leave が発生
7821 Private Sub MenuStrip1_MenuDeactivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuStrip1.MenuDeactivate
7822 If Me.Tag IsNot Nothing Then ' 設定された戻り先へ遷移
7823 If Me.Tag Is Me.ListTab.SelectedTab Then
7824 DirectCast(Me.ListTab.SelectedTab.Tag, Control).Select()
7826 DirectCast(Me.Tag, Control).Select()
7828 Else ' 戻り先が指定されていない (初期状態) 場合はタブに遷移
7829 If ListTab.SelectedIndex > -1 AndAlso ListTab.SelectedTab.HasChildren Then
7830 Me.Tag = ListTab.SelectedTab.Tag
7831 DirectCast(Me.Tag, Control).Select()
7834 ' フォーカスがメニューに遷移したかどうかを表すフラグを降ろす
7835 MenuStrip1.Tag = Nothing
7838 Private Sub MyList_ColumnReordered(ByVal sender As System.Object, ByVal e As ColumnReorderedEventArgs)
7839 Dim lst As DetailsListView = DirectCast(sender, DetailsListView)
7840 If _cfgLocal Is Nothing Then Exit Sub
7843 _cfgLocal.Width1 = lst.Columns(0).Width
7844 _cfgLocal.Width3 = lst.Columns(1).Width
7846 Dim darr(lst.Columns.Count - 1) As Integer
7847 For i As Integer = 0 To lst.Columns.Count - 1
7848 darr(lst.Columns(i).DisplayIndex) = i
7850 MoveArrayItem(darr, e.OldDisplayIndex, e.NewDisplayIndex)
7852 For i As Integer = 0 To lst.Columns.Count - 1
7855 _cfgLocal.DisplayIndex1 = i
7857 _cfgLocal.DisplayIndex2 = i
7859 _cfgLocal.DisplayIndex3 = i
7861 _cfgLocal.DisplayIndex4 = i
7863 _cfgLocal.DisplayIndex5 = i
7865 _cfgLocal.DisplayIndex6 = i
7867 _cfgLocal.DisplayIndex7 = i
7869 _cfgLocal.DisplayIndex8 = i
7872 _cfgLocal.Width1 = lst.Columns(0).Width
7873 _cfgLocal.Width2 = lst.Columns(1).Width
7874 _cfgLocal.Width3 = lst.Columns(2).Width
7875 _cfgLocal.Width4 = lst.Columns(3).Width
7876 _cfgLocal.Width5 = lst.Columns(4).Width
7877 _cfgLocal.Width6 = lst.Columns(5).Width
7878 _cfgLocal.Width7 = lst.Columns(6).Width
7879 _cfgLocal.Width8 = lst.Columns(7).Width
7881 _modifySettingLocal = True
7882 _isColumnChanged = True
7885 Private Sub MyList_ColumnWidthChanged(ByVal sender As System.Object, ByVal e As ColumnWidthChangedEventArgs)
7886 Dim lst As DetailsListView = DirectCast(sender, DetailsListView)
7887 If _cfgLocal Is Nothing Then Exit Sub
7889 If _cfgLocal.Width1 <> lst.Columns(0).Width Then
7890 _cfgLocal.Width1 = lst.Columns(0).Width
7891 _modifySettingLocal = True
7892 _isColumnChanged = True
7894 If _cfgLocal.Width3 <> lst.Columns(1).Width Then
7895 _cfgLocal.Width3 = lst.Columns(1).Width
7896 _modifySettingLocal = True
7897 _isColumnChanged = True
7900 If _cfgLocal.Width1 <> lst.Columns(0).Width Then
7901 _cfgLocal.Width1 = lst.Columns(0).Width
7902 _modifySettingLocal = True
7903 _isColumnChanged = True
7905 If _cfgLocal.Width2 <> lst.Columns(1).Width Then
7906 _cfgLocal.Width2 = lst.Columns(1).Width
7907 _modifySettingLocal = True
7908 _isColumnChanged = True
7910 If _cfgLocal.Width3 <> lst.Columns(2).Width Then
7911 _cfgLocal.Width3 = lst.Columns(2).Width
7912 _modifySettingLocal = True
7913 _isColumnChanged = True
7915 If _cfgLocal.Width4 <> lst.Columns(3).Width Then
7916 _cfgLocal.Width4 = lst.Columns(3).Width
7917 _modifySettingLocal = True
7918 _isColumnChanged = True
7920 If _cfgLocal.Width5 <> lst.Columns(4).Width Then
7921 _cfgLocal.Width5 = lst.Columns(4).Width
7922 _modifySettingLocal = True
7923 _isColumnChanged = True
7925 If _cfgLocal.Width6 <> lst.Columns(5).Width Then
7926 _cfgLocal.Width6 = lst.Columns(5).Width
7927 _modifySettingLocal = True
7928 _isColumnChanged = True
7930 If _cfgLocal.Width7 <> lst.Columns(6).Width Then
7931 _cfgLocal.Width7 = lst.Columns(6).Width
7932 _modifySettingLocal = True
7933 _isColumnChanged = True
7935 If _cfgLocal.Width8 <> lst.Columns(7).Width Then
7936 _cfgLocal.Width8 = lst.Columns(7).Width
7937 _modifySettingLocal = True
7938 _isColumnChanged = True
7941 ' 非表示の時にColumnChangedが呼ばれた場合はForm初期化処理中なので保存しない
7943 ' SaveConfigsLocal()
7947 Public Function WebBrowser_GetSelectionText(ByRef ComponentInstance As WebBrowser) As String
7948 '発言詳細で「選択文字列をコピー」を行う
7949 'WebBrowserコンポーネントのインスタンスを渡す
7950 Dim typ As Type = ComponentInstance.ActiveXInstance.GetType()
7951 Dim _SelObj As Object = typ.InvokeMember("selection", BindingFlags.GetProperty, Nothing, ComponentInstance.Document.DomDocument, Nothing)
7952 Dim _objRange As Object = _SelObj.GetType().InvokeMember("createRange", BindingFlags.InvokeMethod, Nothing, _SelObj, Nothing)
7953 Return DirectCast(_objRange.GetType().InvokeMember("text", BindingFlags.GetProperty, Nothing, _objRange, Nothing), String)
7956 Private Sub SelectionCopyContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionCopyContextMenuItem.Click
7958 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7960 Clipboard.SetDataObject(_selText, False, 5, 100)
7961 Catch ex As Exception
7962 MessageBox.Show(ex.Message)
7966 Private Sub doSearchToolStrip(ByVal url As String)
7967 '発言詳細で「選択文字列で検索」(選択文字列取得)
7968 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7970 If _selText IsNot Nothing Then
7971 If url = My.Resources.SearchItem4Url Then
7973 AddNewTabForSearch(_selText)
7977 Dim tmp As String = String.Format(url, HttpUtility.UrlEncode(_selText))
7982 Private Sub SelectionAllContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionAllContextMenuItem.Click
7984 PostBrowser.Document.ExecCommand("SelectAll", False, Nothing)
7987 Private Sub SearchWikipediaContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchWikipediaContextMenuItem.Click
7988 doSearchToolStrip(My.Resources.SearchItem1Url)
7991 Private Sub SearchGoogleContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchGoogleContextMenuItem.Click
7992 doSearchToolStrip(My.Resources.SearchItem2Url)
7995 Private Sub SearchYatsContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchYatsContextMenuItem.Click
7996 doSearchToolStrip(My.Resources.SearchItem3Url)
7999 Private Sub SearchPublicSearchContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPublicSearchContextMenuItem.Click
8000 doSearchToolStrip(My.Resources.SearchItem4Url)
8003 Private Sub UrlCopyContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlCopyContextMenuItem.Click
8005 Clipboard.SetDataObject(Me._postBrowserStatusText, False, 5, 100)
8006 Catch ex As Exception
8007 MessageBox.Show(ex.Message)
8011 Private Sub ContextMenuPostBrowser_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuPostBrowser.Opening
8013 If PostBrowser.StatusText.StartsWith("http") Then
8014 Me._postBrowserStatusText = PostBrowser.StatusText
8015 Dim name As String = GetUserId()
8016 UrlCopyContextMenuItem.Enabled = True
8017 If name IsNot Nothing Then
8018 FollowContextMenuItem.Enabled = True
8019 RemoveContextMenuItem.Enabled = True
8020 FriendshipContextMenuItem.Enabled = True
8021 ShowUserStatusContextMenuItem.Enabled = True
8022 SearchPostsDetailToolStripMenuItem.Enabled = True
8023 IdFilterAddMenuItem.Enabled = True
8024 ListManageUserContextToolStripMenuItem.Enabled = True
8026 FollowContextMenuItem.Enabled = False
8027 RemoveContextMenuItem.Enabled = False
8028 FriendshipContextMenuItem.Enabled = False
8029 ShowUserStatusContextMenuItem.Enabled = False
8030 SearchPostsDetailToolStripMenuItem.Enabled = False
8031 IdFilterAddMenuItem.Enabled = False
8032 ListManageUserContextToolStripMenuItem.Enabled = False
8035 If Regex.IsMatch(Me._postBrowserStatusText, "^https?://twitter.com/search\?q=%23") Then
8036 UseHashtagMenuItem.Enabled = True
8038 UseHashtagMenuItem.Enabled = False
8041 Me._postBrowserStatusText = ""
8042 UrlCopyContextMenuItem.Enabled = False
8043 FollowContextMenuItem.Enabled = False
8044 RemoveContextMenuItem.Enabled = False
8045 FriendshipContextMenuItem.Enabled = False
8046 ShowUserStatusContextMenuItem.Enabled = False
8047 SearchPostsDetailToolStripMenuItem.Enabled = False
8048 UseHashtagMenuItem.Enabled = False
8049 IdFilterAddMenuItem.Enabled = False
8050 ListManageUserContextToolStripMenuItem.Enabled = False
8052 ' 文字列選択されていないときは選択文字列関係の項目を非表示に
8053 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
8054 If _selText Is Nothing Then
8055 SelectionSearchContextMenuItem.Enabled = False
8056 SelectionCopyContextMenuItem.Enabled = False
8058 SelectionSearchContextMenuItem.Enabled = True
8059 SelectionCopyContextMenuItem.Enabled = True
8061 '発言内に自分以外のユーザーが含まれてればフォロー状態全表示を有効に
8062 Dim ma As MatchCollection = Regex.Matches(Me.PostBrowser.DocumentText, "href=""https?://twitter.com/(#!/)?(?<name>[a-zA-Z0-9_]+)""")
8063 Dim fAllFlag As Boolean = False
8064 For Each mu As Match In ma
8065 If mu.Result("${name}").ToLower <> tw.Username.ToLower Then
8070 Me.FriendshipAllMenuItem.Enabled = fAllFlag
8075 Private Sub CurrentTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurrentTabToolStripMenuItem.Click
8076 '発言詳細の選択文字列で現在のタブを検索
8077 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
8079 If _selText IsNot Nothing Then
8080 SearchDialog.SWord = _selText
8081 SearchDialog.CheckCaseSensitive = False
8082 SearchDialog.CheckRegex = False
8084 DoTabSearch(SearchDialog.SWord, _
8085 SearchDialog.CheckCaseSensitive, _
8086 SearchDialog.CheckRegex, _
8087 SEARCHTYPE.NextSearch)
8091 Private Sub SplitContainer2_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer2.SplitterMoved
8092 If StatusText.Multiline Then _mySpDis2 = StatusText.Height
8093 _modifySettingLocal = True
8096 Private Sub TweenMain_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
8097 If e.Data.GetDataPresent(DataFormats.FileDrop) Then
8098 ImageSelectionPanel.Visible = True
8099 ImageSelectionPanel.Enabled = True
8100 TimelinePanel.Visible = False
8101 TimelinePanel.Enabled = False
8102 ImagefilePathText.Text = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
8103 ImageFromSelectedFile()
8106 ElseIf e.Data.GetDataPresent(DataFormats.StringFormat) Then
8107 Dim data As String = TryCast(e.Data.GetData(DataFormats.StringFormat, True), String)
8108 If data IsNot Nothing Then StatusText.Text += data
8112 Private Sub TweenMain_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragOver
8113 If e.Data.GetDataPresent(DataFormats.FileDrop) Then
8114 Dim filename As String = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
8115 Dim fl As New FileInfo(filename)
8116 Dim ext As String = fl.Extension
8117 Dim picsvc As New PictureService(tw)
8119 If picsvc.IsValidExtension(ext, ImageService) AndAlso _
8120 picsvc.GetMaxFileSize(ext, ImageService) >= fl.Length Then
8121 e.Effect = DragDropEffects.Copy
8124 For Each svc As String In ImageServiceCombo.Items
8125 If picsvc.IsValidExtension(ext, svc) AndAlso _
8126 picsvc.GetMaxFileSize(ext, svc) >= fl.Length Then
8127 ImageServiceCombo.SelectedItem = svc
8128 e.Effect = DragDropEffects.Copy
8134 e.Effect = DragDropEffects.None
8135 ElseIf e.Data.GetDataPresent(DataFormats.StringFormat) Then
8136 e.Effect = DragDropEffects.Copy
8138 e.Effect = DragDropEffects.None
8142 Public Function IsNetworkAvailable() As Boolean
8143 Dim nw As Boolean = True
8145 nw = My.Computer.Network.IsAvailable
8146 Catch ex As Exception
8149 _myStatusOnline = nw
8153 Public Sub OpenUriAsync(ByVal UriString As String)
8154 Dim args As New GetWorkerArg
8155 args.type = WORKERTYPE.OpenUri
8156 args.url = UriString
8161 Private Sub ListTabSelect(ByVal _tab As TabPage)
8164 _itemCache = Nothing
8165 _itemCacheIndex = -1
8166 _postCache = Nothing
8169 _curList = DirectCast(_tab.Tag, DetailsListView)
8170 If _curList.SelectedIndices.Count > 0 Then
8171 _curItemIndex = _curList.SelectedIndices(0)
8172 _curPost = GetCurTabPost(_curItemIndex)
8178 _anchorPost = Nothing
8182 DirectCast(_tab.Tag, DetailsListView).Columns.Item(1).Text = ColumnText(2)
8184 For i As Integer = 0 To _curList.Columns.Count - 1
8185 DirectCast(_tab.Tag, DetailsListView).Columns.Item(i).Text = ColumnText(i)
8190 Private Sub ListTab_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles ListTab.Selecting
8191 ListTabSelect(e.TabPage)
8194 Private Sub SelectListItem(ByVal LView As DetailsListView, ByVal Index As Integer)
8196 Dim bnd As Rectangle
8197 Dim flg As Boolean = False
8198 If LView.FocusedItem IsNot Nothing Then
8199 bnd = LView.FocusedItem.Bounds
8203 LView.SelectedIndices.Clear()
8204 LView.Items(Index).Selected = True
8205 LView.Items(Index).Focused = True
8207 If flg Then LView.Invalidate(bnd)
8210 Private Sub SelectListItem(ByVal LView As DetailsListView, ByVal Index() As Integer, ByVal FocusedIndex As Integer)
8212 Dim bnd As Rectangle
8213 Dim flg As Boolean = False
8214 If LView.FocusedItem IsNot Nothing Then
8215 bnd = LView.FocusedItem.Bounds
8219 If Index IsNot Nothing AndAlso Index(0) > -1 Then
8220 LView.SelectedIndices.Clear()
8221 For Each idx As Integer In Index
8222 LView.SelectedIndices.Add(idx)
8225 If FocusedIndex > -1 Then
8226 LView.Items(FocusedIndex).Focused = True
8228 If flg Then LView.Invalidate(bnd)
8231 Private Sub RunAsync(ByVal args As GetWorkerArg)
8232 Dim bw As BackgroundWorker = Nothing
8233 If args.type <> WORKERTYPE.Follower Then
8234 For i As Integer = 0 To _bw.Length - 1
8235 If _bw(i) IsNot Nothing AndAlso Not _bw(i).IsBusy Then
8240 If bw Is Nothing Then
8241 For i As Integer = 0 To _bw.Length - 1
8242 If _bw(i) Is Nothing Then
8243 _bw(i) = New BackgroundWorker
8245 bw.WorkerReportsProgress = True
8246 bw.WorkerSupportsCancellation = True
8247 AddHandler bw.DoWork, AddressOf GetTimelineWorker_DoWork
8248 AddHandler bw.ProgressChanged, AddressOf GetTimelineWorker_ProgressChanged
8249 AddHandler bw.RunWorkerCompleted, AddressOf GetTimelineWorker_RunWorkerCompleted
8255 If _bwFollower Is Nothing Then
8256 _bwFollower = New BackgroundWorker
8258 bw.WorkerReportsProgress = True
8259 bw.WorkerSupportsCancellation = True
8260 AddHandler bw.DoWork, AddressOf GetTimelineWorker_DoWork
8261 AddHandler bw.ProgressChanged, AddressOf GetTimelineWorker_ProgressChanged
8262 AddHandler bw.RunWorkerCompleted, AddressOf GetTimelineWorker_RunWorkerCompleted
8264 If _bwFollower.IsBusy = False Then
8269 If bw Is Nothing Then Exit Sub
8271 bw.RunWorkerAsync(args)
8274 Private Sub TweenMain_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
8276 PostBrowser.Url = New Uri("about:blank")
8277 PostBrowser.DocumentText = "" '発言詳細部初期化
8278 Catch ex As Exception
8282 NotifyIcon1.Visible = True
8284 If IsNetworkAvailable() Then
8285 If SettingDialog.StartupFollowers Then
8286 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
8288 _waitTimeline = True
8289 GetTimeline(WORKERTYPE.Timeline, 1, 1, "")
8291 GetTimeline(WORKERTYPE.Reply, 1, 1, "")
8293 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 1, "")
8294 If SettingDialog.GetFav Then
8296 GetTimeline(WORKERTYPE.Favorites, 1, 1, "")
8298 _waitPubSearch = True
8299 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, "") 'tabname="":全タブ
8301 GetTimeline(WORKERTYPE.List, 1, 0, "") 'tabname="":全タブ
8302 Dim i As Integer = 0
8303 Dim j As Integer = 0
8304 Do While (_waitTimeline OrElse _waitReply OrElse _waitDm OrElse _waitFav OrElse _waitPubSearch OrElse _waitLists) AndAlso Not _endingFlag
8305 System.Threading.Thread.Sleep(100)
8306 My.Application.DoEvents()
8309 If j > 1200 Then Exit Do ' 120秒間初期処理が終了しなかったら強制的に打ち切る
8318 If _endingFlag Then Exit Sub
8320 'バージョンチェック(引数:起動時チェックの場合はTrue・・・チェック結果のメッセージを表示しない)
8321 If SettingDialog.StartupVersion Then
8322 CheckNewVersion(True)
8326 If Not tw.GetFollowersSuccess AndAlso SettingDialog.StartupFollowers Then
8327 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
8331 AddHandler tw.NewPostFromStream, AddressOf tw_NewPostFromStream
8332 AddHandler tw.UserStreamStarted, AddressOf tw_UserStreamStarted
8333 AddHandler tw.UserStreamStopped, AddressOf tw_UserStreamStopped
8334 AddHandler tw.UserStreamPaused, AddressOf tw_UserStreamPaused
8335 AddHandler tw.PostDeleted, AddressOf tw_PostDeleted
8337 MenuItemUserStream.Text = "&UserStream ■"
8338 MenuItemUserStream.Enabled = True
8339 PauseToolStripMenuItem.Text = "&Pause"
8340 PauseToolStripMenuItem.Enabled = False
8341 StopToolStripMenuItem.Text = "&Start"
8342 StopToolStripMenuItem.Enabled = True
8343 If SettingDialog.UserstreamStartup Then tw.StartUserStream()
8344 TimerTimeline.Enabled = True
8347 Private Sub doGetFollowersMenu()
8348 GetTimeline(WORKERTYPE.Follower, 1, 0, "")
8352 Private Sub GetFollowersAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateFollowersMenuItem1.Click
8353 doGetFollowersMenu()
8356 Private Sub doReTweetUnofficial()
8358 If _curPost IsNot Nothing Then
8359 If _curPost.IsDm OrElse _
8360 Not StatusText.Enabled Then Exit Sub
8362 If _curPost.IsProtect Then
8363 MessageBox.Show("Protected.")
8366 Dim rtdata As String = _curPost.OriginalData
8367 rtdata = CreateRetweetUnofficial(rtdata)
8369 StatusText.Text = "RT @" + _curPost.Name + ": " + HttpUtility.HtmlDecode(rtdata)
8371 StatusText.SelectionStart = 0
8376 Private Sub ReTweetStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReTweetStripMenuItem.Click, RtUnOpMenuItem.Click
8377 doReTweetUnofficial()
8380 Private Sub doReTweetOfficial(ByVal isConfirm As Boolean)
8382 If _curPost IsNot Nothing Then
8383 If _curPost.IsProtect Then
8384 MessageBox.Show("Protected.")
8385 _DoFavRetweetFlags = False
8388 If _curList.SelectedIndices.Count > 15 Then
8389 MessageBox.Show(My.Resources.RetweetLimitText)
8390 _DoFavRetweetFlags = False
8392 ElseIf _curList.SelectedIndices.Count > 1 Then
8393 Dim QuestionText As String = My.Resources.RetweetQuestion2
8394 If _DoFavRetweetFlags Then QuestionText = My.Resources.FavoriteRetweetQuestionText1
8395 Select Case MessageBox.Show(QuestionText, "Retweet", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
8396 Case Windows.Forms.DialogResult.Cancel, Windows.Forms.DialogResult.No
8397 _DoFavRetweetFlags = False
8401 If _curPost.IsDm OrElse _curPost.IsMe Then
8402 _DoFavRetweetFlags = False
8405 If Not SettingDialog.RetweetNoConfirm Then
8406 Dim Questiontext As String = My.Resources.RetweetQuestion1
8407 If _DoFavRetweetFlags Then Questiontext = My.Resources.FavoritesRetweetQuestionText2
8408 If isConfirm AndAlso MessageBox.Show(Questiontext, "Retweet", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
8409 _DoFavRetweetFlags = False
8414 Dim args As New GetWorkerArg
8415 args.ids = New List(Of Long)
8416 args.sIds = New List(Of Long)
8417 args.tName = _curTab.Text
8418 args.type = WORKERTYPE.Retweet
8419 For Each idx As Integer In _curList.SelectedIndices
8420 Dim post As PostClass = GetCurTabPost(idx)
8421 If Not post.IsMe AndAlso Not post.IsProtect AndAlso Not post.IsDm Then args.ids.Add(post.Id)
8427 Private Sub ReTweetOriginalStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReTweetOriginalStripMenuItem.Click, RtOpMenuItem.Click
8428 doReTweetOfficial(True)
8431 Private Sub FavoritesRetweetOriginal()
8432 If _curPost Is Nothing Then Exit Sub
8433 _DoFavRetweetFlags = True
8434 doReTweetOfficial(True)
8435 If _DoFavRetweetFlags Then
8436 _DoFavRetweetFlags = False
8437 FavoriteChange(True, False)
8441 Private Sub FavoritesRetweetUnofficial()
8442 If _curPost IsNot Nothing AndAlso Not _curPost.IsDm Then
8443 _DoFavRetweetFlags = True
8444 FavoriteChange(True)
8445 If Not _curPost.IsProtect AndAlso _DoFavRetweetFlags Then
8446 _DoFavRetweetFlags = False
8447 doReTweetUnofficial()
8452 Private Function CreateRetweetUnofficial(ByVal status As String) As String
8454 ' Twitterにより省略されているURLを含むaタグをキャプチャしてリンク先URLへ置き換える
8457 Dim isUrl As Boolean = False
8458 Dim ms As MatchCollection = Regex.Matches(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>")
8459 For Each m As Match In ms
8460 If m.Result("${link}").EndsWith("...") Then
8466 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>", "${url}")
8468 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>", "${link}")
8471 'その他のリンク(@IDなど)を置き換える
8472 status = Regex.Replace(status, "@<a target=""_self"" href=""https?://twitter.com/(#!/)?(?<url>[^""]+)""[^>]*>(?<link>[^<]+)</a>", "@${url}")
8474 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>[^<]+)</a>", "${link}")
8476 If StatusText.Multiline Then
8477 status = Regex.Replace(status, "(\r\n|\n|\r)?<br>", vbCrLf, RegexOptions.IgnoreCase Or RegexOptions.Multiline)
8479 status = Regex.Replace(status, "(\r\n|\n|\r)?<br>", "", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
8484 status = status.Replace(" ", " ")
8489 Private Sub DumpPostClassToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DumpPostClassToolStripMenuItem.Click
8490 If _curPost IsNot Nothing Then
8495 Private Sub MenuItemHelp_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemHelp.DropDownOpening
8496 If DebugBuild OrElse My.Computer.Keyboard.CapsLock AndAlso My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.ShiftKeyDown Then
8497 DebugModeToolStripMenuItem.Visible = True
8499 DebugModeToolStripMenuItem.Visible = False
8503 Private Sub ToolStripMenuItemUrlAutoShorten_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemUrlAutoShorten.CheckedChanged
8504 SettingDialog.UrlConvertAuto = ToolStripMenuItemUrlAutoShorten.Checked
8507 Private Sub ContextMenuPostMode_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuPostMode.Opening
8508 ToolStripMenuItemUrlAutoShorten.Checked = SettingDialog.UrlConvertAuto
8511 Private Sub TraceOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraceOutToolStripMenuItem.Click
8512 If TraceOutToolStripMenuItem.Checked Then
8519 Private Sub TweenMain_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
8520 '画面が非アクティブになったら、発言欄の背景色をデフォルトへ
8521 Me.StatusText_Leave(StatusText, System.EventArgs.Empty)
8524 Private Sub TabRenameMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabRenameMenuItem.Click, RenameTbMenuItem.Click
8525 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
8526 TabRename(_rclickTabName)
8529 Private Sub BitlyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BitlyToolStripMenuItem.Click
8530 UrlConvert(UrlConverter.Bitly)
8533 Private Sub JmpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JmpStripMenuItem.Click
8534 UrlConvert(UrlConverter.Jmp)
8538 Private Class GetApiInfoArgs
8539 Public tw As Twitter
8540 Public info As ApiInfo
8543 Private Sub GetApiInfo_Dowork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8544 Dim args As GetApiInfoArgs = DirectCast(e.Argument, GetApiInfoArgs)
8545 e.Result = tw.GetInfoApi(args.info)
8548 Private Sub ApiInfoMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApiInfoMenuItem.Click
8549 Dim info As New ApiInfo
8551 Dim args As New GetApiInfoArgs With {.tw = tw, .info = info}
8553 Using dlg As New FormInfo(Me, My.Resources.ApiInfo6, AddressOf GetApiInfo_Dowork, Nothing, args)
8555 If CBool(dlg.Result) Then
8556 tmp = My.Resources.ApiInfo1 + args.info.MaxCount.ToString() + Environment.NewLine + _
8557 My.Resources.ApiInfo2 + args.info.RemainCount.ToString + Environment.NewLine + _
8558 My.Resources.ApiInfo3 + args.info.ResetTime.ToString()
8561 tmp = My.Resources.ApiInfo5
8565 MessageBox.Show(tmp, My.Resources.ApiInfo4, MessageBoxButtons.OK, MessageBoxIcon.Information)
8568 Private Sub FollowCommandMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowCommandMenuItem.Click
8569 Dim id As String = ""
8570 If _curPost IsNot Nothing Then id = _curPost.Name
8574 Private Sub FollowCommand_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8575 Dim arg As FollowRemoveCommandArgs = DirectCast(e.Argument, FollowRemoveCommandArgs)
8576 e.Result = arg.tw.PostFollowCommand(arg.id)
8579 Private Sub FollowCommand(ByVal id As String)
8580 Using inputName As New InputTabName()
8581 inputName.FormTitle = "Follow"
8582 inputName.FormDescription = My.Resources.FRMessage1
8583 inputName.TabName = id
8584 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8585 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8586 Dim arg As New FollowRemoveCommandArgs
8588 arg.id = inputName.TabName.Trim()
8589 Using _info As New FormInfo(Me, My.Resources.FollowCommandText1, _
8590 AddressOf FollowCommand_DoWork, _
8594 Dim ret As String = DirectCast(_info.Result, String)
8595 If Not String.IsNullOrEmpty(ret) Then
8596 MessageBox.Show(My.Resources.FRMessage2 + ret)
8598 MessageBox.Show(My.Resources.FRMessage3)
8605 Private Sub RemoveCommandMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveCommandMenuItem.Click
8606 Dim id As String = ""
8607 If _curPost IsNot Nothing Then id = _curPost.Name
8608 RemoveCommand(id, False)
8611 Private Class FollowRemoveCommandArgs
8612 Public tw As Tween.Twitter
8616 Private Sub RemoveCommand_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8617 Dim arg As FollowRemoveCommandArgs = DirectCast(e.Argument, FollowRemoveCommandArgs)
8618 e.Result = arg.tw.PostRemoveCommand(arg.id)
8621 Private Sub RemoveCommand(ByVal id As String, ByVal skipInput As Boolean)
8622 Dim arg As New FollowRemoveCommandArgs
8625 If Not skipInput Then
8626 Using inputName As New InputTabName()
8627 inputName.FormTitle = "Unfollow"
8628 inputName.FormDescription = My.Resources.FRMessage1
8629 inputName.TabName = id
8630 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8631 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8633 arg.id = inputName.TabName.Trim()
8640 Using _info As New FormInfo(Me, My.Resources.RemoveCommandText1, _
8641 AddressOf RemoveCommand_DoWork, _
8645 Dim ret As String = DirectCast(_info.Result, String)
8646 If Not String.IsNullOrEmpty(ret) Then
8647 MessageBox.Show(My.Resources.FRMessage2 + ret)
8649 MessageBox.Show(My.Resources.FRMessage3)
8654 Private Sub FriendshipMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipMenuItem.Click
8655 Dim id As String = ""
8656 If _curPost IsNot Nothing Then
8662 Private Class ShowFriendshipArgs
8663 Public tw As Tween.Twitter
8664 Public Class FriendshipInfo
8665 Public id As String = ""
8666 Public isFollowing As Boolean = False
8667 Public isFollowed As Boolean = False
8668 Public isError As Boolean = False
8669 Public Sub New(ByVal id As String)
8673 Public ids As New List(Of FriendshipInfo)
8676 Private Sub ShowFriendship_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8677 Dim arg As ShowFriendshipArgs = DirectCast(e.Argument, ShowFriendshipArgs)
8678 Dim result As String = ""
8679 For Each fInfo As ShowFriendshipArgs.FriendshipInfo In arg.ids
8680 Dim rt As String = arg.tw.GetFriendshipInfo(fInfo.id, fInfo.isFollowing, fInfo.isFollowed)
8681 If Not String.IsNullOrEmpty(rt) Then
8682 If String.IsNullOrEmpty(result) Then result = rt
8683 fInfo.isError = True
8689 Private Sub ShowFriendship(ByVal id As String)
8690 Dim args As New ShowFriendshipArgs
8692 Using inputName As New InputTabName()
8693 inputName.FormTitle = "Show Friendships"
8694 inputName.FormDescription = My.Resources.FRMessage1
8695 inputName.TabName = id
8696 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8697 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8698 Dim ret As String = ""
8699 args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(inputName.TabName.Trim))
8700 Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
8701 AddressOf ShowFriendship_DoWork, _
8705 ret = DirectCast(_info.Result, String)
8707 Dim result As String = ""
8708 If String.IsNullOrEmpty(ret) Then
8709 If args.ids(0).isFollowing Then
8710 result = My.Resources.GetFriendshipInfo1 + System.Environment.NewLine
8712 result = My.Resources.GetFriendshipInfo2 + System.Environment.NewLine
8714 If args.ids(0).isFollowed Then
8715 result += My.Resources.GetFriendshipInfo3
8717 result += My.Resources.GetFriendshipInfo4
8719 result = args.ids(0).id + My.Resources.GetFriendshipInfo5 + System.Environment.NewLine + result
8723 MessageBox.Show(result)
8728 Private Sub ShowFriendship(ByVal ids() As String)
8729 For Each id As String In ids
8730 Dim ret As String = ""
8731 Dim args As New ShowFriendshipArgs
8733 args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(id.Trim))
8734 Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
8735 AddressOf ShowFriendship_DoWork, _
8739 ret = DirectCast(_info.Result, String)
8741 Dim result As String = ""
8742 Dim fInfo As ShowFriendshipArgs.FriendshipInfo = args.ids(0)
8743 Dim ff As String = ""
8744 If String.IsNullOrEmpty(ret) Then
8746 If fInfo.isFollowing Then
8747 ff += My.Resources.GetFriendshipInfo1
8749 ff += My.Resources.GetFriendshipInfo2
8751 ff += System.Environment.NewLine + " "
8752 If fInfo.isFollowed Then
8753 ff += My.Resources.GetFriendshipInfo3
8755 ff += My.Resources.GetFriendshipInfo4
8757 result += fInfo.id + My.Resources.GetFriendshipInfo5 + System.Environment.NewLine + ff
8758 If fInfo.isFollowing Then
8759 If MessageBox.Show( _
8760 My.Resources.GetFriendshipInfo7 + System.Environment.NewLine + result, My.Resources.GetFriendshipInfo8, _
8761 MessageBoxButtons.YesNo, _
8762 MessageBoxIcon.Question, _
8763 MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
8764 RemoveCommand(fInfo.id, True)
8767 MessageBox.Show(result)
8770 MessageBox.Show(ret)
8775 Private Sub OwnStatusMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OwnStatusMenuItem.Click
8776 If Not String.IsNullOrEmpty(tw.UserInfoXml) Then
8777 doShowUserStatus(tw.UserInfoXml)
8779 MessageBox.Show(My.Resources.ShowYourProfileText1, "Your status", MessageBoxButtons.OK, MessageBoxIcon.Information)
8784 ' TwitterIDでない固定文字列を調べる(文字列検証のみ 実際に取得はしない)
8787 Private Function IsTwitterId(ByVal name As String) As Boolean
8788 Return Not Regex.Match(name, "^(about|jobs|tos|privacy)$").Success
8791 Private Function GetUserId() As String
8792 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(#!/)?(?<name>[a-zA-Z0-9_]+)$")
8793 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8794 Return m.Result("${name}")
8796 Dim ma As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(#!/)?(?<name>[a-zA-Z0-9_]+)(/(status|statuses)/[0-9]+)$")
8797 If ma.Success AndAlso IsTwitterId(ma.Result("${name}")) Then
8798 Return ma.Result("${name}")
8804 Private Sub FollowContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowContextMenuItem.Click
8805 Dim name As String = GetUserId()
8806 If name IsNot Nothing Then FollowCommand(name)
8809 Private Sub RemoveContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveContextMenuItem.Click
8810 Dim name As String = GetUserId()
8811 If name IsNot Nothing Then RemoveCommand(name, False)
8814 Private Sub FriendshipContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipContextMenuItem.Click
8815 Dim name As String = GetUserId()
8816 If name IsNot Nothing Then ShowFriendship(name)
8819 Private Sub FriendshipAllMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipAllMenuItem.Click
8820 Dim ma As MatchCollection = Regex.Matches(Me.PostBrowser.DocumentText, "href=""https?://twitter.com/(#!/)?(?<name>[a-zA-Z0-9_]+)""")
8821 Dim ids As New List(Of String)
8822 For Each mu As Match In ma
8823 If mu.Result("${name}").ToLower <> tw.Username.ToLower Then
8824 ids.Add(mu.Result("${name}"))
8827 ShowFriendship(ids.ToArray)
8830 Private Sub ShowUserStatusContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowUserStatusContextMenuItem.Click
8831 Dim name As String = GetUserId()
8832 If name IsNot Nothing Then ShowUserStatus(name)
8835 Private Sub SearchPostsDetailToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPostsDetailToolStripMenuItem.Click
8836 Dim name As String = GetUserId()
8837 If name IsNot Nothing Then AddNewTabForSearch("from:" + name)
8840 Private Sub IdeographicSpaceToSpaceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IdeographicSpaceToSpaceToolStripMenuItem.Click
8841 _modifySettingCommon = True
8844 Private Sub ToolStripFocusLockMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripFocusLockMenuItem.Click
8845 _modifySettingCommon = True
8848 Private Sub doQuote()
8851 If _curPost IsNot Nothing Then
8852 If _curPost.IsDm OrElse _
8853 Not StatusText.Enabled Then Exit Sub
8855 If _curPost.IsProtect Then
8856 MessageBox.Show("Protected.")
8859 Dim rtdata As String = _curPost.OriginalData
8860 rtdata = CreateRetweetUnofficial(rtdata)
8862 StatusText.Text = " QT @" + _curPost.Name + ": " + HttpUtility.HtmlDecode(rtdata)
8863 If _curPost.RetweetedId = 0 Then
8864 _reply_to_id = _curPost.Id
8866 _reply_to_id = _curPost.RetweetedId
8868 _reply_to_name = _curPost.Name
8870 StatusText.SelectionStart = 0
8875 Private Sub QuoteStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuoteStripMenuItem.Click, QtOpMenuItem.Click
8879 Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
8881 Dim pnl As Control = DirectCast(sender, Control).Parent
8882 If pnl Is Nothing Then Exit Sub
8883 Dim tbName As String = pnl.Parent.Text
8884 Dim tb As TabClass = _statuses.Tabs(tbName)
8885 Dim cmb As ComboBox = DirectCast(pnl.Controls("comboSearch"), ComboBox)
8886 Dim cmbLang As ComboBox = DirectCast(pnl.Controls("comboLang"), ComboBox)
8887 cmb.Text = cmb.Text.Trim
8888 ' 検索式演算子 OR についてのみ大文字しか認識しないので強制的に大文字とする
8889 Dim Quote As Boolean = False
8890 Dim buf As New StringBuilder()
8891 Dim c As Char() = cmb.Text.ToCharArray()
8892 For cnt As Integer = 0 To cmb.Text.Length - 1
8893 If cnt > cmb.Text.Length - 4 Then
8894 buf.Append(cmb.Text.Substring(cnt))
8897 If c(cnt) = CChar("""") Then
8900 If Not Quote AndAlso cmb.Text.Substring(cnt, 4).Equals(" or ", StringComparison.OrdinalIgnoreCase) Then
8908 cmb.Text = buf.ToString()
8910 tb.SearchWords = cmb.Text
8911 tb.SearchLang = cmbLang.Text
8912 If cmb.Text = "" Then
8913 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
8917 If tb.IsQueryChanged Then
8918 Dim idx As Integer = DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.IndexOf(tb.SearchWords)
8919 If idx > -1 Then DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.RemoveAt(idx)
8920 DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.Insert(0, tb.SearchWords)
8921 cmb.Text = tb.SearchWords
8923 Dim lst As DetailsListView = DirectCast(pnl.Parent.Tag, DetailsListView)
8924 lst.VirtualListSize = 0
8926 _statuses.ClearTabIds(tbName)
8927 SaveConfigsTabs() '検索条件の保存
8930 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, tbName)
8931 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
8934 Private Sub RefreshMoreStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshMoreStripMenuItem.Click, RefreshPrevOpMenuItem.Click
8939 Private Sub UndoRemoveTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoRemoveTabMenuItem.Click
8940 If _statuses.RemovedTab Is Nothing Then
8941 MessageBox.Show("There isn't removed tab.", "Undo", MessageBoxButtons.OK, MessageBoxIcon.Information)
8944 Dim tb As TabClass = _statuses.RemovedTab
8945 _statuses.RemovedTab = Nothing
8946 Dim renamed As String = tb.TabName
8947 For i As Integer = 1 To Integer.MaxValue
8948 If Not _statuses.ContainsTab(renamed) Then Exit For
8949 renamed = tb.TabName + "(" + i.ToString + ")"
8951 tb.TabName = renamed
8952 _statuses.Tabs.Add(renamed, tb)
8953 AddNewTab(renamed, False, tb.TabType)
8954 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
8959 Private Sub doMoveToRTHome()
8960 If _curList.SelectedIndices.Count > 0 Then
8961 Dim post As PostClass = GetCurTabPost(_curList.SelectedIndices(0))
8962 If post.RetweetedId > 0 Then
8963 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).RetweetedBy)
8968 Private Sub MoveToRTHomeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToRTHomeMenuItem.Click, OpenRterHomeMenuItem.Click
8972 Private Sub IdFilterAddMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IdFilterAddMenuItem.Click
8973 Dim name As String = GetUserId()
8974 If name IsNot Nothing Then
8975 Dim tabName As String = ""
8978 If _curList.SelectedIndices.Count = 0 Then Exit Sub
8981 If Not SelectTab(tabName) Then Exit Sub
8983 Dim mv As Boolean = False
8984 Dim mk As Boolean = False
8987 Dim fc As New FiltersClass
8988 fc.NameFilter = name
8989 fc.SearchBoth = True
8993 fc.SearchUrl = False
8994 _statuses.Tabs(tabName).AddFilter(fc)
8997 Me.Cursor = Cursors.WaitCursor
8998 _itemCache = Nothing
8999 _postCache = Nothing
9002 _statuses.FilterAll()
9003 For Each tb As TabPage In ListTab.TabPages
9004 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
9005 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
9006 If SettingDialog.TabIconDisp Then
9010 If SettingDialog.TabIconDisp Then
9015 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
9017 Me.Cursor = Cursors.Default
9023 Private Sub ListManageUserContextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListManageUserContextToolStripMenuItem.Click, ListManageMenuItem.Click, ListManageUserContextToolStripMenuItem2.Click, ListManageUserContextToolStripMenuItem3.Click
9026 Dim menuItem As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
9028 If menuItem.Owner Is Me.ContextMenuPostBrowser Then
9030 If user Is Nothing Then Return
9031 ElseIf Me._curPost IsNot Nothing Then
9032 user = Me._curPost.Name
9037 Dim list As ListElement = Nothing
9039 If TabInformations.GetInstance().SubscribableLists.Count = 0 Then
9040 Dim res As String = Me.tw.GetListsApi()
9043 MessageBox.Show("Failed to get lists. (" + res + ")")
9048 Using listSelectForm As New MyLists(user, Me.tw)
9049 listSelectForm.ShowDialog()
9053 Private Sub SearchControls_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
9054 Dim pnl As Control = DirectCast(sender, Control)
9055 For Each ctl As Control In pnl.Controls
9060 Private Sub SearchControls_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
9061 Dim pnl As Control = DirectCast(sender, Control)
9062 For Each ctl As Control In pnl.Controls
9067 Private Sub PublicSearchQueryMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PublicSearchQueryMenuItem.Click
9068 If ListTab.SelectedTab IsNot Nothing Then
9069 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
9070 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
9074 Private Sub UseHashtagMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UseHashtagMenuItem.Click
9075 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/search\?q=%23(?<hash>[a-zA-Z0-9_]+)$")
9077 HashMgr.SetPermanentHash("#" + m.Result("${hash}"))
9078 HashStripSplitButton.Text = HashMgr.UseHash
9079 HashToggleMenuItem.Checked = True
9080 HashToggleToolStripMenuItem.Checked = True
9082 _modifySettingCommon = True
9086 Private Sub StatusLabel_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusLabel.DoubleClick
9087 MessageBox.Show(StatusLabel.TextHistory, "Logs", MessageBoxButtons.OK, MessageBoxIcon.None)
9090 Private Sub HashManageMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HashManageMenuItem.Click, HashManageToolStripMenuItem.Click
9091 Dim rslt As DialogResult
9093 rslt = HashMgr.ShowDialog()
9094 Catch ex As Exception
9097 Me.TopMost = SettingDialog.AlwaysTop
9098 If rslt = Windows.Forms.DialogResult.Cancel Then Exit Sub
9099 If HashMgr.UseHash <> "" Then
9100 HashStripSplitButton.Text = HashMgr.UseHash
9101 HashToggleMenuItem.Checked = True
9102 HashToggleToolStripMenuItem.Checked = True
9104 HashStripSplitButton.Text = "#[-]"
9105 HashToggleMenuItem.Checked = False
9106 HashToggleToolStripMenuItem.Checked = False
9108 'If HashMgr.IsInsert AndAlso HashMgr.UseHash <> "" Then
9109 ' Dim sidx As Integer = StatusText.SelectionStart
9110 ' Dim hash As String = HashMgr.UseHash + " "
9112 ' If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
9116 ' StatusText.Text = StatusText.Text.Insert(sidx, hash)
9117 ' sidx += hash.Length
9118 ' StatusText.SelectionStart = sidx
9119 ' StatusText.Focus()
9121 _modifySettingCommon = True
9122 Me.StatusText_TextChanged(Nothing, Nothing)
9125 Private Sub HashToggleMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles HashToggleMenuItem.Click, HashToggleToolStripMenuItem.Click
9126 HashMgr.ToggleHash()
9127 If HashMgr.UseHash <> "" Then
9128 HashStripSplitButton.Text = HashMgr.UseHash
9129 HashToggleMenuItem.Checked = True
9130 HashToggleToolStripMenuItem.Checked = True
9132 HashStripSplitButton.Text = "#[-]"
9133 HashToggleMenuItem.Checked = False
9134 HashToggleToolStripMenuItem.Checked = False
9136 _modifySettingCommon = True
9137 Me.StatusText_TextChanged(Nothing, Nothing)
9140 Private Sub HashStripSplitButton_ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles HashStripSplitButton.ButtonClick
9141 HashToggleMenuItem_Click(Nothing, Nothing)
9144 Private Sub MenuItemOperate_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemOperate.DropDownOpening
9145 If ListTab.SelectedTab Is Nothing Then Exit Sub
9146 If _statuses Is Nothing OrElse _statuses.Tabs Is Nothing OrElse Not _statuses.Tabs.ContainsKey(ListTab.SelectedTab.Text) Then Exit Sub
9147 If _curPost Is Nothing Then
9148 Me.ReplyOpMenuItem.Enabled = False
9149 Me.ReplyAllOpMenuItem.Enabled = False
9150 Me.DmOpMenuItem.Enabled = False
9151 Me.ShowProfMenuItem.Enabled = False
9152 Me.ListManageMenuItem.Enabled = False
9153 Me.OpenFavOpMenuItem.Enabled = False
9154 Me.CreateTabRuleOpMenuItem.Enabled = False
9155 Me.CreateIdRuleOpMenuItem.Enabled = False
9156 Me.ReadOpMenuItem.Enabled = False
9157 Me.UnreadOpMenuItem.Enabled = False
9159 Me.ReplyOpMenuItem.Enabled = True
9160 Me.ReplyAllOpMenuItem.Enabled = True
9161 Me.DmOpMenuItem.Enabled = True
9162 Me.ShowProfMenuItem.Enabled = True
9163 Me.ListManageMenuItem.Enabled = True
9164 Me.OpenFavOpMenuItem.Enabled = True
9165 Me.CreateTabRuleOpMenuItem.Enabled = True
9166 Me.CreateIdRuleOpMenuItem.Enabled = True
9167 Me.ReadOpMenuItem.Enabled = True
9168 Me.UnreadOpMenuItem.Enabled = True
9171 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage OrElse _curPost Is Nothing OrElse _curPost.IsDm Then
9172 Me.FavOpMenuItem.Enabled = False
9173 Me.UnFavOpMenuItem.Enabled = False
9174 Me.OpenStatusOpMenuItem.Enabled = False
9175 Me.OpenFavotterOpMenuItem.Enabled = False
9176 Me.ShowRelatedStatusesMenuItem2.Enabled = False
9177 Me.RtOpMenuItem.Enabled = False
9178 Me.RtUnOpMenuItem.Enabled = False
9179 Me.QtOpMenuItem.Enabled = False
9180 Me.FavoriteRetweetMenuItem.Enabled = False
9181 Me.FavoriteRetweetUnofficialMenuItem.Enabled = False
9182 If _curPost IsNot Nothing AndAlso _curPost.IsDm Then Me.DelOpMenuItem.Enabled = True
9184 Me.FavOpMenuItem.Enabled = True
9185 Me.UnFavOpMenuItem.Enabled = True
9186 Me.OpenStatusOpMenuItem.Enabled = True
9187 Me.OpenFavotterOpMenuItem.Enabled = True
9188 Me.ShowRelatedStatusesMenuItem2.Enabled = True 'PublicSearchの時問題出るかも
9190 If _curPost.IsMe Then
9191 Me.RtOpMenuItem.Enabled = False
9192 Me.FavoriteRetweetMenuItem.Enabled = False
9193 Me.DelOpMenuItem.Enabled = True
9195 Me.DelOpMenuItem.Enabled = False
9196 If _curPost.IsProtect Then
9197 Me.RtOpMenuItem.Enabled = False
9198 Me.RtUnOpMenuItem.Enabled = False
9199 Me.QtOpMenuItem.Enabled = False
9200 Me.FavoriteRetweetMenuItem.Enabled = False
9201 Me.FavoriteRetweetUnofficialMenuItem.Enabled = False
9203 Me.RtOpMenuItem.Enabled = True
9204 Me.RtUnOpMenuItem.Enabled = True
9205 Me.QtOpMenuItem.Enabled = True
9206 Me.FavoriteRetweetMenuItem.Enabled = True
9207 Me.FavoriteRetweetUnofficialMenuItem.Enabled = True
9212 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.Favorites Then
9213 Me.RefreshPrevOpMenuItem.Enabled = True
9215 Me.RefreshPrevOpMenuItem.Enabled = False
9217 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch _
9218 OrElse _curPost Is Nothing _
9219 OrElse Not _curPost.InReplyToId > 0 Then
9220 OpenRepSourceOpMenuItem.Enabled = False
9222 OpenRepSourceOpMenuItem.Enabled = True
9224 If _curPost Is Nothing OrElse _curPost.RetweetedBy = "" Then
9225 OpenRterHomeMenuItem.Enabled = False
9227 OpenRterHomeMenuItem.Enabled = True
9231 Private Sub MenuItemTab_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemTab.DropDownOpening
9232 ContextMenuTabProperty_Opening(sender, Nothing)
9235 Public ReadOnly Property TwitterInstance() As Twitter
9242 Private Sub SplitContainer3_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer3.SplitterMoved
9243 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
9244 _mySpDis3 = SplitContainer3.SplitterDistance
9245 _modifySettingLocal = True
9249 Private Sub MenuItemEdit_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemEdit.DropDownOpening
9250 If _statuses.RemovedTab Is Nothing Then
9251 UndoRemoveTabMenuItem.Enabled = False
9253 UndoRemoveTabMenuItem.Enabled = True
9255 If ListTab.SelectedTab IsNot Nothing Then
9256 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch Then
9257 PublicSearchQueryMenuItem.Enabled = True
9259 PublicSearchQueryMenuItem.Enabled = False
9262 PublicSearchQueryMenuItem.Enabled = False
9264 If _curPost Is Nothing Then
9265 Me.CopySTOTMenuItem.Enabled = False
9266 Me.CopyURLMenuItem.Enabled = False
9267 Me.CopyUserIdStripMenuItem.Enabled = False
9269 Me.CopySTOTMenuItem.Enabled = True
9270 Me.CopyURLMenuItem.Enabled = True
9271 Me.CopyUserIdStripMenuItem.Enabled = True
9272 If _curPost.IsProtect Then Me.CopySTOTMenuItem.Enabled = False
9276 Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
9280 Private Sub UserStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserStatusToolStripMenuItem.Click
9281 Dim id As String = ""
9282 If _curPost IsNot Nothing Then
9288 Private Class GetUserInfoArgs
9289 Public tw As Tween.Twitter
9291 Public xmlbuf As String
9294 Private Sub GetUserInfo_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
9295 Dim args As GetUserInfoArgs = DirectCast(e.Argument, GetUserInfoArgs)
9296 e.Result = args.tw.GetUserInfo(args.id, args.xmlbuf)
9299 Private Overloads Sub doShowUserStatus(ByVal id As String, ByVal ShowInputDialog As Boolean)
9300 Dim result As String = ""
9301 Dim xmlbuf As String = ""
9302 Dim args As New GetUserInfoArgs
9303 If ShowInputDialog Then
9304 Using inputName As New InputTabName()
9305 inputName.FormTitle = "Show UserStatus"
9306 inputName.FormDescription = My.Resources.FRMessage1
9307 inputName.TabName = id
9308 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
9309 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
9310 id = inputName.TabName.Trim
9313 args.xmlbuf = xmlbuf
9314 Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
9315 AddressOf GetUserInfo_DoWork, _
9319 Dim ret As String = DirectCast(_info.Result, String)
9320 If String.IsNullOrEmpty(ret) Then
9321 doShowUserStatus(args.xmlbuf)
9323 MessageBox.Show(ret)
9331 args.xmlbuf = xmlbuf
9332 Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
9333 AddressOf GetUserInfo_DoWork, _
9337 Dim ret As String = DirectCast(_info.Result, String)
9338 If String.IsNullOrEmpty(ret) Then
9339 doShowUserStatus(args.xmlbuf)
9341 MessageBox.Show(ret)
9347 Private Overloads Sub doShowUserStatus(ByVal xmldata As String)
9348 Using userinfo As New ShowUserInfo()
9349 userinfo.XmlData = xmldata
9350 userinfo.ShowDialog(Me)
9354 Private Overloads Sub ShowUserStatus(ByVal id As String, ByVal ShowInputDialog As Boolean)
9355 doShowUserStatus(id, ShowInputDialog)
9358 Private Overloads Sub ShowUserStatus(ByVal id As String)
9359 doShowUserStatus(id, True)
9362 Private Sub FollowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowToolStripMenuItem.Click
9363 If NameLabel.Tag IsNot Nothing Then
9364 Dim id As String = DirectCast(NameLabel.Tag, String)
9365 If id <> tw.Username Then
9371 Private Sub UnFollowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnFollowToolStripMenuItem.Click
9372 If NameLabel.Tag IsNot Nothing Then
9373 Dim id As String = DirectCast(NameLabel.Tag, String)
9374 If id <> tw.Username Then
9375 RemoveCommand(id, False)
9380 Private Sub ShowFriendShipToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowFriendShipToolStripMenuItem.Click
9381 If NameLabel.Tag IsNot Nothing Then
9382 Dim id As String = DirectCast(NameLabel.Tag, String)
9383 If id <> tw.Username Then
9389 Private Sub ShowUserStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowUserStatusToolStripMenuItem.Click
9390 If NameLabel.Tag IsNot Nothing Then
9391 Dim id As String = DirectCast(NameLabel.Tag, String)
9392 ShowUserStatus(id, False)
9396 Private Sub SearchPostsDetailNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPostsDetailNameToolStripMenuItem.Click
9397 If NameLabel.Tag IsNot Nothing Then
9398 Dim id As String = DirectCast(NameLabel.Tag, String)
9399 AddNewTabForSearch("from:" + id)
9403 Private Sub SearchAtPostsDetailNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchAtPostsDetailNameToolStripMenuItem.Click, SearchAtPostsDetailToolStripMenuItem.Click
9404 If NameLabel.Tag IsNot Nothing Then
9405 Dim id As String = DirectCast(NameLabel.Tag, String)
9406 AddNewTabForSearch("@" + id)
9410 Private Sub ShowProfileMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowProfileMenuItem.Click, ShowProfMenuItem.Click
9411 If _curPost IsNot Nothing Then
9412 ShowUserStatus(_curPost.Name, False)
9416 Private Sub GetRetweet_DoWork(ByVal sender As Object, ByVal e As ComponentModel.DoWorkEventArgs)
9417 Dim counter As Integer = 0
9419 Dim statusid As Long
9420 If _curPost.RetweetedId > 0 Then
9421 statusid = _curPost.RetweetedId
9423 statusid = _curPost.Id
9425 tw.GetStatus_Retweeted_Count(statusid, counter)
9430 Private Sub RtCountMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtCountMenuItem.Click
9431 If _curPost IsNot Nothing Then
9432 Using _info As New FormInfo(Me, My.Resources.RtCountMenuItem_ClickText1, _
9433 AddressOf GetRetweet_DoWork)
9434 Dim retweet_count As Integer = 0
9438 retweet_count = CType(_info.Result, Integer)
9439 If retweet_count < 0 Then
9440 MessageBox.Show(My.Resources.RtCountText2)
9442 MessageBox.Show(retweet_count.ToString + My.Resources.RtCountText1)
9448 Private WithEvents _hookGlobalHotkey As HookGlobalHotkey
9451 _hookGlobalHotkey = New HookGlobalHotkey(Me)
9452 ' この呼び出しは、Windows フォーム デザイナで必要です。
9453 InitializeComponent()
9455 ' InitializeComponent() 呼び出しの後で初期化を追加します。
9457 Me._apiGauge.Control.Size = New Size(70, 22)
9458 Me._apiGauge.Control.Margin = New Padding(0, 3, 0, 2)
9459 Me._apiGauge.GaugeHeight = 8
9460 AddHandler Me._apiGauge.Control.DoubleClick, AddressOf Me.ApiInfoMenuItem_Click
9461 Me.StatusStrip1.Items.Insert(2, Me._apiGauge)
9464 Private Sub _hookGlobalHotkey_HotkeyPressed(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _hookGlobalHotkey.HotkeyPressed
9465 If (Me.WindowState = FormWindowState.Normal OrElse Me.WindowState = FormWindowState.Maximized) AndAlso Me.Visible AndAlso Form.ActiveForm Is Me Then
9468 ElseIf Form.ActiveForm Is Nothing Then
9470 If Me.WindowState = FormWindowState.Minimized Then Me.WindowState = FormWindowState.Normal
9472 Me.StatusText.Focus()
9476 Private Sub UserPicture_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.MouseEnter
9477 Me.UserPicture.Cursor = Cursors.Hand
9480 Private Sub UserPicture_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.MouseLeave
9481 Me.UserPicture.Cursor = Cursors.Default
9484 Private Sub UserPicture_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.DoubleClick
9485 If NameLabel.Tag IsNot Nothing Then
9486 OpenUriAsync("http://twitter.com/" + NameLabel.Tag.ToString)
9490 Private Sub SplitContainer2_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SplitContainer2.MouseDoubleClick
9491 Me.MultiLineMenuItem.PerformClick()
9494 Public ReadOnly Property CurPost As PostClass
9500 Public ReadOnly Property IsPreviewEnable As Boolean
9502 Return SettingDialog.PreviewEnable
9507 Private Sub ImageSelectMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageSelectMenuItem.Click
9508 If ImageSelectionPanel.Visible = True Then
9509 ImagefilePathText.CausesValidation = False
9510 TimelinePanel.Visible = True
9511 TimelinePanel.Enabled = True
9512 ImageSelectionPanel.Visible = False
9513 ImageSelectionPanel.Enabled = False
9514 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9515 ImagefilePathText.CausesValidation = True
9517 ImageSelectionPanel.Visible = True
9518 ImageSelectionPanel.Enabled = True
9519 TimelinePanel.Visible = False
9520 TimelinePanel.Enabled = False
9521 ImagefilePathText.Focus()
9525 Private Sub FilePickButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilePickButton.Click
9526 OpenFileDialog1.Filter = (New PictureService(tw)).GetFileOpenDialogFilter(ImageService)
9527 OpenFileDialog1.Title = My.Resources.PickPictureDialog1
9528 OpenFileDialog1.FileName = ""
9531 Me.AllowDrop = False
9532 If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub
9537 ImagefilePathText.Text = OpenFileDialog1.FileName
9538 ImageFromSelectedFile()
9541 Private Sub ImagefilePathText_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ImagefilePathText.Validating
9542 If ImageCancelButton.Focused Then
9543 ImagefilePathText.CausesValidation = False
9546 ImagefilePathText.Text = Trim(ImagefilePathText.Text)
9547 If ImagefilePathText.Text = "" Then
9548 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9549 ImageSelectedPicture.Tag = UploadFileType.Invalid
9551 ImageFromSelectedFile()
9555 Private Sub ImageFromSelectedFile()
9557 Dim svc As New PictureService(tw)
9558 If String.IsNullOrEmpty(Trim(ImagefilePathText.Text)) Then
9559 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9560 ImageSelectedPicture.Tag = UploadFileType.Invalid
9561 ImagefilePathText.Text = ""
9565 Dim fl As New FileInfo(Trim(ImagefilePathText.Text))
9566 If Not svc.IsValidExtension(fl.Extension.ToLower, ImageService) Then
9568 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9569 ImageSelectedPicture.Tag = UploadFileType.Invalid
9570 ImagefilePathText.Text = ""
9574 If svc.GetMaxFileSize(fl.Extension, ImageService) < fl.Length Then
9576 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9577 ImageSelectedPicture.Tag = UploadFileType.Invalid
9578 ImagefilePathText.Text = ""
9579 MessageBox.Show("File is too large.")
9583 Select Case svc.GetFileType(fl.Extension.ToLower, ImageService)
9584 Case UploadFileType.Invalid
9585 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9586 ImageSelectedPicture.Tag = UploadFileType.Invalid
9587 ImagefilePathText.Text = ""
9588 Case UploadFileType.Picture
9589 Dim img As Image = Nothing
9590 Using fs As New FileStream(ImagefilePathText.Text, FileMode.Open, FileAccess.Read)
9591 img = Image.FromStream(fs)
9594 ImageSelectedPicture.Image = (New HttpVarious).CheckValidImage( _
9598 ImageSelectedPicture.Tag = UploadFileType.Picture
9599 Case UploadFileType.MultiMedia
9600 ImageSelectedPicture.Image = My.Resources.MultiMediaImage
9601 ImageSelectedPicture.Tag = UploadFileType.MultiMedia
9603 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9604 ImageSelectedPicture.Tag = UploadFileType.Invalid
9605 ImagefilePathText.Text = ""
9608 Catch ex As FileNotFoundException
9609 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9610 ImageSelectedPicture.Tag = UploadFileType.Invalid
9611 ImagefilePathText.Text = ""
9612 MessageBox.Show("File not found.")
9613 Catch ex As Exception
9614 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9615 ImageSelectedPicture.Tag = UploadFileType.Invalid
9616 ImagefilePathText.Text = ""
9617 MessageBox.Show("The type of this file is not image.")
9621 Private Sub ImageSelection_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _
9622 ImagefilePathText.KeyDown, _
9623 FilePickButton.KeyDown, _
9624 ImageServiceCombo.KeyDown
9625 If e.KeyCode = Keys.Escape Then
9626 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9627 ImageSelectedPicture.Tag = UploadFileType.Invalid
9628 TimelinePanel.Visible = True
9629 TimelinePanel.Enabled = True
9630 ImageSelectionPanel.Visible = False
9631 ImageSelectionPanel.Enabled = False
9632 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9633 ImagefilePathText.CausesValidation = True
9637 Private Sub ImageSelection_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
9638 ImagefilePathText.KeyPress, _
9639 FilePickButton.KeyPress, _
9640 ImageServiceCombo.KeyPress
9641 If Convert.ToInt32(e.KeyChar) = &H1B Then
9642 ImagefilePathText.CausesValidation = False
9647 Private Sub ImageSelection_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles _
9648 ImagefilePathText.PreviewKeyDown, _
9649 FilePickButton.PreviewKeyDown, _
9650 ImageServiceCombo.PreviewKeyDown
9651 If e.KeyCode = Keys.Escape Then
9652 ImagefilePathText.CausesValidation = False
9656 Private Sub SetImageServiceCombo()
9657 Dim svc As String = ""
9658 If ImageServiceCombo.SelectedIndex > -1 Then svc = ImageServiceCombo.SelectedItem.ToString
9659 ImageServiceCombo.Items.Clear()
9660 If SettingDialog.IsOAuth Then
9661 ImageServiceCombo.Items.Add("TwitPic")
9662 ImageServiceCombo.Items.Add("img.ly")
9663 ImageServiceCombo.Items.Add("yfrog")
9665 ImageServiceCombo.Items.Add("TwitVideo")
9667 ImageServiceCombo.SelectedIndex = 0
9669 Dim idx As Integer = ImageServiceCombo.Items.IndexOf(svc)
9671 ImageServiceCombo.SelectedIndex = 0
9673 ImageServiceCombo.SelectedIndex = idx
9678 Private ReadOnly Property ImageService() As String
9680 Return CStr(ImageServiceCombo.SelectedItem)
9684 Private Sub ImageCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageCancelButton.Click
9685 ImagefilePathText.CausesValidation = False
9686 TimelinePanel.Visible = True
9687 TimelinePanel.Enabled = True
9688 ImageSelectionPanel.Visible = False
9689 ImageSelectionPanel.Enabled = False
9690 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9691 ImagefilePathText.CausesValidation = True
9694 Private Sub ImageServiceCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageServiceCombo.SelectedIndexChanged
9695 If ImageSelectedPicture.Tag IsNot Nothing Then
9696 Dim svc As New PictureService(tw)
9698 Dim fi As New FileInfo(ImagefilePathText.Text.Trim)
9699 If Not (svc.IsValidExtension(fi.Extension, ImageService) AndAlso _
9700 svc.GetMaxFileSize(fi.Extension, ImageService) >= fi.Length) Then
9701 ImagefilePathText.Text = ""
9702 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9703 ImageSelectedPicture.Tag = UploadFileType.Invalid
9705 Catch ex As Exception
9712 Private Sub ListManageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListManageToolStripMenuItem.Click
9713 Using form As New ListManage(tw)
9718 Public WriteOnly Property ModifySettingCommon() As Boolean
9719 Set(ByVal value As Boolean)
9720 _modifySettingCommon = value
9724 Public WriteOnly Property ModifySettingLocal() As Boolean
9725 Set(ByVal value As Boolean)
9726 _modifySettingLocal = value
9730 Public WriteOnly Property ModifySettingAtId() As Boolean
9731 Set(ByVal value As Boolean)
9732 _modifySettingAtId = value
9736 Private Sub SourceLinkLabel_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles SourceLinkLabel.LinkClicked
9737 Dim link As String = CType(SourceLinkLabel.Tag, String)
9738 If Not String.IsNullOrEmpty(link) Then
9743 Private Sub SourceLinkLabel_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SourceLinkLabel.MouseEnter
9744 Dim link As String = CType(SourceLinkLabel.Tag, String)
9745 If Not String.IsNullOrEmpty(link) Then
9746 StatusLabelUrl.Text = link
9750 Private Sub SourceLinkLabel_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SourceLinkLabel.MouseLeave
9754 Private Sub SourceLinkLabel_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SourceLinkLabel.Enter
9758 Private Sub MenuItemCommand_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemCommand.DropDownOpening
9759 If _curPost IsNot Nothing AndAlso Not _curPost.IsDm Then
9760 RtCountMenuItem.Enabled = True
9762 RtCountMenuItem.Enabled = False
9766 Private Sub CopyUserIdStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyUserIdStripMenuItem.Click
9769 Private Sub CopyUserId()
9770 If _curPost Is Nothing Then Exit Sub
9771 Dim clstr As String = _curPost.Name
9773 Clipboard.SetDataObject(clstr, False, 5, 100)
9774 Catch ex As Exception
9775 MessageBox.Show(ex.Message)
9779 Private Sub ShowRelatedStatusesMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowRelatedStatusesMenuItem.Click, ShowRelatedStatusesMenuItem2.Click
9780 If _curPost IsNot Nothing AndAlso Not _curPost.IsDm Then
9781 'PublicSearchも除外した方がよい?
9782 If _statuses.GetTabByType(TabUsageType.Related) Is Nothing Then
9783 Const TabName As String = "Related Tweets"
9784 Dim tName As String = TabName
9785 If Not Me.AddNewTab(tName, False, TabUsageType.Related) Then
9786 For i As Integer = 2 To 100
9787 tName = TabName + i.ToString()
9788 If Me.AddNewTab(tName, False, TabUsageType.Related) Then
9789 _statuses.AddTab(tName, TabUsageType.Related, Nothing)
9794 _statuses.AddTab(tName, TabUsageType.Related, Nothing)
9798 Dim tb As TabClass = _statuses.GetTabByType(TabUsageType.Related)
9799 tb.RelationTargetPost = _curPost
9800 Me.ClearTab(tb.TabName, False)
9801 For i As Integer = 0 To ListTab.TabPages.Count - 1
9802 If tb.TabName = ListTab.TabPages(i).Text Then
9803 ListTab.SelectedIndex = i
9804 ListTabSelect(ListTab.TabPages(i))
9809 GetTimeline(WORKERTYPE.Related, 1, 1, tb.TabName)
9813 Private Sub CacheInfoMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CacheInfoMenuItem.Click
9814 Dim buf As New StringBuilder
9815 buf.AppendFormat("キャッシュメモリ容量 : {0}bytes({1}MB)" + vbCrLf, DirectCast(TIconDic, ImageDictionary).CacheMemoryLimit, DirectCast(TIconDic, ImageDictionary).CacheMemoryLimit / 1048576)
9816 buf.AppendFormat("物理メモリ使用割合 : {0}%" + vbCrLf, DirectCast(TIconDic, ImageDictionary).PhysicalMemoryLimit)
9817 buf.AppendFormat("キャッシュエントリ保持数 : {0}" + vbCrLf, DirectCast(TIconDic, ImageDictionary).CacheCount)
9818 buf.AppendFormat("キャッシュエントリ破棄数 : {0}" + vbCrLf, DirectCast(TIconDic, ImageDictionary).CacheRemoveCount)
9819 MessageBox.Show(buf.ToString, "アイコンキャッシュ使用状況")
9822 Private Sub tw_PostDeleted(ByVal id As Long)
9823 _statuses.RemovePostReserve(id)
9826 Private Sub tw_NewPostFromStream()
9827 If SettingDialog.ReadOldPosts Then
9828 _statuses.SetRead() '新着時未読クリア
9831 Dim rsltAddCount As Integer = _statuses.DistributePosts()
9832 SyncLock _syncObject
9833 Dim tm As Date = Now
9834 If _tlTimestamps.ContainsKey(tm) Then
9835 _tlTimestamps(tm) += rsltAddCount
9837 _tlTimestamps.Add(Now, rsltAddCount)
9839 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
9840 Dim keys As New List(Of Date)
9842 For Each key As Date In _tlTimestamps.Keys
9843 If key.CompareTo(oneHour) < 0 Then
9846 _tlCount += _tlTimestamps(key)
9849 For Each key As Date In keys
9850 _tlTimestamps.Remove(key)
9854 'Static before As DateTime = Now
9855 'If before.Subtract(Now).Seconds > -5 Then Exit Sub
9859 If SettingDialog.UserstreamPeriodInt > 0 Then Exit Sub
9862 If InvokeRequired AndAlso Not IsDisposed Then
9863 Invoke(New Action(Of Boolean)(AddressOf RefreshTimeline), True)
9866 Catch ex As ObjectDisposedException
9870 Private Sub tw_UserStreamStarted()
9871 If InvokeRequired Then
9872 Invoke(New MethodInvoker(AddressOf tw_UserStreamStarted))
9876 MenuItemUserStream.Text = "&UserStream ▶"
9877 MenuItemUserStream.Enabled = True
9878 PauseToolStripMenuItem.Text = "&Pause"
9879 PauseToolStripMenuItem.Enabled = True
9880 StopToolStripMenuItem.Text = "&Stop"
9881 StopToolStripMenuItem.Enabled = True
9883 StatusLabel.Text = "UserStream Started."
9886 Private Sub tw_UserStreamStopped()
9887 If InvokeRequired Then
9888 Invoke(New MethodInvoker(AddressOf tw_UserStreamStopped))
9892 MenuItemUserStream.Text = "&UserStream ■"
9893 MenuItemUserStream.Enabled = True
9894 PauseToolStripMenuItem.Text = "&Pause"
9895 PauseToolStripMenuItem.Enabled = False
9896 StopToolStripMenuItem.Text = "&Start"
9897 StopToolStripMenuItem.Enabled = True
9899 StatusLabel.Text = "UserStream Stopped."
9902 Private Sub tw_UserStreamPaused()
9903 If InvokeRequired Then
9904 Invoke(New MethodInvoker(AddressOf tw_UserStreamPaused))
9908 MenuItemUserStream.Text = "&UserStream ||"
9909 MenuItemUserStream.Enabled = True
9910 PauseToolStripMenuItem.Text = "&Resume"
9911 PauseToolStripMenuItem.Enabled = True
9912 StopToolStripMenuItem.Text = "&Stop"
9913 StopToolStripMenuItem.Enabled = True
9915 StatusLabel.Text = "UserStream Paused."
9918 'Private ReadOnly Property IsReceivedUserStream As Boolean
9920 ' Static lastTime As DateTime
9921 ' Dim changed As Boolean = (lastTime.CompareTo(tw.LastReceivedUserStream) < 0)
9922 ' lastTime = tw.LastReceivedUserStream
9927 Private Sub PauseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PauseToolStripMenuItem.Click
9928 MenuItemUserStream.Enabled = False
9929 tw.PauseUserStream()
9932 Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
9933 MenuItemUserStream.Enabled = False
9934 tw.StartUserStream()
9937 Private Sub TrackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackToolStripMenuItem.Click
9938 Static inputTrack As String = ""
9939 If TrackToolStripMenuItem.Checked Then
9940 Using inputForm As New InputTabName
9941 inputForm.TabName = inputTrack
9942 inputForm.FormTitle = "Input track word"
9943 inputForm.FormDescription = "Track word"
9944 If inputForm.ShowDialog() <> Windows.Forms.DialogResult.OK Then
9945 TrackToolStripMenuItem.Checked = False
9948 inputTrack = inputForm.TabName.Trim()
9950 If Not inputTrack.Equals(tw.TrackWord) Then
9951 tw.TrackWord = inputTrack
9952 Me._modifySettingCommon = True
9953 TrackToolStripMenuItem.Checked = Not String.IsNullOrEmpty(inputTrack)
9954 tw.ReconnectUserStream()
9958 tw.ReconnectUserStream()
9962 Private Sub AllrepliesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllrepliesToolStripMenuItem.Click
9963 tw.AllAtReply = AllrepliesToolStripMenuItem.Checked
9964 Me._modifySettingCommon = True
9965 tw.ReconnectUserStream()
9968 Private Sub TweenRestartMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TweenRestartMenuItem.Click
9970 Application.Restart()
9973 Private Sub OpenOwnFavedMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenOwnFavedMenuItem.Click
9974 If Not tw.Username = "" Then OpenUriAsync(My.Resources.FavstarUrl + "users/" + tw.Username + "/recent")
9977 Private Sub OpenOwnHomeMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenOwnHomeMenuItem.Click
9978 OpenUriAsync("http://twitter.com/" + tw.Username)