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 Private 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 String) '発言履歴
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 _statuses As TabInformations
169 Private _itemCache() As ListViewItem
170 Private _itemCacheIndex As Integer
171 Private _postCache() As PostClass
172 Private _curTab As TabPage
173 Private _curItemIndex As Integer
174 Private _curList As DetailsListView
175 Private _curPost As PostClass
176 Private _isColumnChanged As Boolean = False
177 'Private _waitFollower As Boolean = False
178 Private _waitTimeline As Boolean = False
179 Private _waitReply As Boolean = False
180 Private _waitDm As Boolean = False
181 Private _waitFav As Boolean = False
182 Private _waitPubSearch As Boolean = False
183 Private _waitLists As Boolean = False
184 Private _bw(18) As BackgroundWorker
185 Private _bwFollower As BackgroundWorker
186 Private cMode As Integer
187 Private shield As New ShieldIcon
188 Private SecurityManager As InternetSecurityManager
189 Private Thumbnail As Thumbnail
191 Private _homeCounter As Integer = 0
192 Private _homeCounterAdjuster As Integer = 0
193 Private _mentionCounter As Integer = 0
194 Private _dmCounter As Integer = 0
195 Private _pubSearchCounter As Integer = 0
196 Private _listsCounter As Integer = 0
198 Private UnreadCounter As Integer = -1
199 Private UnreadAtCounter As Integer = -1
201 Private ColumnOrgText(8) As String
202 Private ColumnText(8) As String
204 '''''''''''''''''''''''''''''''''''''''''''''''''''''
205 Private _postBrowserStatusText As String = ""
207 Private _colorize As Boolean = False
209 Private WithEvents TimerTimeline As New System.Timers.Timer
212 Private Structure urlUndo
213 Public Before As String
214 Public After As String
217 Private urlUndoBuffer As Generic.List(Of urlUndo) = Nothing
219 Private Structure ReplyChain
220 Public OriginalId As Long
221 Public InReplyToId As Long
222 Public OriginalTab As TabPage
224 Sub New(ByVal originalId As Long, ByVal inReplyToId As Long, ByVal originalTab As TabPage)
225 Me.OriginalId = originalId
226 Me.InReplyToId = inReplyToId
227 Me.OriginalTab = originalTab
231 Private replyChains As Stack(Of ReplyChain)
233 'Backgroundworkerの処理結果通知用引数構造体
234 Private Class GetWorkerResult
235 Public retMsg As String = "" '処理結果詳細メッセージ。エラー時に値がセットされる
236 Public page As Integer '取得対象ページ番号
237 Public endPage As Integer '取得終了ページ番号(継続可能ならインクリメントされて返る。pageと比較して継続判定)
238 Public type As WORKERTYPE '処理種別
239 Public imgs As Dictionary(Of String, Image) '新規取得したアイコンイメージ
240 Public tName As String = "" 'Fav追加・削除時のタブ名
241 Public ids As List(Of Long) 'Fav追加・削除時のID
242 Public sIds As List(Of Long) 'Fav追加・削除成功分のID
243 Public newDM As Boolean
244 Public addCount As Integer
245 Public status As PostingStatus
248 'Backgroundworkerへ処理内容を通知するための引数用構造体
249 Private Class GetWorkerArg
250 Public page As Integer '処理対象ページ番号
251 Public endPage As Integer '処理終了ページ番号(起動時の読み込みページ数。通常時はpageと同じ値をセット)
252 Public type As WORKERTYPE '処理種別
253 Public url As String = "" 'URLをブラウザで開くときのアドレス
254 Public status As New PostingStatus '発言POST時の発言内容
255 Public ids As List(Of Long) 'Fav追加・削除時のItemIndex
256 Public sIds As List(Of Long) 'Fav追加・削除成功分のItemIndex
257 Public tName As String = "" 'Fav追加・削除時のタブ名
261 Private Enum SEARCHTYPE
267 Private Class PostingStatus
268 Public status As String = ""
269 Public inReplyToId As Long = 0
270 Public inReplyToName As String = ""
271 Public imageService As String = "" '画像投稿サービス名
272 Public imagePath As String = ""
275 Private Class SpaceKeyCanceler
276 Inherits NativeWindow
277 Implements IDisposable
279 Dim WM_KEYDOWN As Integer = &H100
280 Dim VK_SPACE As Integer = &H20
282 Public Sub New(ByVal control As Control)
283 Me.AssignHandle(control.Handle)
286 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
287 If (m.Msg = WM_KEYDOWN) AndAlso (CInt(m.WParam) = VK_SPACE) Then
288 RaiseEvent SpaceCancel(Me, EventArgs.Empty)
295 Public Event SpaceCancel As EventHandler
297 Public Sub Dispose() Implements IDisposable.Dispose
302 Private Sub TweenMain_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
303 '画面がアクティブになったら、発言欄の背景色戻す
304 If StatusText.Focused Then
305 Me.StatusText_Enter(Me.StatusText, System.EventArgs.Empty)
309 Private Sub TweenMain_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
311 SettingDialog.Dispose()
313 SearchDialog.Dispose()
316 _spaceKeyCanceler.Dispose()
317 If TIconDic IsNot Nothing AndAlso TIconDic.Keys.Count > 0 Then
318 For Each value As Image In TIconDic.Values
322 If NIconAt IsNot Nothing Then NIconAt.Dispose()
323 If NIconAtRed IsNot Nothing Then NIconAtRed.Dispose()
324 If NIconAtSmoke IsNot Nothing Then NIconAtSmoke.Dispose()
325 If NIconRefresh(0) IsNot Nothing Then NIconRefresh(0).Dispose()
326 If NIconRefresh(1) IsNot Nothing Then NIconRefresh(1).Dispose()
327 If NIconRefresh(2) IsNot Nothing Then NIconRefresh(2).Dispose()
328 If NIconRefresh(3) IsNot Nothing Then NIconRefresh(3).Dispose()
329 If TabIcon IsNot Nothing Then TabIcon.Dispose()
330 If MainIcon IsNot Nothing Then MainIcon.Dispose()
331 If ReplyIcon IsNot Nothing Then ReplyIcon.Dispose()
332 If ReplyIconBlink IsNot Nothing Then ReplyIconBlink.Dispose()
333 _brsHighLight.Dispose()
334 _brsHighLightText.Dispose()
335 If _brsForeColorUnread IsNot Nothing Then _brsForeColorUnread.Dispose()
336 If _brsForeColorReaded IsNot Nothing Then _brsForeColorReaded.Dispose()
337 If _brsForeColorFav IsNot Nothing Then _brsForeColorFav.Dispose()
338 If _brsForeColorOWL IsNot Nothing Then _brsForeColorOWL.Dispose()
339 If _brsForeColorRetweet IsNot Nothing Then _brsForeColorRetweet.Dispose()
340 If _brsBackColorMine IsNot Nothing Then _brsBackColorMine.Dispose()
341 If _brsBackColorAt IsNot Nothing Then _brsBackColorAt.Dispose()
342 If _brsBackColorYou IsNot Nothing Then _brsBackColorYou.Dispose()
343 If _brsBackColorAtYou IsNot Nothing Then _brsBackColorAtYou.Dispose()
344 If _brsBackColorAtFromTarget IsNot Nothing Then _brsBackColorAtFromTarget.Dispose()
345 If _brsBackColorAtTo IsNot Nothing Then _brsBackColorAtTo.Dispose()
346 If _brsBackColorNone IsNot Nothing Then _brsBackColorNone.Dispose()
347 If _brsDeactiveSelection IsNot Nothing Then _brsDeactiveSelection.Dispose()
351 For Each bw As BackgroundWorker In _bw
352 If bw IsNot Nothing Then
356 If _bwFollower IsNot Nothing Then
357 _bwFollower.Dispose()
361 Private Sub LoadIcon(ByRef IconInstance As Icon, ByVal FileName As String)
362 Dim dir As String = Application.StartupPath
363 If File.Exists(Path.Combine(dir, FileName)) Then
365 IconInstance = New Icon(Path.Combine(dir, FileName))
366 Catch ex As Exception
371 Private Sub LoadIcons()
374 Dim dir As String = Application.StartupPath
376 NIconAt = My.Resources.At
377 NIconAtRed = My.Resources.AtRed
378 NIconAtSmoke = My.Resources.AtSmoke
379 NIconRefresh(0) = My.Resources.Refresh
380 NIconRefresh(1) = My.Resources.Refresh2
381 NIconRefresh(2) = My.Resources.Refresh3
382 NIconRefresh(3) = My.Resources.Refresh4
383 TabIcon = My.Resources.TabIcon
384 MainIcon = My.Resources.MIcon
385 ReplyIcon = My.Resources.Reply
386 ReplyIconBlink = My.Resources.ReplyBlink
388 If Not Directory.Exists(Path.Combine(dir, "Icons")) Then
392 LoadIcon(NIconAt, "Icons\At.ico")
395 LoadIcon(NIconAtRed, "Icons\AtRed.ico")
398 LoadIcon(NIconAtSmoke, "Icons\AtSmoke.ico")
402 LoadIcon(NIconRefresh(0), "Icons\Refresh.ico")
403 LoadIcon(NIconRefresh(1), "Icons\Refresh2.ico")
404 LoadIcon(NIconRefresh(2), "Icons\Refresh3.ico")
405 LoadIcon(NIconRefresh(3), "Icons\Refresh4.ico")
408 LoadIcon(TabIcon, "Icons\Tab.ico")
411 LoadIcon(MainIcon, "Icons\MIcon.ico")
414 LoadIcon(ReplyIcon, "Icons\Reply.ico")
417 LoadIcon(ReplyIconBlink, "Icons\ReplyBlink.ico")
420 Private Sub InitColumnText()
423 ColumnText(1) = My.Resources.AddNewTabText2
424 ColumnText(2) = My.Resources.AddNewTabText3
425 ColumnText(3) = My.Resources.AddNewTabText4_2
426 ColumnText(4) = My.Resources.AddNewTabText5
429 ColumnText(7) = "Source"
431 ColumnOrgText(0) = ""
432 ColumnOrgText(1) = My.Resources.AddNewTabText2
433 ColumnOrgText(2) = My.Resources.AddNewTabText3
434 ColumnOrgText(3) = My.Resources.AddNewTabText4_2
435 ColumnOrgText(4) = My.Resources.AddNewTabText5
436 ColumnOrgText(5) = ""
437 ColumnOrgText(6) = ""
438 ColumnOrgText(7) = "Source"
441 Select Case _statuses.SortMode
442 Case IdComparerClass.ComparerMode.Nickname 'ニックネーム
444 Case IdComparerClass.ComparerMode.Data '本文
446 Case IdComparerClass.ComparerMode.Id '時刻=発言Id
448 Case IdComparerClass.ComparerMode.Name '名前
450 Case IdComparerClass.ComparerMode.Source 'Source
455 If _statuses.SortOrder() = SortOrder.Descending Then
456 ' U+25BE BLACK DOWN-POINTING SMALL TRIANGLE
457 ColumnText(2) = ColumnOrgText(2) + "▾"
459 ' U+25B4 BLACK UP-POINTING SMALL TRIANGLE
460 ColumnText(2) = ColumnOrgText(2) + "▴"
463 If _statuses.SortOrder() = SortOrder.Descending Then
464 ' U+25BE BLACK DOWN-POINTING SMALL TRIANGLE
465 ColumnText(c) = ColumnOrgText(c) + "▾"
467 ' U+25B4 BLACK UP-POINTING SMALL TRIANGLE
468 ColumnText(c) = ColumnOrgText(c) + "▴"
473 Private Sub InitializeTraceFrag()
475 TraceOutToolStripMenuItem.Checked = True
478 If Not fileVersion.EndsWith("0") Then
479 TraceOutToolStripMenuItem.Checked = True
484 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
485 _ignoreConfigSave = True
487 SecurityManager = New InternetSecurityManager(PostBrowser)
488 Thumbnail = New Thumbnail(Me)
490 AddHandler TwitterApiInfo.Changed, AddressOf SetStatusLabelApiHandler
492 VerUpMenuItem.Image = shield.Icon
493 If Not My.Application.CommandLineArgs.Count = 0 AndAlso My.Application.CommandLineArgs.Contains("/d") Then TraceFlag = True
495 Me._spaceKeyCanceler = New SpaceKeyCanceler(Me.PostButton)
496 AddHandler Me._spaceKeyCanceler.SpaceCancel, AddressOf spaceKeyCanceler_SpaceCancel
498 Regex.CacheSize = 100
500 fileVersion = DirectCast(Assembly.GetExecutingAssembly().GetCustomAttributes(GetType(AssemblyFileVersionAttribute), False)(0), AssemblyFileVersionAttribute).Version
501 InitializeTraceFrag()
502 LoadIcons() ' アイコン読み込み
505 _statuses = TabInformations.GetInstance()
508 Me.Icon = MainIcon 'メインフォーム(TweenMain)
509 NotifyIcon1.Icon = NIconAt 'タスクトレイ
510 TabImage.Images.Add(TabIcon) 'タブ見出し
512 SettingDialog.Owner = Me
513 SearchDialog.Owner = Me
523 '<<<<<<<<<設定関連>>>>>>>>>
530 NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop
531 Me.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked
534 _fntUnread = _cfgLocal.FontUnread
535 _clUnread = _cfgLocal.ColorUnread
536 _fntReaded = _cfgLocal.FontRead
537 _clReaded = _cfgLocal.ColorRead
538 _clFav = _cfgLocal.ColorFav
539 _clOWL = _cfgLocal.ColorOWL
540 _clRetweet = _cfgLocal.ColorRetweet
541 _fntDetail = _cfgLocal.FontDetail
542 _clDetail = _cfgLocal.ColorDetail
543 _clDetailLink = _cfgLocal.ColorDetailLink
544 _clDetailBackcolor = _cfgLocal.ColorDetailBackcolor
545 _clSelf = _cfgLocal.ColorSelf
546 _clAtSelf = _cfgLocal.ColorAtSelf
547 _clTarget = _cfgLocal.ColorTarget
548 _clAtTarget = _cfgLocal.ColorAtTarget
549 _clAtFromTarget = _cfgLocal.ColorAtFromTarget
550 _clAtTo = _cfgLocal.ColorAtTo
551 _clListBackcolor = _cfgLocal.ColorListBackcolor
552 _clInputBackcolor = _cfgLocal.ColorInputBackcolor
553 _clInputFont = _cfgLocal.ColorInputFont
554 _fntInputFont = _cfgLocal.FontInputFont
556 _brsForeColorUnread = New SolidBrush(_clUnread)
557 _brsForeColorReaded = New SolidBrush(_clReaded)
558 _brsForeColorFav = New SolidBrush(_clFav)
559 _brsForeColorOWL = New SolidBrush(_clOWL)
560 _brsForeColorRetweet = New SolidBrush(_clRetweet)
561 _brsBackColorMine = New SolidBrush(_clSelf)
562 _brsBackColorAt = New SolidBrush(_clAtSelf)
563 _brsBackColorYou = New SolidBrush(_clTarget)
564 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
565 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
566 _brsBackColorAtTo = New SolidBrush(_clAtTo)
567 '_brsBackColorNone = New SolidBrush(Color.FromKnownColor(KnownColor.Window))
568 _brsBackColorNone = New SolidBrush(_clListBackcolor)
570 ' StringFormatオブジェクトへの事前設定
571 sf.Alignment = StringAlignment.Near
572 sf.LineAlignment = StringAlignment.Near
573 sfTab.Alignment = StringAlignment.Center
574 sfTab.LineAlignment = StringAlignment.Center
577 SettingDialog.IsOAuth = _cfgCommon.IsOAuth
578 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
579 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
580 SettingDialog.TwitterApiUrl = _cfgCommon.TwitterUrl
581 SettingDialog.TwitterSearchApiUrl = _cfgCommon.TwitterSearchUrl
583 If _cfgCommon.IsOAuth Then
584 If _cfgCommon.Token = "" Then _cfgCommon.UserName = ""
585 tw.Initialize(_cfgCommon.Token, _cfgCommon.TokenSecret, _cfgCommon.UserName)
587 tw.Initialize(_cfgCommon.UserName, _cfgCommon.Password)
590 SettingDialog.TimelinePeriodInt = _cfgCommon.TimelinePeriod
591 SettingDialog.ReplyPeriodInt = _cfgCommon.ReplyPeriod
592 SettingDialog.DMPeriodInt = _cfgCommon.DMPeriod
593 SettingDialog.PubSearchPeriodInt = _cfgCommon.PubSearchPeriod
594 SettingDialog.ListsPeriodInt = _cfgCommon.ListsPeriod
596 If Not My.Application.CommandLineArgs.Contains("nolimit") Then
597 If SettingDialog.TimelinePeriodInt < 15 AndAlso SettingDialog.TimelinePeriodInt > 0 Then SettingDialog.TimelinePeriodInt = 15
598 If SettingDialog.ReplyPeriodInt < 15 AndAlso SettingDialog.ReplyPeriodInt > 0 Then SettingDialog.ReplyPeriodInt = 15
599 If SettingDialog.DMPeriodInt < 15 AndAlso SettingDialog.DMPeriodInt > 0 Then SettingDialog.DMPeriodInt = 15
600 If SettingDialog.PubSearchPeriodInt < 30 AndAlso SettingDialog.PubSearchPeriodInt > 0 Then SettingDialog.PubSearchPeriodInt = 30
601 If SettingDialog.ListsPeriodInt < 15 AndAlso SettingDialog.ListsPeriodInt > 0 Then SettingDialog.ListsPeriodInt = 15
604 '起動時読み込み分を既読にするか。Trueなら既読として処理
605 SettingDialog.Readed = _cfgCommon.Read
606 '新着取得時のリストスクロールをするか。Trueならスクロールしない
607 ListLockMenuItem.Checked = _cfgCommon.ListLock
608 Me.LockListFileMenuItem.Checked = _cfgCommon.ListLock
609 SettingDialog.IconSz = _cfgCommon.IconSize
611 SettingDialog.Status = _cfgLocal.StatusText
613 SettingDialog.UnreadManage = _cfgCommon.UnreadManage
615 SettingDialog.PlaySound = _cfgCommon.PlaySound
616 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
617 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
619 SettingDialog.OneWayLove = _cfgCommon.OneWayLove
621 SettingDialog.FontUnread = _fntUnread
622 SettingDialog.ColorUnread = _clUnread
623 SettingDialog.FontReaded = _fntReaded
624 SettingDialog.ColorReaded = _clReaded
625 SettingDialog.ColorFav = _clFav
626 SettingDialog.ColorOWL = _clOWL
627 SettingDialog.ColorRetweet = _clRetweet
628 SettingDialog.FontDetail = _fntDetail
629 SettingDialog.ColorDetail = _clDetail
630 SettingDialog.ColorDetailLink = _clDetailLink
631 SettingDialog.ColorDetailBackcolor = _clDetailBackcolor
632 SettingDialog.ColorSelf = _clSelf
633 SettingDialog.ColorAtSelf = _clAtSelf
634 SettingDialog.ColorTarget = _clTarget
635 SettingDialog.ColorAtTarget = _clAtTarget
636 SettingDialog.ColorAtFromTarget = _clAtFromTarget
637 SettingDialog.ColorAtTo = _clAtTo
638 SettingDialog.ColorListBackcolor = _clListBackcolor
639 SettingDialog.ColorInputBackcolor = _clInputBackcolor
640 SettingDialog.ColorInputFont = _clInputFont
641 SettingDialog.FontInputFont = _fntInputFont
643 SettingDialog.NameBalloon = _cfgCommon.NameBalloon
644 SettingDialog.PostCtrlEnter = _cfgCommon.PostCtrlEnter
647 SettingDialog.CountApi = _cfgCommon.CountApi
648 SettingDialog.CountApiReply = _cfgCommon.CountApiReply
649 If SettingDialog.CountApi < 20 OrElse SettingDialog.CountApi > 200 Then SettingDialog.CountApi = 60
650 If SettingDialog.CountApiReply < 20 OrElse SettingDialog.CountApiReply > 200 Then SettingDialog.CountApiReply = 40
652 SettingDialog.BrowserPath = _cfgLocal.BrowserPath
653 SettingDialog.PostAndGet = _cfgCommon.PostAndGet
654 SettingDialog.UseRecommendStatus = _cfgLocal.UseRecommendStatus
655 SettingDialog.DispUsername = _cfgCommon.DispUsername
656 SettingDialog.CloseToExit = _cfgCommon.CloseToExit
657 SettingDialog.MinimizeToTray = _cfgCommon.MinimizeToTray
658 SettingDialog.DispLatestPost = _cfgCommon.DispLatestPost
659 SettingDialog.SortOrderLock = _cfgCommon.SortOrderLock
660 SettingDialog.TinyUrlResolve = _cfgCommon.TinyUrlResolve
662 SettingDialog.SelectedProxyType = _cfgLocal.ProxyType
663 SettingDialog.ProxyAddress = _cfgLocal.ProxyAddress
664 SettingDialog.ProxyPort = _cfgLocal.ProxyPort
665 SettingDialog.ProxyUser = _cfgLocal.ProxyUser
666 SettingDialog.ProxyPassword = _cfgLocal.ProxyPassword
668 SettingDialog.PeriodAdjust = _cfgCommon.PeriodAdjust
669 SettingDialog.StartupVersion = _cfgCommon.StartupVersion
670 SettingDialog.StartupFollowers = _cfgCommon.StartupFollowers
671 SettingDialog.RestrictFavCheck = _cfgCommon.RestrictFavCheck
672 SettingDialog.AlwaysTop = _cfgCommon.AlwaysTop
673 SettingDialog.UrlConvertAuto = _cfgCommon.UrlConvertAuto
675 SettingDialog.OutputzEnabled = _cfgCommon.Outputz
676 SettingDialog.OutputzKey = _cfgCommon.OutputzKey
677 SettingDialog.OutputzUrlmode = _cfgCommon.OutputzUrlMode
679 SettingDialog.UseUnreadStyle = _cfgCommon.UseUnreadStyle
680 SettingDialog.DefaultTimeOut = _cfgCommon.DefaultTimeOut
681 SettingDialog.ProtectNotInclude = _cfgCommon.ProtectNotInclude
682 SettingDialog.PlaySound = _cfgCommon.PlaySound
683 SettingDialog.DateTimeFormat = _cfgCommon.DateTimeFormat
684 SettingDialog.LimitBalloon = _cfgCommon.LimitBalloon
685 SettingDialog.AutoShortUrlFirst = _cfgCommon.AutoShortUrlFirst
686 SettingDialog.TabIconDisp = _cfgCommon.TabIconDisp
687 SettingDialog.ReplyIconState = _cfgCommon.ReplyIconState
688 SettingDialog.ReadOwnPost = _cfgCommon.ReadOwnPost
689 SettingDialog.GetFav = _cfgCommon.GetFav
690 SettingDialog.ReadOldPosts = _cfgCommon.ReadOldPosts
691 SettingDialog.UseSsl = _cfgCommon.UseSsl
692 SettingDialog.BitlyUser = _cfgCommon.BilyUser
693 SettingDialog.BitlyPwd = _cfgCommon.BitlyPwd
694 SettingDialog.ShowGrid = _cfgCommon.ShowGrid
695 SettingDialog.Language = _cfgCommon.Language
696 SettingDialog.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement
697 SettingDialog.UseHashSupplement = _cfgCommon.UseHashSupplement
698 SettingDialog.PreviewEnable = _cfgCommon.PreviewEnable
699 AtIdSupl = New AtIdSupplement(SettingAtIdList.Load().AtIdList, "@")
701 SettingDialog.IsMonospace = _cfgCommon.IsMonospace
702 If SettingDialog.IsMonospace Then
703 detailHtmlFormatHeader = detailHtmlFormatMono1
704 detailHtmlFormatFooter = detailHtmlFormatMono7
706 detailHtmlFormatHeader = detailHtmlFormat1
707 detailHtmlFormatFooter = detailHtmlFormat7
709 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
710 If SettingDialog.IsMonospace Then
711 detailHtmlFormatHeader += detailHtmlFormatMono6
713 detailHtmlFormatHeader += detailHtmlFormat6
715 Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert
716 Me.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText
718 'Dim statregex As New Regex("^0*")
719 SettingDialog.RecommendStatusText = " [TWNv" + Regex.Replace(fileVersion.Replace(".", ""), "^0*", "") + "]"
723 If DateTime.Now.ToString(SettingDialog.DateTimeFormat).Length = 0 Then
725 ' 変換が成功した場合にLengthが0にならない
726 SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"
728 Catch ex As FormatException
729 ' FormatExceptionが発生したら初期値を設定 (=yyyy/MM/dd H:mm:ssとみなされる)
730 SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"
733 SettingDialog.Nicoms = _cfgCommon.Nicoms
734 SettingDialog.HotkeyEnabled = _cfgCommon.HotkeyEnabled
735 SettingDialog.HotkeyMod = _cfgCommon.HotkeyModifier
736 SettingDialog.HotkeyKey = _cfgCommon.HotkeyKey
737 SettingDialog.HotkeyValue = _cfgCommon.HotkeyValue
739 SettingDialog.BlinkNewMentions = _cfgCommon.BlinkNewMentions
742 HashSupl = New AtIdSupplement(_cfgCommon.HashTags, "#")
743 HashMgr = New HashtagManage(HashSupl, _
744 _cfgCommon.HashTags.ToArray, _
745 _cfgCommon.HashSelected, _
746 _cfgCommon.HashIsPermanent, _
747 _cfgCommon.HashIsHead)
748 If HashMgr.UseHash <> "" AndAlso HashMgr.IsPermanent Then HashStripSplitButton.Text = HashMgr.UseHash
752 Dim saveRequired As Boolean = False
753 'ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など)
754 If tw.Username = "" Then
756 '設定せずにキャンセルされた場合はプログラム終了
757 If SettingDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
758 Application.Exit() '強制終了
761 '設定されたが、依然ユーザー名とパスワードが未設定ならプログラム終了
762 If tw.Username = "" Then
763 Application.Exit() '強制終了
768 _fntUnread = SettingDialog.FontUnread
769 _clUnread = SettingDialog.ColorUnread
770 _fntReaded = SettingDialog.FontReaded
771 _clReaded = SettingDialog.ColorReaded
772 _clFav = SettingDialog.ColorFav
773 _clOWL = SettingDialog.ColorOWL
774 _clRetweet = SettingDialog.ColorRetweet
775 _fntDetail = SettingDialog.FontDetail
776 _clDetail = SettingDialog.ColorDetail
777 _clDetailLink = SettingDialog.ColorDetailLink
778 _clDetailBackcolor = SettingDialog.ColorDetailBackcolor
779 _clSelf = SettingDialog.ColorSelf
780 _clAtSelf = SettingDialog.ColorAtSelf
781 _clTarget = SettingDialog.ColorTarget
782 _clAtTarget = SettingDialog.ColorAtTarget
783 _clAtFromTarget = SettingDialog.ColorAtFromTarget
784 _clAtTo = SettingDialog.ColorAtTo
785 _clListBackcolor = SettingDialog.ColorListBackcolor
786 _clInputBackcolor = SettingDialog.ColorInputBackcolor
787 _clInputFont = SettingDialog.ColorInputFont
788 _fntInputFont = SettingDialog.FontInputFont
789 _brsForeColorUnread.Dispose()
790 _brsForeColorReaded.Dispose()
791 _brsForeColorFav.Dispose()
792 _brsForeColorOWL.Dispose()
793 _brsForeColorRetweet.Dispose()
794 _brsForeColorUnread = New SolidBrush(_clUnread)
795 _brsForeColorReaded = New SolidBrush(_clReaded)
796 _brsForeColorFav = New SolidBrush(_clFav)
797 _brsForeColorOWL = New SolidBrush(_clOWL)
798 _brsForeColorRetweet = New SolidBrush(_clRetweet)
799 _brsBackColorMine.Dispose()
800 _brsBackColorAt.Dispose()
801 _brsBackColorYou.Dispose()
802 _brsBackColorAtYou.Dispose()
803 _brsBackColorAtFromTarget.Dispose()
804 _brsBackColorAtTo.Dispose()
805 _brsBackColorNone.Dispose()
806 _brsBackColorMine = New SolidBrush(_clSelf)
807 _brsBackColorAt = New SolidBrush(_clAtSelf)
808 _brsBackColorYou = New SolidBrush(_clTarget)
809 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
810 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
811 _brsBackColorAtTo = New SolidBrush(_clAtTo)
812 _brsBackColorNone = New SolidBrush(_clListBackcolor)
814 If SettingDialog.IsMonospace Then
815 detailHtmlFormatHeader = detailHtmlFormatMono1
816 detailHtmlFormatFooter = detailHtmlFormatMono7
818 detailHtmlFormatHeader = detailHtmlFormat1
819 detailHtmlFormatFooter = detailHtmlFormat7
821 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
822 If SettingDialog.IsMonospace Then
823 detailHtmlFormatHeader += detailHtmlFormatMono6
825 detailHtmlFormatHeader += detailHtmlFormat6
827 '他の設定項目は、随時設定画面で保持している値を読み出して使用
830 If SettingDialog.HotkeyEnabled Then
831 '''グローバルホットキーの登録。設定で変更可能にするかも
832 Dim modKey As HookGlobalHotkey.ModKeys = HookGlobalHotkey.ModKeys.None
833 If (SettingDialog.HotkeyMod And Keys.Alt) = Keys.Alt Then modKey = modKey Or HookGlobalHotkey.ModKeys.Alt
834 If (SettingDialog.HotkeyMod And Keys.Control) = Keys.Control Then modKey = modKey Or HookGlobalHotkey.ModKeys.Ctrl
835 If (SettingDialog.HotkeyMod And Keys.Shift) = Keys.Shift Then modKey = modKey Or HookGlobalHotkey.ModKeys.Shift
836 If (SettingDialog.HotkeyMod And Keys.LWin) = Keys.LWin Then modKey = modKey Or HookGlobalHotkey.ModKeys.Win
838 _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey)
842 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, _
843 SettingDialog.SelectedProxyType, _
844 SettingDialog.ProxyAddress, _
845 SettingDialog.ProxyPort, _
846 SettingDialog.ProxyUser, _
847 SettingDialog.ProxyPassword)
848 tw.CountApi = SettingDialog.CountApi
849 tw.CountApiReply = SettingDialog.CountApiReply
850 tw.RestrictFavCheck = SettingDialog.RestrictFavCheck
851 tw.ReadOwnPost = SettingDialog.ReadOwnPost
852 tw.UseSsl = SettingDialog.UseSsl
853 ShortUrl.BitlyId = SettingDialog.BitlyUser
854 ShortUrl.BitlyKey = SettingDialog.BitlyPwd
855 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
856 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
858 Outputz.Key = SettingDialog.OutputzKey
859 Outputz.Enabled = SettingDialog.OutputzEnabled
860 Select Case SettingDialog.OutputzUrlmode
861 Case OutputzUrlmode.twittercom
862 Outputz.OutUrl = "http://twitter.com/"
863 Case OutputzUrlmode.twittercomWithUsername
864 Outputz.OutUrl = "http://twitter.com/" + tw.Username
868 SetImageServiceCombo()
869 ImageSelectionPanel.Enabled = False
872 Me.ClientSize = _cfgLocal.FormSize
873 _mySize = _cfgLocal.FormSize 'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
874 _myLoc = _cfgLocal.FormLocation
876 If Me.WindowState <> FormWindowState.Minimized Then
877 Me.DesktopLocation = _cfgLocal.FormLocation
878 Dim tbarRect As New Rectangle(Me.Location, New Size(_mySize.Width, SystemInformation.CaptionHeight))
879 Dim outOfScreen As Boolean = True
880 If Screen.AllScreens.Length = 1 Then 'ハングするとの報告
881 For Each scr As Screen In Screen.AllScreens
882 If Not Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty Then
888 Me.DesktopLocation = New Point(0, 0)
889 _myLoc = Me.DesktopLocation
893 Me.TopMost = SettingDialog.AlwaysTop
894 _mySpDis = _cfgLocal.SplitterDistance
895 _mySpDis2 = _cfgLocal.StatusTextHeight
896 _mySpDis3 = _cfgLocal.PreviewDistance
897 If _mySpDis3 = -1 Then
898 _mySpDis3 = _mySize.Width - 150
899 If _mySpDis3 < 1 Then _mySpDis3 = 50
900 _cfgLocal.PreviewDistance = _mySpDis3
902 MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline
903 'Me.Tween_ClientSizeChanged(Me, Nothing)
904 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
905 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
907 StatusText.Font = _fntInputFont
908 StatusText.ForeColor = _clInputFont
910 '全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定)
911 If SettingDialog.UnreadManage = False Then
912 ReadedStripMenuItem.Enabled = False
913 UnreadStripMenuItem.Enabled = False
917 TimerTimeline.AutoReset = True
918 TimerTimeline.SynchronizingObject = Me
920 TimerTimeline.Interval = 1000
921 TimerTimeline.Enabled = True
924 TimerRefreshIcon.Interval = 200
925 TimerRefreshIcon.Enabled = True
928 StatusLabel.Text = ""
929 StatusLabel.AutoToolTip = False
930 StatusLabel.ToolTipText = ""
932 lblLen.Text = GetRestStatusCount(True, False).ToString()
934 ''''''''''''''''''''''''''''''''''''''''
935 _statuses.SortOrder = DirectCast(_cfgCommon.SortOrder, System.Windows.Forms.SortOrder)
936 Dim mode As IdComparerClass.ComparerMode
937 Select Case _cfgCommon.SortColumn
938 Case 0, 5, 6 '0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
940 mode = IdComparerClass.ComparerMode.Id 'Idソートに読み替え
942 mode = IdComparerClass.ComparerMode.Nickname
944 mode = IdComparerClass.ComparerMode.Data
946 mode = IdComparerClass.ComparerMode.Id
948 mode = IdComparerClass.ComparerMode.Name
950 mode = IdComparerClass.ComparerMode.Source
952 _statuses.SortMode = mode
953 ''''''''''''''''''''''''''''''''''''''''
955 Select Case SettingDialog.IconSz
956 Case IconSizes.IconNone
958 Case IconSizes.Icon16
960 Case IconSizes.Icon24
962 Case IconSizes.Icon48
964 Case IconSizes.Icon48_2
972 tw.IconSize = _iconSz
974 tw.TinyUrlResolve = SettingDialog.TinyUrlResolve
976 '発言詳細部アイコンをリストアイコンにサイズ変更
977 Dim sz As Integer = _iconSz
983 TIconDic = New Dictionary(Of String, Image)
985 tw.DetailIcon = TIconDic
987 StatusLabel.Text = My.Resources.Form1_LoadText1 '画面右下の状態表示を変更
988 StatusLabelUrl.Text = "" '画面左下のリンク先URL表示部を初期化
989 NameLabel.Text = "" '発言詳細部名前ラベル初期化
990 DateTimeLabel.Text = "" '発言詳細部日時ラベル初期化
993 'デフォルトタブの存在チェック、ない場合には追加
994 If _statuses.GetTabByType(TabUsageType.Home) Is Nothing Then
995 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.RECENT) Then
996 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
998 _statuses.Tabs(DEFAULTTAB.RECENT).TabType = TabUsageType.Home
1001 If _statuses.GetTabByType(TabUsageType.Mentions) Is Nothing Then
1002 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.REPLY) Then
1003 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1005 _statuses.Tabs(DEFAULTTAB.REPLY).TabType = TabUsageType.Mentions
1008 If _statuses.GetTabByType(TabUsageType.DirectMessage) Is Nothing Then
1009 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.DM) Then
1010 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1012 _statuses.Tabs(DEFAULTTAB.DM).TabType = TabUsageType.DirectMessage
1015 If _statuses.GetTabByType(TabUsageType.Favorites) Is Nothing Then
1016 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.FAV) Then
1017 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1019 _statuses.Tabs(DEFAULTTAB.FAV).TabType = TabUsageType.Favorites
1022 For Each tn As String In _statuses.Tabs.Keys
1023 If _statuses.Tabs(tn).TabType = TabUsageType.Undefined Then
1024 _statuses.Tabs(tn).TabType = TabUsageType.UserDefined
1026 If Not AddNewTab(tn, True, _statuses.Tabs(tn).TabType) Then Throw New Exception("タブ作成エラー")
1029 Me.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space"
1030 CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C"
1031 CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C"
1033 If SettingDialog.MinimizeToTray = False OrElse Me.WindowState <> FormWindowState.Minimized Then
1036 _curTab = ListTab.SelectedTab
1038 _curList = DirectCast(_curTab.Tag, DetailsListView)
1039 SetMainWindowTitle()
1042 If SettingDialog.TabIconDisp Then
1043 ListTab.DrawMode = TabDrawMode.Normal
1045 ListTab.DrawMode = TabDrawMode.OwnerDrawFixed
1046 AddHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
1047 ListTab.ImageList = Nothing
1050 _ignoreConfigSave = False
1051 Me.TweenMain_Resize(Nothing, Nothing)
1052 If saveRequired Then SaveConfigsAll(False)
1055 Private Sub spaceKeyCanceler_SpaceCancel(ByVal sender As Object, ByVal e As EventArgs)
1056 JumpUnreadMenuItem_Click(Nothing, Nothing)
1059 Private Sub ListTab_DrawItem( _
1060 ByVal sender As Object, ByVal e As DrawItemEventArgs)
1063 txt = ListTab.TabPages(e.Index).Text
1064 Catch ex As Exception
1068 e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.Bounds)
1069 If e.State = DrawItemState.Selected Then
1070 e.DrawFocusRectangle()
1074 If _statuses.Tabs(txt).UnreadCount > 0 Then
1077 fore = System.Drawing.SystemBrushes.ControlText
1079 Catch ex As Exception
1080 fore = System.Drawing.SystemBrushes.ControlText
1082 e.Graphics.DrawString(txt, e.Font, fore, e.Bounds, sfTab)
1085 Private Function LoadOldConfig() As Boolean
1086 Dim needToSave As Boolean = False
1087 _cfgCommon = SettingCommon.Load()
1088 _cfgLocal = SettingLocal.Load()
1089 If _cfgCommon.TabList.Count > 0 Then
1090 For Each tabName As String In _cfgCommon.TabList
1091 _statuses.Tabs.Add(tabName, SettingTab.Load(tabName).Tab)
1092 If tabName <> ReplaceInvalidFilename(tabName) Then
1093 Dim tb As TabClass = _statuses.Tabs(tabName)
1094 _statuses.RemoveTab(tabName)
1095 tb.TabName = ReplaceInvalidFilename(tabName)
1096 _statuses.Tabs.Add(ReplaceInvalidFilename(tabName), tb)
1097 Dim tabSetting As New SettingTab
1104 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1105 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1106 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1107 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1110 _cfgCommon.TabList.Clear()
1111 For Each tabName As String In _statuses.Tabs.Keys
1112 _cfgCommon.TabList.Add(tabName)
1117 If System.IO.File.Exists(SettingCommon.GetSettingFilePath("")) Then
1124 Private Sub LoadConfig()
1125 Dim needToSave As Boolean = False
1126 _cfgCommon = SettingCommon.Load()
1127 _cfgLocal = SettingLocal.Load()
1128 Dim tabs As List(Of TabClass) = SettingTabs.Load().Tabs
1129 For Each tb As TabClass In tabs
1130 _statuses.Tabs.Add(tb.TabName, tb)
1132 If _statuses.Tabs.Count = 0 Then
1133 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1134 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1135 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1136 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1140 Private Sub ConvertConfig()
1142 If System.IO.File.Exists(SettingTabs.GetSettingFilePath("")) Then
1149 Private Sub TimerTimeline_Elapsed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerTimeline.Elapsed
1151 Dim sw As Stopwatch = Stopwatch.StartNew()
1153 If _homeCounter > 0 Then Interlocked.Decrement(_homeCounter)
1154 If _mentionCounter > 0 Then Interlocked.Decrement(_mentionCounter)
1155 If _dmCounter > 0 Then Interlocked.Decrement(_dmCounter)
1156 If _pubSearchCounter > 0 Then Interlocked.Decrement(_pubSearchCounter)
1157 If _listsCounter > 0 Then Interlocked.Decrement(_listsCounter)
1160 If _homeCounter <= 0 AndAlso SettingDialog.TimelinePeriodInt > 0 Then
1161 Dim period As Integer
1162 Interlocked.Exchange(period, 0)
1163 Interlocked.Add(period, SettingDialog.TimelinePeriodInt)
1164 Interlocked.Add(period, -_homeCounterAdjuster)
1165 Interlocked.Exchange(_homeCounter, period)
1166 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
1168 If _mentionCounter <= 0 AndAlso SettingDialog.ReplyPeriodInt > 0 Then
1169 Interlocked.Exchange(_mentionCounter, SettingDialog.ReplyPeriodInt)
1170 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
1172 If _dmCounter <= 0 AndAlso SettingDialog.DMPeriodInt > 0 Then
1173 Interlocked.Exchange(_dmCounter, SettingDialog.DMPeriodInt)
1174 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
1176 If _pubSearchCounter <= 0 AndAlso SettingDialog.PubSearchPeriodInt > 0 Then
1177 Interlocked.Exchange(_pubSearchCounter, SettingDialog.PubSearchPeriodInt)
1178 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, "")
1180 If _listsCounter <= 0 AndAlso SettingDialog.ListsPeriodInt > 0 Then
1181 Interlocked.Exchange(_listsCounter, SettingDialog.ListsPeriodInt)
1182 GetTimeline(WORKERTYPE.List, 1, 0, "")
1186 Console.WriteLine("Counter: Home {0} Reply {1} Dm {2} Search {3} Lists {4}", _homeCounter, _mentionCounter, _dmCounter, _pubSearchCounter, _listsCounter)
1187 Console.WriteLine(sw.Elapsed)
1191 Private Sub RefreshTimeline()
1193 Dim smode As Integer = -1 '-1:制御しない,-2:最新へ,その他:topitem使用
1194 Dim topId As Long = GetScrollPos(smode)
1195 Dim befCnt As Integer = _curList.VirtualListSize
1198 Dim selId As New Dictionary(Of String, Long())
1199 Dim focusedId As New Dictionary(Of String, Long)
1200 SaveSelectedStatus(selId, focusedId)
1203 Dim dmCount As Integer = _statuses.GetTabByType(TabUsageType.DirectMessage).AllCount
1206 Dim notifyPosts() As PostClass = Nothing
1207 Dim soundFile As String = ""
1208 Dim addCount As Integer = 0
1209 Dim isMention As Boolean = False
1210 addCount = _statuses.SubmitUpdate(soundFile, notifyPosts, isMention)
1212 If _endingFlag Then Exit Sub
1216 For Each tab As TabPage In ListTab.TabPages
1217 Dim lst As DetailsListView = DirectCast(tab.Tag, DetailsListView)
1218 Dim tabInfo As TabClass = _statuses.Tabs(tab.Text)
1220 If lst.VirtualListSize <> tabInfo.AllCount Then
1221 If lst.Equals(_curList) Then
1222 _itemCache = Nothing
1223 _postCache = Nothing
1226 lst.VirtualListSize = tabInfo.AllCount 'リスト件数更新
1227 Catch ex As Exception
1230 Me.SelectListItem(lst, _
1231 _statuses.IndexOf(tab.Text, selId(tab.Text)), _
1232 _statuses.IndexOf(tab.Text, focusedId(tab.Text)))
1235 If tabInfo.UnreadCount > 0 Then
1236 If SettingDialog.TabIconDisp Then
1237 If tab.ImageIndex = -1 Then tab.ImageIndex = 0 'タブアイコン
1241 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
1242 Catch ex As Exception
1243 'ex.Data("Msg") = "Ref1, UseAPI=" + SettingDialog.UseAPI.ToString
1249 If befCnt <> _curList.VirtualListSize Then
1253 _curList.EnsureVisible(0)
1256 If _curList.VirtualListSize > 0 Then _curList.EnsureVisible(_curList.VirtualListSize - 1)
1261 If _curList.VirtualListSize > 0 AndAlso _statuses.IndexOf(_curTab.Text, topId) > -1 Then
1262 _curList.EnsureVisible(_curList.VirtualListSize - 1)
1263 _curList.EnsureVisible(_statuses.IndexOf(_curTab.Text, topId))
1267 Catch ex As Exception
1268 ex.Data("Msg") = "Ref2"
1273 NotifyNewPosts(notifyPosts,
1276 isMention OrElse dmCount <> _statuses.GetTabByType(TabUsageType.DirectMessage).AllCount)
1278 SetMainWindowTitle()
1279 If Not StatusLabelUrl.Text.StartsWith("http") Then SetStatusLabelUrl()
1281 HashSupl.AddRangeItem(tw.GetHashList)
1285 Private Function GetScrollPos(ByRef smode As Integer) As Long
1286 Dim topId As Long = -1
1287 If _curList IsNot Nothing AndAlso _curTab IsNot Nothing AndAlso _curList.VirtualListSize > 0 Then
1288 If _statuses.SortMode = IdComparerClass.ComparerMode.Id Then
1289 If _statuses.SortOrder = SortOrder.Ascending Then
1291 If ListLockMenuItem.Checked Then
1295 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1298 '最下行が表示されていたら、最下行へ強制スクロール。最下行が表示されていなかったら制御しない
1299 Dim _item As ListViewItem
1300 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1) '一番下
1301 If _item Is Nothing Then _item = _curList.Items(_curList.Items.Count - 1)
1302 If _item.Index = _curList.Items.Count - 1 Then
1306 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1312 If ListLockMenuItem.Checked Then
1314 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1317 '最上行が表示されていたら、制御しない。最上行が表示されていなかったら、現在表示位置へ強制スクロール
1318 Dim _item As ListViewItem
1320 _item = _curList.GetItemAt(0, 10) '一番上
1321 If _item Is Nothing Then _item = _curList.Items(0)
1322 If _item.Index = 0 Then
1325 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1332 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1341 Private Sub SaveSelectedStatus(ByVal selId As Dictionary(Of String, Long()), ByVal focusedId As Dictionary(Of String, Long))
1342 If _endingFlag Then Exit Sub
1343 For Each tab As TabPage In ListTab.TabPages
1344 Dim lst As DetailsListView = DirectCast(tab.Tag, DetailsListView)
1345 If lst.SelectedIndices.Count > 0 AndAlso lst.SelectedIndices.Count < 31 Then
1346 selId.Add(tab.Text, _statuses.GetId(tab.Text, lst.SelectedIndices))
1348 selId.Add(tab.Text, New Long(0) {-1})
1350 If lst.FocusedItem IsNot Nothing Then
1351 focusedId.Add(tab.Text, _statuses.GetId(tab.Text, lst.FocusedItem.Index))
1353 focusedId.Add(tab.Text, -1)
1359 Private Sub NotifyNewPosts(ByVal notifyPosts() As PostClass, ByVal soundFile As String, ByVal addCount As Integer, ByVal newMentions As Boolean)
1362 NewPostPopMenuItem.Checked AndAlso _
1363 notifyPosts IsNot Nothing AndAlso _
1364 notifyPosts.Length > 0 AndAlso _
1365 Not _initial AndAlso _
1368 SettingDialog.LimitBalloon AndAlso _
1370 Me.WindowState = FormWindowState.Minimized OrElse _
1371 Not Me.Visible OrElse _
1372 Form.ActiveForm Is Nothing _
1375 Not SettingDialog.LimitBalloon _
1378 Not IsScreenSaverRunning() Then
1379 Dim sb As New StringBuilder
1380 Dim reply As Boolean = False
1381 Dim dm As Boolean = False
1382 For Each post As PostClass In notifyPosts
1383 If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True
1384 If post.IsDm Then dm = True
1385 If sb.Length > 0 Then sb.Append(System.Environment.NewLine)
1386 Select Case SettingDialog.NameBalloon
1387 Case NameBalloonEnum.UserID
1388 sb.Append(post.Name).Append(" : ")
1389 Case NameBalloonEnum.NickName
1390 sb.Append(post.Nickname).Append(" : ")
1392 sb.Append(post.Data)
1394 If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = ""
1396 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
1397 NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2
1399 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
1400 NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
1402 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
1403 NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
1405 Dim bText As String = sb.ToString
1406 If String.IsNullOrEmpty(bText) Then Exit Sub
1407 NotifyIcon1.BalloonTipText = sb.ToString()
1408 NotifyIcon1.ShowBalloonTip(500)
1412 If Not _initial AndAlso SettingDialog.PlaySound AndAlso soundFile <> "" Then
1414 Dim dir As String = My.Application.Info.DirectoryPath
1415 If Directory.Exists(Path.Combine(dir, "Sounds")) Then
1416 dir = Path.Combine(dir, "Sounds")
1418 My.Computer.Audio.Play(Path.Combine(dir, soundFile), AudioPlayMode.Background)
1419 Catch ex As Exception
1425 If Not _initial AndAlso SettingDialog.BlinkNewMentions AndAlso newMentions AndAlso Form.ActiveForm Is Nothing Then
1426 FlashMyWindow(Me.Handle, FlashSpecification.FlashTray, 3)
1431 Private Sub MyList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
1432 If _curList.SelectedIndices.Count <> 1 Then Exit Sub
1433 'If _curList.SelectedIndices.Count = 0 Then Exit Sub
1435 _curItemIndex = _curList.SelectedIndices(0)
1436 'If _curPost Is GetCurTabPost(_curItemIndex) Then Exit Sub 'refreshで既読化されるのを防ぐため追加
1437 _curPost = GetCurTabPost(_curItemIndex)
1438 If SettingDialog.UnreadManage Then _statuses.SetRead(True, _curTab.Text, _curItemIndex)
1439 'MyList.RedrawItems(MyList.SelectedIndices(0), MyList.SelectedIndices(0), False) 'RetrieveVirtualItemが発生することを期待
1441 ChangeCacheStyleRead(True, _curItemIndex, _curTab) '既読へ(フォント、文字色)
1443 'ColorizeList(-1) '全キャッシュ更新(背景色)
1449 Private Sub ChangeCacheStyleRead(ByVal Read As Boolean, ByVal Index As Integer, ByVal Tab As TabPage)
1450 'Read:True=既読 False=未読
1451 '未読管理していなかったら既読として扱う
1452 If Not _statuses.Tabs(_curTab.Text).UnreadManage OrElse _
1453 Not SettingDialog.UnreadManage Then Read = True
1456 Dim itm As ListViewItem
1457 Dim post As PostClass
1458 If Tab.Equals(_curTab) AndAlso _itemCache IsNot Nothing AndAlso Index >= _itemCacheIndex AndAlso Index < _itemCacheIndex + _itemCache.Length Then
1459 itm = _itemCache(Index - _itemCacheIndex)
1460 post = _postCache(Index - _itemCacheIndex)
1462 itm = DirectCast(Tab.Tag, DetailsListView).Items(Index)
1463 post = _statuses.Item(Tab.Text, Index)
1466 ChangeItemStyleRead(Read, itm, post, DirectCast(Tab.Tag, DetailsListView))
1469 Private Sub ChangeItemStyleRead(ByVal Read As Boolean, ByVal Item As ListViewItem, ByVal Post As PostClass, ByVal DList As DetailsListView)
1474 Item.SubItems(5).Text = ""
1477 Item.SubItems(5).Text = "★"
1483 ElseIf Post.RetweetedId > 0 Then
1485 ElseIf Post.IsOwl AndAlso (Post.IsDm OrElse SettingDialog.OneWayLove) Then
1487 ElseIf Read OrElse Not SettingDialog.UseUnreadStyle Then
1492 If DList Is Nothing OrElse Item.Index = -1 Then
1494 If SettingDialog.UseUnreadStyle Then
1499 If SettingDialog.UseUnreadStyle Then
1500 DList.ChangeItemFontAndColor(Item.Index, cl, fnt)
1502 DList.ChangeItemForeColor(Item.Index, cl)
1504 'If _itemCache IsNot Nothing Then DList.RedrawItems(_itemCacheIndex, _itemCacheIndex + _itemCache.Length - 1, False)
1508 Private Sub ColorizeList()
1509 'Index:更新対象のListviewItem.Index。Colorを返す。
1510 '-1は全キャッシュ。Colorは返さない(ダミーを戻す)
1511 Dim _post As PostClass
1518 If _itemCache Is Nothing Then Exit Sub
1520 If _post Is Nothing Then Exit Sub
1523 For cnt As Integer = 0 To _itemCache.Length - 1
1524 _curList.ChangeItemBackColor(_itemCacheIndex + cnt, JudgeColor(_post, _postCache(cnt)))
1526 Catch ex As Exception
1530 Private Sub ColorizeList(ByVal Item As ListViewItem, ByVal Index As Integer)
1531 'Index:更新対象のListviewItem.Index。Colorを返す。
1532 '-1は全キャッシュ。Colorは返さない(ダミーを戻す)
1533 Dim _post As PostClass
1540 Dim tPost As PostClass = GetCurTabPost(Index)
1542 If _post Is Nothing Then Exit Sub
1544 If Item.Index = -1 Then
1545 Item.BackColor = JudgeColor(_post, tPost)
1547 _curList.ChangeItemBackColor(Item.Index, JudgeColor(_post, tPost))
1551 Private Function JudgeColor(ByVal BasePost As PostClass, ByVal TargetPost As PostClass) As Color
1553 If TargetPost.Id = BasePost.InReplyToId Then
1556 ElseIf TargetPost.IsMe Then
1559 ElseIf TargetPost.IsReply Then
1562 ElseIf BasePost.ReplyToList.Contains(TargetPost.Name.ToLower()) Then
1564 cl = _clAtFromTarget
1565 ElseIf TargetPost.ReplyToList.Contains(BasePost.Name.ToLower()) Then
1568 ElseIf TargetPost.Name.Equals(BasePost.Name, StringComparison.OrdinalIgnoreCase) Then
1573 cl = _clListBackcolor
1578 Private Sub PostButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostButton.Click
1579 If StatusText.Text.Trim.Length = 0 Then
1580 If Not ImageSelectionPanel.Enabled Then
1586 If _curPost IsNot Nothing AndAlso StatusText.Text.Trim() = String.Format("RT @{0}: {1}", _curPost.Name, _curPost.Data) Then
1587 Dim rtResult As DialogResult = MessageBox.Show(String.Format(My.Resources.PostButton_Click1, Environment.NewLine),
1589 MessageBoxButtons.YesNoCancel,
1590 MessageBoxIcon.Question)
1591 Select Case rtResult
1592 Case Windows.Forms.DialogResult.Yes
1593 doReTweetOriginal(False)
1594 StatusText.Text = ""
1596 Case Windows.Forms.DialogResult.Cancel
1601 _history(_history.Count - 1) = StatusText.Text.Trim
1603 If SettingDialog.UrlConvertAuto Then
1604 StatusText.SelectionStart = StatusText.Text.Length
1605 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
1606 ElseIf SettingDialog.Nicoms Then
1607 StatusText.SelectionStart = StatusText.Text.Length
1608 UrlConvert(UrlConverter.Nicoms)
1610 StatusText.SelectionStart = StatusText.Text.Length
1611 Dim args As New GetWorkerArg()
1614 args.type = WORKERTYPE.PostMessage
1615 CheckReplyTo(StatusText.Text)
1618 Dim adjustCount As Integer = 0
1619 Dim tmpStatus As String = StatusText.Text.Trim
1620 If ToolStripMenuItemApiCommandEvasion.Checked Then
1622 If Regex.IsMatch(tmpStatus, _
1623 "^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", _
1624 RegexOptions.IgnoreCase) _
1625 AndAlso tmpStatus.EndsWith(" .") = False Then adjustCount += 2
1628 If ToolStripMenuItemUrlMultibyteSplit.Checked Then
1630 adjustCount += Regex.Matches(tmpStatus, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+").Count
1633 Dim isCutOff As Boolean = False
1634 Dim isRemoveFooter As Boolean = My.Computer.Keyboard.ShiftKeyDown
1635 If StatusText.Multiline AndAlso Not SettingDialog.PostCtrlEnter Then
1636 '複数行でEnter投稿の場合、Ctrlも押されていたらフッタ付加しない
1637 isRemoveFooter = My.Computer.Keyboard.CtrlKeyDown
1639 If Not isRemoveFooter AndAlso (StatusText.Text.Contains("RT @") OrElse StatusText.Text.Contains("QT @")) Then
1640 isRemoveFooter = True
1642 If GetRestStatusCount(False, Not isRemoveFooter) - adjustCount < 0 Then
1643 If MessageBox.Show(My.Resources.PostLengthOverMessage1, My.Resources.PostLengthOverMessage2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
1645 If Not SettingDialog.UrlConvertAuto Then UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
1646 If GetRestStatusCount(False, Not isRemoveFooter) - adjustCount < 0 Then
1647 isRemoveFooter = True
1654 Dim footer As String = ""
1655 Dim header As String = ""
1656 If StatusText.Text.StartsWith("D ") OrElse StatusText.Text.StartsWith("d ") Then
1661 If HashMgr.UseHash <> "" Then
1662 If HashMgr.IsHead Then
1663 header = HashMgr.UseHash + " "
1665 footer = " " + HashMgr.UseHash
1668 If Not isRemoveFooter Then
1669 If SettingDialog.UseRecommendStatus Then
1671 footer += SettingDialog.RecommendStatusText
1673 ' テキストボックスに入力されている文字列を使用する
1674 footer += " " + SettingDialog.Status.Trim
1678 args.status.status = header + StatusText.Text.Trim + footer
1680 If ToolStripMenuItemApiCommandEvasion.Checked Then
1682 If Regex.IsMatch(args.status.status, _
1683 "^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", _
1684 RegexOptions.IgnoreCase) _
1685 AndAlso args.status.status.EndsWith(" .") = False Then args.status.status += " ."
1688 If ToolStripMenuItemUrlMultibyteSplit.Checked Then
1690 Dim mc2 As Match = Regex.Match(args.status.status, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+")
1691 If mc2.Success Then args.status.status = Regex.Replace(args.status.status, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+", "$& ")
1694 If IdeographicSpaceToSpaceToolStripMenuItem.Checked Then
1695 ' 文中の全角スペースを半角スペース1個にする
1696 args.status.status = args.status.status.Replace(" ", " ")
1699 If isCutOff AndAlso args.status.status.Length > 140 Then
1700 args.status.status = args.status.status.Substring(0, 140)
1701 If Regex.IsMatch(args.status.status, "@[a-zA-Z0-9_/]+$", RegexOptions.IgnoreCase) Then
1702 MessageBox.Show(My.Resources.PostLengthOverMessage3 + Environment.NewLine + Environment.NewLine + args.status.status, "Abort", MessageBoxButtons.OK)
1705 If MessageBox.Show(args.status.status, "Post or Cancel?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then Exit Sub
1708 args.status.inReplyToId = _reply_to_id
1709 args.status.inReplyToName = _reply_to_name
1710 If ImageSelectionPanel.Visible Then
1712 If ImageSelectedPicture.Image IsNot ImageSelectedPicture.InitialImage AndAlso _
1713 ImageServiceCombo.SelectedIndex > -1 AndAlso _
1714 ImagefilePathText.Text <> "" Then
1715 If MessageBox.Show(My.Resources.PostPictureConfirm1, _
1716 My.Resources.PostPictureConfirm2, _
1717 MessageBoxButtons.OKCancel, _
1718 MessageBoxIcon.Question, _
1719 MessageBoxDefaultButton.Button1) _
1720 = Windows.Forms.DialogResult.Cancel Then
1721 TimelinePanel.Visible = True
1722 TimelinePanel.Enabled = True
1723 ImageSelectionPanel.Visible = False
1724 ImageSelectionPanel.Enabled = False
1725 If _curList IsNot Nothing Then
1730 args.status.imageService = ImageServiceCombo.Text
1731 args.status.imagePath = ImagefilePathText.Text
1732 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
1733 ImagefilePathText.Text = ""
1734 TimelinePanel.Visible = True
1735 TimelinePanel.Enabled = True
1736 ImageSelectionPanel.Visible = False
1737 ImageSelectionPanel.Enabled = False
1738 If _curList IsNot Nothing Then
1742 MessageBox.Show(My.Resources.PostPictureWarn1, My.Resources.PostPictureWarn2)
1750 If StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) AndAlso StatusText.Text.Trim.Length > 7 Then
1751 Dim tmp As String = String.Format(My.Resources.SearchItem2Url, HttpUtility.UrlEncode(StatusText.Text.Substring(7)))
1757 StatusText.Text = ""
1759 _hisIdx = _history.Count - 1
1760 If Not ToolStripFocusLockMenuItem.Checked Then
1761 DirectCast(ListTab.SelectedTab.Tag, Control).Focus()
1763 urlUndoBuffer = Nothing
1764 UrlUndoToolStripMenuItem.Enabled = False 'Undoをできないように設定
1767 Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click, EndFileMenuItem.Click
1772 Private Sub Tween_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
1773 If Not SettingDialog.CloseToExit AndAlso e.CloseReason = CloseReason.UserClosing AndAlso _endingFlag = False Then
1774 '_endingFlag=False:フォームの×ボタン
1778 _hookGlobalHotkey.UnregisterAllOriginalHotkey()
1779 _ignoreConfigSave = True
1781 TimerTimeline.Enabled = False
1782 TimerRefreshIcon.Enabled = False
1786 Private Sub NotifyIcon1_BalloonTipClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyIcon1.BalloonTipClicked
1788 If Me.WindowState = FormWindowState.Minimized Then
1789 Me.WindowState = FormWindowState.Normal
1794 Private Shared Function CheckAccountValid() As Boolean
1795 Static errorCount As Integer = 0
1796 If Twitter.AccountState <> ACCOUNT_STATE.Valid Then
1798 If errorCount > 5 Then
1800 Twitter.AccountState = ACCOUNT_STATE.Valid
1809 Private Sub GetTimelineWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
1810 Dim bw As BackgroundWorker = DirectCast(sender, BackgroundWorker)
1811 If bw.CancellationPending OrElse _endingFlag Then
1816 Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.BelowNormal
1818 My.Application.InitCulture()
1820 Dim ret As String = ""
1821 Dim rslt As New GetWorkerResult()
1823 Dim read As Boolean = Not SettingDialog.UnreadManage
1824 If _initial AndAlso SettingDialog.UnreadManage Then read = SettingDialog.Readed
1826 Dim args As GetWorkerArg = DirectCast(e.Argument, GetWorkerArg)
1828 If Not CheckAccountValid() Then
1829 rslt.retMsg = "Auth error. Check your account"
1830 rslt.type = WORKERTYPE.ErrorState 'エラー表示のみ行ない、後処理キャンセル
1831 rslt.tName = args.tName
1836 If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(0, "") 'Notifyアイコンアニメーション開始
1837 Select Case args.type
1838 Case WORKERTYPE.Timeline, WORKERTYPE.Reply
1839 bw.ReportProgress(50, MakeStatusMessage(args, False))
1840 ret = tw.GetTimelineApi(read, args.type, args.page = -1)
1842 If ret = "" AndAlso args.type = WORKERTYPE.Timeline AndAlso SettingDialog.ReadOldPosts Then
1845 rslt.addCount = _statuses.DistributePosts()
1846 Case WORKERTYPE.DirectMessegeRcv '送信分もまとめて取得
1847 bw.ReportProgress(50, MakeStatusMessage(args, False))
1848 ret = tw.GetDirectMessageApi(read, WORKERTYPE.DirectMessegeRcv, args.page = -1)
1849 If ret = "" Then ret = tw.GetDirectMessageApi(read, WORKERTYPE.DirectMessegeSnt, args.page = -1)
1850 rslt.addCount = _statuses.DistributePosts()
1851 Case WORKERTYPE.FavAdd
1853 If _statuses.Tabs.ContainsKey(args.tName) Then
1854 Dim tbc As TabClass = _statuses.Tabs(args.tName)
1855 For i As Integer = 0 To args.ids.Count - 1
1856 Dim post As PostClass = Nothing
1857 If tbc.TabType = TabUsageType.Lists OrElse tbc.TabType = TabUsageType.PublicSearch Then
1858 post = tbc.Posts(args.ids(i))
1860 post = _statuses.Item(args.ids(i))
1863 bw.ReportProgress(50, MakeStatusMessage(args, False))
1864 If Not post.IsFav Then
1865 If post.RetweetedId = 0 Then
1866 ret = tw.PostFavAdd(post.Id)
1868 ret = tw.PostFavAdd(post.RetweetedId)
1870 If ret.Length = 0 Then
1871 args.sIds.Add(post.Id)
1872 post.IsFav = True 'リスト再描画必要
1873 _favTimestamps.Add(Now)
1874 If post.RelTabName = "" Then
1875 '検索,リストタブからのfavは、favタブへ追加せず。それ以外は追加
1876 _statuses.GetTabByType(TabUsageType.Favorites).Add(post.Id, post.IsRead, False)
1878 '検索・リストタブからのfavで、TLでも取得済みならfav反映
1879 If _statuses.ContainsKey(post.Id) Then
1880 Dim postTl As PostClass = _statuses.Item(post.Id)
1882 _statuses.GetTabByType(TabUsageType.Favorites).Add(postTl.Id, postTl.IsRead, False)
1886 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch Or TabUsageType.Lists)
1887 If tb.Contains(post.Id) Then tb.Posts(post.Id).IsFav = True
1893 rslt.sIds = args.sIds
1894 Case WORKERTYPE.FavRemove
1896 If _statuses.Tabs.ContainsKey(args.tName) Then
1897 Dim tbc As TabClass = _statuses.Tabs(args.tName)
1898 For i As Integer = 0 To args.ids.Count - 1
1899 Dim post As PostClass = Nothing
1900 If tbc.TabType = TabUsageType.Lists OrElse tbc.TabType = TabUsageType.PublicSearch Then
1901 post = tbc.Posts(args.ids(i))
1903 post = _statuses.Item(args.ids(i))
1906 bw.ReportProgress(50, MakeStatusMessage(args, False))
1908 If post.RetweetedId = 0 Then
1909 ret = tw.PostFavRemove(post.Id)
1911 ret = tw.PostFavRemove(post.RetweetedId)
1913 If ret.Length = 0 Then
1914 args.sIds.Add(post.Id)
1915 post.IsFav = False 'リスト再描画必要
1916 If _statuses.ContainsKey(post.Id) Then _statuses.Item(post.Id).IsFav = False
1918 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch Or TabUsageType.Lists)
1919 If tb.Contains(post.Id) Then tb.Posts(post.Id).IsFav = False
1925 rslt.sIds = args.sIds
1926 Case WORKERTYPE.PostMessage
1927 bw.ReportProgress(200)
1928 If String.IsNullOrEmpty(args.status.imagePath) Then
1929 For i As Integer = 0 To 1
1930 ret = tw.PostStatus(args.status.status, args.status.inReplyToId)
1931 If ret = "" OrElse _
1932 ret.StartsWith("OK:") OrElse _
1933 ret.StartsWith("Outputz:") OrElse _
1934 ret.StartsWith("Warn:") OrElse _
1935 ret = "Err:Status is a duplicate." OrElse _
1936 args.status.status.StartsWith("D", StringComparison.OrdinalIgnoreCase) OrElse _
1937 args.status.status.StartsWith("DM", StringComparison.OrdinalIgnoreCase) Then
1942 Dim picSvc As New PictureService(tw)
1943 ret = picSvc.Upload(args.status.imagePath, args.status.status, args.status.imageService)
1945 bw.ReportProgress(300)
1946 rslt.status = args.status
1947 Case WORKERTYPE.Retweet
1948 bw.ReportProgress(200)
1949 ret = tw.PostRetweet(args.ids(0), read)
1950 bw.ReportProgress(300)
1951 Case WORKERTYPE.Follower
1952 bw.ReportProgress(50, My.Resources.UpdateFollowersMenuItem1_ClickText1)
1953 ret = tw.GetFollowersApi()
1954 Case WORKERTYPE.OpenUri
1955 Dim myPath As String = Convert.ToString(args.url)
1958 If SettingDialog.BrowserPath <> "" Then
1959 If SettingDialog.BrowserPath.StartsWith("""") AndAlso SettingDialog.BrowserPath.Length > 2 AndAlso SettingDialog.BrowserPath.IndexOf("""", 2) > -1 Then
1960 Dim sep As Integer = SettingDialog.BrowserPath.IndexOf("""", 2)
1961 Dim browserPath As String = SettingDialog.BrowserPath.Substring(1, sep - 1)
1962 Dim arg As String = ""
1963 If sep < SettingDialog.BrowserPath.Length - 1 Then
1964 arg = SettingDialog.BrowserPath.Substring(sep + 1)
1966 myPath = arg + " " + myPath
1967 System.Diagnostics.Process.Start(browserPath, myPath)
1969 System.Diagnostics.Process.Start(SettingDialog.BrowserPath, myPath)
1972 System.Diagnostics.Process.Start(myPath)
1974 Catch ex As Exception
1975 ' MessageBox.Show("ブラウザの起動に失敗、またはタイムアウトしました。" + ex.ToString())
1977 Case WORKERTYPE.Favorites
1978 bw.ReportProgress(50, MakeStatusMessage(args, False))
1979 ret = tw.GetFavoritesApi(read, args.type)
1980 rslt.addCount = _statuses.DistributePosts()
1981 Case WORKERTYPE.PublicSearch
1982 bw.ReportProgress(50, MakeStatusMessage(args, False))
1983 If args.tName = "" Then
1984 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch)
1985 If tb.SearchWords <> "" Then ret = tw.GetSearch(read, tb, False)
1988 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
1989 If tb IsNot Nothing Then
1990 ret = tw.GetSearch(read, tb, False)
1991 If ret = "" AndAlso args.page = -1 Then
1992 ret = tw.GetSearch(read, tb, True)
1997 rslt.addCount = _statuses.DistributePosts()
1998 Case WORKERTYPE.List
1999 bw.ReportProgress(50, MakeStatusMessage(args, False))
2000 If args.tName = "" Then
2001 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.Lists)
2002 If tb.ListInfo IsNot Nothing AndAlso tb.ListInfo.Id <> 0 Then ret = tw.GetListStatus(read, tb, False)
2005 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2006 If tb IsNot Nothing Then
2007 ret = tw.GetListStatus(read, tb, args.page = -1)
2011 rslt.addCount = _statuses.DistributePosts()
2014 If bw.CancellationPending Then
2020 If args.type = WORKERTYPE.FavAdd Then
2021 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2022 For i As Integer = _favTimestamps.Count - 1 To 0 Step -1
2023 If _favTimestamps(i).CompareTo(oneHour) < 0 Then
2024 _favTimestamps.RemoveAt(i)
2028 If args.type = WORKERTYPE.Timeline AndAlso Not _initial Then
2029 SyncLock _syncObject
2030 Dim tm As Date = Now
2031 If _tlTimestamps.ContainsKey(tm) Then
2032 _tlTimestamps(tm) += rslt.addCount
2034 _tlTimestamps.Add(Now, rslt.addCount)
2036 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2037 Dim keys As New List(Of Date)
2039 For Each key As Date In _tlTimestamps.Keys
2040 If key.CompareTo(oneHour) < 0 Then
2043 _tlCount += _tlTimestamps(key)
2046 For Each key As Date In keys
2047 _tlTimestamps.Remove(key)
2054 If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(100, MakeStatusMessage(args, True)) 'ステータス書き換え、Notifyアイコンアニメーション開始
2057 rslt.type = args.type
2058 rslt.tName = args.tName
2059 If args.type = WORKERTYPE.DirectMessegeRcv OrElse _
2060 args.type = WORKERTYPE.DirectMessegeSnt OrElse _
2061 args.type = WORKERTYPE.Reply OrElse _
2062 args.type = WORKERTYPE.Timeline OrElse _
2063 args.type = WORKERTYPE.Favorites Then
2064 rslt.page = args.page - 1 '値が正しいか後でチェック。10ページ毎の継続確認
2071 Private Function MakeStatusMessage(ByVal AsyncArg As GetWorkerArg, ByVal Finish As Boolean) As String
2072 Dim smsg As String = ""
2075 Select Case AsyncArg.type
2076 Case WORKERTYPE.Timeline
2077 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText5 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2078 Case WORKERTYPE.Reply
2079 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText4 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2080 Case WORKERTYPE.DirectMessegeRcv
2081 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText8 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2082 Case WORKERTYPE.FavAdd
2083 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText15 + AsyncArg.page.ToString() + "/" + AsyncArg.ids.Count.ToString() + _
2084 My.Resources.GetTimelineWorker_RunWorkerCompletedText16 + (AsyncArg.page - AsyncArg.sIds.Count - 1).ToString()
2085 Case WORKERTYPE.FavRemove
2086 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText17 + AsyncArg.page.ToString() + "/" + AsyncArg.ids.Count.ToString() + _
2087 My.Resources.GetTimelineWorker_RunWorkerCompletedText18 + (AsyncArg.page - AsyncArg.sIds.Count - 1).ToString()
2088 Case WORKERTYPE.Favorites
2089 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText19
2090 Case WORKERTYPE.PublicSearch
2091 smsg = "Search refreshing..."
2092 Case WORKERTYPE.List
2093 smsg = "List refreshing..."
2097 Select Case AsyncArg.type
2098 Case WORKERTYPE.Timeline
2099 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText1
2100 Case WORKERTYPE.Reply
2101 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText9
2102 Case WORKERTYPE.DirectMessegeRcv
2103 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText11
2104 Case WORKERTYPE.DirectMessegeSnt
2105 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText13
2106 Case WORKERTYPE.FavAdd
2108 Case WORKERTYPE.FavRemove
2110 Case WORKERTYPE.Favorites
2111 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText20
2112 Case WORKERTYPE.Follower
2113 smsg = My.Resources.UpdateFollowersMenuItem1_ClickText3
2114 Case WORKERTYPE.PublicSearch
2115 smsg = "Search refreshed"
2116 Case WORKERTYPE.List
2117 smsg = "List refreshed"
2123 Private Sub GetTimelineWorker_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
2124 If _endingFlag Then Exit Sub
2125 If e.ProgressPercentage > 100 Then
2127 If e.ProgressPercentage = 200 Then '開始
2128 StatusLabel.Text = "Posting..."
2130 If e.ProgressPercentage = 300 Then '終了
2131 StatusLabel.Text = My.Resources.PostWorker_RunWorkerCompletedText4
2134 Dim smsg As String = DirectCast(e.UserState, String)
2135 If smsg.Length > 0 Then StatusLabel.Text = smsg
2139 Private Sub GetTimelineWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
2141 If _endingFlag OrElse e.Cancelled Then Exit Sub 'キャンセル
2143 If e.Error IsNot Nothing Then
2144 _myStatusError = True
2145 _waitTimeline = False
2149 _waitPubSearch = False
2151 Throw New Exception("BackgroundWorker Exception", e.Error)
2155 Dim rslt As GetWorkerResult = DirectCast(e.Result, GetWorkerResult)
2157 If rslt.type = WORKERTYPE.OpenUri Then Exit Sub
2160 If rslt.retMsg.Length > 0 Then
2161 _myStatusError = True
2162 StatusLabel.Text = rslt.retMsg
2165 If rslt.type = WORKERTYPE.ErrorState Then Exit Sub
2167 If rslt.type = WORKERTYPE.FavRemove Then
2168 DispSelectedPost() ' 詳細画面書き直し
2169 Dim favTabName As String = _statuses.GetTabByType(TabUsageType.Favorites).TabName
2170 For Each i As Long In rslt.sIds
2171 _statuses.RemoveFavPost(i)
2173 If _curTab IsNot Nothing AndAlso _curTab.Text.Equals(favTabName) Then
2174 _itemCache = Nothing 'キャッシュ破棄
2175 _postCache = Nothing
2179 For Each tp As TabPage In ListTab.TabPages
2180 If tp.Text = favTabName Then
2181 DirectCast(tp.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(favTabName).AllCount
2188 'Dim busy As Boolean = False
2189 'For Each bw As BackgroundWorker In _bw
2190 ' If bw IsNot Nothing AndAlso bw.IsBusy Then
2195 'If Not busy Then RefreshTimeline() 'background処理なければ、リスト反映
2196 If rslt.type = WORKERTYPE.Timeline OrElse _
2197 rslt.type = WORKERTYPE.Reply OrElse _
2198 rslt.type = WORKERTYPE.List OrElse _
2199 rslt.type = WORKERTYPE.PublicSearch OrElse _
2200 rslt.type = WORKERTYPE.DirectMessegeRcv OrElse _
2201 rslt.type = WORKERTYPE.DirectMessegeSnt OrElse _
2202 rslt.type = WORKERTYPE.Favorites OrElse _
2203 rslt.type = WORKERTYPE.Follower OrElse _
2204 rslt.type = WORKERTYPE.FavAdd OrElse _
2205 rslt.type = WORKERTYPE.FavRemove Then
2206 RefreshTimeline() 'リスト反映
2209 Select Case rslt.type
2210 Case WORKERTYPE.Timeline
2211 _waitTimeline = False
2212 If Not _initial Then
2213 ' 'API使用時の取得調整は別途考える(カウント調整?)
2215 Case WORKERTYPE.Reply
2217 If rslt.newDM AndAlso Not _initial Then
2218 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
2220 Case WORKERTYPE.Favorites
2222 Case WORKERTYPE.DirectMessegeRcv
2224 Case WORKERTYPE.FavAdd, WORKERTYPE.FavRemove
2225 If _curList IsNot Nothing AndAlso _curTab IsNot Nothing Then
2226 _curList.BeginUpdate()
2227 If rslt.type = WORKERTYPE.FavRemove AndAlso _statuses.Tabs(_curTab.Text).TabType = TabUsageType.Favorites Then
2230 For i As Integer = 0 To rslt.sIds.Count - 1
2231 If _curTab.Text.Equals(rslt.tName) Then
2232 Dim idx As Integer = _statuses.Tabs(rslt.tName).IndexOf(rslt.sIds(i))
2234 Dim post As PostClass = Nothing
2235 Dim tb As TabClass = _statuses.Tabs(rslt.tName)
2236 If tb IsNot Nothing Then
2237 If tb.TabType = TabUsageType.Lists OrElse tb.TabType = TabUsageType.PublicSearch Then
2238 post = tb.Posts(rslt.sIds(i))
2240 post = _statuses.Item(rslt.sIds(i))
2242 ChangeCacheStyleRead(post.IsRead, idx, _curTab)
2244 If idx = _curItemIndex Then DispSelectedPost() '選択アイテム再表示
2249 _curList.EndUpdate()
2251 Case WORKERTYPE.PostMessage
2252 If rslt.retMsg = "" OrElse _
2253 rslt.retMsg.StartsWith("Outputz") OrElse _
2254 rslt.retMsg.StartsWith("OK:") OrElse _
2255 rslt.retMsg = "Warn:Status is a duplicate." Then
2256 _postTimestamps.Add(Now)
2257 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2258 For i As Integer = _postTimestamps.Count - 1 To 0 Step -1
2259 If _postTimestamps(i).CompareTo(oneHour) < 0 Then
2260 _postTimestamps.RemoveAt(i)
2264 If Not HashMgr.IsPermanent AndAlso HashMgr.UseHash <> "" Then
2265 HashMgr.ClearHashtag()
2266 Me.HashStripSplitButton.Text = "#[-]"
2267 Me.HashToggleMenuItem.Checked = False
2268 Me.HashToggleToolStripMenuItem.Checked = False
2270 SetMainWindowTitle()
2273 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
2274 Dim args As New GetWorkerArg()
2277 args.type = WORKERTYPE.PostMessage
2278 args.status = rslt.status
2282 If rslt.retMsg.Length = 0 AndAlso SettingDialog.PostAndGet Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2283 Case WORKERTYPE.Retweet
2284 If rslt.retMsg.Length = 0 Then
2285 _postTimestamps.Add(Now)
2286 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2287 For i As Integer = _postTimestamps.Count - 1 To 0 Step -1
2288 If _postTimestamps(i).CompareTo(oneHour) < 0 Then
2289 _postTimestamps.RemoveAt(i)
2292 If SettingDialog.PostAndGet Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2294 Case WORKERTYPE.Follower
2295 '_waitFollower = False
2296 _itemCache = Nothing
2297 _postCache = Nothing
2298 If _curList IsNot Nothing Then _curList.Refresh()
2299 Case WORKERTYPE.PublicSearch
2300 _waitPubSearch = False
2301 Case WORKERTYPE.List
2307 Private Sub GetTimeline(ByVal WkType As WORKERTYPE, ByVal fromPage As Integer, ByVal toPage As Integer, ByVal tabName As String)
2309 If Not IsNetworkAvailable() Then Exit Sub
2312 Dim args As New GetWorkerArg
2313 args.page = fromPage
2314 args.endPage = toPage
2316 args.tName = tabName
2318 Static lastTime As New Dictionary(Of WORKERTYPE, DateTime)
2319 If Not lastTime.ContainsKey(WkType) Then lastTime.Add(WkType, New DateTime)
2320 Dim period As Double = Now.Subtract(lastTime(WkType)).TotalSeconds
2321 If period > 1 OrElse period < -1 Then
2322 lastTime(WkType) = Now
2326 'Timeline取得モードの場合はReplyも同時に取得
2327 'If Not SettingDialog.UseAPI AndAlso _
2328 ' Not _initial AndAlso _
2329 ' WkType = WORKERTYPE.Timeline AndAlso _
2330 ' SettingDialog.CheckReply Then
2331 ' 'TimerReply.Enabled = False
2332 ' _mentionCounter = SettingDialog.ReplyPeriodInt
2333 ' Dim _args As New GetWorkerArg
2334 ' _args.page = fromPage
2335 ' _args.endPage = toPage
2336 ' _args.type = WORKERTYPE.Reply
2341 Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
2342 If e.Button = Windows.Forms.MouseButtons.Left Then
2344 If Me.WindowState = FormWindowState.Minimized Then
2345 Me.WindowState = FormWindowState.Normal
2351 Private Sub MyList_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
2352 MakeReplyOrDirectStatus()
2355 Private Sub FavAddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavAddToolStripMenuItem.Click, FavOpMenuItem.Click
2356 FavoriteChange(True)
2359 Private Sub FavRemoveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavRemoveToolStripMenuItem.Click, UnFavOpMenuItem.Click
2360 FavoriteChange(False)
2363 Private Sub FavoriteChange(ByVal FavAdd As Boolean)
2364 'TrueでFavAdd,FalseでFavRemove
2365 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage OrElse _curList.SelectedIndices.Count = 0 Then Exit Sub
2368 If _curList.SelectedIndices.Count > 1 Then
2369 If MessageBox.Show(My.Resources.FavAddToolStripMenuItem_ClickText1, My.Resources.FavAddToolStripMenuItem_ClickText2, _
2370 MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
2375 Dim args As New GetWorkerArg
2376 args.ids = New List(Of Long)
2377 args.sIds = New List(Of Long)
2378 args.tName = _curTab.Text
2379 If FavAdd = True Then
2380 args.type = WORKERTYPE.FavAdd
2382 args.type = WORKERTYPE.FavRemove
2384 For Each idx As Integer In _curList.SelectedIndices
2385 Dim post As PostClass = GetCurTabPost(idx)
2386 If FavAdd = True Then
2387 If Not post.IsFav Then args.ids.Add(post.Id)
2389 If post.IsFav Then args.ids.Add(post.Id)
2392 If args.ids.Count = 0 Then
2393 If FavAdd = True Then
2394 StatusLabel.Text = My.Resources.FavAddToolStripMenuItem_ClickText4
2396 StatusLabel.Text = My.Resources.FavRemoveToolStripMenuItem_ClickText4
2404 Private Function GetCurTabPost(ByVal Index As Integer) As PostClass
2405 If _postCache IsNot Nothing AndAlso Index >= _itemCacheIndex AndAlso Index < _itemCacheIndex + _postCache.Length Then
2406 Return _postCache(Index - _itemCacheIndex)
2408 Return _statuses.Item(_curTab.Text, Index)
2413 Private Sub MoveToHomeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToHomeToolStripMenuItem.Click, OpenHomeOpMenuItem.Click
2414 If _curList.SelectedIndices.Count > 0 Then
2415 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
2416 ElseIf _curList.SelectedIndices.Count = 0 Then
2417 OpenUriAsync("http://twitter.com/")
2421 Private Sub MoveToFavToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToFavToolStripMenuItem.Click, OpenFavOpMenuItem.Click
2422 If _curList.SelectedIndices.Count > 0 Then
2423 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
2427 Private Sub Tween_ClientSizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ClientSizeChanged
2428 If Me.WindowState <> FormWindowState.Minimized Then
2429 If Not _initialLayout AndAlso Me.Visible = True Then
2430 If Me.WindowState = FormWindowState.Normal Then
2431 _mySize = Me.ClientSize
2432 _mySpDis = Me.SplitContainer1.SplitterDistance
2433 _mySpDis3 = Me.SplitContainer3.SplitterDistance
2434 If StatusText.Multiline Then _mySpDis2 = Me.StatusText.Height
2435 _modifySettingLocal = True
2441 Private Sub MyList_ColumnClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs)
2442 If SettingDialog.SortOrderLock Then Exit Sub
2443 Dim mode As IdComparerClass.ComparerMode
2445 mode = IdComparerClass.ComparerMode.Id
2447 Select Case e.Column
2448 Case 0, 5, 6 '0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
2452 mode = IdComparerClass.ComparerMode.Nickname
2454 mode = IdComparerClass.ComparerMode.Data
2456 mode = IdComparerClass.ComparerMode.Id
2458 mode = IdComparerClass.ComparerMode.Name
2460 mode = IdComparerClass.ComparerMode.Source
2463 _statuses.ToggleSortOrder(mode)
2467 DirectCast(sender, DetailsListView).Columns.Item(0).Text = ColumnOrgText(0)
2468 DirectCast(sender, DetailsListView).Columns.Item(1).Text = ColumnText(2)
2470 For i As Integer = 0 To 7
2471 DirectCast(sender, DetailsListView).Columns.Item(i).Text = ColumnOrgText(i)
2473 DirectCast(sender, DetailsListView).Columns.Item(e.Column).Text = ColumnText(e.Column)
2476 _itemCache = Nothing
2477 _postCache = Nothing
2479 If _statuses.Tabs(_curTab.Text).AllCount > 0 AndAlso _curPost IsNot Nothing Then
2480 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.Id)
2481 SelectListItem(_curList, idx)
2482 _curList.EnsureVisible(idx)
2485 _modifySettingCommon = True
2488 Private Sub Tween_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
2489 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
2490 _myLoc = Me.DesktopLocation
2491 _modifySettingLocal = True
2495 Private Sub ContextMenuOperate_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuOperate.Opening
2496 If ListTab.SelectedTab Is Nothing Then Exit Sub
2497 If _statuses Is Nothing OrElse _statuses.Tabs Is Nothing OrElse Not _statuses.Tabs.ContainsKey(ListTab.SelectedTab.Text) Then Exit Sub
2498 If _curPost Is Nothing Then
2499 ShowProfileMenuItem.Enabled = False
2500 ListManageUserContextToolStripMenuItem2.Enabled = False
2501 ReplyStripMenuItem.Enabled = False
2502 ReplyAllStripMenuItem.Enabled = False
2503 DMStripMenuItem.Enabled = False
2504 MoveToFavToolStripMenuItem.Enabled = False
2505 StatusOpenMenuItem.Enabled = False
2506 FavorareMenuItem.Enabled = False
2507 TabMenuItem.Enabled = False
2508 IDRuleMenuItem.Enabled = False
2509 ReadedStripMenuItem.Enabled = False
2510 UnreadStripMenuItem.Enabled = False
2511 DeleteStripMenuItem.Enabled = False
2513 ShowProfileMenuItem.Enabled = True
2514 ListManageUserContextToolStripMenuItem2.Enabled = True
2515 ReplyStripMenuItem.Enabled = True
2516 ReplyAllStripMenuItem.Enabled = True
2517 DMStripMenuItem.Enabled = True
2518 MoveToFavToolStripMenuItem.Enabled = True
2519 StatusOpenMenuItem.Enabled = True
2520 FavorareMenuItem.Enabled = True
2521 TabMenuItem.Enabled = True
2522 IDRuleMenuItem.Enabled = True
2523 ReadedStripMenuItem.Enabled = True
2524 UnreadStripMenuItem.Enabled = True
2525 DeleteStripMenuItem.Enabled = True
2527 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage OrElse _curPost Is Nothing Then
2528 FavAddToolStripMenuItem.Enabled = False
2529 FavRemoveToolStripMenuItem.Enabled = False
2530 StatusOpenMenuItem.Enabled = False
2531 FavorareMenuItem.Enabled = False
2533 If IsNetworkAvailable() Then
2534 FavAddToolStripMenuItem.Enabled = True
2535 FavRemoveToolStripMenuItem.Enabled = True
2536 StatusOpenMenuItem.Enabled = True
2537 FavorareMenuItem.Enabled = True
2540 If _curPost Is Nothing OrElse _curPost.IsDm Then
2541 ReTweetStripMenuItem.Enabled = False
2542 ReTweetOriginalStripMenuItem.Enabled = False
2543 QuoteStripMenuItem.Enabled = False
2544 If _curPost IsNot Nothing AndAlso _curPost.IsDm Then DeleteStripMenuItem.Enabled = True
2546 If _curPost.IsMe Then
2547 ReTweetOriginalStripMenuItem.Enabled = False
2548 DeleteStripMenuItem.Enabled = True
2550 ReTweetOriginalStripMenuItem.Enabled = True
2551 DeleteStripMenuItem.Enabled = False
2553 ReTweetStripMenuItem.Enabled = True
2554 QuoteStripMenuItem.Enabled = True
2556 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.Favorites Then
2557 RefreshMoreStripMenuItem.Enabled = True
2559 RefreshMoreStripMenuItem.Enabled = False
2561 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch _
2562 OrElse _curPost Is Nothing _
2563 OrElse Not _curPost.InReplyToId > 0 Then
2564 RepliedStatusOpenMenuItem.Enabled = False
2566 RepliedStatusOpenMenuItem.Enabled = True
2568 If _curPost Is Nothing OrElse _curPost.RetweetedBy = "" Then
2569 MoveToRTHomeMenuItem.Enabled = False
2571 MoveToRTHomeMenuItem.Enabled = True
2575 Private Sub ReplyStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReplyStripMenuItem.Click, ReplyOpMenuItem.Click
2576 MakeReplyOrDirectStatus(False, True)
2579 Private Sub DMStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DMStripMenuItem.Click, DmOpMenuItem.Click
2580 MakeReplyOrDirectStatus(False, False)
2583 Private Sub doStatusDelete()
2584 If _curTab Is Nothing OrElse _curList Is Nothing Then Exit Sub
2585 If _statuses.Tabs(_curTab.Text).TabType <> TabUsageType.DirectMessage Then
2586 Dim myPost As Boolean = False
2587 For Each idx As Integer In _curList.SelectedIndices
2588 If GetCurTabPost(idx).IsMe OrElse _
2589 GetCurTabPost(idx).RetweetedBy.ToLower = tw.Username.ToLower Then
2594 If Not myPost Then Exit Sub
2596 If _curList.SelectedIndices.Count = 0 Then
2601 Dim tmp As String = String.Format(My.Resources.DeleteStripMenuItem_ClickText1, Environment.NewLine)
2603 If MessageBox.Show(tmp, My.Resources.DeleteStripMenuItem_ClickText2, _
2604 MessageBoxButtons.OKCancel, _
2605 MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then Exit Sub
2608 If _curList.FocusedItem IsNot Nothing Then
2609 fidx = _curList.FocusedItem.Index
2610 ElseIf _curList.TopItem IsNot Nothing Then
2611 fidx = _curList.TopItem.Index
2617 Me.Cursor = Cursors.WaitCursor
2619 Dim rslt As Boolean = True
2620 For Each Id As Long In _statuses.GetId(_curTab.Text, _curList.SelectedIndices)
2621 Dim rtn As String = ""
2622 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then
2623 rtn = tw.RemoveDirectMessage(Id)
2625 If _statuses.Item(Id).IsMe OrElse _statuses.Item(Id).RetweetedBy.ToLower = tw.Username.ToLower Then
2626 rtn = tw.RemoveStatus(Id)
2631 If rtn.Length > 0 Then
2635 _statuses.RemovePost(Id)
2640 StatusLabel.Text = My.Resources.DeleteStripMenuItem_ClickText3 '失敗
2642 StatusLabel.Text = My.Resources.DeleteStripMenuItem_ClickText4 '成功
2645 _itemCache = Nothing 'キャッシュ破棄
2646 _postCache = Nothing
2649 For Each tb As TabPage In ListTab.TabPages
2650 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
2651 If _curTab.Equals(tb) Then
2652 _curList.SelectedIndices.Clear()
2653 If _statuses.Tabs(tb.Text).AllCount > 0 Then
2654 If _statuses.Tabs(tb.Text).AllCount - 1 > fidx AndAlso fidx > -1 Then
2655 _curList.SelectedIndices.Add(fidx)
2657 _curList.SelectedIndices.Add(_statuses.Tabs(tb.Text).AllCount - 1)
2659 If _curList.SelectedIndices.Count > 0 Then
2660 _curList.EnsureVisible(_curList.SelectedIndices(0))
2661 _curList.FocusedItem = _curList.Items(_curList.SelectedIndices(0))
2665 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2666 If SettingDialog.TabIconDisp Then
2667 If tb.ImageIndex = 0 Then tb.ImageIndex = -1 'タブアイコン
2671 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2673 Me.Cursor = Cursors.Default
2677 Private Sub DeleteStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteStripMenuItem.Click, DelOpMenuItem.Click
2681 Private Sub ReadedStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadedStripMenuItem.Click, ReadOpMenuItem.Click
2682 _curList.BeginUpdate()
2683 If SettingDialog.UnreadManage Then
2684 For Each idx As Integer In _curList.SelectedIndices
2685 _statuses.SetRead(True, _curTab.Text, idx)
2688 For Each idx As Integer In _curList.SelectedIndices
2689 ChangeCacheStyleRead(True, idx, _curTab)
2692 _curList.EndUpdate()
2693 For Each tb As TabPage In ListTab.TabPages
2694 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2695 If SettingDialog.TabIconDisp Then
2696 If tb.ImageIndex = 0 Then tb.ImageIndex = -1 'タブアイコン
2700 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2703 Private Sub UnreadStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnreadStripMenuItem.Click, UnreadOpMenuItem.Click
2704 _curList.BeginUpdate()
2705 If SettingDialog.UnreadManage Then
2706 For Each idx As Integer In _curList.SelectedIndices
2707 _statuses.SetRead(False, _curTab.Text, idx)
2710 For Each idx As Integer In _curList.SelectedIndices
2711 ChangeCacheStyleRead(False, idx, _curTab)
2714 _curList.EndUpdate()
2715 For Each tb As TabPage In ListTab.TabPages
2716 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
2717 If SettingDialog.TabIconDisp Then
2718 If tb.ImageIndex = -1 Then tb.ImageIndex = 0 'タブアイコン
2722 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2725 Private Sub RefreshStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshStripMenuItem.Click, RefreshOpMenuItem.Click
2729 Private Sub DoRefresh()
2730 If _curTab IsNot Nothing Then
2731 Select Case _statuses.Tabs(_curTab.Text).TabType
2732 Case TabUsageType.Mentions
2733 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
2734 Case TabUsageType.DirectMessage
2735 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
2736 Case TabUsageType.Favorites
2737 GetTimeline(WORKERTYPE.Favorites, 1, 0, "")
2738 'Case TabUsageType.Profile
2740 Case TabUsageType.PublicSearch
2742 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2743 If tb.SearchWords = "" Then Exit Sub
2744 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, _curTab.Text)
2745 Case TabUsageType.Lists
2747 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2748 If tb.ListInfo Is Nothing OrElse tb.ListInfo.Id = 0 Then Exit Sub
2749 GetTimeline(WORKERTYPE.List, 1, 0, _curTab.Text)
2751 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2754 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2758 Private Sub DoRefreshMore()
2759 If _curTab IsNot Nothing Then
2760 Select Case _statuses.Tabs(_curTab.Text).TabType
2761 Case TabUsageType.Mentions
2762 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
2763 Case TabUsageType.DirectMessage
2764 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
2765 Case TabUsageType.Favorites
2766 ' GetTimeline(WORKERTYPE.Favorites, -1, 0, "")
2767 Case TabUsageType.Profile
2769 Case TabUsageType.PublicSearch
2771 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2772 If tb.SearchWords = "" Then Exit Sub
2773 GetTimeline(WORKERTYPE.PublicSearch, -1, 0, _curTab.Text)
2774 Case TabUsageType.Lists
2776 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2777 If tb.ListInfo Is Nothing OrElse tb.ListInfo.Id = 0 Then Exit Sub
2778 GetTimeline(WORKERTYPE.List, -1, 0, _curTab.Text)
2780 GetTimeline(WORKERTYPE.Timeline, -1, 0, "")
2783 GetTimeline(WORKERTYPE.Timeline, -1, 0, "")
2787 Private Sub SettingStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingStripMenuItem.Click, SettingFileMenuItem.Click
2788 Dim result As DialogResult
2789 Dim uid As String = tw.Username.ToLower
2792 result = SettingDialog.ShowDialog()
2793 Catch ex As Exception
2797 If result = Windows.Forms.DialogResult.OK Then
2798 SyncLock _syncObject
2800 If SettingDialog.TimelinePeriodInt > 0 Then
2801 _homeCounterAdjuster = 0
2803 Catch ex As Exception
2804 ex.Data("Instance") = "Set Timers"
2805 ex.Data("IsTerminatePermission") = False
2808 tw.CountApi = SettingDialog.CountApi
2809 tw.CountApiReply = SettingDialog.CountApiReply
2810 tw.TinyUrlResolve = SettingDialog.TinyUrlResolve
2811 tw.RestrictFavCheck = SettingDialog.RestrictFavCheck
2812 tw.ReadOwnPost = SettingDialog.ReadOwnPost
2813 tw.UseSsl = SettingDialog.UseSsl
2814 ShortUrl.BitlyId = SettingDialog.BitlyUser
2815 ShortUrl.BitlyKey = SettingDialog.BitlyPwd
2816 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
2817 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
2819 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, _
2820 SettingDialog.SelectedProxyType, _
2821 SettingDialog.ProxyAddress, _
2822 SettingDialog.ProxyPort, _
2823 SettingDialog.ProxyUser, _
2824 SettingDialog.ProxyPassword)
2826 If SettingDialog.TabIconDisp Then
2827 RemoveHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
2828 ListTab.DrawMode = TabDrawMode.Normal
2829 ListTab.ImageList = Me.TabImage
2831 RemoveHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
2832 AddHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
2833 ListTab.DrawMode = TabDrawMode.OwnerDrawFixed
2834 ListTab.ImageList = Nothing
2836 Catch ex As Exception
2837 ex.Data("Instance") = "ListTab(TabIconDisp)"
2838 ex.Data("IsTerminatePermission") = False
2843 If Not SettingDialog.UnreadManage Then
2844 ReadedStripMenuItem.Enabled = False
2845 UnreadStripMenuItem.Enabled = False
2846 If SettingDialog.TabIconDisp Then
2847 For Each myTab As TabPage In ListTab.TabPages
2848 myTab.ImageIndex = -1
2852 ReadedStripMenuItem.Enabled = True
2853 UnreadStripMenuItem.Enabled = True
2855 Catch ex As Exception
2856 ex.Data("Instance") = "ListTab(UnreadManage)"
2857 ex.Data("IsTerminatePermission") = False
2862 For Each mytab As TabPage In ListTab.TabPages
2863 Dim lst As DetailsListView = DirectCast(mytab.Tag, DetailsListView)
2864 lst.GridLines = SettingDialog.ShowGrid
2866 Catch ex As Exception
2867 ex.Data("Instance") = "ListTab(ShowGrid)"
2868 ex.Data("IsTerminatePermission") = False
2872 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
2873 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
2874 _fntUnread = SettingDialog.FontUnread
2875 _clUnread = SettingDialog.ColorUnread
2876 _fntReaded = SettingDialog.FontReaded
2877 _clReaded = SettingDialog.ColorReaded
2878 _clFav = SettingDialog.ColorFav
2879 _clOWL = SettingDialog.ColorOWL
2880 _clRetweet = SettingDialog.ColorRetweet
2881 _fntDetail = SettingDialog.FontDetail
2882 _clDetail = SettingDialog.ColorDetail
2883 _clDetailLink = SettingDialog.ColorDetailLink
2884 _clDetailBackcolor = SettingDialog.ColorDetailBackcolor
2885 _clSelf = SettingDialog.ColorSelf
2886 _clAtSelf = SettingDialog.ColorAtSelf
2887 _clTarget = SettingDialog.ColorTarget
2888 _clAtTarget = SettingDialog.ColorAtTarget
2889 _clAtFromTarget = SettingDialog.ColorAtFromTarget
2890 _clAtTo = SettingDialog.ColorAtTo
2891 _clListBackcolor = SettingDialog.ColorListBackcolor
2892 _clInputBackcolor = SettingDialog.ColorInputBackcolor
2893 _clInputFont = SettingDialog.ColorInputFont
2894 _fntInputFont = SettingDialog.FontInputFont
2896 If StatusText.Focused Then StatusText.BackColor = _clInputBackcolor
2897 StatusText.Font = _fntInputFont
2898 StatusText.ForeColor = _clInputFont
2899 Catch ex As Exception
2900 MessageBox.Show(ex.Message)
2903 _brsForeColorUnread.Dispose()
2904 _brsForeColorReaded.Dispose()
2905 _brsForeColorFav.Dispose()
2906 _brsForeColorOWL.Dispose()
2907 _brsForeColorRetweet.Dispose()
2908 _brsForeColorUnread = New SolidBrush(_clUnread)
2909 _brsForeColorReaded = New SolidBrush(_clReaded)
2910 _brsForeColorFav = New SolidBrush(_clFav)
2911 _brsForeColorOWL = New SolidBrush(_clOWL)
2912 _brsForeColorRetweet = New SolidBrush(_clRetweet)
2913 _brsBackColorMine.Dispose()
2914 _brsBackColorAt.Dispose()
2915 _brsBackColorYou.Dispose()
2916 _brsBackColorAtYou.Dispose()
2917 _brsBackColorAtFromTarget.Dispose()
2918 _brsBackColorAtTo.Dispose()
2919 _brsBackColorNone.Dispose()
2920 _brsBackColorMine = New SolidBrush(_clSelf)
2921 _brsBackColorAt = New SolidBrush(_clAtSelf)
2922 _brsBackColorYou = New SolidBrush(_clTarget)
2923 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
2924 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
2925 _brsBackColorAtTo = New SolidBrush(_clAtTo)
2926 _brsBackColorNone = New SolidBrush(_clListBackcolor)
2928 If SettingDialog.IsMonospace Then
2929 detailHtmlFormatHeader = detailHtmlFormatMono1
2930 detailHtmlFormatFooter = detailHtmlFormatMono7
2932 detailHtmlFormatHeader = detailHtmlFormat1
2933 detailHtmlFormatFooter = detailHtmlFormat7
2935 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
2936 If SettingDialog.IsMonospace Then
2937 detailHtmlFormatHeader += detailHtmlFormatMono6
2939 detailHtmlFormatHeader += detailHtmlFormat6
2941 Catch ex As Exception
2942 ex.Data("Instance") = "Font"
2943 ex.Data("IsTerminatePermission") = False
2947 _statuses.SetUnreadManage(SettingDialog.UnreadManage)
2948 Catch ex As Exception
2949 ex.Data("Instance") = "_statuses"
2950 ex.Data("IsTerminatePermission") = False
2955 For Each tb As TabPage In ListTab.TabPages
2956 If SettingDialog.TabIconDisp Then
2957 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2963 If tb.Tag IsNot Nothing AndAlso tb.Controls.Count > 0 Then
2964 DirectCast(tb.Tag, DetailsListView).Font = _fntReaded
2965 DirectCast(tb.Tag, DetailsListView).BackColor = _clListBackcolor
2968 Catch ex As Exception
2969 ex.Data("Instance") = "ListTab(TabIconDisp no2)"
2970 ex.Data("IsTerminatePermission") = False
2973 SetMainWindowTitle()
2976 _itemCache = Nothing
2977 _postCache = Nothing
2978 If _curList IsNot Nothing Then _curList.Refresh()
2981 Outputz.Key = SettingDialog.OutputzKey
2982 Outputz.Enabled = SettingDialog.OutputzEnabled
2983 Select Case SettingDialog.OutputzUrlmode
2984 Case OutputzUrlmode.twittercom
2985 Outputz.OutUrl = "http://twitter.com/"
2986 Case OutputzUrlmode.twittercomWithUsername
2987 Outputz.OutUrl = "http://twitter.com/" + tw.Username
2990 _hookGlobalHotkey.UnregisterAllOriginalHotkey()
2991 If SettingDialog.HotkeyEnabled Then
2992 '''グローバルホットキーの登録。設定で変更可能にするかも
2993 Dim modKey As HookGlobalHotkey.ModKeys = HookGlobalHotkey.ModKeys.None
2994 If (SettingDialog.HotkeyMod And Keys.Alt) = Keys.Alt Then modKey = modKey Or HookGlobalHotkey.ModKeys.Alt
2995 If (SettingDialog.HotkeyMod And Keys.Control) = Keys.Control Then modKey = modKey Or HookGlobalHotkey.ModKeys.Ctrl
2996 If (SettingDialog.HotkeyMod And Keys.Shift) = Keys.Shift Then modKey = modKey Or HookGlobalHotkey.ModKeys.Shift
2997 If (SettingDialog.HotkeyMod And Keys.LWin) = Keys.LWin Then modKey = modKey Or HookGlobalHotkey.ModKeys.Win
2999 _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey)
3002 If uid <> tw.Username Then Me.doGetFollowersMenu()
3004 SetImageServiceCombo()
3008 Twitter.AccountState = ACCOUNT_STATE.Valid
3010 Me.TopMost = SettingDialog.AlwaysTop
3011 SaveConfigsAll(False)
3014 Private Sub PostBrowser_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles PostBrowser.Navigated
3015 If e.Url.AbsoluteUri <> "about:blank" Then
3017 OpenUriAsync(e.Url.OriginalString)
3021 Private Sub PostBrowser_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles PostBrowser.Navigating
3022 If e.Url.Scheme = "data" Then
3023 StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&")
3024 ElseIf e.Url.AbsoluteUri <> "about:blank" Then
3027 If e.Url.AbsoluteUri.StartsWith("http://twitter.com/search?q=%23") OrElse _
3028 e.Url.AbsoluteUri.StartsWith("https://twitter.com/search?q=%23") Then
3030 Dim urlStr As String = HttpUtility.UrlDecode(e.Url.AbsoluteUri)
3031 Dim hash As String = urlStr.Substring(urlStr.IndexOf("#"))
3032 AddNewTabForSearch(hash)
3035 OpenUriAsync(e.Url.OriginalString)
3040 Public Sub AddNewTabForSearch(ByVal searchWord As String)
3041 '同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了
3042 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch)
3043 If tb.SearchWords = searchWord AndAlso tb.SearchLang = "" Then
3044 For Each tp As TabPage In ListTab.TabPages
3045 If tb.TabName = tp.Text Then
3046 ListTab.SelectedTab = tp
3053 Dim tabName As String = searchWord
3054 For i As Integer = 0 To 100
3055 If _statuses.ContainsTab(tabName) Then
3062 AddNewTab(tabName, False, TabUsageType.PublicSearch)
3063 _statuses.AddTab(tabName, TabUsageType.PublicSearch, Nothing)
3065 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
3067 Dim cmb As ComboBox = DirectCast(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), ComboBox)
3068 cmb.Items.Add(searchWord)
3069 cmb.Text = searchWord
3072 Me.SearchButton_Click(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), Nothing)
3075 Public Function AddNewTab(ByVal tabName As String, ByVal startup As Boolean, ByVal tabType As TabUsageType) As Boolean
3077 For Each tb As TabPage In ListTab.TabPages
3078 If tb.Text = tabName Then Return False
3082 If tabName = My.Resources.AddNewTabText1 Then Return False
3086 If tabType = TabUsageType.DirectMessage OrElse _
3087 tabType = TabUsageType.Favorites OrElse _
3088 tabType = TabUsageType.Home OrElse _
3089 tabType = TabUsageType.Mentions Then
3090 If _statuses.GetTabByType(tabType) IsNot Nothing Then Return False
3094 Dim _tabPage As TabPage = New TabPage
3095 Dim _listCustom As DetailsListView = New DetailsListView
3096 Dim _colHd1 As ColumnHeader = New ColumnHeader() 'アイコン
3097 Dim _colHd2 As ColumnHeader = New ColumnHeader() 'ニックネーム
3098 Dim _colHd3 As ColumnHeader = New ColumnHeader() '本文
3099 Dim _colHd4 As ColumnHeader = New ColumnHeader() '日付
3100 Dim _colHd5 As ColumnHeader = New ColumnHeader() 'ユーザID
3101 Dim _colHd6 As ColumnHeader = New ColumnHeader() '未読
3102 Dim _colHd7 As ColumnHeader = New ColumnHeader() 'マーク&プロテクト
3103 Dim _colHd8 As ColumnHeader = New ColumnHeader() 'ソース
3105 Dim cnt As Integer = ListTab.TabPages.Count
3107 '''ToDo:Create and set controls follow tabtypes
3109 Me.SplitContainer1.Panel1.SuspendLayout()
3110 Me.SplitContainer1.Panel2.SuspendLayout()
3111 Me.SplitContainer1.SuspendLayout()
3112 Me.ListTab.SuspendLayout()
3115 _tabPage.SuspendLayout()
3120 Dim pnl As Panel = Nothing
3121 If tabType = TabUsageType.PublicSearch Then
3124 Dim lbl As New Label
3125 Dim cmb As New ComboBox
3126 Dim btn As New Button
3127 Dim cmbLang As New ComboBox
3131 pnl.Controls.Add(cmb)
3132 pnl.Controls.Add(cmbLang)
3133 pnl.Controls.Add(btn)
3134 pnl.Controls.Add(lbl)
3135 pnl.Name = "panelSearch"
3136 pnl.Dock = DockStyle.Top
3137 pnl.Height = cmb.Height
3138 AddHandler pnl.Enter, AddressOf SearchControls_Enter
3139 AddHandler pnl.Leave, AddressOf SearchControls_Leave
3142 cmb.Anchor = AnchorStyles.Left Or AnchorStyles.Right
3143 cmb.Dock = DockStyle.Fill
3144 cmb.Name = "comboSearch"
3145 cmb.DropDownStyle = ComboBoxStyle.DropDown
3146 cmb.ImeMode = Windows.Forms.ImeMode.NoControl
3148 cmb.AutoCompleteMode = AutoCompleteMode.None
3150 If _statuses.ContainsTab(tabName) Then
3151 cmb.Items.Add(_statuses.Tabs(tabName).SearchWords)
3152 cmb.Text = _statuses.Tabs(tabName).SearchWords
3156 cmbLang.Anchor = AnchorStyles.Left Or AnchorStyles.Right
3157 cmbLang.Dock = DockStyle.Right
3159 cmbLang.Name = "comboLang"
3160 cmbLang.DropDownStyle = ComboBoxStyle.DropDownList
3161 cmbLang.TabStop = False
3162 cmbLang.Items.Add("")
3163 cmbLang.Items.Add("ja")
3164 cmbLang.Items.Add("en")
3165 cmbLang.Items.Add("ar")
3166 cmbLang.Items.Add("da")
3167 cmbLang.Items.Add("nl")
3168 cmbLang.Items.Add("fa")
3169 cmbLang.Items.Add("fi")
3170 cmbLang.Items.Add("fr")
3171 cmbLang.Items.Add("de")
3172 cmbLang.Items.Add("hu")
3173 cmbLang.Items.Add("is")
3174 cmbLang.Items.Add("it")
3175 cmbLang.Items.Add("no")
3176 cmbLang.Items.Add("pl")
3177 cmbLang.Items.Add("pt")
3178 cmbLang.Items.Add("ru")
3179 cmbLang.Items.Add("es")
3180 cmbLang.Items.Add("sv")
3181 cmbLang.Items.Add("th")
3182 If _statuses.ContainsTab(tabName) Then cmbLang.Text = _statuses.Tabs(tabName).SearchLang
3184 lbl.Text = "Search(C-S-f)"
3186 lbl.Dock = DockStyle.Left
3188 lbl.Height = cmb.Height
3189 lbl.TextAlign = ContentAlignment.MiddleLeft
3192 btn.Name = "buttonSearch"
3193 btn.UseVisualStyleBackColor = True
3194 btn.Dock = DockStyle.Right
3196 AddHandler btn.Click, AddressOf SearchButton_Click
3200 Me.ListTab.Controls.Add(_tabPage)
3201 _tabPage.Controls.Add(_listCustom)
3203 If tabType = TabUsageType.PublicSearch Then _tabPage.Controls.Add(pnl)
3205 _tabPage.Location = New Point(4, 4)
3206 _tabPage.Name = "CTab" + cnt.ToString()
3207 _tabPage.Size = New Size(380, 260)
3208 _tabPage.TabIndex = 2 + cnt
3209 _tabPage.Text = tabName
3210 _tabPage.UseVisualStyleBackColor = True
3212 _listCustom.AllowColumnReorder = True
3213 If Not _iconCol Then
3214 _listCustom.Columns.AddRange(New ColumnHeader() {_colHd1, _colHd2, _colHd3, _colHd4, _colHd5, _colHd6, _colHd7, _colHd8})
3216 _listCustom.Columns.AddRange(New ColumnHeader() {_colHd1, _colHd3})
3218 _listCustom.ContextMenuStrip = Me.ContextMenuOperate
3219 _listCustom.Dock = DockStyle.Fill
3220 _listCustom.FullRowSelect = True
3221 _listCustom.HideSelection = False
3222 _listCustom.Location = New Point(0, 0)
3223 _listCustom.Margin = New Padding(0)
3224 _listCustom.Name = "CList" + Environment.TickCount.ToString()
3225 _listCustom.ShowItemToolTips = True
3226 _listCustom.Size = New Size(380, 260)
3227 _listCustom.UseCompatibleStateImageBehavior = False
3228 _listCustom.View = View.Details
3229 _listCustom.OwnerDraw = True
3230 _listCustom.VirtualMode = True
3231 _listCustom.Font = _fntReaded
3232 _listCustom.BackColor = _clListBackcolor
3234 _listCustom.GridLines = SettingDialog.ShowGrid
3235 _listCustom.AllowDrop = True
3237 AddHandler _listCustom.SelectedIndexChanged, AddressOf MyList_SelectedIndexChanged
3238 AddHandler _listCustom.MouseDoubleClick, AddressOf MyList_MouseDoubleClick
3239 AddHandler _listCustom.ColumnClick, AddressOf MyList_ColumnClick
3240 AddHandler _listCustom.DrawColumnHeader, AddressOf MyList_DrawColumnHeader
3241 AddHandler _listCustom.DragDrop, AddressOf TweenMain_DragDrop
3242 AddHandler _listCustom.DragOver, AddressOf TweenMain_DragOver
3243 AddHandler _listCustom.DrawItem, AddressOf MyList_DrawItem
3244 AddHandler _listCustom.MouseClick, AddressOf MyList_MouseClick
3245 AddHandler _listCustom.ColumnReordered, AddressOf MyList_ColumnReordered
3246 AddHandler _listCustom.ColumnWidthChanged, AddressOf MyList_ColumnWidthChanged
3247 AddHandler _listCustom.CacheVirtualItems, AddressOf MyList_CacheVirtualItems
3248 AddHandler _listCustom.RetrieveVirtualItem, AddressOf MyList_RetrieveVirtualItem
3249 AddHandler _listCustom.DrawSubItem, AddressOf MyList_DrawSubItem
3252 _colHd1.Text = ColumnText(0)
3254 _colHd2.Text = ColumnText(1)
3256 _colHd3.Text = ColumnText(2)
3258 _colHd4.Text = ColumnText(3)
3260 _colHd5.Text = ColumnText(4)
3262 _colHd6.Text = ColumnText(5)
3264 _colHd7.Text = ColumnText(6)
3266 _colHd8.Text = ColumnText(7)
3269 If (_statuses.Tabs.ContainsKey(tabName) AndAlso _statuses.Tabs(tabName).TabType = TabUsageType.Mentions) _
3270 OrElse (Not _statuses.IsDefaultTab(tabName) AndAlso tabType <> TabUsageType.PublicSearch AndAlso tabType <> TabUsageType.Lists) Then
3271 TabDialog.AddTab(tabName)
3274 _listCustom.SmallImageList = New ImageList()
3276 _listCustom.SmallImageList.ImageSize = New Size(_iconSz, _iconSz)
3279 Dim dispOrder(7) As Integer
3281 For i As Integer = 0 To _curList.Columns.Count - 1
3282 For j As Integer = 0 To _curList.Columns.Count - 1
3283 If _curList.Columns(j).DisplayIndex = i Then
3289 For i As Integer = 0 To _curList.Columns.Count - 1
3290 _listCustom.Columns(i).Width = _curList.Columns(i).Width
3291 _listCustom.Columns(dispOrder(i)).DisplayIndex = i
3295 _listCustom.Columns(0).Width = _cfgLocal.Width1
3296 _listCustom.Columns(1).Width = _cfgLocal.Width3
3297 _listCustom.Columns(0).DisplayIndex = 0
3298 _listCustom.Columns(1).DisplayIndex = 1
3300 For i As Integer = 0 To 7
3301 If _cfgLocal.DisplayIndex1 = i Then
3303 ElseIf _cfgLocal.DisplayIndex2 = i Then
3305 ElseIf _cfgLocal.DisplayIndex3 = i Then
3307 ElseIf _cfgLocal.DisplayIndex4 = i Then
3309 ElseIf _cfgLocal.DisplayIndex5 = i Then
3311 ElseIf _cfgLocal.DisplayIndex6 = i Then
3313 ElseIf _cfgLocal.DisplayIndex7 = i Then
3315 ElseIf _cfgLocal.DisplayIndex8 = i Then
3319 _listCustom.Columns(0).Width = _cfgLocal.Width1
3320 _listCustom.Columns(1).Width = _cfgLocal.Width2
3321 _listCustom.Columns(2).Width = _cfgLocal.Width3
3322 _listCustom.Columns(3).Width = _cfgLocal.Width4
3323 _listCustom.Columns(4).Width = _cfgLocal.Width5
3324 _listCustom.Columns(5).Width = _cfgLocal.Width6
3325 _listCustom.Columns(6).Width = _cfgLocal.Width7
3326 _listCustom.Columns(7).Width = _cfgLocal.Width8
3327 For i As Integer = 0 To 7
3328 _listCustom.Columns(dispOrder(i)).DisplayIndex = i
3333 If tabType = TabUsageType.PublicSearch Then pnl.ResumeLayout(False)
3335 _tabPage.ResumeLayout(False)
3337 Me.SplitContainer1.Panel1.ResumeLayout(False)
3338 Me.SplitContainer1.Panel2.ResumeLayout(False)
3339 Me.SplitContainer1.ResumeLayout(False)
3340 Me.ListTab.ResumeLayout(False)
3341 Me.ResumeLayout(False)
3343 _tabPage.Tag = _listCustom
3347 Public Function RemoveSpecifiedTab(ByVal TabName As String) As Boolean
3348 Dim idx As Integer = 0
3349 For idx = 0 To ListTab.TabPages.Count - 1
3350 If ListTab.TabPages(idx).Text = TabName Then Exit For
3353 If _statuses.IsDefaultTab(TabName) Then Return False
3355 Dim tmp As String = String.Format(My.Resources.RemoveSpecifiedTabText1, Environment.NewLine)
3356 If MessageBox.Show(tmp, TabName + " " + My.Resources.RemoveSpecifiedTabText2, _
3357 MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Cancel Then
3361 SetListProperty() '他のタブに列幅等を反映
3363 Dim tabType As TabUsageType = _statuses.Tabs(TabName).TabType
3366 Me.SplitContainer1.Panel1.SuspendLayout()
3367 Me.SplitContainer1.Panel2.SuspendLayout()
3368 Me.SplitContainer1.SuspendLayout()
3369 Me.ListTab.SuspendLayout()
3372 Dim _tabPage As TabPage = ListTab.TabPages(idx)
3373 Dim _listCustom As DetailsListView = DirectCast(_tabPage.Tag, DetailsListView)
3374 _tabPage.Tag = Nothing
3376 _tabPage.SuspendLayout()
3378 Me.ListTab.Controls.Remove(_tabPage)
3380 Dim pnl As Control = Nothing
3381 If tabType = TabUsageType.PublicSearch Then
3382 pnl = _tabPage.Controls("panelSearch")
3383 For Each ctrl As Control In pnl.Controls
3384 If ctrl.Name = "buttonSearch" Then
3385 RemoveHandler ctrl.Click, AddressOf SearchButton_Click
3387 RemoveHandler ctrl.Enter, AddressOf SearchControls_Enter
3388 RemoveHandler ctrl.Leave, AddressOf SearchControls_Leave
3389 pnl.Controls.Remove(ctrl)
3392 _tabPage.Controls.Remove(pnl)
3395 _tabPage.Controls.Remove(_listCustom)
3396 _listCustom.Columns.Clear()
3397 _listCustom.ContextMenuStrip = Nothing
3399 RemoveHandler _listCustom.SelectedIndexChanged, AddressOf MyList_SelectedIndexChanged
3400 RemoveHandler _listCustom.MouseDoubleClick, AddressOf MyList_MouseDoubleClick
3401 RemoveHandler _listCustom.ColumnClick, AddressOf MyList_ColumnClick
3402 RemoveHandler _listCustom.DrawColumnHeader, AddressOf MyList_DrawColumnHeader
3403 RemoveHandler _listCustom.DragDrop, AddressOf TweenMain_DragDrop
3404 RemoveHandler _listCustom.DragOver, AddressOf TweenMain_DragOver
3405 RemoveHandler _listCustom.DrawItem, AddressOf MyList_DrawItem
3406 RemoveHandler _listCustom.MouseClick, AddressOf MyList_MouseClick
3407 RemoveHandler _listCustom.ColumnReordered, AddressOf MyList_ColumnReordered
3408 RemoveHandler _listCustom.ColumnWidthChanged, AddressOf MyList_ColumnWidthChanged
3409 RemoveHandler _listCustom.CacheVirtualItems, AddressOf MyList_CacheVirtualItems
3410 RemoveHandler _listCustom.RetrieveVirtualItem, AddressOf MyList_RetrieveVirtualItem
3411 RemoveHandler _listCustom.DrawSubItem, AddressOf MyList_DrawSubItem
3413 TabDialog.RemoveTab(TabName)
3415 _listCustom.SmallImageList = Nothing
3416 _listCustom.ListViewItemSorter = Nothing
3419 If _curTab.Equals(_tabPage) Then
3425 _itemCache = Nothing
3426 _itemCacheIndex = -1
3427 _postCache = Nothing
3429 _tabPage.ResumeLayout(False)
3431 Me.SplitContainer1.Panel1.ResumeLayout(False)
3432 Me.SplitContainer1.Panel2.ResumeLayout(False)
3433 Me.SplitContainer1.ResumeLayout(False)
3434 Me.ListTab.ResumeLayout(False)
3435 Me.ResumeLayout(False)
3439 _listCustom.Dispose()
3440 _statuses.RemoveTab(TabName)
3442 For Each tp As TabPage In ListTab.TabPages
3443 Dim lst As DetailsListView = DirectCast(tp.Tag, DetailsListView)
3444 If lst.VirtualListSize <> _statuses.Tabs(tp.Text).AllCount Then
3445 lst.VirtualListSize = _statuses.Tabs(tp.Text).AllCount
3451 Private Sub ListTab_Deselected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles ListTab.Deselected
3452 _itemCache = Nothing
3453 _itemCacheIndex = -1
3454 _postCache = Nothing
3457 Private Sub ListTab_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseMove
3459 Dim cpos As New Point(e.X, e.Y)
3461 If e.Button = Windows.Forms.MouseButtons.Left AndAlso _tabDrag Then
3462 Dim tn As String = ""
3463 For i As Integer = 0 To ListTab.TabPages.Count - 1
3464 Dim rect As Rectangle = ListTab.GetTabRect(i)
3465 If rect.Left <= cpos.X AndAlso cpos.X <= rect.Right AndAlso _
3466 rect.Top <= cpos.Y AndAlso cpos.Y <= rect.Bottom Then
3467 tn = ListTab.TabPages(i).Text
3472 If tn = "" Then Exit Sub
3474 For Each tb As TabPage In ListTab.TabPages
3475 If tb.Text = tn Then
3476 ListTab.DoDragDrop(tb, DragDropEffects.All)
3484 For i As Integer = 0 To ListTab.TabPages.Count - 1
3485 Dim rect As Rectangle = ListTab.GetTabRect(i)
3486 If rect.Left <= cpos.X And cpos.X <= rect.Right And _
3487 rect.Top <= cpos.Y And cpos.Y <= rect.Bottom Then
3488 _rclickTabName = ListTab.TabPages(i).Text
3494 Private Sub ListTab_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListTab.SelectedIndexChanged
3497 SetMainWindowTitle()
3499 If ListTab.Focused OrElse DirectCast(ListTab.SelectedTab.Tag, Control).Focused Then Me.Tag = ListTab.Tag
3500 TabMenuControl(ListTab.SelectedTab.Text)
3503 Private Sub SetListProperty()
3505 If _curList Is Nothing Then Exit Sub
3506 If Not _isColumnChanged Then Exit Sub
3508 Dim dispOrder(_curList.Columns.Count - 1) As Integer
3509 For i As Integer = 0 To _curList.Columns.Count - 1
3510 For j As Integer = 0 To _curList.Columns.Count - 1
3511 If _curList.Columns(j).DisplayIndex = i Then
3519 For Each tb As TabPage In ListTab.TabPages
3520 If Not tb.Equals(_curTab) Then
3521 If tb.Tag IsNot Nothing AndAlso tb.Controls.Count > 0 Then
3522 Dim lst As DetailsListView = DirectCast(tb.Tag, DetailsListView)
3523 For i As Integer = 0 To lst.Columns.Count - 1
3524 lst.Columns(dispOrder(i)).DisplayIndex = i
3525 lst.Columns(i).Width = _curList.Columns(i).Width
3531 _isColumnChanged = False
3534 Private Sub PostBrowser_StatusTextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles PostBrowser.StatusTextChanged
3535 If PostBrowser.StatusText.StartsWith("http") OrElse PostBrowser.StatusText.StartsWith("ftp") _
3536 OrElse PostBrowser.StatusText.StartsWith("data") Then
3537 StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&")
3539 If PostBrowser.StatusText = "" Then
3544 Private Sub StatusText_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles StatusText.KeyPress
3545 If e.KeyChar = "@" Then
3546 If Not SettingDialog.UseAtIdSupplement Then Exit Sub
3548 ShowSuplDialog(StatusText, AtIdSupl)
3550 ElseIf e.KeyChar = "#" Then
3551 If Not SettingDialog.UseHashSupplement Then Exit Sub
3552 ShowSuplDialog(StatusText, HashSupl)
3557 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement)
3558 ShowSuplDialog(owner, dialog, 0, "")
3561 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement, ByVal offset As Integer)
3562 ShowSuplDialog(owner, dialog, offset, "")
3565 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement, ByVal offset As Integer, ByVal startswith As String)
3566 dialog.StartsWith = startswith
3568 Me.TopMost = SettingDialog.AlwaysTop
3569 Dim selStart As Integer = owner.SelectionStart
3570 Dim fHalf As String = ""
3571 Dim eHalf As String = ""
3572 If dialog.DialogResult = Windows.Forms.DialogResult.OK Then
3573 If dialog.inputText <> "" Then
3574 If selStart > 0 Then
3575 fHalf = owner.Text.Substring(0, selStart - offset)
3577 If selStart < owner.Text.Length Then
3578 eHalf = owner.Text.Substring(selStart)
3580 owner.Text = fHalf + dialog.inputText + eHalf
3581 owner.SelectionStart = selStart + dialog.inputText.Length
3584 If selStart > 0 Then
3585 fHalf = owner.Text.Substring(0, selStart)
3587 If selStart < owner.Text.Length Then
3588 eHalf = owner.Text.Substring(selStart)
3590 owner.Text = fHalf + eHalf
3591 If selStart > 0 Then
3592 owner.SelectionStart = selStart
3598 Private Sub StatusText_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StatusText.KeyUp
3600 If Not e.Alt AndAlso Not e.Control AndAlso Not e.Shift Then
3601 If e.KeyCode = Keys.Space OrElse e.KeyCode = Keys.ProcessKey Then
3602 Dim isSpace As Boolean = False
3603 For Each c As Char In StatusText.Text.ToCharArray
3604 If c = " " OrElse c = " " Then
3613 StatusText.Text = ""
3614 JumpUnreadMenuItem_Click(Nothing, Nothing)
3618 Me.StatusText_TextChanged(Nothing, Nothing)
3621 Private Sub StatusText_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.TextChanged
3623 Dim pLen As Integer = GetRestStatusCount(True, False)
3624 lblLen.Text = pLen.ToString()
3626 StatusText.ForeColor = Color.Red
3628 StatusText.ForeColor = _clInputFont
3630 If StatusText.Text = "" Then
3636 Private Function GetRestStatusCount(ByVal isAuto As Boolean, ByVal isAddFooter As Boolean) As Integer
3638 Dim pLen As Integer = 140 - StatusText.Text.Length
3639 If (isAuto AndAlso Not My.Computer.Keyboard.ShiftKeyDown) OrElse _
3640 (Not isAuto AndAlso isAddFooter) Then
3641 If SettingDialog.UseRecommendStatus Then
3642 pLen -= SettingDialog.RecommendStatusText.Length
3643 ElseIf SettingDialog.Status.Length > 0 Then
3644 pLen -= SettingDialog.Status.Length + 1
3647 If HashMgr.UseHash <> "" Then
3648 pLen -= HashMgr.UseHash.Length + 1
3653 Private Sub MyList_CacheVirtualItems(ByVal sender As System.Object, ByVal e As System.Windows.Forms.CacheVirtualItemsEventArgs)
3654 If _itemCache IsNot Nothing AndAlso _
3655 e.StartIndex >= _itemCacheIndex AndAlso _
3656 e.EndIndex < _itemCacheIndex + _itemCache.Length AndAlso _
3657 _curList.Equals(sender) Then
3658 'If the newly requested cache is a subset of the old cache,
3659 'no need to rebuild everything, so do nothing.
3663 'Now we need to rebuild the cache.
3664 If _curList.Equals(sender) Then CreateCache(e.StartIndex, e.EndIndex)
3667 Private Sub MyList_RetrieveVirtualItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.RetrieveVirtualItemEventArgs)
3668 If _itemCache IsNot Nothing AndAlso e.ItemIndex >= _itemCacheIndex AndAlso e.ItemIndex < _itemCacheIndex + _itemCache.Length AndAlso _curList.Equals(sender) Then
3669 'A cache hit, so get the ListViewItem from the cache instead of making a new one.
3670 e.Item = _itemCache(e.ItemIndex - _itemCacheIndex)
3672 'A cache miss, so create a new ListViewItem and pass it back.
3673 Dim tb As TabPage = DirectCast(DirectCast(sender, Tween.TweenCustomControl.DetailsListView).Parent, TabPage)
3675 e.Item = CreateItem(tb, _
3676 _statuses.Item(tb.Text, e.ItemIndex), _
3678 Catch ex As Exception
3680 Dim sitem() As String = {"", "", "", "", "", "", "", ""}
3681 e.Item = New ListViewItem(sitem, "")
3686 Private Sub CreateCache(ByVal StartIndex As Integer, ByVal EndIndex As Integer)
3688 'キャッシュ要求(要求範囲±30を作成)
3690 If StartIndex < 0 Then StartIndex = 0
3692 If EndIndex >= _statuses.Tabs(_curTab.Text).AllCount Then EndIndex = _statuses.Tabs(_curTab.Text).AllCount - 1
3693 _postCache = _statuses.Item(_curTab.Text, StartIndex, EndIndex) '配列で取得
3694 _itemCacheIndex = StartIndex
3696 _itemCache = New ListViewItem(_postCache.Length - 1) {}
3697 For i As Integer = 0 To _postCache.Length - 1
3698 _itemCache(i) = CreateItem(_curTab, _postCache(i), StartIndex + i)
3700 Catch ex As Exception
3701 'キャッシュ要求が実データとずれるため(イベントの遅延?)
3702 _postCache = Nothing
3703 _itemCache = Nothing
3707 Private Function CreateItem(ByVal Tab As TabPage, ByVal Post As PostClass, ByVal Index As Integer) As ListViewItem
3708 Dim mk As String = ""
3709 If Post.IsMark Then mk += "♪"
3710 If Post.IsProtect Then mk += "Ю"
3711 If Post.InReplyToId > 0 Then mk += "⇒"
3712 Dim itm As ListViewItem
3713 If Post.RetweetedId = 0 Then
3714 Dim sitem() As String = {"", Post.Nickname, Post.Data, Post.PDate.ToString(SettingDialog.DateTimeFormat), Post.Name, "", mk, Post.Source}
3715 itm = New ListViewItem(sitem, Post.ImageUrl)
3717 Dim sitem() As String = {"", Post.Nickname, Post.Data, Post.PDate.ToString(SettingDialog.DateTimeFormat), Post.Name + "(RT:" + Post.RetweetedBy + ")", "", mk, Post.Source}
3718 itm = New ListViewItem(sitem, Post.ImageUrl)
3721 Dim read As Boolean = Post.IsRead
3722 '未読管理していなかったら既読として扱う
3723 If Not _statuses.Tabs(Tab.Text).UnreadManage OrElse _
3724 Not SettingDialog.UnreadManage Then read = True
3725 ChangeItemStyleRead(read, itm, Post, Nothing)
3726 If Tab.Equals(_curTab) Then ColorizeList(itm, Index)
3730 Private Sub MyList_DrawColumnHeader(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewColumnHeaderEventArgs)
3731 e.DrawDefault = True
3734 Private Sub MyList_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewItemEventArgs)
3735 If e.State = 0 Then Exit Sub
3736 e.DrawDefault = False
3737 If Not e.Item.Selected Then 'e.ItemStateでうまく判定できない???
3738 Dim brs2 As SolidBrush = Nothing
3739 Select Case e.Item.BackColor
3741 brs2 = _brsBackColorMine
3743 brs2 = _brsBackColorAt
3745 brs2 = _brsBackColorYou
3747 brs2 = _brsBackColorAtYou
3748 Case _clAtFromTarget
3749 brs2 = _brsBackColorAtFromTarget
3751 brs2 = _brsBackColorAtTo
3753 brs2 = _brsBackColorNone
3755 e.Graphics.FillRectangle(brs2, e.Bounds)
3758 If DirectCast(sender, Windows.Forms.Control).Focused Then
3759 e.Graphics.FillRectangle(_brsHighLight, e.Bounds)
3761 e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds)
3764 If (e.State And ListViewItemStates.Focused) = ListViewItemStates.Focused Then e.DrawFocusRectangle()
3767 Private Sub MyList_DrawSubItem(ByVal sender As Object, ByVal e As DrawListViewSubItemEventArgs)
3768 If e.ItemState = 0 Then Exit Sub
3770 If e.ColumnIndex = 0 OrElse Math.Abs(e.Header.DisplayIndex - e.Item.ListView.Columns(0).DisplayIndex) = 1 Then
3771 Me.DrawListViewItemIcon(e)
3774 If e.ColumnIndex > 0 Then
3776 Dim rct As RectangleF = e.Bounds
3777 Dim rctB As RectangleF = e.Bounds
3778 rct.Width = e.Header.Width
3779 rctB.Width = e.Header.Width
3780 If _iconCol Then rctB.Height = e.Item.Font.Height
3782 Dim heightDiff As Integer = CType(rct.Height Mod CType(e.Item.Font.Height, Single), Integer)
3783 rct.Inflate(0, CType(heightDiff / -2, Integer))
3784 If Not e.Item.Selected Then 'e.ItemStateでうまく判定できない???
3787 Dim brs As SolidBrush = Nothing
3788 Dim flg As Boolean = False
3789 Select Case e.Item.ForeColor
3791 brs = _brsForeColorUnread
3793 brs = _brsForeColorReaded
3795 brs = _brsForeColorFav
3797 brs = _brsForeColorOWL
3799 brs = _brsForeColorRetweet
3801 brs = New SolidBrush(e.Item.ForeColor)
3804 If rct.Width > 0 Then
3806 Dim fnt As New Font(e.Item.Font, FontStyle.Bold)
3807 e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, brs, rct, sf)
3808 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)
3810 ElseIf e.Bounds.Height < e.Item.Font.Height * 2 Then
3811 TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.Font, Rectangle.Round(rct), brs.Color, TextFormatFlags.SingleLine Or TextFormatFlags.EndEllipsis Or TextFormatFlags.LeftAndRightPadding Or TextFormatFlags.NoPrefix)
3813 e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, brs, rct, sf)
3816 If flg Then brs.Dispose()
3818 If rct.Width > 0 Then
3820 Dim fnt As New Font(e.Item.Font, FontStyle.Bold)
3821 If DirectCast(sender, Windows.Forms.Control).Focused Then
3823 e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, _brsHighLightText, rct, sf)
3824 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)
3825 ElseIf e.Bounds.Height < e.Item.Font.Height * 2 Then
3826 TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.Font, Rectangle.Round(rct), _brsHighLightText.Color, TextFormatFlags.SingleLine Or TextFormatFlags.EndEllipsis Or TextFormatFlags.LeftAndRightPadding Or TextFormatFlags.NoPrefix)
3828 e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsHighLightText, rct, sf)
3832 e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, _brsForeColorUnread, rct, sf)
3833 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)
3834 ElseIf e.Bounds.Height < e.Item.Font.Height * 2 Then
3835 TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.Font, Rectangle.Round(rct), _brsForeColorUnread.Color, TextFormatFlags.SingleLine Or TextFormatFlags.EndEllipsis Or TextFormatFlags.LeftAndRightPadding Or TextFormatFlags.NoPrefix)
3837 e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsForeColorUnread, rct, sf)
3846 Private Sub DrawListViewItemIcon(ByVal e As DrawListViewSubItemEventArgs)
3847 If Not String.IsNullOrEmpty(e.Item.ImageKey) AndAlso Me.TIconDic.ContainsKey(e.Item.ImageKey) Then
3848 'e.Bounds.Leftが常に0を指すから自前で計算
3849 Dim itemRect As Rectangle = e.Item.Bounds
3850 itemRect.Width = e.Item.ListView.Columns(0).Width
3852 For Each clm As ColumnHeader In e.Item.ListView.Columns
3853 If clm.DisplayIndex < e.Item.ListView.Columns(0).DisplayIndex Then
3854 itemRect.X += clm.Width
3858 Dim iconRect As Rectangle = Rectangle.Intersect(e.Item.GetBounds(ItemBoundsPortion.Icon), itemRect)
3859 If iconRect.Width > 0 Then
3860 e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.High
3861 e.Graphics.DrawImage(Me.TIconDic(e.Item.ImageKey), iconRect)
3866 Private Sub DoTabSearch(ByVal _word As String, _
3867 ByVal CaseSensitive As Boolean, _
3868 ByVal UseRegex As Boolean, _
3869 ByVal SType As SEARCHTYPE)
3870 Dim cidx As Integer = 0
3871 Dim fnd As Boolean = False
3872 Dim toIdx As Integer
3873 Dim stp As Integer = 1
3875 If _curList.VirtualListSize = 0 Then
3876 MessageBox.Show(My.Resources.DoTabSearchText2, My.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information)
3879 If _curList.SelectedIndices.Count > 0 Then
3880 cidx = _curList.SelectedIndices(0)
3882 toIdx = _curList.VirtualListSize - 1
3885 Case SEARCHTYPE.DialogSearch 'ダイアログからの検索
3886 If _curList.SelectedIndices.Count > 0 Then
3887 cidx = _curList.SelectedIndices(0)
3891 Case SEARCHTYPE.NextSearch '次を検索
3892 If _curList.SelectedIndices.Count > 0 Then
3893 cidx = _curList.SelectedIndices(0) + 1
3894 If cidx > toIdx Then cidx = toIdx
3898 Case SEARCHTYPE.PrevSearch '前を検索
3899 If _curList.SelectedIndices.Count > 0 Then
3900 cidx = _curList.SelectedIndices(0) - 1
3901 If cidx < 0 Then cidx = 0
3909 Dim regOpt As RegexOptions = RegexOptions.None
3910 Dim fndOpt As StringComparison = StringComparison.Ordinal
3911 If Not CaseSensitive Then
3912 regOpt = RegexOptions.IgnoreCase
3913 fndOpt = StringComparison.OrdinalIgnoreCase
3919 Dim _search As Regex
3921 _search = New Regex(_word)
3922 For idx As Integer = cidx To toIdx Step stp
3923 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
3924 If _search.IsMatch(post.Nickname, regOpt) _
3925 OrElse _search.IsMatch(post.Data, regOpt) _
3926 OrElse _search.IsMatch(post.Name, regOpt) _
3928 SelectListItem(_curList, idx)
3929 _curList.EnsureVisible(idx)
3933 Catch ex As ArgumentException
3934 MsgBox(My.Resources.DoTabSearchText1, MsgBoxStyle.Critical)
3939 For idx As Integer = cidx To toIdx Step stp
3940 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
3941 If post.Nickname.IndexOf(_word, fndOpt) > -1 _
3942 OrElse post.Data.IndexOf(_word, fndOpt) > -1 _
3943 OrElse post.Name.IndexOf(_word, fndOpt) > -1 _
3945 SelectListItem(_curList, idx)
3946 _curList.EnsureVisible(idx)
3954 Case SEARCHTYPE.DialogSearch, SEARCHTYPE.NextSearch
3957 Case SEARCHTYPE.PrevSearch
3959 cidx = _curList.Items.Count - 1
3964 Catch ex As ArgumentOutOfRangeException
3967 MessageBox.Show(My.Resources.DoTabSearchText2, My.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information)
3970 Private Sub MenuItemSubSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSubSearch.Click
3972 SearchDialog.Owner = Me
3973 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
3974 Me.TopMost = SettingDialog.AlwaysTop
3977 Me.TopMost = SettingDialog.AlwaysTop
3979 If SearchDialog.SWord <> "" Then
3980 DoTabSearch(SearchDialog.SWord, _
3981 SearchDialog.CheckCaseSensitive, _
3982 SearchDialog.CheckRegex, _
3983 SEARCHTYPE.DialogSearch)
3987 Private Sub MenuItemSearchNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSearchNext.Click
3989 If SearchDialog.SWord = "" Then
3990 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
3991 Me.TopMost = SettingDialog.AlwaysTop
3994 Me.TopMost = SettingDialog.AlwaysTop
3995 If SearchDialog.SWord = "" Then Exit Sub
3997 DoTabSearch(SearchDialog.SWord, _
3998 SearchDialog.CheckCaseSensitive, _
3999 SearchDialog.CheckRegex, _
4000 SEARCHTYPE.DialogSearch)
4002 DoTabSearch(SearchDialog.SWord, _
4003 SearchDialog.CheckCaseSensitive, _
4004 SearchDialog.CheckRegex, _
4005 SEARCHTYPE.NextSearch)
4009 Private Sub MenuItemSearchPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSearchPrev.Click
4011 If SearchDialog.SWord = "" Then
4012 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4013 Me.TopMost = SettingDialog.AlwaysTop
4016 Me.TopMost = SettingDialog.AlwaysTop
4017 If SearchDialog.SWord = "" Then Exit Sub
4020 DoTabSearch(SearchDialog.SWord, _
4021 SearchDialog.CheckCaseSensitive, _
4022 SearchDialog.CheckRegex, _
4023 SEARCHTYPE.PrevSearch)
4026 Private Sub AboutMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutMenuItem.Click
4027 TweenAboutBox.ShowDialog()
4028 Me.TopMost = SettingDialog.AlwaysTop
4031 Private Sub JumpUnreadMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JumpUnreadMenuItem.Click, JumpReadOpMenuItem.Click
4032 Dim bgnIdx As Integer = ListTab.TabPages.IndexOf(_curTab)
4033 Dim idx As Integer = -1
4034 Dim lst As DetailsListView = Nothing
4036 If ImageSelectionPanel.Enabled Then
4041 For i As Integer = bgnIdx To ListTab.TabPages.Count - 1
4043 idx = _statuses.GetOldestUnreadId(ListTab.TabPages(i).Text)
4045 ListTab.SelectedIndex = i
4046 lst = DirectCast(ListTab.TabPages(i).Tag, DetailsListView)
4047 '_curTab = ListTab.TabPages(i)
4052 '未読みつからず&現在タブが先頭ではなかったら、先頭タブから現在タブの手前まで探索
4053 If idx = -1 AndAlso bgnIdx > 0 Then
4054 For i As Integer = 0 To bgnIdx - 1
4055 idx = _statuses.GetOldestUnreadId(ListTab.TabPages(i).Text)
4057 ListTab.SelectedIndex = i
4058 lst = DirectCast(ListTab.TabPages(i).Tag, DetailsListView)
4059 '_curTab = ListTab.TabPages(i)
4065 '全部調べたが未読見つからず→先頭タブの最新発言へ
4067 ListTab.SelectedIndex = 0
4068 lst = DirectCast(ListTab.TabPages(0).Tag, DetailsListView)
4069 '_curTab = ListTab.TabPages(0)
4070 If _statuses.SortOrder = SortOrder.Ascending Then
4071 idx = lst.VirtualListSize - 1
4077 If lst.VirtualListSize > 0 AndAlso idx > -1 AndAlso lst.VirtualListSize > idx Then
4078 SelectListItem(lst, idx)
4079 If _statuses.SortMode = IdComparerClass.ComparerMode.Id Then
4080 If _statuses.SortOrder = SortOrder.Ascending AndAlso lst.Items(idx).Position.Y > lst.ClientSize.Height - _iconSz - 10 OrElse _
4081 _statuses.SortOrder = SortOrder.Descending AndAlso lst.Items(idx).Position.Y < _iconSz + 10 Then
4084 lst.EnsureVisible(idx)
4087 lst.EnsureVisible(idx)
4093 Private Sub StatusOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusOpenMenuItem.Click, OpenStatusOpMenuItem.Click
4094 If _curList.SelectedIndices.Count > 0 AndAlso _statuses.Tabs(_curTab.Text).TabType <> TabUsageType.DirectMessage Then
4095 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(0))
4096 If post.RetweetedId = 0 Then
4097 OpenUriAsync("http://twitter.com/" + post.Name + "/status/" + post.Id.ToString)
4099 OpenUriAsync("http://twitter.com/" + post.Name + "/status/" + post.RetweetedId.ToString)
4104 Private Sub FavorareMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FavorareMenuItem.Click, OpenFavotterOpMenuItem.Click
4105 If _curList.SelectedIndices.Count > 0 Then
4106 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(0))
4107 'OpenUriAsync("http://favotter.net/user/" + post.Name)
4108 OpenUriAsync("http://favstar.fm/users/" + post.Name + "/recent")
4112 Private Sub VerUpMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VerUpMenuItem.Click
4116 Private Sub RunTweenUp()
4118 Dim pinfo As New ProcessStartInfo
4119 pinfo.UseShellExecute = True
4120 pinfo.WorkingDirectory = Application.StartupPath
4121 pinfo.FileName = Path.Combine(Application.StartupPath(), "TweenUp.exe")
4123 Process.Start(pinfo)
4124 Catch ex As Exception
4125 MsgBox("Failed to execute TweenUp.exe.")
4129 Private Sub CheckNewVersion(Optional ByVal startup As Boolean = False)
4130 Dim retMsg As String = ""
4131 Dim strVer As String = ""
4132 Dim strDetail As String = ""
4133 Dim forceUpdate As Boolean = My.Computer.Keyboard.ShiftKeyDown
4136 retMsg = tw.GetVersionInfo()
4137 Catch ex As Exception
4138 StatusLabel.Text = My.Resources.CheckNewVersionText9
4139 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText10, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
4142 If retMsg.Length > 0 Then
4143 strVer = retMsg.Substring(0, 4)
4144 If retMsg.Length > 4 Then
4145 strDetail = retMsg.Substring(5).Trim
4147 If fileVersion <> "" AndAlso strVer.CompareTo(fileVersion.Replace(".", "")) > 0 Then
4148 Dim tmp As String = String.Format(My.Resources.CheckNewVersionText3, strVer)
4149 Using dialogAsShieldicon As New DialogAsShieldIcon
4150 If dialogAsShieldicon.Show(tmp, strDetail, My.Resources.CheckNewVersionText1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
4151 retMsg = tw.GetTweenBinary(strVer)
4152 If retMsg.Length = 0 Then
4155 dialogAsShieldicon.Dispose()
4159 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText5 + System.Environment.NewLine + retMsg, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4162 dialogAsShieldicon.Dispose()
4166 Dim tmp As String = String.Format(My.Resources.CheckNewVersionText6, strVer)
4167 Using dialogAsShieldicon As New DialogAsShieldIcon
4168 If dialogAsShieldicon.Show(tmp, strDetail, My.Resources.CheckNewVersionText1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
4169 retMsg = tw.GetTweenBinary(strVer)
4170 If retMsg.Length = 0 Then
4173 dialogAsShieldicon.Dispose()
4177 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText5 + System.Environment.NewLine + retMsg, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4180 dialogAsShieldicon.Dispose()
4182 ElseIf Not startup Then
4183 MessageBox.Show(My.Resources.CheckNewVersionText7 + fileVersion.Replace(".", "") + My.Resources.CheckNewVersionText8 + strVer, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Information)
4187 StatusLabel.Text = My.Resources.CheckNewVersionText9
4188 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText10, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4192 Private Sub Colorize()
4196 If SettingDialog.DispLatestPost <> DispTitleEnum.None AndAlso _
4197 SettingDialog.DispLatestPost <> DispTitleEnum.Post AndAlso _
4198 SettingDialog.DispLatestPost <> DispTitleEnum.Ver AndAlso _
4199 SettingDialog.DispLatestPost <> DispTitleEnum.OwnStatus Then
4200 SetMainWindowTitle()
4202 If Not StatusLabelUrl.Text.StartsWith("http") Then SetStatusLabelUrl()
4203 For Each tb As TabPage In ListTab.TabPages
4204 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
4205 If SettingDialog.TabIconDisp Then
4206 If tb.ImageIndex = 0 Then tb.ImageIndex = -1
4210 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
4213 Public Function createDetailHtml(ByVal orgdata As String) As String
4214 Return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter
4217 Private Sub DispSelectedPost()
4219 If _curList.SelectedIndices.Count = 0 OrElse _curPost Is Nothing Then Exit Sub
4221 Dim dTxt As String = createDetailHtml(_curPost.OriginalData)
4222 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage AndAlso Not _curPost.IsOwl Then
4223 NameLabel.Text = "DM TO -> "
4224 ElseIf _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then
4225 NameLabel.Text = "DM FROM <- "
4229 NameLabel.Text += _curPost.Name + "/" + _curPost.Nickname
4230 NameLabel.Tag = _curPost.Name
4231 If Not String.IsNullOrEmpty(_curPost.RetweetedBy) Then
4232 NameLabel.Text += " (RT:" + _curPost.RetweetedBy + ")"
4234 If Not String.IsNullOrEmpty(_curPost.ImageUrl) AndAlso TIconDic.ContainsKey(_curPost.ImageUrl) Then
4235 UserPicture.Image = TIconDic(_curPost.ImageUrl)
4237 UserPicture.Image = Nothing
4240 NameLabel.ForeColor = System.Drawing.SystemColors.ControlText
4241 DateTimeLabel.Text = _curPost.PDate.ToString()
4242 If _curPost.IsOwl AndAlso (SettingDialog.OneWayLove OrElse _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage) Then NameLabel.ForeColor = _clOWL
4243 If _curPost.RetweetedId > 0 Then NameLabel.ForeColor = _clRetweet
4244 If _curPost.IsFav Then NameLabel.ForeColor = _clFav
4246 If DumpPostClassToolStripMenuItem.Checked Then
4247 Dim sb As New StringBuilder(512)
4249 sb.Append("-----Start PostClass Dump<br>")
4250 sb.AppendFormat("Data : {0}<br>", _curPost.Data)
4251 sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.Data)
4252 sb.AppendFormat("Id : {0}<br>", _curPost.Id.ToString)
4253 'sb.AppendFormat("ImageIndex : {0}<br>", _curPost.ImageIndex.ToString)
4254 sb.AppendFormat("ImageUrl : {0}<br>", _curPost.ImageUrl)
4255 sb.AppendFormat("InReplyToId : {0}<br>", _curPost.InReplyToId.ToString)
4256 sb.AppendFormat("InReplyToUser : {0}<br>", _curPost.InReplyToUser)
4257 sb.AppendFormat("IsDM : {0}<br>", _curPost.IsDm.ToString)
4258 sb.AppendFormat("IsFav : {0}<br>", _curPost.IsFav.ToString)
4259 sb.AppendFormat("IsMark : {0}<br>", _curPost.IsMark.ToString)
4260 sb.AppendFormat("IsMe : {0}<br>", _curPost.IsMe.ToString)
4261 sb.AppendFormat("IsOwl : {0}<br>", _curPost.IsOwl.ToString)
4262 sb.AppendFormat("IsProtect : {0}<br>", _curPost.IsProtect.ToString)
4263 sb.AppendFormat("IsRead : {0}<br>", _curPost.IsRead.ToString)
4264 sb.AppendFormat("IsReply : {0}<br>", _curPost.IsReply.ToString)
4266 For Each nm As String In _curPost.ReplyToList
4267 sb.AppendFormat("ReplyToList : {0}<br>", nm)
4270 sb.AppendFormat("Name : {0}<br>", _curPost.Name)
4271 sb.AppendFormat("NickName : {0}<br>", _curPost.Nickname)
4272 sb.AppendFormat("OriginalData : {0}<br>", _curPost.OriginalData)
4273 sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.OriginalData)
4274 sb.AppendFormat("PDate : {0}<br>", _curPost.PDate.ToString)
4275 sb.AppendFormat("Source : {0}<br>", _curPost.Source)
4276 sb.AppendFormat("Uid : {0}<br>", _curPost.Uid)
4277 sb.AppendFormat("FilterHit : {0}<br>", _curPost.FilterHit)
4278 sb.AppendFormat("RetweetedBy : {0}<br>", _curPost.RetweetedBy)
4279 sb.AppendFormat("RetweetedId : {0}<br>", _curPost.RetweetedId)
4280 sb.AppendFormat("SearchTabName : {0}<br>", _curPost.RelTabName)
4281 sb.Append("-----End PostClass Dump<br>")
4283 PostBrowser.Visible = False
4284 PostBrowser.DocumentText = detailHtmlFormatHeader + sb.ToString + detailHtmlFormatFooter
4285 PostBrowser.Visible = True
4288 If PostBrowser.DocumentText <> dTxt Then
4289 PostBrowser.Visible = False
4290 PostBrowser.DocumentText = dTxt
4291 Dim lnks As New List(Of String)
4292 For Each lnk As Match In Regex.Matches(dTxt, "<a target=""_self"" href=""(?<url>http[^""]+)""", RegexOptions.IgnoreCase)
4293 lnks.Add(lnk.Result("${url}"))
4295 Thumbnail.thumbnail(_curPost.Id, lnks)
4297 Catch ex As System.Runtime.InteropServices.COMException
4300 PostBrowser.Visible = True
4305 Private Sub MatomeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MatomeMenuItem.Click
4306 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
4309 Private Sub ShortcutKeyListMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShortcutKeyListMenuItem.Click
4310 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")
4313 Private Sub ListTab_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListTab.KeyDown
4314 If ListTab.SelectedTab IsNot Nothing Then
4315 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch Then
4316 Dim pnl As Control = ListTab.SelectedTab.Controls("panelSearch")
4317 If pnl.Controls("comboSearch").Focused OrElse _
4318 pnl.Controls("comboLang").Focused OrElse _
4319 pnl.Controls("buttonSearch").Focused Then Exit Sub
4323 If e.Modifiers = Keys.None Then
4324 ' ModifierKeyが押されていない場合
4325 If e.KeyCode = Keys.N OrElse e.KeyCode = Keys.Right Then
4327 e.SuppressKeyPress = True
4330 ElseIf e.KeyCode = Keys.P OrElse e.KeyCode = Keys.Left Then
4332 e.SuppressKeyPress = True
4335 ElseIf e.KeyCode = Keys.OemPeriod Then
4337 e.SuppressKeyPress = True
4342 If e.KeyCode = Keys.Space OrElse e.KeyCode = Keys.ProcessKey Then
4344 e.SuppressKeyPress = True
4345 JumpUnreadMenuItem_Click(Nothing, Nothing)
4346 ElseIf e.KeyCode = Keys.Enter OrElse e.KeyCode = Keys.Return Then
4348 e.SuppressKeyPress = True
4349 MakeReplyOrDirectStatus()
4350 ElseIf e.KeyCode = Keys.L Then
4352 e.SuppressKeyPress = True
4354 ElseIf e.KeyCode = Keys.H Then
4356 e.SuppressKeyPress = True
4358 ElseIf e.KeyCode = Keys.J AndAlso Not e.Alt Then
4360 e.SuppressKeyPress = True
4361 SendKeys.Send("{DOWN}")
4362 ElseIf e.KeyCode = Keys.K AndAlso Not e.Alt Then
4364 e.SuppressKeyPress = True
4365 SendKeys.Send("{UP}")
4367 If e.KeyCode = Keys.Z Or e.KeyCode = Keys.Oemcomma Then
4369 e.SuppressKeyPress = True
4371 ElseIf e.KeyCode = Keys.R OrElse e.KeyCode = Keys.F5 Then
4373 e.SuppressKeyPress = True
4375 ElseIf e.KeyCode = Keys.S Then
4377 e.SuppressKeyPress = True
4379 ElseIf e.KeyCode = Keys.A Then
4381 e.SuppressKeyPress = True
4384 'If e.KeyCode = Keys.OemQuestion Then
4386 ' e.SuppressKeyPress = True
4387 ' MenuItemSubSearch_Click(Nothing, Nothing) '/検索
4389 If e.KeyCode = Keys.F Then
4391 e.SuppressKeyPress = True
4392 SendKeys.Send("{PGDN}")
4394 If e.KeyCode = Keys.B Then
4396 e.SuppressKeyPress = True
4397 SendKeys.Send("{PGUP}")
4399 If e.KeyCode = Keys.I Then
4401 e.SuppressKeyPress = True
4402 SendKeys.Send("{TAB}")
4404 ' ] in_reply_to参照元へ戻る
4405 If e.KeyCode = Keys.Oem4 Then
4407 e.SuppressKeyPress = True
4410 ' [ in_reply_toへジャンプ
4411 If e.KeyCode = Keys.Oem6 Then
4413 e.SuppressKeyPress = True
4414 GoBackInReplyToPost()
4416 If e.KeyCode = Keys.F1 Then
4418 e.SuppressKeyPress = True
4419 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
4420 ElseIf e.KeyCode = Keys.F3 Then
4422 e.SuppressKeyPress = True
4423 MenuItemSearchNext_Click(Nothing, Nothing)
4424 ElseIf e.KeyCode = Keys.F6 Then
4426 e.SuppressKeyPress = True
4427 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
4428 ElseIf e.KeyCode = Keys.F7 Then
4430 e.SuppressKeyPress = True
4431 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
4437 If e.Control AndAlso Not e.Alt AndAlso Not e.Shift Then
4439 If e.KeyCode = Keys.Home OrElse e.KeyCode = Keys.End Then
4442 If e.KeyCode = Keys.N Then
4444 e.SuppressKeyPress = True
4446 ElseIf e.KeyCode = Keys.P Then
4448 e.SuppressKeyPress = True
4450 ElseIf e.KeyCode = Keys.R Then
4452 e.SuppressKeyPress = True
4453 MakeReplyOrDirectStatus(False, True)
4454 ElseIf e.KeyCode = Keys.M Then
4456 e.SuppressKeyPress = True
4457 MakeReplyOrDirectStatus(False, False)
4458 ElseIf e.KeyCode = Keys.S Then
4460 e.SuppressKeyPress = True
4461 FavoriteChange(True)
4462 ElseIf e.KeyCode = Keys.I Then
4464 e.SuppressKeyPress = True
4465 doRepliedStatusOpen()
4466 ElseIf e.KeyCode = Keys.D Then
4468 e.SuppressKeyPress = True
4470 ElseIf e.KeyCode = Keys.Q Then
4472 e.SuppressKeyPress = True
4474 ElseIf e.KeyCode = Keys.B Then
4476 e.SuppressKeyPress = True
4477 ReadedStripMenuItem_Click(Nothing, Nothing)
4478 ElseIf e.KeyCode = Keys.T Then
4480 e.SuppressKeyPress = True
4481 HashManageMenuItem_Click(Nothing, Nothing)
4482 ElseIf e.KeyCode = Keys.L Then
4484 e.SuppressKeyPress = True
4485 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
4486 ElseIf e.KeyCode = Keys.Y Then
4488 e.SuppressKeyPress = True
4489 MultiLineMenuItem_Click(Nothing, Nothing)
4490 ElseIf e.KeyCode = Keys.F Then
4492 e.SuppressKeyPress = True
4493 MenuItemSubSearch_Click(Nothing, Nothing)
4494 ElseIf e.KeyCode = Keys.C Then
4495 Dim clstr As String = ""
4497 e.SuppressKeyPress = True
4502 Select Case e.KeyCode
4504 If _curList.SelectedIndices.Count > 0 Then
4505 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
4506 ElseIf _curList.SelectedIndices.Count = 0 Then
4507 OpenUriAsync("http://twitter.com/")
4510 If _curList.SelectedIndices.Count > 0 Then
4511 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
4514 StatusOpenMenuItem_Click(Nothing, Nothing)
4516 OpenURLMenuItem_Click(Nothing, Nothing)
4519 ' タブダイレクト選択(Ctrl+1~8,Ctrl+9)
4521 Select Case e.KeyCode
4522 Case Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8
4523 Dim tabNo As Integer = e.KeyCode - Keys.D1
4524 If ListTab.TabPages.Count < tabNo Then
4527 ListTab.SelectedIndex = tabNo
4528 ListTabSelect(ListTab.TabPages(tabNo))
4530 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
4531 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
4537 If Not e.Control AndAlso e.Alt AndAlso Not e.Shift Then
4539 ' 別タブの同じ書き込みへ(ALT+←/→)
4540 If e.KeyCode = Keys.Right Then
4542 e.SuppressKeyPress = True
4543 GoSamePostToAnotherTab(False)
4544 ElseIf e.KeyCode = Keys.Left Then
4546 e.SuppressKeyPress = True
4547 GoSamePostToAnotherTab(True)
4548 ElseIf e.KeyCode = Keys.R Then
4550 e.SuppressKeyPress = True
4551 doReTweetOriginal(True)
4552 ElseIf e.KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
4554 e.SuppressKeyPress = True
4555 doShowUserStatus(_curPost.Name, False)
4557 If e.KeyCode = Keys.Up Then
4558 ScrollDownPostBrowser(False)
4559 ElseIf e.KeyCode = Keys.Down Then
4560 ScrollDownPostBrowser(True)
4561 ElseIf e.KeyCode = Keys.PageUp Then
4562 PageDownPostBrowser(False)
4563 ElseIf e.KeyCode = Keys.PageDown Then
4564 PageDownPostBrowser(True)
4568 If e.Shift AndAlso Not e.Control AndAlso Not e.Alt Then
4570 If e.KeyCode = Keys.H Then
4572 e.SuppressKeyPress = True
4574 ElseIf e.KeyCode = Keys.L Then
4576 e.SuppressKeyPress = True
4578 ElseIf e.KeyCode = Keys.M Then
4580 e.SuppressKeyPress = True
4582 ElseIf e.KeyCode = Keys.G Then
4584 e.SuppressKeyPress = True
4586 ElseIf e.KeyCode = Keys.Z Then
4588 e.SuppressKeyPress = True
4592 ' お気に入り前後ジャンプ(SHIFT+N←/P→)
4593 If e.KeyCode = Keys.N OrElse e.KeyCode = Keys.Right Then
4595 e.SuppressKeyPress = True
4597 ElseIf e.KeyCode = Keys.P OrElse e.KeyCode = Keys.Left Then
4599 e.SuppressKeyPress = True
4601 ElseIf e.KeyCode = Keys.R OrElse e.KeyCode = Keys.F5 Then
4603 e.SuppressKeyPress = True
4606 If e.KeyCode = Keys.F3 Then
4608 e.SuppressKeyPress = True
4609 MenuItemSearchPrev_Click(Nothing, Nothing)
4610 ElseIf e.KeyCode = Keys.F6 Then
4612 e.SuppressKeyPress = True
4613 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
4614 ElseIf e.KeyCode = Keys.F7 Then
4616 e.SuppressKeyPress = True
4617 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
4621 If e.Control AndAlso Not e.Alt AndAlso e.Shift Then
4622 ' CTRL+SHIFTキーが押されている場合
4623 If e.KeyCode = Keys.R Then
4625 e.SuppressKeyPress = True
4626 MakeReplyOrDirectStatus(False, True, True)
4627 ElseIf e.KeyCode = Keys.C Then
4628 Dim clstr As String = ""
4630 e.SuppressKeyPress = True
4632 ElseIf e.KeyCode = Keys.F Then
4634 e.SuppressKeyPress = True
4635 If ListTab.SelectedTab IsNot Nothing Then
4636 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
4637 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
4639 ElseIf e.KeyCode = Keys.S Then
4641 e.SuppressKeyPress = True
4642 FavoriteChange(False)
4643 ElseIf e.KeyCode = Keys.B Then
4645 e.SuppressKeyPress = True
4646 UnreadStripMenuItem_Click(Nothing, Nothing)
4648 If e.KeyCode = Keys.T Then
4650 e.SuppressKeyPress = True
4651 HashToggleMenuItem_Click(Nothing, Nothing)
4652 ElseIf e.KeyCode = Keys.P Then
4654 e.SuppressKeyPress = True
4655 ImageSelectMenuItem_Click(Nothing, Nothing)
4656 ElseIf e.KeyCode = Keys.H Then
4658 e.SuppressKeyPress = True
4660 ElseIf e.KeyCode = Keys.O Then
4662 e.SuppressKeyPress = True
4663 FavorareMenuItem_Click(Nothing, Nothing)
4667 If Not e.Control AndAlso e.Alt AndAlso e.Shift Then
4668 ' ALT+SHIFTキーが押されている場合
4669 If e.KeyCode = Keys.R Then
4671 e.SuppressKeyPress = True
4672 doReTweetUnofficial()
4673 ElseIf e.KeyCode = Keys.Up Then
4674 Thumbnail.ScrollThumbnail(False)
4675 ElseIf e.KeyCode = Keys.Down Then
4676 Thumbnail.ScrollThumbnail(True)
4678 If e.KeyCode = Keys.Enter Then
4679 If Not Me.SplitContainer3.Panel2Collapsed Then
4680 Thumbnail.OpenPicture()
4683 e.SuppressKeyPress = True
4689 Private Sub ScrollDownPostBrowser(ByVal forward As Boolean)
4690 Dim doc As HtmlDocument = PostBrowser.Document
4691 If doc Is Nothing Then Exit Sub
4692 If doc.Body Is Nothing Then Exit Sub
4695 doc.Body.ScrollTop += SettingDialog.FontDetail.Height
4697 doc.Body.ScrollTop -= SettingDialog.FontDetail.Height
4701 Private Sub PageDownPostBrowser(ByVal forward As Boolean)
4702 Dim doc As HtmlDocument = PostBrowser.Document
4703 If doc Is Nothing Then Exit Sub
4704 If doc.Body Is Nothing Then Exit Sub
4707 doc.Body.ScrollTop += PostBrowser.ClientRectangle.Height - SettingDialog.FontDetail.Height
4709 doc.Body.ScrollTop -= PostBrowser.ClientRectangle.Height - SettingDialog.FontDetail.Height
4713 Private Sub GoNextTab(ByVal forward As Boolean)
4714 Dim idx As Integer = ListTab.SelectedIndex
4717 If idx > ListTab.TabPages.Count - 1 Then idx = 0
4720 If idx < 0 Then idx = ListTab.TabPages.Count - 1
4722 ListTab.SelectedIndex = idx
4723 ListTabSelect(ListTab.TabPages(idx))
4726 Private Sub CopyStot()
4727 Dim clstr As String = ""
4728 Dim sb As New StringBuilder()
4729 Dim IsProtected As Boolean = False
4730 For Each idx As Integer In _curList.SelectedIndices
4731 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4732 If post.IsProtect AndAlso SettingDialog.ProtectNotInclude Then
4736 If post.RetweetedId > 0 Then
4737 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.Name, post.Data, post.RetweetedId, Environment.NewLine)
4739 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.Name, post.Data, post.Id, Environment.NewLine)
4743 MessageBox.Show(My.Resources.CopyStotText1)
4745 If sb.Length > 0 Then
4746 clstr = sb.ToString()
4748 Clipboard.SetDataObject(clstr, False, 5, 100)
4749 Catch ex As Exception
4750 MessageBox.Show(ex.Message)
4753 ' Dim proc As New Action(Of String)(Sub(text)
4754 ' Me.Invoke(New Action(Of String)(AddressOf Clipboard.SetText), text)
4756 ' proc.BeginInvoke(clstr, Nothing, Nothing)
4757 'Catch ex As Exception
4758 ' MessageBox.Show(ex.Message)
4763 Private Sub CopyIdUri()
4764 Dim clstr As String = ""
4765 Dim sb As New StringBuilder()
4766 For Each idx As Integer In _curList.SelectedIndices
4767 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4768 If post.RetweetedId > 0 Then
4769 sb.AppendFormat("http://twitter.com/{0}/status/{1}{2}", post.Name, post.RetweetedId, Environment.NewLine)
4771 sb.AppendFormat("http://twitter.com/{0}/status/{1}{2}", post.Name, post.Id, Environment.NewLine)
4774 If sb.Length > 0 Then
4775 clstr = sb.ToString()
4777 Clipboard.SetDataObject(clstr, False, 5, 100)
4778 Catch ex As Exception
4779 MessageBox.Show(ex.Message)
4784 Private Sub GoFav(ByVal forward As Boolean)
4785 If _curList.VirtualListSize = 0 Then Exit Sub
4786 Dim fIdx As Integer = 0
4787 Dim toIdx As Integer = 0
4788 Dim stp As Integer = 1
4791 If _curList.SelectedIndices.Count = 0 Then
4794 fIdx = _curList.SelectedIndices(0) + 1
4795 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
4797 toIdx = _curList.VirtualListSize - 1
4800 If _curList.SelectedIndices.Count = 0 Then
4801 fIdx = _curList.VirtualListSize - 1
4803 fIdx = _curList.SelectedIndices(0) - 1
4804 If fIdx < 0 Then Exit Sub
4810 For idx As Integer = fIdx To toIdx Step stp
4811 If _statuses.Item(_curTab.Text, idx).IsFav Then
4812 SelectListItem(_curList, idx)
4813 _curList.EnsureVisible(idx)
4819 Private Sub GoSamePostToAnotherTab(ByVal left As Boolean)
4820 If _curList.VirtualListSize = 0 Then Exit Sub
4821 Dim fIdx As Integer = 0
4822 Dim toIdx As Integer = 0
4823 Dim stp As Integer = 1
4824 Dim targetId As Long = 0
4826 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then Exit Sub ' Directタブは対象外(見つかるはずがない)
4827 If _curList.SelectedIndices.Count = 0 Then Exit Sub '未選択も処理しない
4829 targetId = GetCurTabPost(_curList.SelectedIndices(0)).Id
4833 If ListTab.SelectedIndex = 0 Then
4836 fIdx = ListTab.SelectedIndex - 1
4842 If ListTab.SelectedIndex = ListTab.TabCount - 1 Then
4845 fIdx = ListTab.SelectedIndex + 1
4847 toIdx = ListTab.TabCount - 1
4851 Dim found As Boolean = False
4852 For tabidx As Integer = fIdx To toIdx Step stp
4853 If _statuses.Tabs(ListTab.TabPages(tabidx).Text).TabType = TabUsageType.DirectMessage Then Continue For ' Directタブは対象外
4854 For idx As Integer = 0 To DirectCast(ListTab.TabPages(tabidx).Tag, DetailsListView).VirtualListSize - 1
4855 If _statuses.Item(ListTab.TabPages(tabidx).Text, idx).Id = targetId Then
4856 ListTab.SelectedIndex = tabidx
4857 ListTabSelect(ListTab.TabPages(tabidx))
4858 SelectListItem(_curList, idx)
4859 _curList.EnsureVisible(idx)
4864 If found Then Exit For
4868 Private Sub GoPost(ByVal forward As Boolean)
4869 If _curList.SelectedIndices.Count = 0 OrElse _curPost Is Nothing Then Exit Sub
4870 Dim fIdx As Integer = 0
4871 Dim toIdx As Integer = 0
4872 Dim stp As Integer = 1
4875 fIdx = _curList.SelectedIndices(0) + 1
4876 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
4877 toIdx = _curList.VirtualListSize - 1
4880 fIdx = _curList.SelectedIndices(0) - 1
4881 If fIdx < 0 Then Exit Sub
4886 Dim name As String = ""
4887 If _curPost.RetweetedId = 0 Then
4888 name = _curPost.Name
4890 name = _curPost.RetweetedBy
4892 For idx As Integer = fIdx To toIdx Step stp
4893 If _statuses.Item(_curTab.Text, idx).RetweetedId = 0 Then
4894 If _statuses.Item(_curTab.Text, idx).Name = name Then
4895 SelectListItem(_curList, idx)
4896 _curList.EnsureVisible(idx)
4900 If _statuses.Item(_curTab.Text, idx).RetweetedBy = name Then
4901 SelectListItem(_curList, idx)
4902 _curList.EnsureVisible(idx)
4909 Private Sub GoRelPost(ByVal forward As Boolean)
4910 If _curList.SelectedIndices.Count = 0 Then Exit Sub
4912 Dim fIdx As Integer = 0
4913 Dim toIdx As Integer = 0
4914 Dim stp As Integer = 1
4916 fIdx = _curList.SelectedIndices(0) + 1
4917 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
4918 toIdx = _curList.VirtualListSize - 1
4921 fIdx = _curList.SelectedIndices(0) - 1
4922 If fIdx < 0 Then Exit Sub
4927 If Not _anchorFlag Then
4928 If _curPost Is Nothing Then Exit Sub
4929 _anchorPost = _curPost
4932 If _anchorPost Is Nothing Then Exit Sub
4935 For idx As Integer = fIdx To toIdx Step stp
4936 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4937 If post.Name = _anchorPost.Name OrElse _
4938 post.RetweetedBy = _anchorPost.Name OrElse _
4939 post.Name = _anchorPost.RetweetedBy OrElse _
4940 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso post.RetweetedBy = _anchorPost.RetweetedBy) OrElse _
4941 _anchorPost.ReplyToList.Contains(post.Name.ToLower()) OrElse _
4942 _anchorPost.ReplyToList.Contains(post.RetweetedBy.ToLower()) OrElse _
4943 post.ReplyToList.Contains(_anchorPost.Name.ToLower()) OrElse _
4944 post.ReplyToList.Contains(_anchorPost.RetweetedBy.ToLower()) Then
4945 SelectListItem(_curList, idx)
4946 _curList.EnsureVisible(idx)
4952 Private Sub GoAnchor()
4953 If _anchorPost Is Nothing Then Exit Sub
4954 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_anchorPost.Id)
4955 If idx = -1 Then Exit Sub
4957 SelectListItem(_curList, idx)
4958 _curList.EnsureVisible(idx)
4961 Private Sub GoTopEnd(ByVal GoTop As Boolean)
4962 Dim _item As ListViewItem
4966 _item = _curList.GetItemAt(0, 25)
4967 If _item Is Nothing Then
4973 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
4974 If _item Is Nothing Then
4975 idx = _curList.VirtualListSize - 1
4980 SelectListItem(_curList, idx)
4983 Private Sub GoMiddle()
4984 Dim _item As ListViewItem
4989 _item = _curList.GetItemAt(0, 0)
4990 If _item Is Nothing Then
4995 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
4996 If _item Is Nothing Then
4997 idx2 = _curList.VirtualListSize - 1
5001 idx3 = (idx1 + idx2) \ 2
5003 SelectListItem(_curList, idx3)
5006 Private Sub GoLast()
5007 If _curList.VirtualListSize = 0 Then Exit Sub
5009 If _statuses.SortOrder = SortOrder.Ascending Then
5010 SelectListItem(_curList, _curList.VirtualListSize - 1)
5011 _curList.EnsureVisible(_curList.VirtualListSize - 1)
5013 SelectListItem(_curList, 0)
5014 _curList.EnsureVisible(0)
5018 Private Sub MoveTop()
5019 If _curList.SelectedIndices.Count = 0 Then Exit Sub
5020 Dim idx As Integer = _curList.SelectedIndices(0)
5021 If _statuses.SortOrder = SortOrder.Ascending Then
5022 _curList.EnsureVisible(_curList.VirtualListSize - 1)
5024 _curList.EnsureVisible(0)
5026 _curList.EnsureVisible(idx)
5029 Private Sub GoInReplyToPost()
5030 If _curPost IsNot Nothing AndAlso _curPost.InReplyToUser IsNot Nothing AndAlso _curPost.InReplyToId > 0 Then
5031 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.Lists Then
5032 If _statuses.Tabs(_curTab.Text).Posts.ContainsKey(_curPost.InReplyToId) Then
5033 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.InReplyToId)
5035 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
5036 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
5038 If replyChains Is Nothing OrElse (replyChains.Count > 0 AndAlso replyChains.Peek().InReplyToId <> _curPost.Id) Then
5039 replyChains = New Stack(Of ReplyChain)
5041 replyChains.Push(New ReplyChain(_curPost.Id, _curPost.InReplyToId, _curTab))
5042 SelectListItem(_curList, idx)
5043 _curList.EnsureVisible(idx)
5046 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/statuses/" + _curPost.InReplyToId.ToString())
5049 If _statuses.ContainsKey(_curPost.InReplyToId) Then
5050 Dim tab As TabPage = _curTab
5051 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.InReplyToId)
5053 For Each tab In ListTab.TabPages
5054 idx = _statuses.Tabs(tab.Text).IndexOf(_curPost.InReplyToId)
5061 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
5062 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
5064 If replyChains Is Nothing OrElse (replyChains.Count > 0 AndAlso replyChains.Peek().InReplyToId <> _curPost.Id) Then
5065 replyChains = New Stack(Of ReplyChain)
5067 replyChains.Push(New ReplyChain(_curPost.Id, _curPost.InReplyToId, _curTab))
5069 If tab IsNot _curTab Then
5070 ListTab.SelectTab(tab)
5072 SelectListItem(_curList, idx)
5073 _curList.EnsureVisible(idx)
5076 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/statuses/" + _curPost.InReplyToId.ToString())
5082 Private Sub GoBackInReplyToPost()
5083 If replyChains Is Nothing OrElse replyChains.Count < 1 Then
5087 Dim chainHead As ReplyChain = replyChains.Pop()
5088 If chainHead.InReplyToId = _curPost.Id Then
5089 Dim idx As Integer = _statuses.Tabs(chainHead.OriginalTab.Text).IndexOf(chainHead.OriginalId)
5091 replyChains = Nothing
5094 ListTab.SelectTab(chainHead.OriginalTab)
5095 Catch ex As Exception
5096 replyChains = Nothing
5098 SelectListItem(_curList, idx)
5099 _curList.EnsureVisible(idx)
5102 replyChains = Nothing
5106 Private Sub MyList_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
5110 Private Sub StatusText_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.Enter
5111 ' フォーカスの戻り先を StatusText に設定
5113 StatusText.BackColor = _clInputBackcolor
5116 Public Property InputBackColor() As System.Drawing.Color
5118 Return _clInputBackcolor
5120 Set(ByVal value As System.Drawing.Color)
5121 _clInputBackcolor = value
5125 Private Sub StatusText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.Leave
5126 ' フォーカスがメニューに遷移しないならばフォーカスはタブに移ることを期待
5127 If ListTab.SelectedTab IsNot Nothing AndAlso MenuStrip1.Tag Is Nothing Then Me.Tag = ListTab.SelectedTab.Tag
5128 StatusText.BackColor = Color.FromKnownColor(KnownColor.Window)
5131 Private Sub StatusText_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StatusText.KeyDown
5133 If e.Modifiers = Keys.None Then
5134 If e.KeyCode = Keys.F1 Then
5136 e.SuppressKeyPress = True
5137 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
5138 ElseIf e.KeyCode = Keys.F3 Then
5140 e.SuppressKeyPress = True
5141 MenuItemSearchNext_Click(Nothing, Nothing)
5142 ElseIf e.KeyCode = Keys.F5 Then
5144 e.SuppressKeyPress = True
5146 ElseIf e.KeyCode = Keys.F6 Then
5148 e.SuppressKeyPress = True
5149 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
5150 ElseIf e.KeyCode = Keys.F7 Then
5152 e.SuppressKeyPress = True
5153 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
5158 If e.Control AndAlso Not e.Alt AndAlso Not e.Shift Then
5159 If e.KeyCode = Keys.A Then
5160 StatusText.SelectAll()
5161 ElseIf e.KeyCode = Keys.Up OrElse e.KeyCode = Keys.Down Then
5162 If StatusText.Text.Trim() <> "" Then _history(_hisIdx) = StatusText.Text
5163 If e.KeyCode = Keys.Up Then
5165 If _hisIdx < 0 Then _hisIdx = 0
5168 If _hisIdx > _history.Count - 1 Then _hisIdx = _history.Count - 1
5170 StatusText.Text = _history(_hisIdx)
5171 StatusText.SelectionStart = StatusText.Text.Length
5173 e.SuppressKeyPress = True
5174 ElseIf e.KeyCode = Keys.PageUp OrElse e.KeyCode = Keys.P Then
5175 If ListTab.SelectedIndex = 0 Then
5176 ListTab.SelectedIndex = ListTab.TabCount - 1
5178 ListTab.SelectedIndex -= 1
5181 e.SuppressKeyPress = True
5183 ElseIf e.KeyCode = Keys.PageDown OrElse e.KeyCode = Keys.N Then
5184 If ListTab.SelectedIndex = ListTab.TabCount - 1 Then
5185 ListTab.SelectedIndex = 0
5187 ListTab.SelectedIndex += 1
5190 e.SuppressKeyPress = True
5192 ElseIf e.KeyCode = Keys.R Then
5194 e.SuppressKeyPress = True
5195 MakeReplyOrDirectStatus(False, True)
5196 ElseIf e.KeyCode = Keys.M Then
5198 e.SuppressKeyPress = True
5199 MakeReplyOrDirectStatus(False, False)
5200 ElseIf e.KeyCode = Keys.S Then
5202 e.SuppressKeyPress = True
5203 FavoriteChange(True)
5204 ElseIf e.KeyCode = Keys.I Then
5206 e.SuppressKeyPress = True
5207 doRepliedStatusOpen()
5208 ElseIf e.KeyCode = Keys.Q Then
5210 e.SuppressKeyPress = True
5212 ElseIf e.KeyCode = Keys.B Then
5214 e.SuppressKeyPress = True
5215 ReadedStripMenuItem_Click(Nothing, Nothing)
5216 ElseIf e.KeyCode = Keys.T Then
5218 e.SuppressKeyPress = True
5219 HashManageMenuItem_Click(Nothing, Nothing)
5220 ElseIf e.KeyCode = Keys.L Then
5222 e.SuppressKeyPress = True
5223 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
5224 ElseIf e.KeyCode = Keys.Y Then
5226 e.SuppressKeyPress = True
5227 MultiLineMenuItem_Click(Nothing, Nothing)
5230 Select Case e.KeyCode
5232 If _curList.SelectedIndices.Count > 0 Then
5233 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
5234 ElseIf _curList.SelectedIndices.Count = 0 Then
5235 OpenUriAsync("http://twitter.com/")
5238 If _curList.SelectedIndices.Count > 0 Then
5239 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
5242 OpenURLMenuItem_Click(Nothing, Nothing)
5244 StatusOpenMenuItem_Click(Nothing, Nothing)
5250 If e.KeyCode = Keys.F3 Then
5252 e.SuppressKeyPress = True
5253 MenuItemSearchPrev_Click(Nothing, Nothing)
5254 ElseIf e.KeyCode = Keys.F5 Then
5256 e.SuppressKeyPress = True
5258 ElseIf e.KeyCode = Keys.F6 Then
5260 e.SuppressKeyPress = True
5261 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
5262 ElseIf e.KeyCode = Keys.F7 Then
5264 e.SuppressKeyPress = True
5265 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
5270 If e.Alt AndAlso Not e.Control AndAlso e.Shift Then
5271 If e.KeyCode = Keys.R Then
5273 e.SuppressKeyPress = True
5274 doReTweetOriginal(True)
5275 ElseIf e.KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
5277 e.SuppressKeyPress = True
5278 doShowUserStatus(_curPost.Name, False)
5280 If e.KeyCode = Keys.Up Then
5281 ScrollDownPostBrowser(False)
5282 ElseIf e.KeyCode = Keys.Down Then
5283 ScrollDownPostBrowser(True)
5284 ElseIf e.KeyCode = Keys.PageUp Then
5285 PageDownPostBrowser(False)
5286 ElseIf e.KeyCode = Keys.PageDown Then
5287 PageDownPostBrowser(True)
5291 If e.KeyCode = Keys.Space AndAlso e.Modifiers = (Keys.Shift Or Keys.Control) Then
5292 If StatusText.SelectionStart > 0 Then
5293 Dim endidx As Integer = StatusText.SelectionStart - 1
5294 Dim startstr As String = ""
5295 For i As Integer = StatusText.SelectionStart - 1 To 0 Step -1
5296 Dim c As Char = StatusText.Text.Chars(i)
5297 If Char.IsLetterOrDigit(c) OrElse c = "_" Then
5301 startstr = StatusText.Text.Substring(i + 1, endidx - i)
5302 ShowSuplDialog(StatusText, AtIdSupl, startstr.Length + 1, startstr)
5304 startstr = StatusText.Text.Substring(i + 1, endidx - i)
5305 ShowSuplDialog(StatusText, HashSupl, startstr.Length + 1, startstr)
5315 If e.Shift AndAlso e.Control Then
5316 If e.KeyCode = Keys.Up Then
5318 e.SuppressKeyPress = True
5319 Dim idx As Integer = 0
5320 If _curList IsNot Nothing AndAlso _curList.Items.Count <> 0 AndAlso _
5321 _curList.SelectedIndices.Count > 0 AndAlso _curList.SelectedIndices(0) > 0 Then
5322 idx = _curList.SelectedIndices(0) - 1
5323 SelectListItem(_curList, idx)
5324 _curList.EnsureVisible(idx)
5326 ElseIf e.KeyCode = Keys.Down Then
5328 e.SuppressKeyPress = True
5329 Dim idx As Integer = 0
5330 If _curList IsNot Nothing AndAlso _curList.Items.Count <> 0 AndAlso _curList.SelectedIndices.Count > 0 _
5331 AndAlso _curList.SelectedIndices(0) < _curList.Items.Count - 1 Then
5332 idx = _curList.SelectedIndices(0) + 1
5333 SelectListItem(_curList, idx)
5334 _curList.EnsureVisible(idx)
5337 If e.KeyCode = Keys.R Then
5339 e.SuppressKeyPress = True
5340 MakeReplyOrDirectStatus(False, True, True)
5341 ElseIf e.KeyCode = Keys.H Then
5343 e.SuppressKeyPress = True
5345 ElseIf e.KeyCode = Keys.T Then
5347 e.SuppressKeyPress = True
5348 HashToggleMenuItem_Click(Nothing, Nothing)
5349 ElseIf e.KeyCode = Keys.S Then
5351 e.SuppressKeyPress = True
5352 FavoriteChange(False)
5353 ElseIf e.KeyCode = Keys.B Then
5355 e.SuppressKeyPress = True
5356 UnreadStripMenuItem_Click(Nothing, Nothing)
5357 ElseIf e.KeyCode = Keys.G Then
5359 e.SuppressKeyPress = True
5360 FavorareMenuItem_Click(Nothing, Nothing)
5361 ElseIf e.KeyCode = Keys.C Then
5362 Dim clstr As String = ""
5364 e.SuppressKeyPress = True
5366 ElseIf e.KeyCode = Keys.O Then
5368 e.SuppressKeyPress = True
5369 FavorareMenuItem_Click(Nothing, Nothing)
5374 If e.Alt AndAlso e.Shift Then
5375 If e.KeyCode = Keys.R Then
5377 e.SuppressKeyPress = True
5378 doReTweetUnofficial()
5379 ElseIf e.KeyCode = Keys.Up Then
5380 Thumbnail.ScrollThumbnail(False)
5381 ElseIf e.KeyCode = Keys.Down Then
5382 Thumbnail.ScrollThumbnail(True)
5385 Me.StatusText_TextChanged(Nothing, Nothing)
5388 Private Sub SaveConfigsAll(ByVal ifModified As Boolean)
5389 If Not ifModified Then
5392 'SaveConfigsTab(True) 'True:事前に設定ファイル削除
5395 If _modifySettingCommon Then SaveConfigsCommon()
5396 If _modifySettingLocal Then SaveConfigsLocal()
5397 If _modifySettingAtId AndAlso SettingDialog.UseAtIdSupplement AndAlso AtIdSupl IsNot Nothing Then
5398 _modifySettingAtId = False
5399 Dim cfgAtId As New SettingAtIdList(AtIdSupl.GetItemList)
5405 Private Sub SaveConfigsCommon()
5406 If _ignoreConfigSave Then Exit Sub
5408 _modifySettingCommon = False
5409 SyncLock _syncObject
5410 _cfgCommon.UserName = tw.Username
5411 _cfgCommon.Password = tw.Password
5412 _cfgCommon.IsOAuth = SettingDialog.IsOAuth
5413 _cfgCommon.Token = tw.AccessToken
5414 _cfgCommon.TokenSecret = tw.AccessTokenSecret
5415 _cfgCommon.TimelinePeriod = SettingDialog.TimelinePeriodInt
5416 _cfgCommon.ReplyPeriod = SettingDialog.ReplyPeriodInt
5417 _cfgCommon.DMPeriod = SettingDialog.DMPeriodInt
5418 _cfgCommon.PubSearchPeriod = SettingDialog.PubSearchPeriodInt
5419 _cfgCommon.ListsPeriod = SettingDialog.ListsPeriodInt
5420 _cfgCommon.Read = SettingDialog.Readed
5421 _cfgCommon.IconSize = SettingDialog.IconSz
5422 _cfgCommon.UnreadManage = SettingDialog.UnreadManage
5423 _cfgCommon.PlaySound = SettingDialog.PlaySound
5424 _cfgCommon.OneWayLove = SettingDialog.OneWayLove
5426 _cfgCommon.NameBalloon = SettingDialog.NameBalloon
5427 _cfgCommon.PostCtrlEnter = SettingDialog.PostCtrlEnter
5428 _cfgCommon.CountApi = SettingDialog.CountApi
5429 _cfgCommon.CountApiReply = SettingDialog.CountApiReply
5430 '_cfgCommon.CheckReply = SettingDialog.CheckReply
5431 _cfgCommon.PostAndGet = SettingDialog.PostAndGet
5432 _cfgCommon.DispUsername = SettingDialog.DispUsername
5433 _cfgCommon.MinimizeToTray = SettingDialog.MinimizeToTray
5434 _cfgCommon.CloseToExit = SettingDialog.CloseToExit
5435 _cfgCommon.DispLatestPost = SettingDialog.DispLatestPost
5436 _cfgCommon.SortOrderLock = SettingDialog.SortOrderLock
5437 _cfgCommon.TinyUrlResolve = SettingDialog.TinyUrlResolve
5438 _cfgCommon.PeriodAdjust = SettingDialog.PeriodAdjust
5439 _cfgCommon.StartupVersion = SettingDialog.StartupVersion
5440 _cfgCommon.StartupFollowers = SettingDialog.StartupFollowers
5441 _cfgCommon.RestrictFavCheck = SettingDialog.RestrictFavCheck
5442 _cfgCommon.AlwaysTop = SettingDialog.AlwaysTop
5443 _cfgCommon.UrlConvertAuto = SettingDialog.UrlConvertAuto
5444 _cfgCommon.Outputz = SettingDialog.OutputzEnabled
5445 _cfgCommon.OutputzKey = SettingDialog.OutputzKey
5446 _cfgCommon.OutputzUrlMode = SettingDialog.OutputzUrlmode
5447 _cfgCommon.UseUnreadStyle = SettingDialog.UseUnreadStyle
5448 _cfgCommon.DateTimeFormat = SettingDialog.DateTimeFormat
5449 _cfgCommon.DefaultTimeOut = SettingDialog.DefaultTimeOut
5450 _cfgCommon.ProtectNotInclude = SettingDialog.ProtectNotInclude
5451 _cfgCommon.LimitBalloon = SettingDialog.LimitBalloon
5452 _cfgCommon.AutoShortUrlFirst = SettingDialog.AutoShortUrlFirst
5453 _cfgCommon.TabIconDisp = SettingDialog.TabIconDisp
5454 _cfgCommon.ReplyIconState = SettingDialog.ReplyIconState
5455 _cfgCommon.ReadOwnPost = SettingDialog.ReadOwnPost
5456 _cfgCommon.GetFav = SettingDialog.GetFav
5457 _cfgCommon.IsMonospace = SettingDialog.IsMonospace
5458 If IdeographicSpaceToSpaceToolStripMenuItem IsNot Nothing AndAlso _
5459 IdeographicSpaceToSpaceToolStripMenuItem.IsDisposed = False Then
5460 _cfgCommon.WideSpaceConvert = Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked
5462 _cfgCommon.ReadOldPosts = SettingDialog.ReadOldPosts
5463 _cfgCommon.UseSsl = SettingDialog.UseSsl
5464 _cfgCommon.BilyUser = SettingDialog.BitlyUser
5465 _cfgCommon.BitlyPwd = SettingDialog.BitlyPwd
5466 _cfgCommon.ShowGrid = SettingDialog.ShowGrid
5467 _cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement
5468 _cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement
5469 _cfgCommon.PreviewEnable = SettingDialog.PreviewEnable
5470 _cfgCommon.Language = SettingDialog.Language
5472 _cfgCommon.SortOrder = _statuses.SortOrder
5473 Select Case _statuses.SortMode
5474 Case IdComparerClass.ComparerMode.Nickname 'ニックネーム
5475 _cfgCommon.SortColumn = 1
5476 Case IdComparerClass.ComparerMode.Data '本文
5477 _cfgCommon.SortColumn = 2
5478 Case IdComparerClass.ComparerMode.Id '時刻=発言Id
5479 _cfgCommon.SortColumn = 3
5480 Case IdComparerClass.ComparerMode.Name '名前
5481 _cfgCommon.SortColumn = 4
5482 Case IdComparerClass.ComparerMode.Source 'Source
5483 _cfgCommon.SortColumn = 7
5486 _cfgCommon.Nicoms = SettingDialog.Nicoms
5487 _cfgCommon.HashTags = HashMgr.HashHistories
5488 If HashMgr.IsPermanent Then
5489 _cfgCommon.HashSelected = HashMgr.UseHash
5491 _cfgCommon.HashSelected = ""
5493 _cfgCommon.HashIsHead = HashMgr.IsHead
5494 _cfgCommon.HashIsPermanent = HashMgr.IsPermanent
5495 _cfgCommon.TwitterUrl = SettingDialog.TwitterApiUrl
5496 _cfgCommon.TwitterSearchUrl = SettingDialog.TwitterSearchApiUrl
5497 _cfgCommon.HotkeyEnabled = SettingDialog.HotkeyEnabled
5498 _cfgCommon.HotkeyModifier = SettingDialog.HotkeyMod
5499 _cfgCommon.HotkeyKey = SettingDialog.HotkeyKey
5500 _cfgCommon.HotkeyValue = SettingDialog.HotkeyValue
5501 _cfgCommon.BlinkNewMentions = SettingDialog.BlinkNewMentions
5502 If ToolStripFocusLockMenuItem IsNot Nothing AndAlso _
5503 ToolStripFocusLockMenuItem.IsDisposed = False Then
5504 _cfgCommon.FocusLockToStatusText = Me.ToolStripFocusLockMenuItem.Checked
5511 Private Sub SaveConfigsLocal()
5512 If _ignoreConfigSave Then Exit Sub
5513 SyncLock _syncObject
5514 _modifySettingLocal = False
5515 _cfgLocal.FormSize = _mySize
5516 _cfgLocal.FormLocation = _myLoc
5517 _cfgLocal.SplitterDistance = _mySpDis
5518 _cfgLocal.PreviewDistance = _mySpDis3
5519 _cfgLocal.StatusMultiline = StatusText.Multiline
5520 _cfgLocal.StatusTextHeight = _mySpDis2
5521 _cfgLocal.StatusText = SettingDialog.Status
5523 _cfgLocal.FontUnread = _fntUnread
5524 _cfgLocal.ColorUnread = _clUnread
5525 _cfgLocal.FontRead = _fntReaded
5526 _cfgLocal.ColorRead = _clReaded
5527 _cfgLocal.FontDetail = _fntDetail
5528 _cfgLocal.ColorDetail = _clDetail
5529 _cfgLocal.ColorDetailBackcolor = _clDetailBackcolor
5530 _cfgLocal.ColorDetailLink = _clDetailLink
5531 _cfgLocal.ColorFav = _clFav
5532 _cfgLocal.ColorOWL = _clOWL
5533 _cfgLocal.ColorRetweet = _clRetweet
5534 _cfgLocal.ColorSelf = _clSelf
5535 _cfgLocal.ColorAtSelf = _clAtSelf
5536 _cfgLocal.ColorTarget = _clTarget
5537 _cfgLocal.ColorAtTarget = _clAtTarget
5538 _cfgLocal.ColorAtFromTarget = _clAtFromTarget
5539 _cfgLocal.ColorAtTo = _clAtTo
5540 _cfgLocal.ColorListBackcolor = _clListBackcolor
5541 _cfgLocal.ColorInputBackcolor = _clInputBackcolor
5542 _cfgLocal.ColorInputFont = _clInputFont
5543 _cfgLocal.FontInputFont = _fntInputFont
5545 _cfgLocal.BrowserPath = SettingDialog.BrowserPath
5546 _cfgLocal.UseRecommendStatus = SettingDialog.UseRecommendStatus
5547 _cfgLocal.ProxyType = SettingDialog.SelectedProxyType
5548 _cfgLocal.ProxyAddress = SettingDialog.ProxyAddress
5549 _cfgLocal.ProxyPort = SettingDialog.ProxyPort
5550 _cfgLocal.ProxyUser = SettingDialog.ProxyUser
5551 _cfgLocal.ProxyPassword = SettingDialog.ProxyPassword
5552 If _ignoreConfigSave Then Exit Sub
5557 Private Sub SaveConfigsTabs()
5558 Dim tabSetting As New SettingTabs
5559 For i As Integer = 0 To ListTab.TabPages.Count - 1
5560 tabSetting.Tabs.Add(_statuses.Tabs(ListTab.TabPages(i).Text))
5565 Private Sub SaveLogMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveLogMenuItem.Click, SaveFileMenuItem.Click
5566 Dim rslt As DialogResult = MessageBox.Show(String.Format(My.Resources.SaveLogMenuItem_ClickText1, Environment.NewLine), _
5567 My.Resources.SaveLogMenuItem_ClickText2, _
5568 MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
5569 If rslt = Windows.Forms.DialogResult.Cancel Then Exit Sub
5571 SaveFileDialog1.FileName = "TweenPosts" + Format(Now, "yyMMdd-HHmmss") + ".tsv"
5572 SaveFileDialog1.InitialDirectory = My.Application.Info.DirectoryPath
5573 SaveFileDialog1.Filter = My.Resources.SaveLogMenuItem_ClickText3
5574 SaveFileDialog1.FilterIndex = 0
5575 SaveFileDialog1.Title = My.Resources.SaveLogMenuItem_ClickText4
5576 SaveFileDialog1.RestoreDirectory = True
5578 If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
5579 If Not SaveFileDialog1.ValidateNames Then Exit Sub
5580 Using sw As StreamWriter = New StreamWriter(SaveFileDialog1.FileName, False, Encoding.UTF8)
5581 If rslt = Windows.Forms.DialogResult.Yes Then
5583 For idx As Integer = 0 To _curList.VirtualListSize - 1
5584 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5585 Dim protect As String = ""
5586 If post.IsProtect Then protect = "Protect"
5587 sw.WriteLine(post.Nickname & vbTab & _
5588 """" & post.Data.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
5589 post.PDate.ToString() & vbTab & _
5590 post.Name & vbTab & _
5591 post.Id.ToString() & vbTab & _
5592 post.ImageUrl & vbTab & _
5593 """" & post.OriginalData.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
5597 For Each idx As Integer In _curList.SelectedIndices
5598 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5599 Dim protect As String = ""
5600 If post.IsProtect Then protect = "Protect"
5601 sw.WriteLine(post.Nickname & vbTab & _
5602 """" & post.Data.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
5603 post.PDate.ToString() & vbTab & _
5604 post.Name & vbTab & _
5605 post.Id.ToString() & vbTab & _
5606 post.ImageUrl & vbTab & _
5607 """" & post.OriginalData.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
5615 Me.TopMost = SettingDialog.AlwaysTop
5618 Private Sub PostBrowser_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles PostBrowser.PreviewKeyDown
5620 If e.Modifiers = Keys.None Then
5621 Select Case e.KeyCode
5625 JumpUnreadMenuItem_Click(Nothing, Nothing)
5628 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
5631 MenuItemSearchNext_Click(Nothing, Nothing)
5638 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
5641 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
5648 If e.Modifiers = Keys.Shift Then
5649 Select Case e.KeyCode
5652 MenuItemSearchPrev_Click(Nothing, Nothing)
5659 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
5662 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
5668 If e.Modifiers = Keys.Control Then
5669 Select Case e.KeyCode
5672 PostBrowser.Document.ExecCommand("SelectAll", False, Nothing)
5673 Case Keys.C, Keys.Insert
5675 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
5676 If Not String.IsNullOrEmpty(_selText) Then
5678 Clipboard.SetDataObject(_selText, False, 5, 100)
5679 Catch ex As Exception
5680 MessageBox.Show(ex.Message)
5685 MakeReplyOrDirectStatus(False, True)
5688 MakeReplyOrDirectStatus(False, False)
5691 doReTweetOriginal(True)
5697 FavoriteChange(True)
5700 ReadedStripMenuItem_Click(Nothing, Nothing)
5703 MultiLineMenuItem.Checked = Not MultiLineMenuItem.Checked
5704 MultiLineMenuItem_Click(Nothing, Nothing)
5710 MenuItemSubSearch_Click(Nothing, Nothing)
5713 If _curList.SelectedIndices.Count > 0 Then
5714 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name)
5715 ElseIf _curList.SelectedIndices.Count = 0 Then
5716 OpenUriAsync("http://twitter.com/")
5720 If _curList.SelectedIndices.Count > 0 Then
5721 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).Name + "/favorites")
5725 MoveToFavToolStripMenuItem_Click(Nothing, Nothing)
5728 OpenURLMenuItem_Click(Nothing, Nothing)
5733 If e.Modifiers = Keys.Alt Then
5734 If e.KeyCode = Keys.R Then
5736 doReTweetOriginal(True)
5737 ElseIf e.KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
5739 doShowUserStatus(_curPost.Name, False)
5743 ' ControlKey + ShiftKey + 何か
5744 If e.Modifiers = (Keys.Control Or Keys.Shift) Then
5745 Select Case e.KeyCode
5748 MakeReplyOrDirectStatus(False, True, True)
5751 If ListTab.SelectedTab IsNot Nothing Then
5752 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
5753 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
5757 FavoriteChange(False)
5760 UnreadStripMenuItem_Click(Nothing, Nothing)
5763 HashToggleMenuItem_Click(Nothing, Nothing)
5766 ImageSelectMenuItem_Click(Nothing, Nothing)
5769 FavorareMenuItem_Click(Nothing, Nothing)
5778 'AltKey + ShiftKey + 何か
5779 If e.Modifiers = (Keys.Alt Or Keys.Shift) Then
5780 Select Case e.KeyCode
5782 e.IsInputKey = False
5783 doReTweetUnofficial()
5789 Public Function TabRename(ByRef tabName As String) As Boolean
5791 Dim newTabText As String = Nothing
5792 Using inputName As New InputTabName()
5793 inputName.TabName = tabName
5794 inputName.ShowDialog()
5795 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Return False
5796 newTabText = inputName.TabName
5799 Me.TopMost = SettingDialog.AlwaysTop
5800 If Not String.IsNullOrEmpty(newTabText) Then
5802 For i As Integer = 0 To ListTab.TabCount - 1
5803 If ListTab.TabPages(i).Text = newTabText Then
5804 Dim tmp As String = String.Format(My.Resources.Tabs_DoubleClickText1, newTabText)
5805 MessageBox.Show(tmp, My.Resources.Tabs_DoubleClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
5809 'タブ名のリスト作り直し(デフォルトタブ以外は再作成)
5810 For i As Integer = 0 To ListTab.TabCount - 1
5811 If _statuses.Tabs(ListTab.TabPages(i).Text).TabType = TabUsageType.Mentions OrElse _
5812 (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) Then
5813 TabDialog.RemoveTab(ListTab.TabPages(i).Text)
5815 If ListTab.TabPages(i).Text = tabName Then
5816 ListTab.TabPages(i).Text = newTabText
5819 _statuses.RenameTab(tabName, newTabText)
5821 For i As Integer = 0 To ListTab.TabCount - 1
5822 If _statuses.Tabs(ListTab.TabPages(i).Text).TabType = TabUsageType.Mentions OrElse _
5823 (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) Then
5824 If ListTab.TabPages(i).Text = tabName Then
5825 ListTab.TabPages(i).Text = newTabText
5827 TabDialog.AddTab(ListTab.TabPages(i).Text)
5832 _rclickTabName = newTabText
5833 tabName = newTabText
5840 Private Sub Tabs_DoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDoubleClick
5841 Dim tn As String = ListTab.SelectedTab.Text
5845 Private Sub Tabs_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDown
5846 Dim cpos As New Point(e.X, e.Y)
5847 If e.Button = Windows.Forms.MouseButtons.Left Then
5848 For i As Integer = 0 To ListTab.TabPages.Count - 1
5849 Dim rect As Rectangle = ListTab.GetTabRect(i)
5850 If rect.Left <= cpos.X AndAlso cpos.X <= rect.Right AndAlso _
5851 rect.Top <= cpos.Y AndAlso cpos.Y <= rect.Bottom Then
5861 Private Sub Tabs_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListTab.DragEnter
5862 If e.Data.GetDataPresent(GetType(TabPage)) Then
5863 e.Effect = DragDropEffects.Move
5865 e.Effect = DragDropEffects.None
5869 Private Sub Tabs_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListTab.DragDrop
5870 If Not e.Data.GetDataPresent(GetType(TabPage)) Then Exit Sub
5873 Dim tn As String = ""
5875 Dim cpos As New Point(e.X, e.Y)
5876 Dim spos As Point = ListTab.PointToClient(cpos)
5878 For i = 0 To ListTab.TabPages.Count - 1
5879 Dim rect As Rectangle = ListTab.GetTabRect(i)
5880 If rect.Left <= spos.X AndAlso spos.X <= rect.Right AndAlso _
5881 rect.Top <= spos.Y AndAlso spos.Y <= rect.Bottom Then
5882 tn = ListTab.TabPages(i).Text
5883 If spos.X <= (rect.Left + rect.Right) / 2 Then
5892 'タブのないところにドロップ->最後尾へ移動
5893 If String.IsNullOrEmpty(tn) Then
5894 tn = ListTab.TabPages(ListTab.TabPages.Count - 1).Text
5896 i = ListTab.TabPages.Count - 1
5899 Dim tp As TabPage = DirectCast(e.Data.GetData(GetType(TabPage)), TabPage)
5900 If tp.Text = tn Then Exit Sub
5902 ReOrderTab(tp.Text, tn, bef)
5905 Public Sub ReOrderTab(ByVal targetTabText As String, ByVal baseTabText As String, ByVal isBeforeBaseTab As Boolean)
5906 Dim baseIndex As Integer = 0
5907 For baseIndex = 0 To ListTab.TabPages.Count - 1
5908 If ListTab.TabPages(baseIndex).Text = baseTabText Then Exit For
5911 ListTab.SuspendLayout()
5913 Dim mTp As TabPage = Nothing
5914 For j As Integer = 0 To ListTab.TabPages.Count - 1
5915 If ListTab.TabPages(j).Text = targetTabText Then
5916 mTp = ListTab.TabPages(j)
5917 ListTab.TabPages.Remove(mTp)
5918 If j < baseIndex Then baseIndex -= 1
5922 If isBeforeBaseTab Then
5923 ListTab.TabPages.Insert(baseIndex, mTp)
5925 ListTab.TabPages.Insert(baseIndex + 1, mTp)
5928 ListTab.ResumeLayout()
5933 Private Sub MakeReplyOrDirectStatus(Optional ByVal isAuto As Boolean = True, Optional ByVal isReply As Boolean = True, Optional ByVal isAll As Boolean = False)
5934 'isAuto:True=先頭に挿入、False=カーソル位置に挿入
5935 'isReply:True=@,False=DM
5936 If Not StatusText.Enabled Then Exit Sub
5937 If _curList Is Nothing Then Exit Sub
5938 If _curTab Is Nothing Then Exit Sub
5939 If _curPost Is Nothing Then Exit Sub
5941 ' 複数あてリプライはReplyではなく通常ポスト
5942 '↑仕様変更で全部リプライ扱いでOK(先頭ドット付加しない)
5943 '090403暫定でドットを付加しないようにだけ修正。単独と複数の処理は統合できると思われる。
5944 '090513 all @ replies 廃止の仕様変更によりドット付加に戻し(syo68k)
5946 If _curList.SelectedIndices.Count > 0 Then
5948 If _curList.SelectedIndices.Count = 1 AndAlso Not isAll AndAlso _curPost IsNot Nothing Then
5950 If (_statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage AndAlso isAuto) OrElse (Not isAuto AndAlso Not isReply) Then
5952 StatusText.Text = "D " + _curPost.Name + " " + StatusText.Text
5953 StatusText.SelectionStart = StatusText.Text.Length
5959 If String.IsNullOrEmpty(StatusText.Text) Then
5962 ' ステータステキストが入力されていない場合先頭に@ユーザー名を追加する
5963 StatusText.Text = "@" + _curPost.Name + " "
5964 If _curPost.RetweetedId > 0 Then
5965 _reply_to_id = _curPost.RetweetedId
5967 _reply_to_id = _curPost.Id
5969 _reply_to_name = _curPost.Name
5974 '1件選んでEnter or DoubleClick
5975 If StatusText.Text.Contains("@" + _curPost.Name + " ") Then
5976 If _reply_to_id > 0 AndAlso _reply_to_name = _curPost.Name Then
5978 If _curPost.RetweetedId > 0 Then
5979 _reply_to_id = _curPost.RetweetedId
5981 _reply_to_id = _curPost.Id
5983 _reply_to_name = _curPost.Name
5987 If Not StatusText.Text.StartsWith("@") Then
5989 If StatusText.Text.StartsWith(". ") Then
5991 StatusText.Text = StatusText.Text.Insert(2, "@" + _curPost.Name + " ")
5996 StatusText.Text = "@" + _curPost.Name + " " + StatusText.Text
5997 If _curPost.RetweetedId > 0 Then
5998 _reply_to_id = _curPost.RetweetedId
6000 _reply_to_id = _curPost.Id
6002 _reply_to_name = _curPost.Name
6007 StatusText.Text = ". @" + _curPost.Name + " " + StatusText.Text
6008 'StatusText.Text = "@" + _curPost.Name + " " + StatusText.Text
6013 '1件選んでCtrl-Rの場合(返信先操作せず)
6014 Dim sidx As Integer = StatusText.SelectionStart
6015 Dim id As String = "@" + _curPost.Name + " "
6017 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6021 StatusText.Text = StatusText.Text.Insert(sidx, id)
6023 'If StatusText.Text.StartsWith("@") Then
6025 ' StatusText.Text = ". " + StatusText.Text.Insert(sidx, " @" + _curPost.Name + " ")
6026 ' sidx += 5 + _curPost.Name.Length
6029 ' StatusText.Text = StatusText.Text.Insert(sidx, " @" + _curPost.Name + " ")
6030 ' sidx += 3 + _curPost.Name.Length
6032 StatusText.SelectionStart = sidx
6035 '_reply_to_name = Nothing
6041 If Not isAuto AndAlso Not isReply Then Exit Sub
6043 'C-S-rか、複数の宛先を選択中にEnter/DoubleClick/C-r/C-S-r
6046 'Enter or DoubleClick
6048 Dim sTxt As String = StatusText.Text
6049 If Not sTxt.StartsWith(". ") Then
6054 For cnt As Integer = 0 To _curList.SelectedIndices.Count - 1
6055 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(cnt))
6056 If Not sTxt.Contains("@" + post.Name + " ") Then
6057 sTxt = sTxt.Insert(2, "@" + post.Name + " ")
6058 'sTxt = "@" + post.Name + " " + sTxt
6061 StatusText.Text = sTxt
6064 If _curList.SelectedIndices.Count > 1 Then
6067 Dim ids As String = ""
6068 Dim sidx As Integer = StatusText.SelectionStart
6069 For cnt As Integer = 0 To _curList.SelectedIndices.Count - 1
6070 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(cnt))
6071 If Not ids.Contains("@" + post.Name + " ") AndAlso _
6072 Not post.Name.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6073 ids += "@" + post.Name + " "
6076 For Each nm As String In post.ReplyToList
6077 If Not ids.Contains("@" + nm + " ") AndAlso _
6078 Not nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6079 Dim m As Match = Regex.Match(post.Data, "[@@](?<id>" + nm + ")([^a-zA-Z0-9]|$)", RegexOptions.IgnoreCase)
6081 ids += "@" + m.Result("${id}") + " "
6083 ids += "@" + nm + " "
6089 If ids.Length = 0 Then Exit Sub
6090 If Not StatusText.Text.StartsWith(". ") Then
6091 StatusText.Text = ". " + StatusText.Text
6097 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6101 StatusText.Text = StatusText.Text.Insert(sidx, ids)
6103 'If StatusText.Text.StartsWith("@") Then
6104 ' StatusText.Text = ". " + StatusText.Text.Insert(sidx, ids)
6105 ' sidx += 2 + ids.Length
6107 ' StatusText.Text = StatusText.Text.Insert(sidx, ids)
6108 ' sidx += 1 + ids.Length
6110 StatusText.SelectionStart = sidx
6114 '1件のみ選択のC-S-r(返信元付加する可能性あり)
6116 Dim ids As String = ""
6117 Dim sidx As Integer = StatusText.SelectionStart
6118 Dim post As PostClass = _curPost
6119 If Not ids.Contains("@" + post.Name + " ") AndAlso _
6120 Not post.Name.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6121 ids += "@" + post.Name + " "
6123 For Each nm As String In post.ReplyToList
6124 If Not ids.Contains("@" + nm + " ") AndAlso _
6125 Not nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6126 Dim m As Match = Regex.Match(post.Data, "[@@](?<id>" + nm + ")([^a-zA-Z0-9]|$)", RegexOptions.IgnoreCase)
6128 ids += "@" + m.Result("${id}") + " "
6130 ids += "@" + nm + " "
6134 If Not String.IsNullOrEmpty(post.RetweetedBy) Then
6135 If Not ids.Contains("@" + post.RetweetedBy + " ") AndAlso _
6136 Not post.RetweetedBy.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6137 ids += "@" + post.RetweetedBy + " "
6140 If ids.Length = 0 Then Exit Sub
6141 If String.IsNullOrEmpty(StatusText.Text) Then
6143 StatusText.Text = ids
6144 StatusText.SelectionStart = ids.Length
6146 If post.RetweetedId > 0 Then
6147 _reply_to_id = post.RetweetedId
6149 _reply_to_id = post.Id
6151 _reply_to_name = post.Name
6156 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6160 StatusText.Text = StatusText.Text.Insert(sidx, ids)
6162 StatusText.SelectionStart = sidx
6168 StatusText.SelectionStart = StatusText.Text.Length
6173 Private Sub ListTab_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseUp
6177 Private Sub TimerRefreshIcon_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerRefreshIcon.Tick
6178 If _colorize Then Colorize()
6179 If Not TimerRefreshIcon.Enabled Then Exit Sub
6180 Static iconCnt As Integer = 0
6181 Static blinkCnt As Integer = 0
6182 Static blink As Boolean = False
6183 Static idle As Boolean = False
6188 Dim busy As Boolean = False
6189 For Each bw As BackgroundWorker In Me._bw
6190 If bw IsNot Nothing AndAlso bw.IsBusy Then
6199 If blinkCnt > 10 Then
6202 SaveConfigsAll(True)
6206 NotifyIcon1.Icon = NIconRefresh(iconCnt)
6208 _myStatusError = False
6212 Dim tb As TabClass = _statuses.GetTabByType(TabUsageType.Mentions)
6213 If SettingDialog.ReplyIconState <> REPLY_ICONSTATE.None AndAlso tb IsNot Nothing AndAlso tb.UnreadCount > 0 Then
6214 If blinkCnt > 0 Then Exit Sub
6216 If blink OrElse SettingDialog.ReplyIconState = REPLY_ICONSTATE.StaticIcon Then
6217 NotifyIcon1.Icon = ReplyIcon
6219 NotifyIcon1.Icon = ReplyIconBlink
6225 If idle Then Exit Sub
6229 If _myStatusError Then
6230 NotifyIcon1.Icon = NIconAtRed
6233 If _myStatusOnline Then
6234 NotifyIcon1.Icon = NIconAt
6236 NotifyIcon1.Icon = NIconAtSmoke
6240 Private Sub ContextMenuTabProperty_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuTabProperty.Opening
6241 '右クリックの場合はタブ名が設定済。アプリケーションキーの場合は現在のタブを対象とする
6242 If String.IsNullOrEmpty(_rclickTabName) OrElse sender IsNot ContextMenuTabProperty Then
6243 If ListTab IsNot Nothing AndAlso ListTab.SelectedTab IsNot Nothing Then
6244 _rclickTabName = ListTab.SelectedTab.Text
6250 If _statuses Is Nothing Then Exit Sub
6251 If _statuses.Tabs Is Nothing Then Exit Sub
6253 Dim tb As TabClass = _statuses.Tabs(_rclickTabName)
6254 If tb Is Nothing Then Exit Sub
6256 NotifyDispMenuItem.Checked = tb.Notify
6257 Me.NotifyTbMenuItem.Checked = tb.Notify
6259 soundfileListup = True
6260 SoundFileComboBox.Items.Clear()
6261 Me.SoundFileTbComboBox.Items.Clear()
6262 SoundFileComboBox.Items.Add("")
6263 Me.SoundFileTbComboBox.Items.Add("")
6264 Dim oDir As IO.DirectoryInfo = New IO.DirectoryInfo(My.Application.Info.DirectoryPath + IO.Path.DirectorySeparatorChar)
6265 If IO.Directory.Exists(IO.Path.Combine(My.Application.Info.DirectoryPath, "Sounds")) Then
6266 oDir = oDir.GetDirectories("Sounds")(0)
6268 For Each oFile As IO.FileInfo In oDir.GetFiles("*.wav")
6269 SoundFileComboBox.Items.Add(oFile.Name)
6270 Me.SoundFileTbComboBox.Items.Add(oFile.Name)
6272 Dim idx As Integer = SoundFileComboBox.Items.IndexOf(tb.SoundFile)
6273 If idx = -1 Then idx = 0
6274 SoundFileComboBox.SelectedIndex = idx
6275 Me.SoundFileTbComboBox.SelectedIndex = idx
6276 soundfileListup = False
6277 UreadManageMenuItem.Checked = tb.UnreadManage
6278 Me.UnreadMngTbMenuItem.Checked = tb.UnreadManage
6280 TabMenuControl(_rclickTabName)
6283 Private Sub TabMenuControl(ByVal tabName As String)
6284 If _statuses.Tabs(tabName).TabType <> TabUsageType.Mentions AndAlso _statuses.IsDefaultTab(tabName) Then
6285 FilterEditMenuItem.Enabled = True
6286 Me.EditRuleTbMenuItem.Enabled = True
6287 DeleteTabMenuItem.Enabled = False
6288 Me.DeleteTbMenuItem.Enabled = False
6289 ElseIf _statuses.Tabs(tabName).TabType = TabUsageType.Mentions Then
6290 FilterEditMenuItem.Enabled = True
6291 Me.EditRuleTbMenuItem.Enabled = True
6292 DeleteTabMenuItem.Enabled = False
6293 Me.DeleteTbMenuItem.Enabled = False
6295 FilterEditMenuItem.Enabled = True
6296 Me.EditRuleTbMenuItem.Enabled = True
6297 DeleteTabMenuItem.Enabled = True
6298 Me.DeleteTbMenuItem.Enabled = True
6302 Private Sub UreadManageMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UreadManageMenuItem.Click, UnreadMngTbMenuItem.Click
6303 UreadManageMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
6304 Me.UnreadMngTbMenuItem.Checked = UreadManageMenuItem.Checked
6306 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6307 ChangeTabUnreadManage(_rclickTabName, UreadManageMenuItem.Checked)
6312 Public Sub ChangeTabUnreadManage(ByVal tabName As String, ByVal isManage As Boolean)
6315 For idx = 0 To ListTab.TabCount
6316 If ListTab.TabPages(idx).Text = tabName Then Exit For
6319 _statuses.SetTabUnreadManage(tabName, isManage)
6320 If SettingDialog.TabIconDisp Then
6321 If _statuses.Tabs(tabName).UnreadCount > 0 Then
6322 ListTab.TabPages(idx).ImageIndex = 0
6324 ListTab.TabPages(idx).ImageIndex = -1
6328 If _curTab.Text = tabName Then
6329 _itemCache = Nothing
6330 _postCache = Nothing
6334 SetMainWindowTitle()
6336 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6339 Private Sub NotifyDispMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyDispMenuItem.Click, NotifyTbMenuItem.Click
6340 NotifyDispMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
6341 Me.NotifyTbMenuItem.Checked = NotifyDispMenuItem.Checked
6343 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6345 _statuses.Tabs(_rclickTabName).Notify = NotifyDispMenuItem.Checked
6350 Private Sub SoundFileComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SoundFileComboBox.SelectedIndexChanged, SoundFileTbComboBox.SelectedIndexChanged
6351 If soundfileListup OrElse _rclickTabName = "" Then Exit Sub
6353 _statuses.Tabs(_rclickTabName).SoundFile = DirectCast(DirectCast(sender, ToolStripComboBox).SelectedItem, String)
6358 Private Sub DeleteTabMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteTabMenuItem.Click, DeleteTbMenuItem.Click
6359 If String.IsNullOrEmpty(_rclickTabName) OrElse sender Is Me.DeleteTbMenuItem Then _rclickTabName = ListTab.SelectedTab.Text
6361 RemoveSpecifiedTab(_rclickTabName)
6365 Private Sub FilterEditMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilterEditMenuItem.Click, EditRuleTbMenuItem.Click
6367 If String.IsNullOrEmpty(_rclickTabName) Then _rclickTabName = _statuses.GetTabByType(TabUsageType.Home).TabName
6368 fDialog.SetCurrent(_rclickTabName)
6369 fDialog.ShowDialog()
6370 Me.TopMost = SettingDialog.AlwaysTop
6373 Me.Cursor = Cursors.WaitCursor
6374 _itemCache = Nothing
6375 _postCache = Nothing
6378 _statuses.FilterAll()
6379 For Each tb As TabPage In ListTab.TabPages
6380 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6381 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6382 If SettingDialog.TabIconDisp Then
6386 If SettingDialog.TabIconDisp Then
6391 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6393 Me.Cursor = Cursors.Default
6398 Private Sub AddTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabMenuItem.Click, CreateTbMenuItem.Click
6399 Dim tabName As String = Nothing
6400 Dim tabUsage As TabUsageType
6401 Using inputName As New InputTabName()
6402 inputName.TabName = _statuses.GetUniqueTabName
6403 inputName.IsShowUsage = True
6404 inputName.ShowDialog()
6405 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Exit Sub
6406 tabName = inputName.TabName
6407 tabUsage = inputName.Usage
6410 Me.TopMost = SettingDialog.AlwaysTop
6411 If Not String.IsNullOrEmpty(tabName) Then
6413 Dim list As ListElement = Nothing
6414 If tabUsage = TabUsageType.Lists Then
6415 Using listAvail As New ListAvailable
6416 If listAvail.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then Exit Sub
6417 If listAvail.SelectedList Is Nothing Then Exit Sub
6418 list = listAvail.SelectedList
6421 If Not AddNewTab(tabName, False, tabUsage) Then
6422 Dim tmp As String = String.Format(My.Resources.AddTabMenuItem_ClickText1, tabName)
6423 MessageBox.Show(tmp, My.Resources.AddTabMenuItem_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
6426 _statuses.AddTab(tabName, tabUsage, list)
6428 If tabUsage = TabUsageType.PublicSearch Then
6429 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
6430 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
6431 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
6433 If tabUsage = TabUsageType.Lists Then
6434 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
6435 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
6436 GetTimeline(WORKERTYPE.List, 1, 0, tabName)
6442 Private Sub TabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabMenuItem.Click, CreateTabRuleOpMenuItem.Click
6444 For Each idx As Integer In _curList.SelectedIndices
6445 Dim tabName As String = ""
6447 If Not SelectTab(tabName) Then Exit For
6449 fDialog.SetCurrent(tabName)
6450 If _statuses.Item(_curTab.Text, idx).RetweetedId = 0 Then
6451 fDialog.AddNewFilter(_statuses.Item(_curTab.Text, idx).Name, _statuses.Item(_curTab.Text, idx).Data)
6453 fDialog.AddNewFilter(_statuses.Item(_curTab.Text, idx).RetweetedBy, _statuses.Item(_curTab.Text, idx).Data)
6455 fDialog.ShowDialog()
6456 Me.TopMost = SettingDialog.AlwaysTop
6460 Me.Cursor = Cursors.WaitCursor
6461 _itemCache = Nothing
6462 _postCache = Nothing
6465 _statuses.FilterAll()
6466 For Each tb As TabPage In ListTab.TabPages
6467 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6468 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6469 If SettingDialog.TabIconDisp Then
6473 If SettingDialog.TabIconDisp Then
6478 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6480 Me.Cursor = Cursors.Default
6485 Protected Overrides Function ProcessDialogKey( _
6486 ByVal keyData As Keys) As Boolean
6487 'TextBox1でEnterを押してもビープ音が鳴らないようにする
6488 If (keyData And Keys.KeyCode) = Keys.Enter Then
6489 If StatusText.Focused Then
6491 If StatusText.Multiline AndAlso _
6492 (keyData And Keys.Shift) = Keys.Shift AndAlso _
6493 (keyData And Keys.Control) <> Keys.Control Then
6494 Dim pos1 As Integer = StatusText.SelectionStart
6495 If StatusText.SelectionLength > 0 Then
6496 StatusText.Text = StatusText.Text.Remove(pos1, StatusText.SelectionLength) '選択状態文字列削除
6498 StatusText.Text = StatusText.Text.Insert(pos1, Environment.NewLine) '改行挿入
6499 StatusText.SelectionStart = pos1 + Environment.NewLine.Length 'カーソルを改行の次の文字へ移動
6503 If (Not StatusText.Multiline AndAlso _
6504 ((keyData And Keys.Control) = Keys.Control AndAlso SettingDialog.PostCtrlEnter) OrElse _
6505 ((keyData And Keys.Control) <> Keys.Control AndAlso Not SettingDialog.PostCtrlEnter)) OrElse _
6506 (StatusText.Multiline AndAlso _
6507 (Not SettingDialog.PostCtrlEnter AndAlso _
6508 ((keyData And Keys.Control) <> Keys.Control AndAlso (keyData And Keys.Shift) <> Keys.Shift) OrElse _
6509 ((keyData And Keys.Control) = Keys.Control AndAlso (keyData And Keys.Shift) = Keys.Shift)) OrElse _
6510 (SettingDialog.PostCtrlEnter AndAlso (keyData And Keys.Control) = Keys.Control)) Then
6511 PostButton_Click(Nothing, Nothing)
6514 ElseIf _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch AndAlso _
6515 (ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focused OrElse _
6516 ListTab.SelectedTab.Controls("panelSearch").Controls("comboLang").Focused) Then
6517 Me.SearchButton_Click(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), Nothing)
6522 Return MyBase.ProcessDialogKey(keyData)
6525 Private Sub ReplyAllStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReplyAllStripMenuItem.Click, ReplyAllOpMenuItem.Click
6526 MakeReplyOrDirectStatus(False, True, True)
6529 Private Sub IDRuleMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IDRuleMenuItem.Click, CreateIdRuleOpMenuItem.Click
6530 Dim tabName As String = ""
6533 If _curList.SelectedIndices.Count = 0 Then Exit Sub
6536 If Not SelectTab(tabName) Then Exit Sub
6538 Dim mv As Boolean = False
6539 Dim mk As Boolean = False
6542 Dim ids As New List(Of String)
6543 For Each idx As Integer In _curList.SelectedIndices
6544 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
6545 If Not ids.Contains(post.Name) Then
6546 Dim fc As New FiltersClass
6548 If post.RetweetedId = 0 Then
6549 fc.NameFilter = post.Name
6551 fc.NameFilter = post.RetweetedBy
6553 fc.SearchBoth = True
6557 fc.SearchUrl = False
6558 _statuses.Tabs(tabName).AddFilter(fc)
6561 If ids.Count <> 0 Then
6562 Dim atids As New List(Of String)
6563 For Each id As String In ids
6566 Dim cnt As Integer = AtIdSupl.ItemCount
6567 AtIdSupl.AddRangeItem(atids.ToArray)
6568 If AtIdSupl.ItemCount <> cnt Then _modifySettingAtId = True
6572 Me.Cursor = Cursors.WaitCursor
6573 _itemCache = Nothing
6574 _postCache = Nothing
6577 _statuses.FilterAll()
6578 For Each tb As TabPage In ListTab.TabPages
6579 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6580 If _statuses.ContainsTab(tb.Text) Then
6581 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6582 If SettingDialog.TabIconDisp Then
6586 If SettingDialog.TabIconDisp Then
6592 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6594 Me.Cursor = Cursors.Default
6599 Private Function SelectTab(ByRef tabName As String) As Boolean
6602 If TabDialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
6603 Me.TopMost = SettingDialog.AlwaysTop
6606 Me.TopMost = SettingDialog.AlwaysTop
6607 tabName = TabDialog.SelectedTabName
6609 ListTab.SelectedTab.Focus()
6611 If tabName = My.Resources.IDRuleMenuItem_ClickText1 Then
6612 Using inputName As New InputTabName()
6613 inputName.TabName = _statuses.GetUniqueTabName
6614 inputName.ShowDialog()
6615 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Return False
6616 tabName = inputName.TabName
6619 Me.TopMost = SettingDialog.AlwaysTop
6620 If Not String.IsNullOrEmpty(tabName) Then
6621 If Not AddNewTab(tabName, False, TabUsageType.UserDefined) Then
6622 Dim tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText2, tabName)
6623 MessageBox.Show(tmp, My.Resources.IDRuleMenuItem_ClickText3, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
6626 _statuses.AddTab(tabName, TabUsageType.UserDefined, Nothing)
6638 Private Sub MoveOrCopy(ByRef move As Boolean, ByRef mark As Boolean)
6641 Dim _tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText4, Environment.NewLine)
6642 If MessageBox.Show(_tmp, My.Resources.IDRuleMenuItem_ClickText5, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
6650 Dim _tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText6, vbCrLf)
6651 If MessageBox.Show(_tmp, My.Resources.IDRuleMenuItem_ClickText7, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
6658 Private Sub CopySTOTMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopySTOTMenuItem.Click
6662 Private Sub CopyURLMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyURLMenuItem.Click
6666 Private Sub SelectAllMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllMenuItem.Click, SelAllOpMenuItem.Click
6667 If StatusText.Focused Then
6669 StatusText.SelectAll()
6672 For i As Integer = 0 To _curList.VirtualListSize - 1
6673 _curList.SelectedIndices.Add(i)
6678 Private Sub MoveMiddle()
6679 Dim _item As ListViewItem
6683 If _curList.SelectedIndices.Count = 0 Then Exit Sub
6685 Dim idx As Integer = _curList.SelectedIndices(0)
6687 _item = _curList.GetItemAt(0, 25)
6688 If _item Is Nothing Then
6693 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
6694 If _item Is Nothing Then
6695 idx2 = _curList.VirtualListSize - 1
6700 idx -= Math.Abs(idx1 - idx2) \ 2
6701 If idx < 0 Then idx = 0
6703 _curList.EnsureVisible(_curList.VirtualListSize - 1)
6704 _curList.EnsureVisible(idx)
6707 Private Sub OpenURLMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenURLMenuItem.Click, OpenUrlOpMenuItem.Click
6708 If PostBrowser.Document.Links.Count > 0 Then
6709 UrlDialog.ClearUrl()
6711 Dim openUrlStr As String = ""
6713 If PostBrowser.Document.Links.Count = 1 Then
6714 Dim urlStr As String = ""
6716 urlStr = IDNDecode(PostBrowser.Document.Links(0).GetAttribute("href"))
6717 Catch ex As ArgumentException
6721 If String.IsNullOrEmpty(urlStr) Then Exit Sub
6722 openUrlStr = urlEncodeMultibyteChar(urlStr)
6724 For Each linkElm As HtmlElement In PostBrowser.Document.Links
6725 Dim urlStr As String = ""
6726 Dim linkText As String = ""
6728 urlStr = IDNDecode(linkElm.GetAttribute("href"))
6729 linkText = linkElm.InnerText
6730 If Not linkText.StartsWith("http") AndAlso Not linkText.StartsWith("#") Then
6731 linkText = "@" + linkText
6733 Catch ex As ArgumentException
6737 If String.IsNullOrEmpty(urlStr) Then Continue For
6738 UrlDialog.AddUrl(New OpenUrlItem(linkText, urlEncodeMultibyteChar(urlStr)))
6741 If UrlDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
6742 openUrlStr = UrlDialog.SelectedUrl
6744 Catch ex As Exception
6747 Me.TopMost = SettingDialog.AlwaysTop
6749 If String.IsNullOrEmpty(openUrlStr) Then Exit Sub
6751 If openUrlStr.StartsWith("http://twitter.com/search?q=%23") OrElse _
6752 openUrlStr.StartsWith("https://twitter.com/search?q=%23") Then
6754 Dim urlStr As String = HttpUtility.UrlDecode(openUrlStr)
6755 Dim hash As String = urlStr.Substring(urlStr.IndexOf("#"))
6756 AddNewTabForSearch(hash)
6760 openUrlStr = openUrlStr.Replace("://twitter.com/search?q=#", "://twitter.com/search?q=%23")
6761 OpenUriAsync(openUrlStr)
6765 Private Sub ClearTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearTabMenuItem.Click, ClearTbMenuItem.Click
6766 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6767 Dim tmp As String = String.Format(My.Resources.ClearTabMenuItem_ClickText1, Environment.NewLine)
6768 If MessageBox.Show(tmp, _rclickTabName + " " + My.Resources.ClearTabMenuItem_ClickText2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
6772 _statuses.ClearTabIds(_rclickTabName)
6773 If ListTab.SelectedTab.Text = _rclickTabName Then
6774 _anchorPost = Nothing
6776 _itemCache = Nothing
6777 _postCache = Nothing
6778 _itemCacheIndex = -1
6782 For Each tb As TabPage In ListTab.TabPages
6783 If tb.Text = _rclickTabName Then
6785 DirectCast(tb.Tag, DetailsListView).VirtualListSize = 0
6789 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6791 SetMainWindowTitle()
6795 Private Sub SetMainWindowTitle()
6797 Dim ttl As New StringBuilder(256)
6798 Dim ur As Integer = 0
6799 Dim al As Integer = 0
6800 Static myVer As String = fileVersion
6801 Static followers As Long = 0
6802 If SettingDialog.DispLatestPost <> DispTitleEnum.None AndAlso _
6803 SettingDialog.DispLatestPost <> DispTitleEnum.Post AndAlso _
6804 SettingDialog.DispLatestPost <> DispTitleEnum.Ver AndAlso _
6805 SettingDialog.DispLatestPost <> DispTitleEnum.OwnStatus Then
6806 For Each key As String In _statuses.Tabs.Keys
6807 ur += _statuses.Tabs(key).UnreadCount
6808 al += _statuses.Tabs(key).AllCount
6812 If SettingDialog.DispUsername Then ttl.Append(tw.Username).Append(" - ")
6813 ttl.Append("Tween ")
6814 Select Case SettingDialog.DispLatestPost
6815 Case DispTitleEnum.Ver
6816 ttl.Append("Ver:").Append(myVer)
6817 Case DispTitleEnum.Post
6818 If _history IsNot Nothing AndAlso _history.Count > 1 Then
6819 ttl.Append(_history(_history.Count - 2).Replace(vbCrLf, ""))
6821 Case DispTitleEnum.UnreadRepCount
6822 ttl.AppendFormat(My.Resources.SetMainWindowTitleText1, _statuses.GetTabByType(TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(TabUsageType.DirectMessage).UnreadCount)
6823 Case DispTitleEnum.UnreadAllCount
6824 ttl.AppendFormat(My.Resources.SetMainWindowTitleText2, ur)
6825 Case DispTitleEnum.UnreadAllRepCount
6826 ttl.AppendFormat(My.Resources.SetMainWindowTitleText3, ur, _statuses.GetTabByType(TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(TabUsageType.DirectMessage).UnreadCount)
6827 Case DispTitleEnum.UnreadCountAllCount
6828 ttl.AppendFormat(My.Resources.SetMainWindowTitleText4, ur, al)
6829 Case DispTitleEnum.OwnStatus
6830 If followers = 0 AndAlso tw.FollowersCount > 0 Then followers = tw.FollowersCount
6831 ttl.AppendFormat(My.Resources.OwnStatusTitle, tw.StatusesCount, tw.FriendsCount, tw.FollowersCount, tw.FollowersCount - followers)
6835 Me.Text = ttl.ToString()
6836 Catch ex As AccessViolationException
6837 '原因不明。ポスト内容に依存か?たまーに発生するが再現せず。
6841 Private Function GetStatusLabelText() As String
6843 'タブ未読数/タブ発言数 全未読数/総発言数 (未読@+未読DM数)
6844 If _statuses Is Nothing Then Return ""
6845 Dim tbRep As TabClass = _statuses.GetTabByType(TabUsageType.Mentions)
6846 Dim tbDm As TabClass = _statuses.GetTabByType(TabUsageType.DirectMessage)
6847 If tbRep Is Nothing OrElse tbDm Is Nothing Then Return ""
6848 Dim urat As Integer = tbRep.UnreadCount + tbDm.UnreadCount
6849 Dim ur As Integer = 0
6850 Dim al As Integer = 0
6851 Dim tur As Integer = 0
6852 Dim tal As Integer = 0
6853 Dim slbl As StringBuilder = New StringBuilder(256)
6855 For Each key As String In _statuses.Tabs.Keys
6856 ur += _statuses.Tabs(key).UnreadCount
6857 al += _statuses.Tabs(key).AllCount
6858 If key.Equals(_curTab.Text) Then
6859 tur = _statuses.Tabs(key).UnreadCount
6860 tal = _statuses.Tabs(key).AllCount
6863 Catch ex As Exception
6868 UnreadAtCounter = urat
6870 slbl.AppendFormat(My.Resources.SetStatusLabelText1, tur, tal, ur, al, urat, _postTimestamps.Count, _favTimestamps.Count, _tlCount)
6871 If SettingDialog.TimelinePeriodInt = 0 Then
6872 slbl.Append(My.Resources.SetStatusLabelText2)
6874 slbl.Append((SettingDialog.TimelinePeriodInt - _homeCounterAdjuster).ToString() + My.Resources.SetStatusLabelText3)
6876 Return slbl.ToString()
6879 Delegate Sub SetStatusLabelApiDelegate()
6881 Private Sub SetStatusLabelApiHandler(ByVal sender As Object, ByVal e As ApiInformationChangedEventArgs)
6882 If InvokeRequired Then
6883 Invoke(New SetStatusLabelApiDelegate(AddressOf SetStatusLabelApi))
6889 Private Sub SetStatusLabelApi()
6890 Dim slbl As New StringBuilder(256)
6892 If TwitterApiInfo.RemainCount > -1 AndAlso TwitterApiInfo.MaxCount > -1 Then
6894 slbl.Append("API " + TwitterApiInfo.RemainCount.ToString + "/" + TwitterApiInfo.MaxCount.ToString)
6895 ElseIf TwitterApiInfo.RemainCount > -1 Then
6897 slbl.Append("API " + TwitterApiInfo.RemainCount.ToString + "/???")
6898 ElseIf TwitterApiInfo.MaxCount > -1 Then
6900 slbl.Append("API ???/" + TwitterApiInfo.MaxCount.ToString)
6903 slbl.Append("API ???/???")
6906 StatusLabelApi.Text = slbl.ToString()
6907 If TwitterApiInfo.ResetTime >= DateTime.Now Then
6908 StatusLabelApi.ToolTipText = "ResetTime " + TwitterApiInfo.ResetTime.ToString
6910 StatusLabelApi.ToolTipText = "ResetTime ???"
6914 Private Sub SetStatusLabelUrl()
6915 StatusLabelUrl.Text = GetStatusLabelText()
6918 Public Sub SetStatusLabel(ByVal text As String)
6919 StatusLabel.Text = text
6922 Private Sub SetNotifyIconText()
6923 ' タスクトレイアイコンのツールチップテキスト書き換え
6925 Static ur As New StringBuilder(64)
6926 ur.Remove(0, ur.Length)
6927 If SettingDialog.DispUsername Then
6928 ur.Append(tw.Username)
6933 ur.Append("(Debug Build)")
6935 If UnreadCounter <> -1 AndAlso UnreadAtCounter <> -1 Then
6937 ur.Append(UnreadCounter)
6939 ur.Append(UnreadAtCounter)
6942 NotifyIcon1.Text = ur.ToString()
6945 Friend Sub CheckReplyTo(ByVal StatusText As String)
6946 Dim m As MatchCollection
6948 m = Regex.Matches(StatusText, "(^|[^a-zA-Z0-9_/])[#|#](?<hash>[a-zA-Z0-9_]+)")
6949 Dim hstr As String = ""
6950 For Each hm As Match In m
6951 If Not IsNumeric(hm.Result("${hash}")) Then
6952 If Not hstr.Contains("#" + hm.Result("${hash}") + " ") Then
6953 hstr += "#" + hm.Result("${hash}") + " "
6954 HashSupl.AddItem("#" + hm.Result("${hash}"))
6958 If Not String.IsNullOrEmpty(HashMgr.UseHash) AndAlso Not hstr.Contains(HashMgr.UseHash + " ") Then
6959 hstr += HashMgr.UseHash
6961 If Not String.IsNullOrEmpty(hstr) Then HashMgr.AddHashToHistory(hstr.Trim, False)
6963 ' 本当にリプライ先指定すべきかどうかの判定
6964 m = Regex.Matches(StatusText, "(^|[ -/:-@[-^`{-~])(?<id>@[a-zA-Z0-9_]+)")
6966 If SettingDialog.UseAtIdSupplement Then
6967 Dim bCnt As Integer = AtIdSupl.ItemCount
6968 For Each mid As Match In m
6969 AtIdSupl.AddItem(mid.Result("${id}"))
6971 If bCnt <> AtIdSupl.ItemCount Then _modifySettingAtId = True
6974 ' リプライ先ステータスIDの指定がない場合は指定しない
6975 If _reply_to_id = 0 Then Exit Sub
6977 ' リプライ先ユーザー名がない場合も指定しない
6978 If String.IsNullOrEmpty(_reply_to_name) Then
6984 ' 次の条件を満たす場合に in_reply_to_status_id 指定
6985 ' 1. Twitterによりリンクと判定される @idが文中に1つ含まれる (2009/5/28 リンク化される@IDのみカウントするように修正)
6986 ' 2. リプライ先ステータスIDが設定されている(リストをダブルクリックで返信している)
6987 ' 3. 文中に含まれた@idがリプライ先のポスト者のIDと一致する
6989 If m IsNot Nothing Then
6990 If StatusText.StartsWith("@") Then
6991 If StatusText.StartsWith("@" + _reply_to_name) Then Exit Sub
6993 For Each mid As Match In m
6994 If StatusText.Contains("QT " + mid.Result("${id}") + ":") AndAlso mid.Result("${id}") = "@" + _reply_to_name Then Exit Sub
7004 Private Sub TweenMain_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
7005 If Not _initialLayout AndAlso SettingDialog.MinimizeToTray AndAlso WindowState = FormWindowState.Minimized Then
7008 If _initialLayout AndAlso _cfgLocal IsNot Nothing AndAlso Me.WindowState = FormWindowState.Normal AndAlso Me.Visible Then
7009 Me.ClientSize = _cfgLocal.FormSize
7010 '_mySize = Me.ClientSize 'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
7011 Me.DesktopLocation = _cfgLocal.FormLocation
7012 '_myLoc = Me.DesktopLocation '位置保持(最小化・最大化されたまま終了した場合の対応用)
7013 If _cfgLocal.SplitterDistance > Me.SplitContainer1.Panel1MinSize AndAlso _cfgLocal.SplitterDistance < Me.SplitContainer1.Height - Me.SplitContainer1.Panel2MinSize - Me.SplitContainer1.SplitterWidth Then
7014 Me.SplitContainer1.SplitterDistance = _cfgLocal.SplitterDistance 'Splitterの位置設定
7017 StatusText.Multiline = _cfgLocal.StatusMultiline
7018 If StatusText.Multiline Then
7019 Dim dis As Integer = SplitContainer2.Height - _cfgLocal.StatusTextHeight - SplitContainer2.SplitterWidth
7020 If dis > SplitContainer2.Panel1MinSize AndAlso dis < SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth Then
7021 SplitContainer2.SplitterDistance = SplitContainer2.Height - _cfgLocal.StatusTextHeight - SplitContainer2.SplitterWidth
7023 StatusText.Height = _cfgLocal.StatusTextHeight
7025 If SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth > 0 Then
7026 SplitContainer2.SplitterDistance = SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth
7029 If _cfgLocal.PreviewDistance > Me.SplitContainer3.Panel1MinSize AndAlso _cfgLocal.PreviewDistance < Me.SplitContainer3.Width - Me.SplitContainer3.Panel2MinSize - Me.SplitContainer3.SplitterWidth Then
7030 Me.SplitContainer3.SplitterDistance = _cfgLocal.PreviewDistance
7032 _initialLayout = False
7036 Private Sub PlaySoundMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlaySoundMenuItem.CheckedChanged, PlaySoundFileMenuItem.CheckStateChanged
7037 PlaySoundMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7038 Me.PlaySoundFileMenuItem.Checked = PlaySoundMenuItem.Checked
7039 If PlaySoundMenuItem.Checked Then
7040 SettingDialog.PlaySound = True
7042 SettingDialog.PlaySound = False
7044 _modifySettingCommon = True
7047 Private Sub SplitContainer1_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved
7048 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
7049 _mySpDis = SplitContainer1.SplitterDistance
7050 If StatusText.Multiline Then _mySpDis2 = StatusText.Height
7051 _modifySettingLocal = True
7055 Private Sub doRepliedStatusOpen()
7056 If _curPost IsNot Nothing AndAlso _curPost.InReplyToUser IsNot Nothing AndAlso _curPost.InReplyToId > 0 Then
7057 If My.Computer.Keyboard.ShiftKeyDown Then
7058 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/status/" + _curPost.InReplyToId.ToString())
7061 If _statuses.ContainsKey(_curPost.InReplyToId) Then
7062 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
7063 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
7065 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.Lists Or TabUsageType.PublicSearch)
7066 If tb Is Nothing OrElse Not tb.Contains(_curPost.InReplyToId) Then Exit For
7067 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToId)
7068 MessageBox.Show(repPost.Name + " / " + repPost.Nickname + " (" + repPost.PDate.ToString() + ")" + Environment.NewLine + repPost.Data)
7071 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/status/" + _curPost.InReplyToId.ToString())
7076 Private Sub RepliedStatusOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RepliedStatusOpenMenuItem.Click, OpenRepSourceOpMenuItem.Click
7077 doRepliedStatusOpen()
7080 Private Sub ContextMenuUserPicture_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuUserPicture.Opening
7081 '発言詳細のアイコン右クリック時のメニュー制御
7082 If _curList.SelectedIndices.Count > 0 AndAlso _curPost IsNot Nothing Then
7083 Dim name As String = _curPost.ImageUrl
7084 If name IsNot Nothing AndAlso name.Length > 0 Then
7085 Dim idx As Integer = name.LastIndexOf("/"c)
7087 name = IO.Path.GetFileNameWithoutExtension(name.Substring(idx))
7088 If name.EndsWith("_normal", StringComparison.OrdinalIgnoreCase) Then
7089 name = name.Substring(0, name.Length - 7) ' "_normal".Length
7090 Me.IconNameToolStripMenuItem.Text = name
7091 Me.IconNameToolStripMenuItem.Enabled = True
7093 Me.IconNameToolStripMenuItem.Enabled = False
7094 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7097 Me.IconNameToolStripMenuItem.Enabled = False
7098 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7100 If Me.TIconDic.ContainsKey(_curPost.ImageUrl) AndAlso Me.TIconDic(_curPost.ImageUrl) IsNot Nothing Then
7101 Me.SaveIconPictureToolStripMenuItem.Enabled = True
7103 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7106 Me.IconNameToolStripMenuItem.Enabled = False
7107 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7108 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7111 Me.IconNameToolStripMenuItem.Enabled = False
7112 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7113 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText2
7115 If NameLabel.Tag IsNot Nothing Then
7116 Dim id As String = DirectCast(NameLabel.Tag, String)
7117 If id = tw.Username Then
7118 FollowToolStripMenuItem.Enabled = False
7119 UnFollowToolStripMenuItem.Enabled = False
7120 ShowFriendShipToolStripMenuItem.Enabled = False
7121 ShowUserStatusToolStripMenuItem.Enabled = True
7122 SearchPostsDetailNameToolStripMenuItem.Enabled = False
7123 ListManageUserContextToolStripMenuItem3.Enabled = True
7125 FollowToolStripMenuItem.Enabled = True
7126 UnFollowToolStripMenuItem.Enabled = True
7127 ShowFriendShipToolStripMenuItem.Enabled = True
7128 ShowUserStatusToolStripMenuItem.Enabled = True
7129 SearchPostsDetailNameToolStripMenuItem.Enabled = True
7130 ListManageUserContextToolStripMenuItem3.Enabled = True
7133 FollowToolStripMenuItem.Enabled = False
7134 UnFollowToolStripMenuItem.Enabled = False
7135 ShowFriendShipToolStripMenuItem.Enabled = False
7136 ShowUserStatusToolStripMenuItem.Enabled = False
7137 SearchPostsDetailNameToolStripMenuItem.Enabled = False
7138 ListManageUserContextToolStripMenuItem3.Enabled = False
7142 Private Sub IconNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IconNameToolStripMenuItem.Click
7143 If _curPost Is Nothing Then Exit Sub
7144 Dim name As String = _curPost.ImageUrl
7145 OpenUriAsync(name.Remove(name.LastIndexOf("_normal"), 7)) ' "_normal".Length
7148 Private Sub SaveOriginalSizeIconPictureToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
7149 If _curPost Is Nothing Then Exit Sub
7150 Dim name As String = _curPost.ImageUrl
7151 name = IO.Path.GetFileNameWithoutExtension(name.Substring(name.LastIndexOf("/"c)))
7153 Me.SaveFileDialog1.FileName = name.Substring(0, name.Length - 8) ' "_normal".Length + 1
7155 If Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
7160 Private Sub SaveIconPictureToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveIconPictureToolStripMenuItem.Click
7161 If _curPost Is Nothing Then Exit Sub
7162 Dim name As String = _curPost.ImageUrl
7164 Me.SaveFileDialog1.FileName = name.Substring(name.LastIndexOf("/"c) + 1)
7166 If Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
7167 Using bmp2 As New Bitmap(TIconDic(name).Size.Width, TIconDic(name).Size.Height)
7168 Using g As Graphics = Graphics.FromImage(bmp2)
7169 g.InterpolationMode = Drawing2D.InterpolationMode.High
7170 g.DrawImage(TIconDic(name), 0, 0, TIconDic(name).Size.Width, TIconDic(name).Size.Height)
7173 bmp2.Save(Me.SaveFileDialog1.FileName)
7179 Private Sub SplitContainer2_Panel2_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitContainer2.Panel2.Resize
7180 Me.StatusText.Multiline = Me.SplitContainer2.Panel2.Height > Me.SplitContainer2.Panel2MinSize + 2
7181 MultiLineMenuItem.Checked = Me.StatusText.Multiline
7182 _modifySettingLocal = True
7185 Private Sub StatusText_MultilineChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.MultilineChanged
7186 If Me.StatusText.Multiline Then
7187 Me.StatusText.ScrollBars = ScrollBars.Vertical
7189 Me.StatusText.ScrollBars = ScrollBars.None
7191 _modifySettingLocal = True
7194 Private Sub MultiLineMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MultiLineMenuItem.Click
7196 StatusText.Multiline = MultiLineMenuItem.Checked
7197 _cfgLocal.StatusMultiline = MultiLineMenuItem.Checked
7198 If MultiLineMenuItem.Checked Then
7199 If SplitContainer2.Height - _mySpDis2 - SplitContainer2.SplitterWidth < 0 Then
7200 SplitContainer2.SplitterDistance = 0
7202 SplitContainer2.SplitterDistance = SplitContainer2.Height - _mySpDis2 - SplitContainer2.SplitterWidth
7205 SplitContainer2.SplitterDistance = SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth
7207 _modifySettingLocal = True
7210 Private Function UrlConvert(ByVal Converter_Type As UrlConverter) As Boolean
7211 'Converter_Type=Nicomsの場合は、nicovideoのみ短縮する
7212 Dim result As String = ""
7213 Const url As String = "(?<before>(?:[^\""':!=]|^|\:))" + _
7214 "(?<url>(?<protocol>https?://)" + _
7215 "(?<domain>(?:[\.-]|[^\p{P}\s])+\.[a-z]{2,}(?::[0-9]+)?)" + _
7216 "(?<path>/[a-z0-9!*'();:&=+$/%#\[\]\-_.,~@^]*[a-z0-9)=#/]?)?" + _
7217 "(?<query>\?[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9_&=#/])?)"
7219 Const nico As String = "^https?://[a-z]+\.(nicovideo|niconicommons|nicolive)\.jp/[a-z]+/[a-z0-9]+$"
7221 If StatusText.SelectionLength > 0 Then
7222 Dim tmp As String = StatusText.SelectedText
7223 ' httpから始まらない場合、ExcludeStringで指定された文字列で始まる場合は対象としない
7224 If tmp.StartsWith("http") Then
7225 ' 文字列が選択されている場合はその文字列について処理
7227 'nico.ms使用、nicovideoにマッチしたら変換
7228 If SettingDialog.Nicoms AndAlso Regex.IsMatch(tmp, nico) Then
7229 result = nicoms.Shorten(tmp)
7230 ElseIf Converter_Type <> UrlConverter.Nicoms Then
7231 '短縮URL変換 日本語を含むかもしれないのでURLエンコードする
7232 result = ShortUrl.Make(Converter_Type, tmp)
7233 If result.Equals("Can't convert") Then
7234 StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":")
7241 If Not String.IsNullOrEmpty(result) Then
7242 Dim undotmp As New urlUndo
7244 StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length)
7245 StatusText.SelectedText = result
7248 undotmp.Before = tmp
7249 undotmp.After = result
7251 If urlUndoBuffer Is Nothing Then
7252 urlUndoBuffer = New List(Of urlUndo)
7253 UrlUndoToolStripMenuItem.Enabled = True
7256 urlUndoBuffer.Add(undotmp)
7260 ' 正規表現にマッチしたURL文字列をtinyurl化
7261 For Each mt As Match In Regex.Matches(StatusText.Text, url, RegexOptions.IgnoreCase)
7262 If StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal) = -1 Then Continue For
7263 Dim tmp As String = mt.Result("${url}")
7264 If tmp.StartsWith("w", StringComparison.OrdinalIgnoreCase) Then tmp = "http://" + tmp
7265 Dim undotmp As New urlUndo
7268 StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length)
7270 'nico.ms使用、nicovideoにマッチしたら変換
7271 If SettingDialog.Nicoms AndAlso Regex.IsMatch(tmp, nico) Then
7272 result = nicoms.Shorten(tmp)
7273 ElseIf Converter_Type <> UrlConverter.Nicoms Then
7274 '短縮URL変換 日本語を含むかもしれないのでURLエンコードする
7275 result = ShortUrl.Make(Converter_Type, tmp)
7276 If result.Equals("Can't convert") Then
7277 StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":")
7284 If Not String.IsNullOrEmpty(result) Then
7285 StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length)
7286 StatusText.SelectedText = result
7288 undotmp.Before = mt.Result("${url}")
7289 undotmp.After = result
7291 If urlUndoBuffer Is Nothing Then
7292 urlUndoBuffer = New List(Of urlUndo)
7293 UrlUndoToolStripMenuItem.Enabled = True
7296 urlUndoBuffer.Add(undotmp)
7305 Private Sub doUrlUndo()
7306 If urlUndoBuffer IsNot Nothing Then
7307 Dim tmp As String = StatusText.Text
7308 For Each data As urlUndo In urlUndoBuffer
7309 tmp = tmp.Replace(data.After, data.Before)
7311 StatusText.Text = tmp
7312 urlUndoBuffer = Nothing
7313 UrlUndoToolStripMenuItem.Enabled = False
7317 Private Sub TinyURLToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TinyURLToolStripMenuItem.Click
7318 UrlConvert(UrlConverter.TinyUrl)
7321 Private Sub IsgdToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IsgdToolStripMenuItem.Click
7322 UrlConvert(UrlConverter.Isgd)
7325 Private Sub TwurlnlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TwurlnlToolStripMenuItem.Click
7326 UrlConvert(UrlConverter.Twurl)
7329 Private Sub UrlConvertAutoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlConvertAutoToolStripMenuItem.Click
7330 If Not UrlConvert(SettingDialog.AutoShortUrlFirst) Then
7331 Dim svc As UrlConverter = SettingDialog.AutoShortUrlFirst
7332 Dim rnd As New Random()
7333 ' 前回使用した短縮URLサービス以外を選択する
7335 svc = CType(rnd.Next(System.Enum.GetNames(GetType(UrlConverter)).Length), UrlConverter)
7336 Loop Until svc <> SettingDialog.AutoShortUrlFirst
7341 Private Sub UrlUndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlUndoToolStripMenuItem.Click
7345 Private Sub NewPostPopMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewPostPopMenuItem.CheckStateChanged, NotifyFileMenuItem.CheckStateChanged
7346 Me.NotifyFileMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7347 Me.NewPostPopMenuItem.Checked = Me.NotifyFileMenuItem.Checked
7348 _cfgCommon.NewAllPop = NewPostPopMenuItem.Checked
7349 _modifySettingCommon = True
7352 Private Sub ListLockMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListLockMenuItem.CheckStateChanged, LockListFileMenuItem.CheckStateChanged
7353 ListLockMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7354 Me.LockListFileMenuItem.Checked = ListLockMenuItem.Checked
7355 _cfgCommon.ListLock = ListLockMenuItem.Checked
7356 _modifySettingCommon = True
7359 Private Sub MenuStrip1_MenuActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuStrip1.MenuActivate
7360 ' フォーカスがメニューに移る (MenuStrip1.Tag フラグを立てる)
7361 MenuStrip1.Tag = New Object()
7362 MenuStrip1.Select() ' StatusText がフォーカスを持っている場合 Leave が発生
7365 Private Sub MenuStrip1_MenuDeactivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuStrip1.MenuDeactivate
7366 If Me.Tag IsNot Nothing Then ' 設定された戻り先へ遷移
7367 If Me.Tag Is Me.ListTab.SelectedTab Then
7368 DirectCast(Me.ListTab.SelectedTab.Tag, Control).Select()
7370 DirectCast(Me.Tag, Control).Select()
7372 Else ' 戻り先が指定されていない (初期状態) 場合はタブに遷移
7373 If ListTab.SelectedIndex > -1 AndAlso ListTab.SelectedTab.HasChildren Then
7374 Me.Tag = ListTab.SelectedTab.Tag
7375 DirectCast(Me.Tag, Control).Select()
7378 ' フォーカスがメニューに遷移したかどうかを表すフラグを降ろす
7379 MenuStrip1.Tag = Nothing
7382 Private Sub MyList_ColumnReordered(ByVal sender As System.Object, ByVal e As ColumnReorderedEventArgs)
7383 Dim lst As DetailsListView = DirectCast(sender, DetailsListView)
7384 If _cfgLocal Is Nothing Then Exit Sub
7387 _cfgLocal.Width1 = lst.Columns(0).Width
7388 _cfgLocal.Width3 = lst.Columns(1).Width
7390 Dim darr(lst.Columns.Count - 1) As Integer
7391 For i As Integer = 0 To lst.Columns.Count - 1
7392 darr(lst.Columns(i).DisplayIndex) = i
7394 MoveArrayItem(darr, e.OldDisplayIndex, e.NewDisplayIndex)
7396 For i As Integer = 0 To lst.Columns.Count - 1
7399 _cfgLocal.DisplayIndex1 = i
7401 _cfgLocal.DisplayIndex2 = i
7403 _cfgLocal.DisplayIndex3 = i
7405 _cfgLocal.DisplayIndex4 = i
7407 _cfgLocal.DisplayIndex5 = i
7409 _cfgLocal.DisplayIndex6 = i
7411 _cfgLocal.DisplayIndex7 = i
7413 _cfgLocal.DisplayIndex8 = i
7416 _cfgLocal.Width1 = lst.Columns(0).Width
7417 _cfgLocal.Width2 = lst.Columns(1).Width
7418 _cfgLocal.Width3 = lst.Columns(2).Width
7419 _cfgLocal.Width4 = lst.Columns(3).Width
7420 _cfgLocal.Width5 = lst.Columns(4).Width
7421 _cfgLocal.Width6 = lst.Columns(5).Width
7422 _cfgLocal.Width7 = lst.Columns(6).Width
7423 _cfgLocal.Width8 = lst.Columns(7).Width
7425 _modifySettingLocal = True
7426 _isColumnChanged = True
7429 Private Sub MyList_ColumnWidthChanged(ByVal sender As System.Object, ByVal e As ColumnWidthChangedEventArgs)
7430 Dim lst As DetailsListView = DirectCast(sender, DetailsListView)
7431 If _cfgLocal Is Nothing Then Exit Sub
7433 If _cfgLocal.Width1 <> lst.Columns(0).Width Then
7434 _cfgLocal.Width1 = lst.Columns(0).Width
7435 _modifySettingLocal = True
7436 _isColumnChanged = True
7438 If _cfgLocal.Width3 <> lst.Columns(1).Width Then
7439 _cfgLocal.Width3 = lst.Columns(1).Width
7440 _modifySettingLocal = True
7441 _isColumnChanged = True
7444 If _cfgLocal.Width1 <> lst.Columns(0).Width Then
7445 _cfgLocal.Width1 = lst.Columns(0).Width
7446 _modifySettingLocal = True
7447 _isColumnChanged = True
7449 If _cfgLocal.Width2 <> lst.Columns(1).Width Then
7450 _cfgLocal.Width2 = lst.Columns(1).Width
7451 _modifySettingLocal = True
7452 _isColumnChanged = True
7454 If _cfgLocal.Width3 <> lst.Columns(2).Width Then
7455 _cfgLocal.Width3 = lst.Columns(2).Width
7456 _modifySettingLocal = True
7457 _isColumnChanged = True
7459 If _cfgLocal.Width4 <> lst.Columns(3).Width Then
7460 _cfgLocal.Width4 = lst.Columns(3).Width
7461 _modifySettingLocal = True
7462 _isColumnChanged = True
7464 If _cfgLocal.Width5 <> lst.Columns(4).Width Then
7465 _cfgLocal.Width5 = lst.Columns(4).Width
7466 _modifySettingLocal = True
7467 _isColumnChanged = True
7469 If _cfgLocal.Width6 <> lst.Columns(5).Width Then
7470 _cfgLocal.Width6 = lst.Columns(5).Width
7471 _modifySettingLocal = True
7472 _isColumnChanged = True
7474 If _cfgLocal.Width7 <> lst.Columns(6).Width Then
7475 _cfgLocal.Width7 = lst.Columns(6).Width
7476 _modifySettingLocal = True
7477 _isColumnChanged = True
7479 If _cfgLocal.Width8 <> lst.Columns(7).Width Then
7480 _cfgLocal.Width8 = lst.Columns(7).Width
7481 _modifySettingLocal = True
7482 _isColumnChanged = True
7485 ' 非表示の時にColumnChangedが呼ばれた場合はForm初期化処理中なので保存しない
7487 ' SaveConfigsLocal()
7491 Public Function WebBrowser_GetSelectionText(ByRef ComponentInstance As WebBrowser) As String
7492 '発言詳細で「選択文字列をコピー」を行う
7493 'WebBrowserコンポーネントのインスタンスを渡す
7494 Dim typ As Type = ComponentInstance.ActiveXInstance.GetType()
7495 Dim _SelObj As Object = typ.InvokeMember("selection", BindingFlags.GetProperty, Nothing, ComponentInstance.Document.DomDocument, Nothing)
7496 Dim _objRange As Object = _SelObj.GetType().InvokeMember("createRange", BindingFlags.InvokeMethod, Nothing, _SelObj, Nothing)
7497 Return DirectCast(_objRange.GetType().InvokeMember("text", BindingFlags.GetProperty, Nothing, _objRange, Nothing), String)
7500 Private Sub SelectionCopyContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionCopyContextMenuItem.Click
7502 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7504 Clipboard.SetDataObject(_selText, False, 5, 100)
7505 Catch ex As Exception
7506 MessageBox.Show(ex.Message)
7510 Private Sub doSearchToolStrip(ByVal url As String)
7511 '発言詳細で「選択文字列で検索」(選択文字列取得)
7512 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7514 If _selText IsNot Nothing Then
7515 If url = My.Resources.SearchItem4Url Then
7517 AddNewTabForSearch(_selText)
7521 Dim tmp As String = String.Format(url, HttpUtility.UrlEncode(_selText))
7526 Private Sub SelectionAllContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionAllContextMenuItem.Click
7528 PostBrowser.Document.ExecCommand("SelectAll", False, Nothing)
7531 Private Sub SearchWikipediaContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchWikipediaContextMenuItem.Click
7532 doSearchToolStrip(My.Resources.SearchItem1Url)
7535 Private Sub SearchGoogleContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchGoogleContextMenuItem.Click
7536 doSearchToolStrip(My.Resources.SearchItem2Url)
7539 Private Sub SearchYatsContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchYatsContextMenuItem.Click
7540 doSearchToolStrip(My.Resources.SearchItem3Url)
7543 Private Sub SearchPublicSearchContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPublicSearchContextMenuItem.Click
7544 doSearchToolStrip(My.Resources.SearchItem4Url)
7547 Private Sub UrlCopyContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlCopyContextMenuItem.Click
7549 Clipboard.SetDataObject(Me._postBrowserStatusText, False, 5, 100)
7550 Catch ex As Exception
7551 MessageBox.Show(ex.Message)
7555 Private Sub ContextMenuPostBrowser_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuPostBrowser.Opening
7557 If PostBrowser.StatusText.StartsWith("http") Then
7558 Me._postBrowserStatusText = PostBrowser.StatusText
7559 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
7560 UrlCopyContextMenuItem.Enabled = True
7561 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
7562 FollowContextMenuItem.Enabled = True
7563 RemoveContextMenuItem.Enabled = True
7564 FriendshipContextMenuItem.Enabled = True
7565 ShowUserStatusContextMenuItem.Enabled = True
7566 SearchPostsDetailToolStripMenuItem.Enabled = True
7567 IdFilterAddMenuItem.Enabled = True
7568 ListManageUserContextToolStripMenuItem.Enabled = True
7570 FollowContextMenuItem.Enabled = False
7571 RemoveContextMenuItem.Enabled = False
7572 FriendshipContextMenuItem.Enabled = False
7573 ShowUserStatusContextMenuItem.Enabled = False
7574 SearchPostsDetailToolStripMenuItem.Enabled = False
7575 IdFilterAddMenuItem.Enabled = False
7576 ListManageUserContextToolStripMenuItem.Enabled = False
7579 If Regex.IsMatch(Me._postBrowserStatusText, "^https?://twitter.com/search\?q=%23") Then
7580 UseHashtagMenuItem.Enabled = True
7582 UseHashtagMenuItem.Enabled = False
7585 Me._postBrowserStatusText = ""
7586 UrlCopyContextMenuItem.Enabled = False
7587 FollowContextMenuItem.Enabled = False
7588 RemoveContextMenuItem.Enabled = False
7589 FriendshipContextMenuItem.Enabled = False
7590 ShowUserStatusContextMenuItem.Enabled = False
7591 SearchPostsDetailToolStripMenuItem.Enabled = False
7592 UseHashtagMenuItem.Enabled = False
7593 IdFilterAddMenuItem.Enabled = False
7594 ListManageUserContextToolStripMenuItem.Enabled = False
7596 ' 文字列選択されていないときは選択文字列関係の項目を非表示に
7597 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7598 If _selText Is Nothing Then
7599 SelectionSearchContextMenuItem.Enabled = False
7600 SelectionCopyContextMenuItem.Enabled = False
7602 SelectionSearchContextMenuItem.Enabled = True
7603 SelectionCopyContextMenuItem.Enabled = True
7605 '発言内に自分以外のユーザーが含まれてればフォロー状態全表示を有効に
7606 Dim ma As MatchCollection = Regex.Matches(Me.PostBrowser.DocumentText, "href=""https?://twitter.com/(?<name>[a-zA-Z0-9_]+)""")
7607 Dim fAllFlag As Boolean = False
7608 For Each mu As Match In ma
7609 If mu.Result("${name}").ToLower <> tw.Username.ToLower Then
7614 Me.FriendshipAllMenuItem.Enabled = fAllFlag
7619 Private Sub CurrentTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurrentTabToolStripMenuItem.Click
7620 '発言詳細の選択文字列で現在のタブを検索
7621 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7623 If _selText IsNot Nothing Then
7624 SearchDialog.SWord = _selText
7625 SearchDialog.CheckCaseSensitive = False
7626 SearchDialog.CheckRegex = False
7628 DoTabSearch(SearchDialog.SWord, _
7629 SearchDialog.CheckCaseSensitive, _
7630 SearchDialog.CheckRegex, _
7631 SEARCHTYPE.NextSearch)
7635 Private Sub SplitContainer2_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer2.SplitterMoved
7636 If StatusText.Multiline Then _mySpDis2 = StatusText.Height
7637 _modifySettingLocal = True
7640 Private Sub TweenMain_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
7641 If e.Data.GetDataPresent(DataFormats.FileDrop) Then
7642 ImageSelectionPanel.Visible = True
7643 ImageSelectionPanel.Enabled = True
7644 TimelinePanel.Visible = False
7645 TimelinePanel.Enabled = False
7646 ImagefilePathText.Text = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
7647 ImageFromSelectedFile()
7648 ElseIf e.Data.GetDataPresent(DataFormats.StringFormat) Then
7649 Dim data As String = TryCast(e.Data.GetData(DataFormats.StringFormat, True), String)
7650 If data IsNot Nothing Then StatusText.Text += data
7654 Private Sub TweenMain_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragOver
7655 If e.Data.GetDataPresent(DataFormats.FileDrop) Then
7656 Dim filename As String = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
7657 Dim fl As New FileInfo(filename)
7658 Dim ext As String = fl.Extension
7659 Dim picsvc As New PictureService(tw)
7661 If picsvc.IsValidExtension(ext, ImageService) AndAlso _
7662 picsvc.GetMaxFileSize(ext, ImageService) >= fl.Length Then
7663 e.Effect = DragDropEffects.Copy
7666 For Each svc As String In ImageServiceCombo.Items
7667 If picsvc.IsValidExtension(ext, svc) AndAlso _
7668 picsvc.GetMaxFileSize(ext, svc) >= fl.Length Then
7669 ImageServiceCombo.SelectedItem = svc
7670 e.Effect = DragDropEffects.Copy
7676 e.Effect = DragDropEffects.None
7677 ElseIf e.Data.GetDataPresent(DataFormats.StringFormat) Then
7678 e.Effect = DragDropEffects.Copy
7680 e.Effect = DragDropEffects.None
7684 Public Function IsNetworkAvailable() As Boolean
7685 Dim nw As Boolean = True
7687 nw = My.Computer.Network.IsAvailable
7688 Catch ex As Exception
7691 _myStatusOnline = nw
7695 Public Sub OpenUriAsync(ByVal UriString As String)
7696 Dim args As New GetWorkerArg
7697 args.type = WORKERTYPE.OpenUri
7698 args.url = UriString
7703 Private Sub ListTabSelect(ByVal _tab As TabPage)
7706 _itemCache = Nothing
7707 _itemCacheIndex = -1
7708 _postCache = Nothing
7711 _curList = DirectCast(_tab.Tag, DetailsListView)
7712 If _curList.SelectedIndices.Count > 0 Then
7713 _curItemIndex = _curList.SelectedIndices(0)
7714 _curPost = GetCurTabPost(_curItemIndex)
7720 _anchorPost = Nothing
7724 DirectCast(_tab.Tag, DetailsListView).Columns.Item(1).Text = ColumnText(2)
7726 For i As Integer = 0 To _curList.Columns.Count - 1
7727 DirectCast(_tab.Tag, DetailsListView).Columns.Item(i).Text = ColumnText(i)
7732 Private Sub ListTab_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles ListTab.Selecting
7733 ListTabSelect(e.TabPage)
7736 Private Sub SelectListItem(ByVal LView As DetailsListView, ByVal Index As Integer)
7738 Dim bnd As Rectangle
7739 Dim flg As Boolean = False
7740 If LView.FocusedItem IsNot Nothing Then
7741 bnd = LView.FocusedItem.Bounds
7745 LView.SelectedIndices.Clear()
7746 LView.Items(Index).Selected = True
7747 LView.Items(Index).Focused = True
7749 If flg Then LView.Invalidate(bnd)
7752 Private Sub SelectListItem(ByVal LView As DetailsListView, ByVal Index() As Integer, ByVal FocusedIndex As Integer)
7754 Dim bnd As Rectangle
7755 Dim flg As Boolean = False
7756 If LView.FocusedItem IsNot Nothing Then
7757 bnd = LView.FocusedItem.Bounds
7761 If Index IsNot Nothing AndAlso Index(0) > -1 Then
7762 LView.SelectedIndices.Clear()
7763 For Each idx As Integer In Index
7764 LView.SelectedIndices.Add(idx)
7767 If FocusedIndex > -1 Then
7768 LView.Items(FocusedIndex).Focused = True
7770 If flg Then LView.Invalidate(bnd)
7773 Private Sub RunAsync(ByVal args As GetWorkerArg)
7774 Dim bw As BackgroundWorker = Nothing
7775 If args.type <> WORKERTYPE.Follower Then
7776 For i As Integer = 0 To _bw.Length - 1
7777 If _bw(i) IsNot Nothing AndAlso Not _bw(i).IsBusy Then
7782 If bw Is Nothing Then
7783 For i As Integer = 0 To _bw.Length - 1
7784 If _bw(i) Is Nothing Then
7785 _bw(i) = New BackgroundWorker
7787 bw.WorkerReportsProgress = True
7788 bw.WorkerSupportsCancellation = True
7789 AddHandler bw.DoWork, AddressOf GetTimelineWorker_DoWork
7790 AddHandler bw.ProgressChanged, AddressOf GetTimelineWorker_ProgressChanged
7791 AddHandler bw.RunWorkerCompleted, AddressOf GetTimelineWorker_RunWorkerCompleted
7797 If _bwFollower Is Nothing Then
7798 _bwFollower = New BackgroundWorker
7800 bw.WorkerReportsProgress = True
7801 bw.WorkerSupportsCancellation = True
7802 AddHandler bw.DoWork, AddressOf GetTimelineWorker_DoWork
7803 AddHandler bw.ProgressChanged, AddressOf GetTimelineWorker_ProgressChanged
7804 AddHandler bw.RunWorkerCompleted, AddressOf GetTimelineWorker_RunWorkerCompleted
7806 If _bwFollower.IsBusy = False Then
7811 If bw Is Nothing Then Exit Sub
7813 bw.RunWorkerAsync(args)
7816 Private Sub TweenMain_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
7818 PostBrowser.Url = New Uri("about:blank")
7819 PostBrowser.DocumentText = "" '発言詳細部初期化
7820 Catch ex As Exception
7824 NotifyIcon1.Visible = True
7826 If IsNetworkAvailable() Then
7827 If SettingDialog.StartupFollowers Then
7828 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
7830 _waitTimeline = True
7831 GetTimeline(WORKERTYPE.Timeline, 1, 1, "")
7833 GetTimeline(WORKERTYPE.Reply, 1, 1, "")
7835 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 1, "")
7836 If SettingDialog.GetFav Then
7838 GetTimeline(WORKERTYPE.Favorites, 1, 1, "")
7840 _waitPubSearch = True
7841 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, "") 'tabname="":全タブ
7843 GetTimeline(WORKERTYPE.List, 1, 0, "") 'tabname="":全タブ
7844 Dim i As Integer = 0
7845 Do While (_waitTimeline OrElse _waitReply OrElse _waitDm OrElse _waitFav OrElse _waitPubSearch OrElse _waitLists) AndAlso Not _endingFlag
7846 System.Threading.Thread.Sleep(100)
7847 My.Application.DoEvents()
7857 If _endingFlag Then Exit Sub
7859 'バージョンチェック(引数:起動時チェックの場合はTrue・・・チェック結果のメッセージを表示しない)
7860 If SettingDialog.StartupVersion Then
7861 CheckNewVersion(True)
7865 If Not tw.GetFollowersSuccess AndAlso SettingDialog.StartupFollowers Then
7866 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
7869 If Not _cfgCommon.IsOAuth Then
7870 MessageBox.Show(String.Format(My.Resources.BasicAuthWarning, Environment.NewLine))
7874 TimerTimeline.Enabled = True
7877 Private Sub doGetFollowersMenu()
7878 GetTimeline(WORKERTYPE.Follower, 1, 0, "")
7882 Private Sub GetFollowersAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateFollowersMenuItem1.Click
7883 doGetFollowersMenu()
7886 Private Sub doReTweetUnofficial()
7888 If _curPost IsNot Nothing Then
7889 If _curPost.IsDm OrElse _
7890 Not StatusText.Enabled Then Exit Sub
7892 If SettingDialog.ProtectNotInclude AndAlso _curPost.IsProtect Then
7893 MessageBox.Show("Protected.")
7896 Dim rtdata As String = _curPost.OriginalData
7897 rtdata = CreateRetweetUnofficial(rtdata)
7899 StatusText.Text = "RT @" + _curPost.Name + ": " + HttpUtility.HtmlDecode(rtdata)
7901 StatusText.SelectionStart = 0
7906 Private Sub ReTweetStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReTweetStripMenuItem.Click, RtUnOpMenuItem.Click
7907 doReTweetUnofficial()
7910 Private Sub doReTweetOriginal(ByVal isConfirm As Boolean)
7912 If _curPost IsNot Nothing AndAlso Not _curPost.IsDm AndAlso Not _curPost.IsMe Then
7913 If SettingDialog.ProtectNotInclude AndAlso _curPost.IsProtect Then
7914 MessageBox.Show("Protected.")
7917 If isConfirm AndAlso MessageBox.Show(My.Resources.RetweetQuestion1, "Retweet", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
7920 Dim args As New GetWorkerArg
7921 args.ids = New List(Of Long)
7922 args.sIds = New List(Of Long)
7923 args.tName = _curTab.Text
7924 args.type = WORKERTYPE.Retweet
7925 args.ids.Add(_curPost.Id)
7931 Private Sub ReTweetOriginalStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReTweetOriginalStripMenuItem.Click, RtOpMenuItem.Click
7932 doReTweetOriginal(True)
7935 Private Function CreateRetweetUnofficial(ByVal status As String) As String
7937 ' Twitterにより省略されているURLを含むaタグをキャプチャしてリンク先URLへ置き換える
7940 Dim isUrl As Boolean = False
7941 Dim ms As MatchCollection = Regex.Matches(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>")
7942 For Each m As Match In ms
7943 If m.Result("${link}").EndsWith("...") Then
7949 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>", "${url}")
7951 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>", "${link}")
7954 'その他のリンク(@IDなど)を置き換える
7955 status = Regex.Replace(status, "@<a target=""_self"" href=""https?://twitter.com/(?<url>[^""]+)""[^>]*>(?<link>[^<]+)</a>", "@${url}")
7957 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>[^<]+)</a>", "${link}")
7959 If StatusText.Multiline Then
7960 status = Regex.Replace(status, "(\r\n|\n|\r)?<br>", vbCrLf, RegexOptions.IgnoreCase Or RegexOptions.Multiline)
7962 status = Regex.Replace(status, "(\r\n|\n|\r)?<br>", "", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
7967 status = status.Replace(" ", " ")
7972 Private Sub DumpPostClassToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DumpPostClassToolStripMenuItem.Click
7973 If _curPost IsNot Nothing Then
7978 Private Sub MenuItemHelp_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemHelp.DropDownOpening
7979 If DebugBuild OrElse My.Computer.Keyboard.CapsLock AndAlso My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.ShiftKeyDown Then
7980 DebugModeToolStripMenuItem.Visible = True
7982 DebugModeToolStripMenuItem.Visible = False
7986 Private Sub ToolStripMenuItemUrlAutoShorten_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemUrlAutoShorten.CheckedChanged
7987 SettingDialog.UrlConvertAuto = ToolStripMenuItemUrlAutoShorten.Checked
7990 Private Sub ContextMenuPostMode_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuPostMode.Opening
7991 ToolStripMenuItemUrlAutoShorten.Checked = SettingDialog.UrlConvertAuto
7994 Private Sub TraceOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraceOutToolStripMenuItem.Click
7995 If TraceOutToolStripMenuItem.Checked Then
8002 Private Sub TweenMain_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
8003 '画面が非アクティブになったら、発言欄の背景色をデフォルトへ
8004 Me.StatusText_Leave(StatusText, System.EventArgs.Empty)
8007 Private Sub TabRenameMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabRenameMenuItem.Click, RenameTbMenuItem.Click
8008 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
8009 TabRename(_rclickTabName)
8012 Private Sub UnuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnuToolStripMenuItem.Click
8013 UrlConvert(UrlConverter.Unu)
8016 Private Sub BitlyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BitlyToolStripMenuItem.Click
8017 UrlConvert(UrlConverter.Bitly)
8020 Private Sub JmpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JmpStripMenuItem.Click
8021 UrlConvert(UrlConverter.Jmp)
8025 Private Class GetApiInfoArgs
8026 Public tw As Twitter
8027 Public info As ApiInfo
8030 Private Sub GetApiInfo_Dowork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8031 Dim args As GetApiInfoArgs = DirectCast(e.Argument, GetApiInfoArgs)
8032 e.Result = tw.GetInfoApi(args.info)
8035 Private Sub ApiInfoMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApiInfoMenuItem.Click
8036 Dim info As New ApiInfo
8038 Dim args As New GetApiInfoArgs With {.tw = tw, .info = info}
8040 Using dlg As New FormInfo(Me, My.Resources.ApiInfo6, AddressOf GetApiInfo_Dowork, Nothing, args)
8042 If CBool(dlg.Result) Then
8043 tmp = My.Resources.ApiInfo1 + args.info.MaxCount.ToString() + Environment.NewLine + _
8044 My.Resources.ApiInfo2 + args.info.RemainCount.ToString + Environment.NewLine + _
8045 My.Resources.ApiInfo3 + args.info.ResetTime.ToString()
8048 tmp = My.Resources.ApiInfo5
8052 MessageBox.Show(tmp, My.Resources.ApiInfo4, MessageBoxButtons.OK, MessageBoxIcon.Information)
8055 Private Sub FollowCommandMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowCommandMenuItem.Click
8056 Dim id As String = ""
8057 If _curPost IsNot Nothing Then id = _curPost.Name
8061 Private Sub FollowCommand_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8062 Dim arg As FollowRemoveCommandArgs = DirectCast(e.Argument, FollowRemoveCommandArgs)
8063 e.Result = arg.tw.PostFollowCommand(arg.id)
8066 Private Sub FollowCommand(ByVal id As String)
8067 Using inputName As New InputTabName()
8068 inputName.FormTitle = "Follow"
8069 inputName.FormDescription = My.Resources.FRMessage1
8070 inputName.TabName = id
8071 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8072 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8073 Dim arg As New FollowRemoveCommandArgs
8075 arg.id = inputName.TabName.Trim()
8076 Using _info As New FormInfo(Me, My.Resources.FollowCommandText1, _
8077 AddressOf FollowCommand_DoWork, _
8081 Dim ret As String = DirectCast(_info.Result, String)
8082 If Not String.IsNullOrEmpty(ret) Then
8083 MessageBox.Show(My.Resources.FRMessage2 + ret)
8085 MessageBox.Show(My.Resources.FRMessage3)
8092 Private Sub RemoveCommandMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveCommandMenuItem.Click
8093 Dim id As String = ""
8094 If _curPost IsNot Nothing Then id = _curPost.Name
8095 RemoveCommand(id, False)
8098 Private Class FollowRemoveCommandArgs
8099 Public tw As Tween.Twitter
8103 Private Sub RemoveCommand_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8104 Dim arg As FollowRemoveCommandArgs = DirectCast(e.Argument, FollowRemoveCommandArgs)
8105 e.Result = arg.tw.PostRemoveCommand(arg.id)
8108 Private Sub RemoveCommand(ByVal id As String, ByVal skipInput As Boolean)
8109 Dim arg As New FollowRemoveCommandArgs
8112 If Not skipInput Then
8113 Using inputName As New InputTabName()
8114 inputName.FormTitle = "Unfollow"
8115 inputName.FormDescription = My.Resources.FRMessage1
8116 inputName.TabName = id
8117 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8118 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8120 arg.id = inputName.TabName.Trim()
8127 Using _info As New FormInfo(Me, My.Resources.RemoveCommandText1, _
8128 AddressOf RemoveCommand_DoWork, _
8132 Dim ret As String = DirectCast(_info.Result, String)
8133 If Not String.IsNullOrEmpty(ret) Then
8134 MessageBox.Show(My.Resources.FRMessage2 + ret)
8136 MessageBox.Show(My.Resources.FRMessage3)
8141 Private Sub FriendshipMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipMenuItem.Click
8142 Dim id As String = ""
8143 If _curPost IsNot Nothing Then
8149 Private Class ShowFriendshipArgs
8150 Public tw As Tween.Twitter
8151 Public Class FriendshipInfo
8152 Public id As String = ""
8153 Public isFollowing As Boolean = False
8154 Public isFollowed As Boolean = False
8155 Public isError As Boolean = False
8156 Public Sub New(ByVal id As String)
8160 Public ids As New List(Of FriendshipInfo)
8163 Private Sub ShowFriendship_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8164 Dim arg As ShowFriendshipArgs = DirectCast(e.Argument, ShowFriendshipArgs)
8165 Dim result As String = ""
8166 For Each fInfo As ShowFriendshipArgs.FriendshipInfo In arg.ids
8167 Dim rt As String = arg.tw.GetFriendshipInfo(fInfo.id, fInfo.isFollowing, fInfo.isFollowed)
8168 If Not String.IsNullOrEmpty(rt) Then
8169 If String.IsNullOrEmpty(result) Then result = rt
8170 fInfo.isError = True
8176 Private Sub ShowFriendship(ByVal id As String)
8177 Dim args As New ShowFriendshipArgs
8179 Using inputName As New InputTabName()
8180 inputName.FormTitle = "Show Friendships"
8181 inputName.FormDescription = My.Resources.FRMessage1
8182 inputName.TabName = id
8183 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8184 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8185 Dim ret As String = ""
8186 args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(inputName.TabName.Trim))
8187 Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
8188 AddressOf ShowFriendship_DoWork, _
8192 ret = DirectCast(_info.Result, String)
8194 Dim result As String = ""
8195 If String.IsNullOrEmpty(ret) Then
8196 If args.ids(0).isFollowing Then
8197 result = My.Resources.GetFriendshipInfo1 + System.Environment.NewLine
8199 result = My.Resources.GetFriendshipInfo2 + System.Environment.NewLine
8201 If args.ids(0).isFollowed Then
8202 result += My.Resources.GetFriendshipInfo3
8204 result += My.Resources.GetFriendshipInfo4
8206 result = args.ids(0).id + My.Resources.GetFriendshipInfo5 + System.Environment.NewLine + result
8210 MessageBox.Show(result)
8215 Private Sub ShowFriendship(ByVal ids() As String)
8216 For Each id As String In ids
8217 Dim ret As String = ""
8218 Dim args As New ShowFriendshipArgs
8220 args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(id.Trim))
8221 Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
8222 AddressOf ShowFriendship_DoWork, _
8226 ret = DirectCast(_info.Result, String)
8228 Dim result As String = ""
8229 Dim fInfo As ShowFriendshipArgs.FriendshipInfo = args.ids(0)
8230 Dim ff As String = ""
8231 If String.IsNullOrEmpty(ret) Then
8233 If fInfo.isFollowing Then
8234 ff += My.Resources.GetFriendshipInfo1
8236 ff += My.Resources.GetFriendshipInfo2
8238 ff += System.Environment.NewLine + " "
8239 If fInfo.isFollowed Then
8240 ff += My.Resources.GetFriendshipInfo3
8242 ff += My.Resources.GetFriendshipInfo4
8244 result += fInfo.id + My.Resources.GetFriendshipInfo5 + System.Environment.NewLine + ff
8245 If fInfo.isFollowing Then
8246 If MessageBox.Show( _
8247 "フォロー解除しますか?" + System.Environment.NewLine + result, "フォロー解除確認", _
8248 MessageBoxButtons.YesNo, _
8249 MessageBoxIcon.Question, _
8250 MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
8251 RemoveCommand(fInfo.id, True)
8254 MessageBox.Show(result)
8257 MessageBox.Show(ret)
8262 Private Sub OwnStatusMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OwnStatusMenuItem.Click
8263 If Not String.IsNullOrEmpty(tw.UserInfoXml) Then
8264 doShowUserStatus(tw.UserInfoXml)
8266 MessageBox.Show(My.Resources.ShowYourProfileText1, "Your status", MessageBoxButtons.OK, MessageBoxIcon.Information)
8271 ' TwitterIDでない固定文字列を調べる(文字列検証のみ 実際に取得はしない)
8274 Private Function IsTwitterId(ByVal name As String) As Boolean
8275 Return Not Regex.Match(name, "^(about|jobs|tos|privacy)$").Success
8278 Private Sub FollowContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowContextMenuItem.Click
8279 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8280 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8281 FollowCommand(m.Result("${name}"))
8285 Private Sub RemoveContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveContextMenuItem.Click
8286 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8287 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8288 RemoveCommand(m.Result("${name}"), False)
8292 Private Sub FriendshipContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipContextMenuItem.Click
8293 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8294 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8295 ShowFriendship(m.Result("${name}"))
8299 Private Sub FriendshipAllMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipAllMenuItem.Click
8300 Dim ma As MatchCollection = Regex.Matches(Me.PostBrowser.DocumentText, "href=""https?://twitter.com/(?<name>[a-zA-Z0-9_]+)""")
8301 Dim ids As New List(Of String)
8302 For Each mu As Match In ma
8303 If mu.Result("${name}").ToLower <> tw.Username.ToLower Then
8304 ids.Add(mu.Result("${name}"))
8307 ShowFriendship(ids.ToArray)
8310 Private Sub ShowUserStatusContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowUserStatusContextMenuItem.Click
8311 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8312 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8313 ShowUserStatus(m.Result("${name}"))
8317 Private Sub SearchPostsDetailToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPostsDetailToolStripMenuItem.Click
8318 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8319 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8320 AddNewTabForSearch("from:" + m.Result("${name}"))
8324 Private Sub IdeographicSpaceToSpaceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IdeographicSpaceToSpaceToolStripMenuItem.Click
8325 _modifySettingCommon = True
8328 Private Sub ToolStripFocusLockMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripFocusLockMenuItem.Click
8329 _modifySettingCommon = True
8332 Private Sub doQuote()
8335 If _curPost IsNot Nothing Then
8336 If _curPost.IsDm OrElse _
8337 Not StatusText.Enabled Then Exit Sub
8339 If SettingDialog.ProtectNotInclude AndAlso _curPost.IsProtect Then
8340 MessageBox.Show("Protected.")
8343 Dim rtdata As String = _curPost.OriginalData
8344 rtdata = CreateRetweetUnofficial(rtdata)
8346 StatusText.Text = " QT @" + _curPost.Name + ": " + HttpUtility.HtmlDecode(rtdata)
8347 If _curPost.RetweetedId = 0 Then
8348 _reply_to_id = _curPost.Id
8350 _reply_to_id = _curPost.RetweetedId
8352 _reply_to_name = _curPost.Name
8354 StatusText.SelectionStart = 0
8359 Private Sub QuoteStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuoteStripMenuItem.Click, QtOpMenuItem.Click
8363 Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
8365 Dim pnl As Control = DirectCast(sender, Control).Parent
8366 If pnl Is Nothing Then Exit Sub
8367 Dim tbName As String = pnl.Parent.Text
8368 Dim tb As TabClass = _statuses.Tabs(tbName)
8369 Dim cmb As ComboBox = DirectCast(pnl.Controls("comboSearch"), ComboBox)
8370 Dim cmbLang As ComboBox = DirectCast(pnl.Controls("comboLang"), ComboBox)
8371 cmb.Text = cmb.Text.Trim
8372 ' 検索式演算子 OR についてのみ大文字しか認識しないので強制的に大文字とする
8373 Dim Quote As Boolean = False
8374 Dim buf As New StringBuilder()
8375 Dim c As Char() = cmb.Text.ToCharArray()
8376 For cnt As Integer = 0 To cmb.Text.Length - 1
8377 If cnt > cmb.Text.Length - 4 Then
8378 buf.Append(cmb.Text.Substring(cnt))
8381 If c(cnt) = CChar("""") Then
8384 If Not Quote AndAlso cmb.Text.Substring(cnt, 4).Equals(" or ", StringComparison.OrdinalIgnoreCase) Then
8392 cmb.Text = buf.ToString()
8394 tb.SearchWords = cmb.Text
8395 tb.SearchLang = cmbLang.Text
8396 If cmb.Text = "" Then
8397 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
8401 If tb.IsQueryChanged Then
8402 Dim idx As Integer = DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.IndexOf(tb.SearchWords)
8403 If idx > -1 Then DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.RemoveAt(idx)
8404 DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.Insert(0, tb.SearchWords)
8405 cmb.Text = tb.SearchWords
8407 Dim lst As DetailsListView = DirectCast(pnl.Parent.Tag, DetailsListView)
8408 lst.VirtualListSize = 0
8410 _statuses.ClearTabIds(tbName)
8411 SaveConfigsTabs() '検索条件の保存
8414 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, tbName)
8415 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
8418 Private Sub RefreshMoreStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshMoreStripMenuItem.Click, RefreshPrevOpMenuItem.Click
8423 Private Sub UndoRemoveTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoRemoveTabMenuItem.Click
8424 If _statuses.RemovedTab Is Nothing Then
8425 MessageBox.Show("There isn't removed tab.", "Undo", MessageBoxButtons.OK, MessageBoxIcon.Information)
8428 Dim tb As TabClass = _statuses.RemovedTab
8429 _statuses.RemovedTab = Nothing
8430 Dim renamed As String = tb.TabName
8431 For i As Integer = 1 To Integer.MaxValue
8432 If Not _statuses.ContainsTab(renamed) Then Exit For
8433 renamed = tb.TabName + "(" + i.ToString + ")"
8435 tb.TabName = renamed
8436 _statuses.Tabs.Add(renamed, tb)
8437 AddNewTab(renamed, False, tb.TabType)
8438 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
8443 Private Sub doMoveToRTHome()
8444 If _curList.SelectedIndices.Count > 0 Then
8445 Dim post As PostClass = GetCurTabPost(_curList.SelectedIndices(0))
8446 If post.RetweetedId > 0 Then
8447 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).RetweetedBy)
8452 Private Sub MoveToRTHomeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToRTHomeMenuItem.Click, OpenRterHomeMenuItem.Click
8456 Private Sub IdFilterAddMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IdFilterAddMenuItem.Click
8457 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8458 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8459 Dim tabName As String = ""
8462 If _curList.SelectedIndices.Count = 0 Then Exit Sub
8465 If Not SelectTab(tabName) Then Exit Sub
8467 Dim mv As Boolean = False
8468 Dim mk As Boolean = False
8471 Dim fc As New FiltersClass
8472 fc.NameFilter = m.Result("${name}")
8473 fc.SearchBoth = True
8477 fc.SearchUrl = False
8478 _statuses.Tabs(tabName).AddFilter(fc)
8481 Me.Cursor = Cursors.WaitCursor
8482 _itemCache = Nothing
8483 _postCache = Nothing
8486 _statuses.FilterAll()
8487 For Each tb As TabPage In ListTab.TabPages
8488 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
8489 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
8490 If SettingDialog.TabIconDisp Then
8494 If SettingDialog.TabIconDisp Then
8499 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
8501 Me.Cursor = Cursors.Default
8507 Private Sub ListManageUserContextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListManageUserContextToolStripMenuItem.Click, ToolStripMenuItem9.Click, ListManageUserContextToolStripMenuItem2.Click, ListManageUserContextToolStripMenuItem3.Click
8510 Dim menuItem As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
8512 If menuItem.Owner Is Me.ContextMenuPostBrowser Then
8513 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(?<name>[a-zA-Z0-9_]+)$")
8514 If m.Success AndAlso IsTwitterId(m.Result("${name}")) Then
8515 user = m.Result("${name}")
8519 ElseIf Me._curPost IsNot Nothing Then
8520 user = Me._curPost.Name
8525 Dim list As ListElement = Nothing
8527 If TabInformations.GetInstance().SubscribableLists.Count = 0 Then
8528 Dim res As String = Me.tw.GetListsApi()
8531 MessageBox.Show("Failed to get lists. (" + res + ")")
8536 Using listSelectForm As New MyLists(user, Me.tw)
8537 listSelectForm.ShowDialog()
8541 Private Sub SearchControls_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
8542 Dim pnl As Control = DirectCast(sender, Control)
8543 For Each ctl As Control In pnl.Controls
8548 Private Sub SearchControls_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
8549 Dim pnl As Control = DirectCast(sender, Control)
8550 For Each ctl As Control In pnl.Controls
8555 Private Sub PublicSearchQueryMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PublicSearchQueryMenuItem.Click
8556 If ListTab.SelectedTab IsNot Nothing Then
8557 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
8558 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
8562 Private Sub UseHashtagMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UseHashtagMenuItem.Click
8563 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/search\?q=%23(?<hash>[a-zA-Z0-9_]+)$")
8565 HashMgr.SetPermanentHash("#" + m.Result("${hash}"))
8566 HashStripSplitButton.Text = HashMgr.UseHash
8567 HashToggleMenuItem.Checked = True
8568 HashToggleToolStripMenuItem.Checked = True
8570 _modifySettingCommon = True
8574 Private Sub StatusLabel_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusLabel.DoubleClick
8575 MessageBox.Show(StatusLabel.TextHistory, "Logs", MessageBoxButtons.OK, MessageBoxIcon.None)
8578 Private Sub HashManageMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HashManageMenuItem.Click, HashManageToolStripMenuItem.Click
8579 Dim rslt As DialogResult
8581 rslt = HashMgr.ShowDialog()
8582 Catch ex As Exception
8585 Me.TopMost = SettingDialog.AlwaysTop
8586 If rslt = Windows.Forms.DialogResult.Cancel Then Exit Sub
8587 If HashMgr.UseHash <> "" Then
8588 HashStripSplitButton.Text = HashMgr.UseHash
8589 HashToggleMenuItem.Checked = True
8590 HashToggleToolStripMenuItem.Checked = True
8592 HashStripSplitButton.Text = "#[-]"
8593 HashToggleMenuItem.Checked = False
8594 HashToggleToolStripMenuItem.Checked = False
8596 'If HashMgr.IsInsert AndAlso HashMgr.UseHash <> "" Then
8597 ' Dim sidx As Integer = StatusText.SelectionStart
8598 ' Dim hash As String = HashMgr.UseHash + " "
8600 ' If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
8604 ' StatusText.Text = StatusText.Text.Insert(sidx, hash)
8605 ' sidx += hash.Length
8606 ' StatusText.SelectionStart = sidx
8607 ' StatusText.Focus()
8609 _modifySettingCommon = True
8610 Me.StatusText_TextChanged(Nothing, Nothing)
8613 Private Sub HashToggleMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles HashToggleMenuItem.Click, HashToggleToolStripMenuItem.Click
8614 HashMgr.ToggleHash()
8615 If HashMgr.UseHash <> "" Then
8616 HashStripSplitButton.Text = HashMgr.UseHash
8617 HashToggleMenuItem.Checked = True
8618 HashToggleToolStripMenuItem.Checked = True
8620 HashStripSplitButton.Text = "#[-]"
8621 HashToggleMenuItem.Checked = False
8622 HashToggleToolStripMenuItem.Checked = False
8624 _modifySettingCommon = True
8625 Me.StatusText_TextChanged(Nothing, Nothing)
8628 Private Sub HashStripSplitButton_ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles HashStripSplitButton.ButtonClick
8629 HashToggleMenuItem_Click(Nothing, Nothing)
8632 Private Sub MenuItemOperate_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemOperate.DropDownOpening
8633 If ListTab.SelectedTab Is Nothing Then Exit Sub
8634 If _statuses Is Nothing OrElse _statuses.Tabs Is Nothing OrElse Not _statuses.Tabs.ContainsKey(ListTab.SelectedTab.Text) Then Exit Sub
8635 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage Then
8636 Me.FavOpMenuItem.Enabled = False
8637 Me.UnFavOpMenuItem.Enabled = False
8638 Me.OpenStatusOpMenuItem.Enabled = False
8639 Me.OpenFavotterOpMenuItem.Enabled = False
8641 Me.FavOpMenuItem.Enabled = True
8642 Me.UnFavOpMenuItem.Enabled = True
8643 Me.OpenStatusOpMenuItem.Enabled = True
8644 Me.OpenFavotterOpMenuItem.Enabled = True
8646 If _curPost Is Nothing OrElse _curPost.IsDm Then
8647 Me.RtOpMenuItem.Enabled = False
8648 Me.RtUnOpMenuItem.Enabled = False
8649 Me.QtOpMenuItem.Enabled = False
8650 If _curPost IsNot Nothing AndAlso _curPost.IsDm Then Me.DelOpMenuItem.Enabled = True
8652 If _curPost.IsProtect = True AndAlso SettingDialog.ProtectNotInclude Then
8653 Me.RtOpMenuItem.Enabled = False
8654 Me.RtUnOpMenuItem.Enabled = False
8655 Me.QtOpMenuItem.Enabled = False
8657 Me.RtOpMenuItem.Enabled = True
8658 Me.RtUnOpMenuItem.Enabled = True
8659 Me.QtOpMenuItem.Enabled = True
8661 If _curPost.IsMe Then
8662 Me.RtOpMenuItem.Enabled = False
8663 Me.DelOpMenuItem.Enabled = True
8665 Me.RtOpMenuItem.Enabled = True
8666 Me.DelOpMenuItem.Enabled = False
8670 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.Favorites Then
8671 Me.RefreshPrevOpMenuItem.Enabled = True
8673 Me.RefreshPrevOpMenuItem.Enabled = False
8675 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch _
8676 OrElse _curPost Is Nothing _
8677 OrElse Not _curPost.InReplyToId > 0 Then
8678 OpenRepSourceOpMenuItem.Enabled = False
8680 OpenRepSourceOpMenuItem.Enabled = True
8682 If _curPost Is Nothing OrElse _curPost.RetweetedBy = "" Then
8683 OpenRterHomeMenuItem.Enabled = False
8685 OpenRterHomeMenuItem.Enabled = True
8687 If _curPost Is Nothing Then
8688 Me.ReplyOpMenuItem.Enabled = False
8689 Me.ReplyAllOpMenuItem.Enabled = False
8690 Me.DmOpMenuItem.Enabled = False
8691 Me.FavOpMenuItem.Enabled = False
8692 Me.UnFavOpMenuItem.Enabled = False
8693 Me.OpenFavOpMenuItem.Enabled = False
8694 Me.OpenStatusOpMenuItem.Enabled = False
8695 Me.OpenFavotterOpMenuItem.Enabled = False
8696 Me.CreateTabRuleOpMenuItem.Enabled = False
8697 Me.CreateIdRuleOpMenuItem.Enabled = False
8698 Me.ReadOpMenuItem.Enabled = False
8699 Me.UnreadOpMenuItem.Enabled = False
8700 Me.ShowProfMenuItem.Enabled = False
8701 Me.ToolStripMenuItem9.Enabled = False
8702 Me.DelOpMenuItem.Enabled = False
8704 Me.ReplyOpMenuItem.Enabled = True
8705 Me.ReplyAllOpMenuItem.Enabled = True
8706 Me.DmOpMenuItem.Enabled = True
8707 Me.FavOpMenuItem.Enabled = True
8708 Me.UnFavOpMenuItem.Enabled = True
8709 Me.OpenFavOpMenuItem.Enabled = True
8710 Me.OpenStatusOpMenuItem.Enabled = True
8711 Me.OpenFavotterOpMenuItem.Enabled = True
8712 Me.CreateTabRuleOpMenuItem.Enabled = True
8713 Me.CreateIdRuleOpMenuItem.Enabled = True
8714 Me.ReadOpMenuItem.Enabled = True
8715 Me.UnreadOpMenuItem.Enabled = True
8716 Me.ShowProfMenuItem.Enabled = True
8717 Me.ToolStripMenuItem9.Enabled = True
8718 Me.DelOpMenuItem.Enabled = True
8722 Private Sub MenuItemTab_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemTab.DropDownOpening
8723 ContextMenuTabProperty_Opening(sender, Nothing)
8726 Public ReadOnly Property TwitterInstance() As Twitter
8733 Private Sub SplitContainer3_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer3.SplitterMoved
8734 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
8735 _mySpDis3 = SplitContainer3.SplitterDistance
8736 _modifySettingLocal = True
8740 Private Sub MenuItemEdit_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemEdit.DropDownOpening
8741 If _statuses.RemovedTab Is Nothing Then
8742 UndoRemoveTabMenuItem.Enabled = False
8744 UndoRemoveTabMenuItem.Enabled = True
8746 If ListTab.SelectedTab IsNot Nothing Then
8747 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch Then
8748 PublicSearchQueryMenuItem.Enabled = True
8750 PublicSearchQueryMenuItem.Enabled = False
8753 PublicSearchQueryMenuItem.Enabled = False
8755 If _curPost Is Nothing Then
8756 Me.CopySTOTMenuItem.Enabled = False
8757 Me.CopyURLMenuItem.Enabled = False
8759 Me.CopySTOTMenuItem.Enabled = True
8760 Me.CopyURLMenuItem.Enabled = True
8764 Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
8768 Private Sub UserStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserStatusToolStripMenuItem.Click
8769 Dim id As String = ""
8770 If _curPost IsNot Nothing Then
8776 Private Class GetUserInfoArgs
8777 Public tw As Tween.Twitter
8779 Public xmlbuf As String
8782 Private Sub GetUserInfo_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8783 Dim args As GetUserInfoArgs = DirectCast(e.Argument, GetUserInfoArgs)
8784 e.Result = args.tw.GetUserInfo(args.id, args.xmlbuf)
8787 Private Overloads Sub doShowUserStatus(ByVal id As String, ByVal ShowInputDialog As Boolean)
8788 Dim result As String = ""
8789 Dim xmlbuf As String = ""
8790 Dim args As New GetUserInfoArgs
8791 If ShowInputDialog Then
8792 Using inputName As New InputTabName()
8793 inputName.FormTitle = "Show UserStatus"
8794 inputName.FormDescription = My.Resources.FRMessage1
8795 inputName.TabName = id
8796 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8797 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8798 id = inputName.TabName.Trim
8801 args.xmlbuf = xmlbuf
8802 Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
8803 AddressOf GetUserInfo_DoWork, _
8807 Dim ret As String = DirectCast(_info.Result, String)
8808 If String.IsNullOrEmpty(ret) Then
8809 doShowUserStatus(args.xmlbuf)
8811 MessageBox.Show(ret)
8819 args.xmlbuf = xmlbuf
8820 Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
8821 AddressOf GetUserInfo_DoWork, _
8825 Dim ret As String = DirectCast(_info.Result, String)
8826 If String.IsNullOrEmpty(ret) Then
8827 doShowUserStatus(args.xmlbuf)
8829 MessageBox.Show(ret)
8835 Private Overloads Sub doShowUserStatus(ByVal xmldata As String)
8836 Using userinfo As New ShowUserInfo()
8837 userinfo.XmlData = xmldata
8838 userinfo.ShowDialog(Me)
8842 Private Overloads Sub ShowUserStatus(ByVal id As String, ByVal ShowInputDialog As Boolean)
8843 doShowUserStatus(id, ShowInputDialog)
8846 Private Overloads Sub ShowUserStatus(ByVal id As String)
8847 doShowUserStatus(id, True)
8850 Private Sub FollowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowToolStripMenuItem.Click
8851 If NameLabel.Tag IsNot Nothing Then
8852 Dim id As String = DirectCast(NameLabel.Tag, String)
8853 If id <> tw.Username Then
8859 Private Sub UnFollowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnFollowToolStripMenuItem.Click
8860 If NameLabel.Tag IsNot Nothing Then
8861 Dim id As String = DirectCast(NameLabel.Tag, String)
8862 If id <> tw.Username Then
8863 RemoveCommand(id, False)
8868 Private Sub ShowFriendShipToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowFriendShipToolStripMenuItem.Click
8869 If NameLabel.Tag IsNot Nothing Then
8870 Dim id As String = DirectCast(NameLabel.Tag, String)
8871 If id <> tw.Username Then
8877 Private Sub ShowUserStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowUserStatusToolStripMenuItem.Click
8878 If NameLabel.Tag IsNot Nothing Then
8879 Dim id As String = DirectCast(NameLabel.Tag, String)
8880 ShowUserStatus(id, False)
8884 Private Sub SearchPostsDetailNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPostsDetailNameToolStripMenuItem.Click
8885 If NameLabel.Tag IsNot Nothing Then
8886 Dim id As String = DirectCast(NameLabel.Tag, String)
8887 AddNewTabForSearch("from:" + id)
8891 Private Sub ShowProfileMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowProfileMenuItem.Click, ShowProfMenuItem.Click
8892 If _curPost IsNot Nothing Then
8893 ShowUserStatus(_curPost.Name, False)
8897 Private Sub GetRetweet_DoWork(ByVal sender As Object, ByVal e As ComponentModel.DoWorkEventArgs)
8898 Dim counter As Integer = 0
8900 Dim statusid As Long
8901 If _curPost.RetweetedId > 0 Then
8902 statusid = _curPost.RetweetedId
8904 statusid = _curPost.Id
8906 tw.GetStatus_Retweeted_Count(statusid, counter)
8911 Private Sub RtCountMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtCountMenuItem.Click
8912 If _curPost IsNot Nothing Then
8913 Using _info As New FormInfo(Me, My.Resources.RtCountMenuItem_ClickText1, _
8914 AddressOf GetRetweet_DoWork)
8915 Dim retweet_count As Integer = 0
8919 retweet_count = CType(_info.Result, Integer)
8920 If retweet_count < 0 Then
8921 MessageBox.Show(My.Resources.RtCountText2)
8923 MessageBox.Show(retweet_count.ToString + My.Resources.RtCountText1)
8929 Private WithEvents _hookGlobalHotkey As HookGlobalHotkey
8932 _hookGlobalHotkey = New HookGlobalHotkey(Me)
8933 ' この呼び出しは、Windows フォーム デザイナで必要です。
8934 InitializeComponent()
8936 ' InitializeComponent() 呼び出しの後で初期化を追加します。
8940 Private Sub _hookGlobalHotkey_HotkeyPressed(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _hookGlobalHotkey.HotkeyPressed
8941 If (Me.WindowState = FormWindowState.Normal OrElse Me.WindowState = FormWindowState.Maximized) AndAlso Me.Visible AndAlso Form.ActiveForm Is Me Then
8944 ElseIf Form.ActiveForm Is Nothing Then
8946 If Me.WindowState = FormWindowState.Minimized Then Me.WindowState = FormWindowState.Normal
8948 Me.StatusText.Focus()
8952 Private Sub UserPicture_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.MouseEnter
8953 Me.UserPicture.Cursor = Cursors.Hand
8956 Private Sub UserPicture_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.MouseLeave
8957 Me.UserPicture.Cursor = Cursors.Default
8960 Private Sub UserPicture_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.DoubleClick
8961 If NameLabel.Tag IsNot Nothing Then
8962 OpenUriAsync("http://twitter.com/" + NameLabel.Tag.ToString)
8966 Private Sub SplitContainer2_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SplitContainer2.MouseDoubleClick
8967 Me.MultiLineMenuItem.PerformClick()
8970 Public ReadOnly Property CurPost As PostClass
8976 Public ReadOnly Property IsPreviewEnable As Boolean
8978 Return SettingDialog.PreviewEnable
8983 Private Sub ImageSelectMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageSelectMenuItem.Click
8984 If ImageSelectionPanel.Visible = True Then
8985 ImagefilePathText.CausesValidation = False
8986 TimelinePanel.Visible = True
8987 TimelinePanel.Enabled = True
8988 ImageSelectionPanel.Visible = False
8989 ImageSelectionPanel.Enabled = False
8990 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
8991 ImagefilePathText.CausesValidation = True
8993 ImageSelectionPanel.Visible = True
8994 ImageSelectionPanel.Enabled = True
8995 TimelinePanel.Visible = False
8996 TimelinePanel.Enabled = False
8997 ImagefilePathText.Focus()
9001 Private Sub FilePickButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilePickButton.Click
9002 OpenFileDialog1.Filter = (New PictureService(tw)).GetFileOpenDialogFilter(ImageService)
9003 OpenFileDialog1.Title = My.Resources.PickPictureDialog1
9004 OpenFileDialog1.FileName = ""
9007 Me.AllowDrop = False
9008 If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub
9013 ImagefilePathText.Text = OpenFileDialog1.FileName
9014 ImageFromSelectedFile()
9017 Private Sub ImagefilePathText_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ImagefilePathText.Validating
9018 If ImageCancelButton.Focused Then
9019 ImagefilePathText.CausesValidation = False
9022 ImagefilePathText.Text = Trim(ImagefilePathText.Text)
9023 If ImagefilePathText.Text = "" Then
9024 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9025 ImageSelectedPicture.Tag = UploadFileType.Invalid
9027 ImageFromSelectedFile()
9031 Private Sub ImageFromSelectedFile()
9033 Dim svc As New PictureService(tw)
9034 If String.IsNullOrEmpty(Trim(ImagefilePathText.Text)) Then
9035 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9036 ImageSelectedPicture.Tag = UploadFileType.Invalid
9037 ImagefilePathText.Text = ""
9041 Dim fl As New FileInfo(Trim(ImagefilePathText.Text))
9042 If Not svc.IsValidExtension(fl.Extension.ToLower, ImageService) Then
9044 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9045 ImageSelectedPicture.Tag = UploadFileType.Invalid
9046 ImagefilePathText.Text = ""
9050 If svc.GetMaxFileSize(fl.Extension, ImageService) < fl.Length Then
9052 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9053 ImageSelectedPicture.Tag = UploadFileType.Invalid
9054 ImagefilePathText.Text = ""
9055 MessageBox.Show("File is too large.")
9059 Select Case svc.GetFileType(fl.Extension.ToLower, ImageService)
9060 Case UploadFileType.Invalid
9061 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9062 ImageSelectedPicture.Tag = UploadFileType.Invalid
9063 ImagefilePathText.Text = ""
9064 Case UploadFileType.Picture
9065 Dim img As Image = Nothing
9066 Using fs As New FileStream(ImagefilePathText.Text, FileMode.Open, FileAccess.Read)
9067 img = Image.FromStream(fs)
9070 ImageSelectedPicture.Image = (New HttpVarious).CheckValidImage( _
9074 ImageSelectedPicture.Tag = UploadFileType.Picture
9075 Case UploadFileType.MultiMedia
9076 ImageSelectedPicture.Image = My.Resources.MultiMediaImage
9077 ImageSelectedPicture.Tag = UploadFileType.MultiMedia
9079 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9080 ImageSelectedPicture.Tag = UploadFileType.Invalid
9081 ImagefilePathText.Text = ""
9084 Catch ex As FileNotFoundException
9085 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9086 ImageSelectedPicture.Tag = UploadFileType.Invalid
9087 ImagefilePathText.Text = ""
9088 MessageBox.Show("File not found.")
9089 Catch ex As Exception
9090 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9091 ImageSelectedPicture.Tag = UploadFileType.Invalid
9092 ImagefilePathText.Text = ""
9093 MessageBox.Show("The type of this file is not image.")
9097 Private Sub ImageSelection_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _
9098 ImagefilePathText.KeyDown, _
9099 FilePickButton.KeyDown, _
9100 ImageServiceCombo.KeyDown
9101 If e.KeyCode = Keys.Escape Then
9102 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9103 ImageSelectedPicture.Tag = UploadFileType.Invalid
9104 TimelinePanel.Visible = True
9105 TimelinePanel.Enabled = True
9106 ImageSelectionPanel.Visible = False
9107 ImageSelectionPanel.Enabled = False
9108 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9109 ImagefilePathText.CausesValidation = True
9113 Private Sub ImageSelection_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
9114 ImagefilePathText.KeyPress, _
9115 FilePickButton.KeyPress, _
9116 ImageServiceCombo.KeyPress
9117 If Convert.ToInt32(e.KeyChar) = &H1B Then
9118 ImagefilePathText.CausesValidation = False
9123 Private Sub ImageSelection_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles _
9124 ImagefilePathText.PreviewKeyDown, _
9125 FilePickButton.PreviewKeyDown, _
9126 ImageServiceCombo.PreviewKeyDown
9127 If e.KeyCode = Keys.Escape Then
9128 ImagefilePathText.CausesValidation = False
9132 Private Sub SetImageServiceCombo()
9133 Dim svc As String = ""
9134 If ImageServiceCombo.SelectedIndex > -1 Then svc = ImageServiceCombo.SelectedItem.ToString
9135 ImageServiceCombo.Items.Clear()
9136 If SettingDialog.IsOAuth Then
9137 ImageServiceCombo.Items.Add("TwitPic")
9138 ImageServiceCombo.Items.Add("img.ly")
9140 ImageServiceCombo.Items.Add("TwitVideo")
9142 ImageServiceCombo.SelectedIndex = 0
9144 Dim idx As Integer = ImageServiceCombo.Items.IndexOf(svc)
9146 ImageServiceCombo.SelectedIndex = 0
9148 ImageServiceCombo.SelectedIndex = idx
9153 Private ReadOnly Property ImageService() As String
9155 Return CStr(ImageServiceCombo.SelectedItem)
9159 Private Sub ImageCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageCancelButton.Click
9160 ImagefilePathText.CausesValidation = False
9161 TimelinePanel.Visible = True
9162 TimelinePanel.Enabled = True
9163 ImageSelectionPanel.Visible = False
9164 ImageSelectionPanel.Enabled = False
9165 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9166 ImagefilePathText.CausesValidation = True
9169 Private Sub ImageServiceCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageServiceCombo.SelectedIndexChanged
9170 If ImageSelectedPicture.Tag IsNot Nothing Then
9171 Dim svc As New PictureService(tw)
9173 Dim fi As New FileInfo(ImagefilePathText.Text.Trim)
9174 If Not (svc.IsValidExtension(fi.Extension, ImageService) AndAlso _
9175 svc.GetMaxFileSize(fi.Extension, ImageService) >= fi.Length) Then
9176 ImagefilePathText.Text = ""
9177 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9178 ImageSelectedPicture.Tag = UploadFileType.Invalid
9180 Catch ex As Exception
9187 Private Sub ListManageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListManageToolStripMenuItem.Click
9188 Using form As New ListManage(tw)
9193 Public WriteOnly Property ModifySettingCommon() As Boolean
9194 Set(ByVal value As Boolean)
9195 _modifySettingCommon = value
9199 Public WriteOnly Property ModifySettingLocal() As Boolean
9200 Set(ByVal value As Boolean)
9201 _modifySettingLocal = value
9205 Public WriteOnly Property ModifySettingAtId() As Boolean
9206 Set(ByVal value As Boolean)
9207 _modifySettingAtId = value