1 ' Tween - Client of Twitter
2 ' Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 ' (c) 2008-2011 Moz (@syo68k)
4 ' (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 ' (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 ' (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
9 ' This file is part of Tween.
11 ' This program is free software; you can redistribute it and/or modify it
12 ' under the terms of the GNU General Public License as published by the Free
13 ' Software Foundation; either version 3 of the License, or (at your option)
16 ' This program is distributed in the hope that it will be useful, but
17 ' WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 ' or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 ' You should have received a copy of the GNU General Public License along
22 ' with this program. If not, see <http://www.gnu.org/licenses/>, or write to
23 ' the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
24 ' Boston, MA 02110-1301, USA.
27 '"c:\Program Files\Microsoft.NET\SDK\v2.0\Bin\sgen.exe" /f /a:"$(TargetPath)"
28 '"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /f /a:"$(TargetPath)"
33 Imports System.Text.RegularExpressions
34 Imports Tween.TweenCustomControl
37 Imports System.Reflection
38 Imports System.ComponentModel
39 Imports System.Diagnostics
40 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 _beforeSelectedTab As TabPage 'タブが削除されたときに前回選択されていたときのタブを選択する為に保持
60 Private _tabMouseDownPoint As Point
61 Private _rclickTabName As String '右クリックしたタブの名前(Tabコントロール機能不足対応)
62 Private ReadOnly _syncObject As New Object() 'ロック用
63 Private Const detailHtmlFormatMono1 As String = "<html><head><style type=""text/css""><!-- pre {font-family: """
64 Private Const detailHtmlFormat2 As String = """, sans-serif; font-size: "
65 Private Const detailHtmlFormat3 As String = "pt; word-wrap: break-word; color:rgb("
66 Private Const detailHtmlFormat4 As String = ");} a:link, a:visited, a:active, a:hover {color:rgb("
67 Private Const detailHtmlFormat5 As String = "); } --></style></head><body style=""margin:0px; background-color:rgb("
68 Private Const detailHtmlFormatMono6 As String = ");""><pre>"
69 Private Const detailHtmlFormatMono7 As String = "</pre></body></html>"
70 Private Const detailHtmlFormat1 As String = "<html><head><style type=""text/css""><!-- p {font-family: """
71 Private Const detailHtmlFormat6 As String = ");""><p>"
72 Private Const detailHtmlFormat7 As String = "</p></body></html>"
73 Private detailHtmlFormatHeader As String
74 Private detailHtmlFormatFooter As String
75 Private _myStatusError As Boolean = False
76 Private _myStatusOnline As Boolean = False
77 Private soundfileListup As Boolean = False
78 Private _spaceKeyCanceler As SpaceKeyCanceler
81 'Private _cfg As SettingToConfig '旧
82 Private _cfgLocal As SettingLocal
83 Private _cfgCommon As SettingCommon
84 Private _modifySettingLocal As Boolean = False
85 Private _modifySettingCommon As Boolean = False
86 Private _modifySettingAtId As Boolean = False
89 Private tw As New Twitter
92 Private SettingDialog As AppendSettingDialog = AppendSettingDialog.Instance '設定画面インスタンス
93 Private TabDialog As New TabsDialog 'タブ選択ダイアログインスタンス
94 Private SearchDialog As New SearchWord '検索画面インスタンス
95 Private fltDialog As New FilterDialog 'フィルター編集画面
96 Private UrlDialog As New OpenURL
97 Private dialogAsShieldicon As DialogAsShieldIcon ' シールドアイコン付きダイアログ
98 Public AtIdSupl As AtIdSupplement '@id補助
99 Public HashSupl As AtIdSupplement 'Hashtag補助
100 Public HashMgr As HashtagManage
101 Private evtDialog As EventViewerDialog
104 Private _fntUnread As Font '未読用フォント
105 Private _clUnread As Color '未読用文字色
106 Private _fntReaded As Font '既読用フォント
107 Private _clReaded As Color '既読用文字色
108 Private _clFav As Color 'Fav用文字色
109 Private _clOWL As Color '片思い用文字色
110 Private _clRetweet As Color 'Retweet用文字色
111 Private _fntDetail As Font '発言詳細部用フォント
112 Private _clDetail As Color '発言詳細部用色
113 Private _clDetailLink As Color '発言詳細部用リンク文字色
114 Private _clDetailBackcolor As Color '発言詳細部用背景色
115 Private _clSelf As Color '自分の発言用背景色
116 Private _clAtSelf As Color '自分宛返信用背景色
117 Private _clTarget As Color '選択発言者の他の発言用背景色
118 Private _clAtTarget As Color '選択発言中の返信先用背景色
119 Private _clAtFromTarget As Color '選択発言者への返信発言用背景色
120 Private _clAtTo As Color '選択発言の唯一@先
121 Private _clListBackcolor As Color 'リスト部通常発言背景色
122 Private _clInputBackcolor As Color '入力欄背景色
123 Private _clInputFont As Color '入力欄文字色
124 Private _fntInputFont As Font '入力欄フォント
125 Private TIconDic As IDictionary(Of String, Image) 'アイコン画像リスト
126 Private NIconAt As Icon 'At.ico タスクトレイアイコン:通常時
127 Private NIconAtRed As Icon 'AtRed.ico タスクトレイアイコン:通信エラー時
128 Private NIconAtSmoke As Icon 'AtSmoke.ico タスクトレイアイコン:オフライン時
129 Private NIconRefresh(3) As Icon 'Refresh.ico タスクトレイアイコン:更新中(アニメーション用に4種類を保持するリスト)
130 Private TabIcon As Icon 'Tab.ico 未読のあるタブ用アイコン
131 Private MainIcon As Icon 'Main.ico 画面左上のアイコン
132 Private ReplyIcon As Icon '5g
133 Private ReplyIconBlink As Icon '6g
135 Private _anchorPost As PostClass
136 Private _anchorFlag As Boolean 'True:関連発言移動中(関連移動以外のオペレーションをするとFalseへ。Trueだとリスト背景色をアンカー発言選択中として描画)
138 Private _history As New List(Of PostingStatus) '発言履歴
139 Private _hisIdx As Integer '発言履歴カレントインデックス
141 '発言投稿時のAPI引数(発言編集時に設定。手書きreplyでは設定されない)
142 Private _reply_to_id As Long ' リプライ先のステータスID 0の場合はリプライではない 注:複数あてのものはリプライではない
143 Private _reply_to_name As String ' リプライ先ステータスの書き込み者の名前
146 Private _postTimestamps As New List(Of Date)
147 Private _favTimestamps As New List(Of Date)
148 Private _tlTimestamps As New Dictionary(Of Date, Integer)
149 Private _tlCount As Integer
152 Private _brsHighLight As New SolidBrush(Color.FromKnownColor(KnownColor.Highlight))
153 Private _brsHighLightText As New SolidBrush(Color.FromKnownColor(KnownColor.HighlightText))
154 Private _brsForeColorUnread As SolidBrush
155 Private _brsForeColorReaded As SolidBrush
156 Private _brsForeColorFav As SolidBrush
157 Private _brsForeColorOWL As SolidBrush
158 Private _brsForeColorRetweet As SolidBrush
159 Private _brsBackColorMine As SolidBrush
160 Private _brsBackColorAt As SolidBrush
161 Private _brsBackColorYou As SolidBrush
162 Private _brsBackColorAtYou As SolidBrush
163 Private _brsBackColorAtFromTarget As SolidBrush
164 Private _brsBackColorAtTo As SolidBrush
165 Private _brsBackColorNone As SolidBrush
166 Private _brsDeactiveSelection As New SolidBrush(Color.FromKnownColor(KnownColor.ButtonFace)) 'Listにフォーカスないときの選択行の背景色
167 Private sfTab As New StringFormat()
169 '''''''''''''''''''''''''''''''''''''''''''''''''''''
170 Private _apiGauge As New ToolStripAPIGauge()
171 Private _statuses As TabInformations
172 Private _itemCache() As ListViewItem
173 Private _itemCacheIndex As Integer
174 Private _postCache() As PostClass
175 Private _curTab As TabPage
176 Private _curItemIndex As Integer
177 Private _curList As DetailsListView
178 Private _curPost As PostClass
179 Private _isColumnChanged As Boolean = False
180 Private _waitTimeline As Boolean = False
181 Private _waitReply As Boolean = False
182 Private _waitDm As Boolean = False
183 Private _waitFav As Boolean = False
184 Private _waitPubSearch As Boolean = False
185 Private _waitUserTimeline As Boolean = False
186 Private _waitLists As Boolean = False
187 Private _bw(18) As BackgroundWorker
188 Private _bwFollower As BackgroundWorker
189 Private cMode As Integer
190 Private shield As New ShieldIcon
191 Private SecurityManager As InternetSecurityManager
192 Private Thumbnail As Thumbnail
194 Private UnreadCounter As Integer = -1
195 Private UnreadAtCounter As Integer = -1
197 Private ColumnOrgText(8) As String
198 Private ColumnText(8) As String
200 Private _DoFavRetweetFlags As Boolean = False
201 Private osResumed As Boolean = False
202 Private pictureService As Dictionary(Of String, IMultimediaShareService)
204 '''''''''''''''''''''''''''''''''''''''''''''''''''''
205 Private _postBrowserStatusText As String = ""
207 Private _colorize As Boolean = False
209 Private WithEvents TimerTimeline As New System.Timers.Timer
211 Private WithEvents displayItem As ImageListViewItem
214 Private Structure urlUndo
215 Public Before As String
216 Public After As String
219 Private urlUndoBuffer As Generic.List(Of urlUndo) = Nothing
221 Private Structure ReplyChain
222 Public OriginalId As Long
223 Public InReplyToId As Long
224 Public OriginalTab As TabPage
226 Sub New(ByVal originalId As Long, ByVal inReplyToId As Long, ByVal originalTab As TabPage)
227 Me.OriginalId = originalId
228 Me.InReplyToId = inReplyToId
229 Me.OriginalTab = originalTab
233 Private replyChains As Stack(Of ReplyChain)
235 'Backgroundworkerの処理結果通知用引数構造体
236 Private Class GetWorkerResult
237 Public retMsg As String = "" '処理結果詳細メッセージ。エラー時に値がセットされる
238 Public page As Integer '取得対象ページ番号
239 Public endPage As Integer '取得終了ページ番号(継続可能ならインクリメントされて返る。pageと比較して継続判定)
240 Public type As WORKERTYPE '処理種別
241 Public imgs As Dictionary(Of String, Image) '新規取得したアイコンイメージ
242 Public tName As String = "" 'Fav追加・削除時のタブ名
243 Public ids As List(Of Long) 'Fav追加・削除時のID
244 Public sIds As List(Of Long) 'Fav追加・削除成功分のID
245 Public newDM As Boolean
246 Public addCount As Integer
247 Public status As PostingStatus
250 'Backgroundworkerへ処理内容を通知するための引数用構造体
251 Private Class GetWorkerArg
252 Public page As Integer '処理対象ページ番号
253 Public endPage As Integer '処理終了ページ番号(起動時の読み込みページ数。通常時はpageと同じ値をセット)
254 Public type As WORKERTYPE '処理種別
255 Public url As String = "" 'URLをブラウザで開くときのアドレス
256 Public status As New PostingStatus '発言POST時の発言内容
257 Public ids As List(Of Long) 'Fav追加・削除時のItemIndex
258 Public sIds As List(Of Long) 'Fav追加・削除成功分のItemIndex
259 Public tName As String = "" 'Fav追加・削除時のタブ名
263 Private Enum SEARCHTYPE
269 Private Class PostingStatus
270 Public status As String = ""
271 Public inReplyToId As Long = 0
272 Public inReplyToName As String = ""
273 Public imageService As String = "" '画像投稿サービス名
274 Public imagePath As String = ""
278 Public Sub New(ByVal status As String, ByVal replyToId As Long, ByVal replyToName As String)
280 Me.inReplyToId = replyToId
281 Me.inReplyToName = replyToName
285 Private Class SpaceKeyCanceler
286 Inherits NativeWindow
287 Implements IDisposable
289 Dim WM_KEYDOWN As Integer = &H100
290 Dim VK_SPACE As Integer = &H20
292 Public Sub New(ByVal control As Control)
293 Me.AssignHandle(control.Handle)
296 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
297 If (m.Msg = WM_KEYDOWN) AndAlso (CInt(m.WParam) = VK_SPACE) Then
298 RaiseEvent SpaceCancel(Me, EventArgs.Empty)
305 Public Event SpaceCancel As EventHandler
307 Public Sub Dispose() Implements IDisposable.Dispose
312 Private Sub TweenMain_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
313 '画面がアクティブになったら、発言欄の背景色戻す
314 If StatusText.Focused Then
315 Me.StatusText_Enter(Me.StatusText, System.EventArgs.Empty)
319 Private Sub TweenMain_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
321 SettingDialog.Dispose()
323 SearchDialog.Dispose()
326 _spaceKeyCanceler.Dispose()
327 If NIconAt IsNot Nothing Then NIconAt.Dispose()
328 If NIconAtRed IsNot Nothing Then NIconAtRed.Dispose()
329 If NIconAtSmoke IsNot Nothing Then NIconAtSmoke.Dispose()
330 If NIconRefresh(0) IsNot Nothing Then NIconRefresh(0).Dispose()
331 If NIconRefresh(1) IsNot Nothing Then NIconRefresh(1).Dispose()
332 If NIconRefresh(2) IsNot Nothing Then NIconRefresh(2).Dispose()
333 If NIconRefresh(3) IsNot Nothing Then NIconRefresh(3).Dispose()
334 If TabIcon IsNot Nothing Then TabIcon.Dispose()
335 If MainIcon IsNot Nothing Then MainIcon.Dispose()
336 If ReplyIcon IsNot Nothing Then ReplyIcon.Dispose()
337 If ReplyIconBlink IsNot Nothing Then ReplyIconBlink.Dispose()
338 _brsHighLight.Dispose()
339 _brsHighLightText.Dispose()
340 If _brsForeColorUnread IsNot Nothing Then _brsForeColorUnread.Dispose()
341 If _brsForeColorReaded IsNot Nothing Then _brsForeColorReaded.Dispose()
342 If _brsForeColorFav IsNot Nothing Then _brsForeColorFav.Dispose()
343 If _brsForeColorOWL IsNot Nothing Then _brsForeColorOWL.Dispose()
344 If _brsForeColorRetweet IsNot Nothing Then _brsForeColorRetweet.Dispose()
345 If _brsBackColorMine IsNot Nothing Then _brsBackColorMine.Dispose()
346 If _brsBackColorAt IsNot Nothing Then _brsBackColorAt.Dispose()
347 If _brsBackColorYou IsNot Nothing Then _brsBackColorYou.Dispose()
348 If _brsBackColorAtYou IsNot Nothing Then _brsBackColorAtYou.Dispose()
349 If _brsBackColorAtFromTarget IsNot Nothing Then _brsBackColorAtFromTarget.Dispose()
350 If _brsBackColorAtTo IsNot Nothing Then _brsBackColorAtTo.Dispose()
351 If _brsBackColorNone IsNot Nothing Then _brsBackColorNone.Dispose()
352 If _brsDeactiveSelection IsNot Nothing Then _brsDeactiveSelection.Dispose()
356 For Each bw As BackgroundWorker In _bw
357 If bw IsNot Nothing Then
361 If _bwFollower IsNot Nothing Then
362 _bwFollower.Dispose()
364 Me._apiGauge.Dispose()
365 If TIconDic IsNot Nothing Then
366 DirectCast(Me.TIconDic, ImageDictionary).PauseGetImage = True
367 DirectCast(TIconDic, IDisposable).Dispose()
369 ' 終了時にRemoveHandlerしておかないとメモリリークする
370 ' http://msdn.microsoft.com/ja-jp/library/microsoft.win32.systemevents.powermodechanged.aspx
371 RemoveHandler Microsoft.Win32.SystemEvents.PowerModeChanged, AddressOf SystemEvents_PowerModeChanged
374 Private Sub LoadIcon(ByRef IconInstance As Icon, ByVal FileName As String)
375 Dim dir As String = Application.StartupPath
376 If File.Exists(Path.Combine(dir, FileName)) Then
378 IconInstance = New Icon(Path.Combine(dir, FileName))
379 Catch ex As Exception
384 Private Sub LoadIcons()
387 Dim dir As String = Application.StartupPath
389 NIconAt = My.Resources.At
390 NIconAtRed = My.Resources.AtRed
391 NIconAtSmoke = My.Resources.AtSmoke
392 NIconRefresh(0) = My.Resources.Refresh
393 NIconRefresh(1) = My.Resources.Refresh2
394 NIconRefresh(2) = My.Resources.Refresh3
395 NIconRefresh(3) = My.Resources.Refresh4
396 TabIcon = My.Resources.TabIcon
397 MainIcon = My.Resources.MIcon
398 ReplyIcon = My.Resources.Reply
399 ReplyIconBlink = My.Resources.ReplyBlink
401 If Not Directory.Exists(Path.Combine(dir, "Icons")) Then
405 LoadIcon(NIconAt, "Icons\At.ico")
408 LoadIcon(NIconAtRed, "Icons\AtRed.ico")
411 LoadIcon(NIconAtSmoke, "Icons\AtSmoke.ico")
415 LoadIcon(NIconRefresh(0), "Icons\Refresh.ico")
416 LoadIcon(NIconRefresh(1), "Icons\Refresh2.ico")
417 LoadIcon(NIconRefresh(2), "Icons\Refresh3.ico")
418 LoadIcon(NIconRefresh(3), "Icons\Refresh4.ico")
421 LoadIcon(TabIcon, "Icons\Tab.ico")
424 LoadIcon(MainIcon, "Icons\MIcon.ico")
427 LoadIcon(ReplyIcon, "Icons\Reply.ico")
430 LoadIcon(ReplyIconBlink, "Icons\ReplyBlink.ico")
433 Private Sub InitColumnText()
436 ColumnText(1) = My.Resources.AddNewTabText2
437 ColumnText(2) = My.Resources.AddNewTabText3
438 ColumnText(3) = My.Resources.AddNewTabText4_2
439 ColumnText(4) = My.Resources.AddNewTabText5
442 ColumnText(7) = "Source"
444 ColumnOrgText(0) = ""
445 ColumnOrgText(1) = My.Resources.AddNewTabText2
446 ColumnOrgText(2) = My.Resources.AddNewTabText3
447 ColumnOrgText(3) = My.Resources.AddNewTabText4_2
448 ColumnOrgText(4) = My.Resources.AddNewTabText5
449 ColumnOrgText(5) = ""
450 ColumnOrgText(6) = ""
451 ColumnOrgText(7) = "Source"
454 Select Case _statuses.SortMode
455 Case IdComparerClass.ComparerMode.Nickname 'ニックネーム
457 Case IdComparerClass.ComparerMode.Data '本文
459 Case IdComparerClass.ComparerMode.Id '時刻=発言Id
461 Case IdComparerClass.ComparerMode.Name '名前
463 Case IdComparerClass.ComparerMode.Source 'Source
468 If _statuses.SortOrder() = SortOrder.Descending Then
469 ' U+25BE BLACK DOWN-POINTING SMALL TRIANGLE
470 ColumnText(2) = ColumnOrgText(2) + "▾"
472 ' U+25B4 BLACK UP-POINTING SMALL TRIANGLE
473 ColumnText(2) = ColumnOrgText(2) + "▴"
476 If _statuses.SortOrder() = SortOrder.Descending Then
477 ' U+25BE BLACK DOWN-POINTING SMALL TRIANGLE
478 ColumnText(c) = ColumnOrgText(c) + "▾"
480 ' U+25B4 BLACK UP-POINTING SMALL TRIANGLE
481 ColumnText(c) = ColumnOrgText(c) + "▴"
486 Private Sub InitializeTraceFrag()
488 TraceOutToolStripMenuItem.Checked = True
491 If Not fileVersion.EndsWith("0") Then
492 TraceOutToolStripMenuItem.Checked = True
497 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
498 _ignoreConfigSave = True
500 SecurityManager = New InternetSecurityManager(PostBrowser)
501 Thumbnail = New Thumbnail(Me)
503 AddHandler TwitterApiInfo.Changed, AddressOf SetStatusLabelApiHandler
504 AddHandler Microsoft.Win32.SystemEvents.PowerModeChanged, AddressOf SystemEvents_PowerModeChanged
506 VerUpMenuItem.Image = shield.Icon
507 If Not My.Application.CommandLineArgs.Count = 0 AndAlso My.Application.CommandLineArgs.Contains("/d") Then TraceFlag = True
509 Me._spaceKeyCanceler = New SpaceKeyCanceler(Me.PostButton)
510 AddHandler Me._spaceKeyCanceler.SpaceCancel, AddressOf spaceKeyCanceler_SpaceCancel
512 Regex.CacheSize = 100
514 fileVersion = DirectCast(Assembly.GetExecutingAssembly().GetCustomAttributes(GetType(AssemblyFileVersionAttribute), False)(0), AssemblyFileVersionAttribute).Version
515 InitializeTraceFrag()
516 LoadIcons() ' アイコン読み込み
519 _statuses = TabInformations.GetInstance()
522 Me.Icon = MainIcon 'メインフォーム(TweenMain)
523 NotifyIcon1.Icon = NIconAt 'タスクトレイ
524 TabImage.Images.Add(TabIcon) 'タブ見出し
526 SettingDialog.Owner = Me
527 SearchDialog.Owner = Me
532 _history.Add(New PostingStatus)
537 '<<<<<<<<<設定関連>>>>>>>>>
545 NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop
546 Me.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked
549 _fntUnread = _cfgLocal.FontUnread
550 _clUnread = _cfgLocal.ColorUnread
551 _fntReaded = _cfgLocal.FontRead
552 _clReaded = _cfgLocal.ColorRead
553 _clFav = _cfgLocal.ColorFav
554 _clOWL = _cfgLocal.ColorOWL
555 _clRetweet = _cfgLocal.ColorRetweet
556 _fntDetail = _cfgLocal.FontDetail
557 _clDetail = _cfgLocal.ColorDetail
558 _clDetailLink = _cfgLocal.ColorDetailLink
559 _clDetailBackcolor = _cfgLocal.ColorDetailBackcolor
560 _clSelf = _cfgLocal.ColorSelf
561 _clAtSelf = _cfgLocal.ColorAtSelf
562 _clTarget = _cfgLocal.ColorTarget
563 _clAtTarget = _cfgLocal.ColorAtTarget
564 _clAtFromTarget = _cfgLocal.ColorAtFromTarget
565 _clAtTo = _cfgLocal.ColorAtTo
566 _clListBackcolor = _cfgLocal.ColorListBackcolor
567 _clInputBackcolor = _cfgLocal.ColorInputBackcolor
568 _clInputFont = _cfgLocal.ColorInputFont
569 _fntInputFont = _cfgLocal.FontInputFont
571 _brsForeColorUnread = New SolidBrush(_clUnread)
572 _brsForeColorReaded = New SolidBrush(_clReaded)
573 _brsForeColorFav = New SolidBrush(_clFav)
574 _brsForeColorOWL = New SolidBrush(_clOWL)
575 _brsForeColorRetweet = New SolidBrush(_clRetweet)
576 _brsBackColorMine = New SolidBrush(_clSelf)
577 _brsBackColorAt = New SolidBrush(_clAtSelf)
578 _brsBackColorYou = New SolidBrush(_clTarget)
579 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
580 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
581 _brsBackColorAtTo = New SolidBrush(_clAtTo)
582 '_brsBackColorNone = New SolidBrush(Color.FromKnownColor(KnownColor.Window))
583 _brsBackColorNone = New SolidBrush(_clListBackcolor)
585 ' StringFormatオブジェクトへの事前設定
586 'sf.Alignment = StringAlignment.Near ' Textを近くへ配置(左から右の場合は左寄せ)
587 'sf.LineAlignment = StringAlignment.Near ' Textを近くへ配置(上寄せ)
588 'sf.FormatFlags = StringFormatFlags.LineLimit '
589 sfTab.Alignment = StringAlignment.Center
590 sfTab.LineAlignment = StringAlignment.Center
593 SettingDialog.IsOAuth = _cfgCommon.IsOAuth
594 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
595 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
596 SettingDialog.TwitterApiUrl = _cfgCommon.TwitterUrl
597 SettingDialog.TwitterSearchApiUrl = _cfgCommon.TwitterSearchUrl
599 If _cfgCommon.IsOAuth Then
600 If _cfgCommon.Token = "" Then _cfgCommon.UserName = ""
601 tw.Initialize(_cfgCommon.Token, _cfgCommon.TokenSecret, _cfgCommon.UserName)
603 tw.Initialize(_cfgCommon.UserName, _cfgCommon.Password)
606 SettingDialog.TimelinePeriodInt = _cfgCommon.TimelinePeriod
607 SettingDialog.ReplyPeriodInt = _cfgCommon.ReplyPeriod
608 SettingDialog.DMPeriodInt = _cfgCommon.DMPeriod
609 SettingDialog.PubSearchPeriodInt = _cfgCommon.PubSearchPeriod
610 SettingDialog.UserTimelinePeriodInt = _cfgCommon.UserTimelinePeriod
611 SettingDialog.ListsPeriodInt = _cfgCommon.ListsPeriod
613 If Not My.Application.CommandLineArgs.Contains("nolimit") Then
614 If SettingDialog.TimelinePeriodInt < 15 AndAlso SettingDialog.TimelinePeriodInt > 0 Then SettingDialog.TimelinePeriodInt = 15
615 If SettingDialog.ReplyPeriodInt < 15 AndAlso SettingDialog.ReplyPeriodInt > 0 Then SettingDialog.ReplyPeriodInt = 15
616 If SettingDialog.DMPeriodInt < 15 AndAlso SettingDialog.DMPeriodInt > 0 Then SettingDialog.DMPeriodInt = 15
617 If SettingDialog.PubSearchPeriodInt < 30 AndAlso SettingDialog.PubSearchPeriodInt > 0 Then SettingDialog.PubSearchPeriodInt = 30
618 If SettingDialog.UserTimelinePeriodInt < 15 AndAlso SettingDialog.UserTimelinePeriodInt > 0 Then SettingDialog.UserTimelinePeriodInt = 15
619 If SettingDialog.ListsPeriodInt < 15 AndAlso SettingDialog.ListsPeriodInt > 0 Then SettingDialog.ListsPeriodInt = 15
622 '起動時読み込み分を既読にするか。Trueなら既読として処理
623 SettingDialog.Readed = _cfgCommon.Read
624 '新着取得時のリストスクロールをするか。Trueならスクロールしない
625 ListLockMenuItem.Checked = _cfgCommon.ListLock
626 Me.LockListFileMenuItem.Checked = _cfgCommon.ListLock
627 SettingDialog.IconSz = _cfgCommon.IconSize
629 SettingDialog.Status = _cfgLocal.StatusText
631 SettingDialog.UnreadManage = _cfgCommon.UnreadManage
633 SettingDialog.PlaySound = _cfgCommon.PlaySound
634 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
635 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
637 SettingDialog.OneWayLove = _cfgCommon.OneWayLove
639 SettingDialog.FontUnread = _fntUnread
640 SettingDialog.ColorUnread = _clUnread
641 SettingDialog.FontReaded = _fntReaded
642 SettingDialog.ColorReaded = _clReaded
643 SettingDialog.ColorFav = _clFav
644 SettingDialog.ColorOWL = _clOWL
645 SettingDialog.ColorRetweet = _clRetweet
646 SettingDialog.FontDetail = _fntDetail
647 SettingDialog.ColorDetail = _clDetail
648 SettingDialog.ColorDetailLink = _clDetailLink
649 SettingDialog.ColorDetailBackcolor = _clDetailBackcolor
650 SettingDialog.ColorSelf = _clSelf
651 SettingDialog.ColorAtSelf = _clAtSelf
652 SettingDialog.ColorTarget = _clTarget
653 SettingDialog.ColorAtTarget = _clAtTarget
654 SettingDialog.ColorAtFromTarget = _clAtFromTarget
655 SettingDialog.ColorAtTo = _clAtTo
656 SettingDialog.ColorListBackcolor = _clListBackcolor
657 SettingDialog.ColorInputBackcolor = _clInputBackcolor
658 SettingDialog.ColorInputFont = _clInputFont
659 SettingDialog.FontInputFont = _fntInputFont
661 SettingDialog.NameBalloon = _cfgCommon.NameBalloon
662 SettingDialog.PostCtrlEnter = _cfgCommon.PostCtrlEnter
663 SettingDialog.PostShiftEnter = _cfgCommon.PostShiftEnter
665 SettingDialog.CountApi = _cfgCommon.CountApi
666 SettingDialog.CountApiReply = _cfgCommon.CountApiReply
667 If SettingDialog.CountApi < 20 OrElse SettingDialog.CountApi > 200 Then SettingDialog.CountApi = 60
668 If SettingDialog.CountApiReply < 20 OrElse SettingDialog.CountApiReply > 200 Then SettingDialog.CountApiReply = 40
670 SettingDialog.BrowserPath = _cfgLocal.BrowserPath
671 SettingDialog.PostAndGet = _cfgCommon.PostAndGet
672 SettingDialog.UseRecommendStatus = _cfgLocal.UseRecommendStatus
673 SettingDialog.DispUsername = _cfgCommon.DispUsername
674 SettingDialog.CloseToExit = _cfgCommon.CloseToExit
675 SettingDialog.MinimizeToTray = _cfgCommon.MinimizeToTray
676 SettingDialog.DispLatestPost = _cfgCommon.DispLatestPost
677 SettingDialog.SortOrderLock = _cfgCommon.SortOrderLock
678 SettingDialog.TinyUrlResolve = _cfgCommon.TinyUrlResolve
680 SettingDialog.SelectedProxyType = _cfgLocal.ProxyType
681 SettingDialog.ProxyAddress = _cfgLocal.ProxyAddress
682 SettingDialog.ProxyPort = _cfgLocal.ProxyPort
683 SettingDialog.ProxyUser = _cfgLocal.ProxyUser
684 SettingDialog.ProxyPassword = _cfgLocal.ProxyPassword
686 SettingDialog.PeriodAdjust = _cfgCommon.PeriodAdjust
687 SettingDialog.StartupVersion = _cfgCommon.StartupVersion
688 SettingDialog.StartupFollowers = _cfgCommon.StartupFollowers
689 SettingDialog.RestrictFavCheck = _cfgCommon.RestrictFavCheck
690 SettingDialog.AlwaysTop = _cfgCommon.AlwaysTop
691 SettingDialog.UrlConvertAuto = _cfgCommon.UrlConvertAuto
693 SettingDialog.OutputzEnabled = _cfgCommon.Outputz
694 SettingDialog.OutputzKey = _cfgCommon.OutputzKey
695 SettingDialog.OutputzUrlmode = _cfgCommon.OutputzUrlMode
697 SettingDialog.UseUnreadStyle = _cfgCommon.UseUnreadStyle
698 SettingDialog.DefaultTimeOut = _cfgCommon.DefaultTimeOut
699 SettingDialog.RetweetNoConfirm = _cfgCommon.RetweetNoConfirm
700 SettingDialog.PlaySound = _cfgCommon.PlaySound
701 SettingDialog.DateTimeFormat = _cfgCommon.DateTimeFormat
702 SettingDialog.LimitBalloon = _cfgCommon.LimitBalloon
703 SettingDialog.EventNotifyEnabled = _cfgCommon.EventNotifyEnabled
704 SettingDialog.EventNotifyFlag = _cfgCommon.EventNotifyFlag
705 SettingDialog.IsMyEventNotifyFlag = _cfgCommon.IsMyEventNotifyFlag
706 SettingDialog.ForceEventNotify = _cfgCommon.ForceEventNotify
707 SettingDialog.FavEventUnread = _cfgCommon.FavEventUnread
708 SettingDialog.TranslateLanguage = _cfgCommon.TranslateLanguage
709 SettingDialog.EventSoundFile = _cfgCommon.EventSoundFile
711 '廃止サービスが選択されていた場合bit.lyへ読み替え
712 If _cfgCommon.AutoShortUrlFirst < 0 Then
713 _cfgCommon.AutoShortUrlFirst = Tween.UrlConverter.Bitly
716 SettingDialog.AutoShortUrlFirst = _cfgCommon.AutoShortUrlFirst
717 SettingDialog.TabIconDisp = _cfgCommon.TabIconDisp
718 SettingDialog.ReplyIconState = _cfgCommon.ReplyIconState
719 SettingDialog.ReadOwnPost = _cfgCommon.ReadOwnPost
720 SettingDialog.GetFav = _cfgCommon.GetFav
721 SettingDialog.ReadOldPosts = _cfgCommon.ReadOldPosts
722 SettingDialog.UseSsl = _cfgCommon.UseSsl
723 SettingDialog.BitlyUser = _cfgCommon.BilyUser
724 SettingDialog.BitlyPwd = _cfgCommon.BitlyPwd
725 SettingDialog.ShowGrid = _cfgCommon.ShowGrid
726 SettingDialog.Language = _cfgCommon.Language
727 SettingDialog.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement
728 SettingDialog.UseHashSupplement = _cfgCommon.UseHashSupplement
729 SettingDialog.PreviewEnable = _cfgCommon.PreviewEnable
730 AtIdSupl = New AtIdSupplement(SettingAtIdList.Load().AtIdList, "@")
732 SettingDialog.IsMonospace = _cfgCommon.IsMonospace
733 If SettingDialog.IsMonospace Then
734 detailHtmlFormatHeader = detailHtmlFormatMono1
735 detailHtmlFormatFooter = detailHtmlFormatMono7
737 detailHtmlFormatHeader = detailHtmlFormat1
738 detailHtmlFormatFooter = detailHtmlFormat7
740 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
741 If SettingDialog.IsMonospace Then
742 detailHtmlFormatHeader += detailHtmlFormatMono6
744 detailHtmlFormatHeader += detailHtmlFormat6
746 Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert
747 Me.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText
749 'Dim statregex As New Regex("^0*")
750 SettingDialog.RecommendStatusText = " [TWNv" + Regex.Replace(fileVersion.Replace(".", ""), "^0*", "") + "]"
754 If DateTime.Now.ToString(SettingDialog.DateTimeFormat).Length = 0 Then
756 ' 変換が成功した場合にLengthが0にならない
757 SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"
759 Catch ex As FormatException
760 ' FormatExceptionが発生したら初期値を設定 (=yyyy/MM/dd H:mm:ssとみなされる)
761 SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"
764 SettingDialog.Nicoms = _cfgCommon.Nicoms
765 SettingDialog.HotkeyEnabled = _cfgCommon.HotkeyEnabled
766 SettingDialog.HotkeyMod = _cfgCommon.HotkeyModifier
767 SettingDialog.HotkeyKey = _cfgCommon.HotkeyKey
768 SettingDialog.HotkeyValue = _cfgCommon.HotkeyValue
770 SettingDialog.BlinkNewMentions = _cfgCommon.BlinkNewMentions
772 SettingDialog.UseAdditionalCount = _cfgCommon.UseAdditionalCount
773 SettingDialog.MoreCountApi = _cfgCommon.MoreCountApi
774 SettingDialog.FirstCountApi = _cfgCommon.FirstCountApi
775 SettingDialog.SearchCountApi = _cfgCommon.SearchCountApi
776 SettingDialog.FavoritesCountApi = _cfgCommon.FavoritesCountApi
777 SettingDialog.UserTimelineCountApi = _cfgCommon.UserTimelineCountApi
778 SettingDialog.ListCountApi = _cfgCommon.ListCountApi
780 SettingDialog.UserstreamStartup = _cfgCommon.UserstreamStartup
781 SettingDialog.UserstreamPeriodInt = _cfgCommon.UserstreamPeriod
782 SettingDialog.OpenUserTimeline = _cfgCommon.OpenUserTimeline
785 HashSupl = New AtIdSupplement(_cfgCommon.HashTags, "#")
786 HashMgr = New HashtagManage(HashSupl, _
787 _cfgCommon.HashTags.ToArray, _
788 _cfgCommon.HashSelected, _
789 _cfgCommon.HashIsPermanent, _
790 _cfgCommon.HashIsHead)
791 If HashMgr.UseHash <> "" AndAlso HashMgr.IsPermanent Then HashStripSplitButton.Text = HashMgr.UseHash
797 TIconDic = New ImageDictionary(5)
798 Catch ex As Exception
799 MessageBox.Show("Please install [.NET Framework 4 (Full)].")
803 DirectCast(Me.TIconDic, ImageDictionary).PauseGetImage = False
805 Dim saveRequired As Boolean = False
806 'ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など)
807 If tw.Username = "" Then
809 '設定せずにキャンセルされた場合はプログラム終了
810 If SettingDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
811 Application.Exit() '強制終了
814 '設定されたが、依然ユーザー名とパスワードが未設定ならプログラム終了
815 If tw.Username = "" Then
816 Application.Exit() '強制終了
821 _fntUnread = SettingDialog.FontUnread
822 _clUnread = SettingDialog.ColorUnread
823 _fntReaded = SettingDialog.FontReaded
824 _clReaded = SettingDialog.ColorReaded
825 _clFav = SettingDialog.ColorFav
826 _clOWL = SettingDialog.ColorOWL
827 _clRetweet = SettingDialog.ColorRetweet
828 _fntDetail = SettingDialog.FontDetail
829 _clDetail = SettingDialog.ColorDetail
830 _clDetailLink = SettingDialog.ColorDetailLink
831 _clDetailBackcolor = SettingDialog.ColorDetailBackcolor
832 _clSelf = SettingDialog.ColorSelf
833 _clAtSelf = SettingDialog.ColorAtSelf
834 _clTarget = SettingDialog.ColorTarget
835 _clAtTarget = SettingDialog.ColorAtTarget
836 _clAtFromTarget = SettingDialog.ColorAtFromTarget
837 _clAtTo = SettingDialog.ColorAtTo
838 _clListBackcolor = SettingDialog.ColorListBackcolor
839 _clInputBackcolor = SettingDialog.ColorInputBackcolor
840 _clInputFont = SettingDialog.ColorInputFont
841 _fntInputFont = SettingDialog.FontInputFont
842 _brsForeColorUnread.Dispose()
843 _brsForeColorReaded.Dispose()
844 _brsForeColorFav.Dispose()
845 _brsForeColorOWL.Dispose()
846 _brsForeColorRetweet.Dispose()
847 _brsForeColorUnread = New SolidBrush(_clUnread)
848 _brsForeColorReaded = New SolidBrush(_clReaded)
849 _brsForeColorFav = New SolidBrush(_clFav)
850 _brsForeColorOWL = New SolidBrush(_clOWL)
851 _brsForeColorRetweet = New SolidBrush(_clRetweet)
852 _brsBackColorMine.Dispose()
853 _brsBackColorAt.Dispose()
854 _brsBackColorYou.Dispose()
855 _brsBackColorAtYou.Dispose()
856 _brsBackColorAtFromTarget.Dispose()
857 _brsBackColorAtTo.Dispose()
858 _brsBackColorNone.Dispose()
859 _brsBackColorMine = New SolidBrush(_clSelf)
860 _brsBackColorAt = New SolidBrush(_clAtSelf)
861 _brsBackColorYou = New SolidBrush(_clTarget)
862 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
863 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
864 _brsBackColorAtTo = New SolidBrush(_clAtTo)
865 _brsBackColorNone = New SolidBrush(_clListBackcolor)
867 If SettingDialog.IsMonospace Then
868 detailHtmlFormatHeader = detailHtmlFormatMono1
869 detailHtmlFormatFooter = detailHtmlFormatMono7
871 detailHtmlFormatHeader = detailHtmlFormat1
872 detailHtmlFormatFooter = detailHtmlFormat7
874 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
875 If SettingDialog.IsMonospace Then
876 detailHtmlFormatHeader += detailHtmlFormatMono6
878 detailHtmlFormatHeader += detailHtmlFormat6
880 '他の設定項目は、随時設定画面で保持している値を読み出して使用
883 If SettingDialog.HotkeyEnabled Then
885 Dim modKey As HookGlobalHotkey.ModKeys = HookGlobalHotkey.ModKeys.None
886 If (SettingDialog.HotkeyMod And Keys.Alt) = Keys.Alt Then modKey = modKey Or HookGlobalHotkey.ModKeys.Alt
887 If (SettingDialog.HotkeyMod And Keys.Control) = Keys.Control Then modKey = modKey Or HookGlobalHotkey.ModKeys.Ctrl
888 If (SettingDialog.HotkeyMod And Keys.Shift) = Keys.Shift Then modKey = modKey Or HookGlobalHotkey.ModKeys.Shift
889 If (SettingDialog.HotkeyMod And Keys.LWin) = Keys.LWin Then modKey = modKey Or HookGlobalHotkey.ModKeys.Win
891 _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey)
895 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, _
896 SettingDialog.SelectedProxyType, _
897 SettingDialog.ProxyAddress, _
898 SettingDialog.ProxyPort, _
899 SettingDialog.ProxyUser, _
900 SettingDialog.ProxyPassword)
902 tw.RestrictFavCheck = SettingDialog.RestrictFavCheck
903 tw.ReadOwnPost = SettingDialog.ReadOwnPost
904 tw.UseSsl = SettingDialog.UseSsl
905 ShortUrl.IsResolve = SettingDialog.TinyUrlResolve
906 ShortUrl.BitlyId = SettingDialog.BitlyUser
907 ShortUrl.BitlyKey = SettingDialog.BitlyPwd
908 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
909 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
910 tw.TrackWord = _cfgCommon.TrackWord
911 TrackToolStripMenuItem.Checked = Not String.IsNullOrEmpty(tw.TrackWord)
912 tw.AllAtReply = _cfgCommon.AllAtReply
913 AllrepliesToolStripMenuItem.Checked = tw.AllAtReply
915 Outputz.Key = SettingDialog.OutputzKey
916 Outputz.Enabled = SettingDialog.OutputzEnabled
917 Select Case SettingDialog.OutputzUrlmode
918 Case OutputzUrlmode.twittercom
919 Outputz.OutUrl = "http://twitter.com/"
920 Case OutputzUrlmode.twittercomWithUsername
921 Outputz.OutUrl = "http://twitter.com/" + tw.Username
925 Me.pictureService = New Dictionary(Of String, IMultimediaShareService) From {
926 {"TwitPic", New TwitPic(tw)},
927 {"img.ly", New imgly(tw)},
928 {"yfrog", New yfrog(tw)},
929 {"Plixi", New Plixi(tw)}}
930 SetImageServiceCombo()
931 ImageSelectionPanel.Enabled = False
933 ImageServiceCombo.SelectedIndex = _cfgCommon.UseImageService
936 Me.ClientSize = _cfgLocal.FormSize
937 _mySize = _cfgLocal.FormSize 'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
938 _myLoc = _cfgLocal.FormLocation
940 If Me.WindowState <> FormWindowState.Minimized Then
941 Me.DesktopLocation = _cfgLocal.FormLocation
942 Dim tbarRect As New Rectangle(Me.Location, New Size(_mySize.Width, SystemInformation.CaptionHeight))
943 Dim outOfScreen As Boolean = True
944 If Screen.AllScreens.Length = 1 Then 'ハングするとの報告
945 For Each scr As Screen In Screen.AllScreens
946 If Not Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty Then
952 Me.DesktopLocation = New Point(0, 0)
953 _myLoc = Me.DesktopLocation
957 Me.TopMost = SettingDialog.AlwaysTop
958 _mySpDis = _cfgLocal.SplitterDistance
959 _mySpDis2 = _cfgLocal.StatusTextHeight
960 _mySpDis3 = _cfgLocal.PreviewDistance
961 If _mySpDis3 = -1 Then
962 _mySpDis3 = _mySize.Width - 150
963 If _mySpDis3 < 1 Then _mySpDis3 = 50
964 _cfgLocal.PreviewDistance = _mySpDis3
966 MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline
967 'Me.Tween_ClientSizeChanged(Me, Nothing)
968 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
969 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
971 StatusText.Font = _fntInputFont
972 StatusText.ForeColor = _clInputFont
974 '全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定)
975 If SettingDialog.UnreadManage = False Then
976 ReadedStripMenuItem.Enabled = False
977 UnreadStripMenuItem.Enabled = False
981 TimerTimeline.AutoReset = True
982 TimerTimeline.SynchronizingObject = Me
984 TimerTimeline.Interval = 1000
985 TimerTimeline.Enabled = True
988 TimerRefreshIcon.Interval = 200
989 TimerRefreshIcon.Enabled = True
992 StatusLabel.Text = ""
993 StatusLabel.AutoToolTip = False
994 StatusLabel.ToolTipText = ""
996 lblLen.Text = GetRestStatusCount(True, False).ToString()
998 ''''''''''''''''''''''''''''''''''''''''
999 _statuses.SortOrder = DirectCast(_cfgCommon.SortOrder, System.Windows.Forms.SortOrder)
1000 Dim mode As IdComparerClass.ComparerMode
1001 Select Case _cfgCommon.SortColumn
1002 Case 0, 5, 6 '0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
1004 mode = IdComparerClass.ComparerMode.Id 'Idソートに読み替え
1006 mode = IdComparerClass.ComparerMode.Nickname
1008 mode = IdComparerClass.ComparerMode.Data
1010 mode = IdComparerClass.ComparerMode.Id
1012 mode = IdComparerClass.ComparerMode.Name
1014 mode = IdComparerClass.ComparerMode.Source
1016 _statuses.SortMode = mode
1017 ''''''''''''''''''''''''''''''''''''''''
1019 Select Case SettingDialog.IconSz
1020 Case IconSizes.IconNone
1022 Case IconSizes.Icon16
1024 Case IconSizes.Icon24
1026 Case IconSizes.Icon48
1028 Case IconSizes.Icon48_2
1036 tw.IconSize = _iconSz
1038 tw.TinyUrlResolve = SettingDialog.TinyUrlResolve
1040 '発言詳細部アイコンをリストアイコンにサイズ変更
1041 Dim sz As Integer = _iconSz
1046 tw.DetailIcon = TIconDic
1048 StatusLabel.Text = My.Resources.Form1_LoadText1 '画面右下の状態表示を変更
1049 StatusLabelUrl.Text = "" '画面左下のリンク先URL表示部を初期化
1050 NameLabel.Text = "" '発言詳細部名前ラベル初期化
1051 DateTimeLabel.Text = "" '発言詳細部日時ラベル初期化
1052 SourceLinkLabel.Text = "" 'Source部分初期化
1054 '<<<<<<<<タブ関連>>>>>>>
1055 'デフォルトタブの存在チェック、ない場合には追加
1056 If _statuses.GetTabByType(TabUsageType.Home) Is Nothing Then
1057 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.RECENT) Then
1058 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1060 _statuses.Tabs(DEFAULTTAB.RECENT).TabType = TabUsageType.Home
1063 If _statuses.GetTabByType(TabUsageType.Mentions) Is Nothing Then
1064 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.REPLY) Then
1065 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1067 _statuses.Tabs(DEFAULTTAB.REPLY).TabType = TabUsageType.Mentions
1070 If _statuses.GetTabByType(TabUsageType.DirectMessage) Is Nothing Then
1071 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.DM) Then
1072 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1074 _statuses.Tabs(DEFAULTTAB.DM).TabType = TabUsageType.DirectMessage
1077 If _statuses.GetTabByType(TabUsageType.Favorites) Is Nothing Then
1078 If Not _statuses.Tabs.ContainsKey(DEFAULTTAB.FAV) Then
1079 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1081 _statuses.Tabs(DEFAULTTAB.FAV).TabType = TabUsageType.Favorites
1084 For Each tn As String In _statuses.Tabs.Keys
1085 If _statuses.Tabs(tn).TabType = TabUsageType.Undefined Then
1086 _statuses.Tabs(tn).TabType = TabUsageType.UserDefined
1088 If Not AddNewTab(tn, True, _statuses.Tabs(tn).TabType, _statuses.Tabs(tn).ListInfo) Then Throw New Exception(My.Resources.TweenMain_LoadText1)
1091 Me.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space"
1092 CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C"
1093 CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C"
1094 CopyUserIdStripMenuItem.ShortcutKeyDisplayString = "Shift+Alt+C"
1096 If SettingDialog.MinimizeToTray = False OrElse Me.WindowState <> FormWindowState.Minimized Then
1099 _curTab = ListTab.SelectedTab
1101 _curList = DirectCast(_curTab.Tag, DetailsListView)
1102 SetMainWindowTitle()
1105 If SettingDialog.TabIconDisp Then
1106 ListTab.DrawMode = TabDrawMode.Normal
1108 ListTab.DrawMode = TabDrawMode.OwnerDrawFixed
1109 AddHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
1110 ListTab.ImageList = Nothing
1113 _ignoreConfigSave = False
1114 Me.TweenMain_Resize(Nothing, Nothing)
1115 If saveRequired Then SaveConfigsAll(False)
1118 Private Sub spaceKeyCanceler_SpaceCancel(ByVal sender As Object, ByVal e As EventArgs)
1119 JumpUnreadMenuItem_Click(Nothing, Nothing)
1122 Private Sub ListTab_DrawItem( _
1123 ByVal sender As Object, ByVal e As DrawItemEventArgs)
1126 txt = ListTab.TabPages(e.Index).Text
1127 Catch ex As Exception
1131 e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.Bounds)
1132 If e.State = DrawItemState.Selected Then
1133 e.DrawFocusRectangle()
1137 If _statuses.Tabs(txt).UnreadCount > 0 Then
1140 fore = System.Drawing.SystemBrushes.ControlText
1142 Catch ex As Exception
1143 fore = System.Drawing.SystemBrushes.ControlText
1145 e.Graphics.DrawString(txt, e.Font, fore, e.Bounds, sfTab)
1148 Private Sub LoadConfig()
1149 Dim needToSave As Boolean = False
1150 _cfgCommon = SettingCommon.Load()
1151 _cfgLocal = SettingLocal.Load()
1152 Dim tabs As List(Of TabClass) = SettingTabs.Load().Tabs
1153 For Each tb As TabClass In tabs
1155 _statuses.Tabs.Add(tb.TabName, tb)
1156 Catch ex As Exception
1157 tb.TabName = _statuses.GetUniqueTabName()
1158 _statuses.Tabs.Add(tb.TabName, tb)
1161 If _statuses.Tabs.Count = 0 Then
1162 _statuses.AddTab(DEFAULTTAB.RECENT, TabUsageType.Home, Nothing)
1163 _statuses.AddTab(DEFAULTTAB.REPLY, TabUsageType.Mentions, Nothing)
1164 _statuses.AddTab(DEFAULTTAB.DM, TabUsageType.DirectMessage, Nothing)
1165 _statuses.AddTab(DEFAULTTAB.FAV, TabUsageType.Favorites, Nothing)
1169 'Private Sub ConvertConfig()
1171 ' If System.IO.File.Exists(SettingTabs.GetSettingFilePath("")) Then
1178 Private Sub TimerTimeline_Elapsed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerTimeline.Elapsed
1179 Static homeCounter As Integer = 0
1180 Static mentionCounter As Integer = 0
1181 Static dmCounter As Integer = 0
1182 Static pubSearchCounter As Integer = 0
1183 Static userTimelineCounter As Integer = 0
1184 Static listsCounter As Integer = 0
1185 Static usCounter As Integer = 0
1186 Static ResumeWait As Integer = 0
1187 Static refreshFollowers As Integer = 0
1189 If homeCounter > 0 Then Interlocked.Decrement(homeCounter)
1190 If mentionCounter > 0 Then Interlocked.Decrement(mentionCounter)
1191 If dmCounter > 0 Then Interlocked.Decrement(dmCounter)
1192 If pubSearchCounter > 0 Then Interlocked.Decrement(pubSearchCounter)
1193 If userTimelineCounter > 0 Then Interlocked.Decrement(userTimelineCounter)
1194 If listsCounter > 0 Then Interlocked.Decrement(listsCounter)
1195 If usCounter > 0 Then Interlocked.Decrement(usCounter)
1196 Interlocked.Increment(refreshFollowers)
1199 If homeCounter <= 0 AndAlso SettingDialog.TimelinePeriodInt > 0 Then
1200 Interlocked.Exchange(homeCounter, SettingDialog.TimelinePeriodInt)
1201 If Not tw.IsUserstreamDataReceived Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
1203 If mentionCounter <= 0 AndAlso SettingDialog.ReplyPeriodInt > 0 Then
1204 Interlocked.Exchange(mentionCounter, SettingDialog.ReplyPeriodInt)
1205 If Not tw.IsUserstreamDataReceived Then GetTimeline(WORKERTYPE.Reply, 1, 0, "")
1207 If dmCounter <= 0 AndAlso SettingDialog.DMPeriodInt > 0 Then
1208 Interlocked.Exchange(dmCounter, SettingDialog.DMPeriodInt)
1209 If Not tw.IsUserstreamDataReceived Then GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
1211 If pubSearchCounter <= 0 AndAlso SettingDialog.PubSearchPeriodInt > 0 Then
1212 Interlocked.Exchange(pubSearchCounter, SettingDialog.PubSearchPeriodInt)
1213 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, "")
1215 If userTimelineCounter <= 0 AndAlso SettingDialog.UserTimelinePeriodInt > 0 Then
1216 Interlocked.Exchange(userTimelineCounter, SettingDialog.UserTimelinePeriodInt)
1217 GetTimeline(WORKERTYPE.UserTimeline, 1, 0, "")
1219 If listsCounter <= 0 AndAlso SettingDialog.ListsPeriodInt > 0 Then
1220 Interlocked.Exchange(listsCounter, SettingDialog.ListsPeriodInt)
1221 GetTimeline(WORKERTYPE.List, 1, 0, "")
1223 If usCounter <= 0 AndAlso SettingDialog.UserstreamPeriodInt > 0 Then
1224 Interlocked.Exchange(usCounter, SettingDialog.UserstreamPeriodInt)
1225 If Me._isActiveUserstream Then RefreshTimeline(True)
1227 If refreshFollowers > 3600 Then
1228 Interlocked.Exchange(refreshFollowers, 0)
1229 doGetFollowersMenu()
1232 Interlocked.Increment(ResumeWait)
1233 If ResumeWait > 30 Then
1235 Interlocked.Exchange(ResumeWait, 0)
1236 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
1237 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
1238 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
1243 Private Sub RefreshTimeline(ByVal isUserStream As Boolean)
1244 If isUserStream Then Me.RefreshTasktrayIcon(True)
1246 Dim smode As Integer = -1 '-1:制御しない,-2:最新へ,その他:topitem使用
1247 Dim topId As Long = GetScrollPos(smode)
1248 Dim befCnt As Integer = _curList.VirtualListSize
1251 Dim selId As New Dictionary(Of String, Long())
1252 Dim focusedId As New Dictionary(Of String, Long)
1253 SaveSelectedStatus(selId, focusedId)
1256 Dim dmCount As Integer = _statuses.GetTabByType(TabUsageType.DirectMessage).AllCount
1259 Dim notifyPosts() As PostClass = Nothing
1260 Dim soundFile As String = ""
1261 Dim addCount As Integer = 0
1262 Dim isMention As Boolean = False
1263 Dim isDelete As Boolean = False
1264 addCount = _statuses.SubmitUpdate(soundFile, notifyPosts, isMention, isDelete, isUserStream)
1266 If _endingFlag Then Exit Sub
1270 For Each tab As TabPage In ListTab.TabPages
1271 Dim lst As DetailsListView = DirectCast(tab.Tag, DetailsListView)
1272 Dim tabInfo As TabClass = _statuses.Tabs(tab.Text)
1274 If isDelete OrElse lst.VirtualListSize <> tabInfo.AllCount Then
1275 If lst.Equals(_curList) Then
1276 _itemCache = Nothing
1277 _postCache = Nothing
1280 lst.VirtualListSize = tabInfo.AllCount 'リスト件数更新
1281 Catch ex As Exception
1284 Me.SelectListItem(lst, _
1285 _statuses.IndexOf(tab.Text, selId(tab.Text)), _
1286 _statuses.IndexOf(tab.Text, focusedId(tab.Text)))
1289 If tabInfo.UnreadCount > 0 Then
1290 If SettingDialog.TabIconDisp Then
1291 If tab.ImageIndex = -1 Then tab.ImageIndex = 0 'タブアイコン
1295 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
1296 Catch ex As Exception
1297 'ex.Data("Msg") = "Ref1, UseAPI=" + SettingDialog.UseAPI.ToString
1304 If befCnt <> _curList.VirtualListSize Then
1308 If _curList.VirtualListSize > 0 Then _curList.EnsureVisible(0)
1311 If _curList.VirtualListSize > 0 Then _curList.EnsureVisible(_curList.VirtualListSize - 1)
1316 If _curList.VirtualListSize > 0 AndAlso _statuses.IndexOf(_curTab.Text, topId) > -1 Then
1317 _curList.EnsureVisible(_curList.VirtualListSize - 1)
1318 _curList.EnsureVisible(_statuses.IndexOf(_curTab.Text, topId))
1322 Catch ex As Exception
1323 ex.Data("Msg") = "Ref2"
1329 NotifyNewPosts(notifyPosts,
1332 isMention OrElse dmCount <> _statuses.GetTabByType(TabUsageType.DirectMessage).AllCount)
1334 SetMainWindowTitle()
1335 If Not StatusLabelUrl.Text.StartsWith("http") Then SetStatusLabelUrl()
1337 HashSupl.AddRangeItem(tw.GetHashList)
1341 Private Function GetScrollPos(ByRef smode As Integer) As Long
1342 Dim topId As Long = -1
1343 If _curList IsNot Nothing AndAlso _curTab IsNot Nothing AndAlso _curList.VirtualListSize > 0 Then
1344 If _statuses.SortMode = IdComparerClass.ComparerMode.Id Then
1345 If _statuses.SortOrder = SortOrder.Ascending Then
1347 If ListLockMenuItem.Checked Then
1351 'If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1354 '最下行が表示されていたら、最下行へ強制スクロール。最下行が表示されていなかったら制御しない
1355 Dim _item As ListViewItem
1356 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1) '一番下
1357 If _item Is Nothing Then _item = _curList.Items(_curList.Items.Count - 1)
1358 If _item.Index = _curList.Items.Count - 1 Then
1362 'If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1368 If ListLockMenuItem.Checked Then
1370 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1373 '最上行が表示されていたら、制御しない。最上行が表示されていなかったら、現在表示位置へ強制スクロール
1374 Dim _item As ListViewItem
1376 _item = _curList.GetItemAt(0, 10) '一番上
1377 If _item Is Nothing Then _item = _curList.Items(0)
1378 If _item.Index = 0 Then
1381 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1388 If _curList.TopItem IsNot Nothing Then topId = _statuses.GetId(_curTab.Text, _curList.TopItem.Index)
1397 Private Sub SaveSelectedStatus(ByVal selId As Dictionary(Of String, Long()), ByVal focusedId As Dictionary(Of String, Long))
1398 If _endingFlag Then Exit Sub
1399 For Each tab As TabPage In ListTab.TabPages
1400 Dim lst As DetailsListView = DirectCast(tab.Tag, DetailsListView)
1401 If lst.SelectedIndices.Count > 0 AndAlso lst.SelectedIndices.Count < 61 Then
1402 selId.Add(tab.Text, _statuses.GetId(tab.Text, lst.SelectedIndices))
1404 selId.Add(tab.Text, New Long(0) {-2})
1406 If lst.FocusedItem IsNot Nothing Then
1407 focusedId.Add(tab.Text, _statuses.GetId(tab.Text, lst.FocusedItem.Index))
1409 focusedId.Add(tab.Text, -2)
1415 Private Overloads Function BalloonRequired() As Boolean
1416 Return BalloonRequired(New Twitter.FormattedEvent With {.Eventtype = EVENTTYPE.None})
1419 Private Function IsEventNotifyAsEventType(ByVal type As EVENTTYPE) As Boolean
1420 Return SettingDialog.EventNotifyEnabled AndAlso CBool(type And SettingDialog.EventNotifyFlag) OrElse type = EVENTTYPE.None
1423 Private Function IsMyEventNotityAsEventType(ByVal ev As Twitter.FormattedEvent) As Boolean
1424 Return If(CBool(ev.Eventtype And SettingDialog.IsMyEventNotifyFlag), True, Not ev.IsMe)
1427 Private Overloads Function BalloonRequired(ByVal ev As Twitter.FormattedEvent) As Boolean
1429 IsEventNotifyAsEventType(ev.Eventtype) AndAlso IsMyEventNotityAsEventType(ev) AndAlso
1430 (NewPostPopMenuItem.Checked OrElse (SettingDialog.ForceEventNotify AndAlso ev.Eventtype <> EVENTTYPE.None)) AndAlso
1431 Not _initial AndAlso
1434 SettingDialog.LimitBalloon AndAlso
1436 Me.WindowState = FormWindowState.Minimized OrElse
1437 Not Me.Visible OrElse
1438 Form.ActiveForm Is Nothing
1441 Not SettingDialog.LimitBalloon
1444 Not IsScreenSaverRunning() Then
1451 Private Sub NotifyNewPosts(ByVal notifyPosts() As PostClass, ByVal soundFile As String, ByVal addCount As Integer, ByVal newMentions As Boolean)
1452 If notifyPosts IsNot Nothing AndAlso _
1453 notifyPosts.Count > 0 AndAlso _
1454 Me.SettingDialog.ReadOwnPost AndAlso _
1455 notifyPosts.All(Function(post) post.UserId.ToString() = tw.UserIdNo OrElse post.ScreenName = tw.Username) Then
1460 If BalloonRequired() Then
1461 If notifyPosts IsNot Nothing AndAlso notifyPosts.Length > 0 Then
1462 Dim sb As New StringBuilder
1463 Dim reply As Boolean = False
1464 Dim dm As Boolean = False
1465 For Each post As PostClass In notifyPosts
1466 If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True
1467 If post.IsDm Then dm = True
1468 If sb.Length > 0 Then sb.Append(System.Environment.NewLine)
1469 Select Case SettingDialog.NameBalloon
1470 Case NameBalloonEnum.UserID
1471 sb.Append(post.ScreenName).Append(" : ")
1472 Case NameBalloonEnum.NickName
1473 sb.Append(post.Nickname).Append(" : ")
1475 sb.Append(post.TextFromApi)
1477 If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = ""
1479 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
1480 NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2
1482 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
1483 NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
1485 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
1486 NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
1488 Dim bText As String = sb.ToString
1489 If String.IsNullOrEmpty(bText) Then Exit Sub
1490 NotifyIcon1.BalloonTipText = sb.ToString()
1491 NotifyIcon1.ShowBalloonTip(500)
1496 If Not _initial AndAlso SettingDialog.PlaySound AndAlso soundFile <> "" Then
1498 Dim dir As String = My.Application.Info.DirectoryPath
1499 If Directory.Exists(Path.Combine(dir, "Sounds")) Then
1500 dir = Path.Combine(dir, "Sounds")
1502 My.Computer.Audio.Play(Path.Combine(dir, soundFile), AudioPlayMode.Background)
1503 Catch ex As Exception
1509 If Not _initial AndAlso SettingDialog.BlinkNewMentions AndAlso newMentions AndAlso Form.ActiveForm Is Nothing Then
1510 FlashMyWindow(Me.Handle, FlashSpecification.FlashTray, 3)
1514 Private Sub MyList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
1515 If _curList Is Nothing OrElse _curList.SelectedIndices.Count <> 1 Then Exit Sub
1517 _curItemIndex = _curList.SelectedIndices(0)
1518 If _curItemIndex > _curList.VirtualListSize - 1 Then Exit Sub
1520 _curPost = GetCurTabPost(_curItemIndex)
1522 If SettingDialog.UnreadManage Then _statuses.SetReadAllTab(True, _curTab.Text, _curItemIndex)
1524 ChangeCacheStyleRead(True, _curItemIndex, _curTab) '既読へ(フォント、文字色)
1530 Private Sub ChangeCacheStyleRead(ByVal Read As Boolean, ByVal Index As Integer, ByVal Tab As TabPage)
1531 'Read:True=既読 False=未読
1532 '未読管理していなかったら既読として扱う
1533 If Not _statuses.Tabs(_curTab.Text).UnreadManage OrElse _
1534 Not SettingDialog.UnreadManage Then Read = True
1537 Dim itm As ListViewItem
1538 Dim post As PostClass
1539 If Tab.Equals(_curTab) AndAlso _itemCache IsNot Nothing AndAlso Index >= _itemCacheIndex AndAlso Index < _itemCacheIndex + _itemCache.Length Then
1540 itm = _itemCache(Index - _itemCacheIndex)
1541 post = _postCache(Index - _itemCacheIndex)
1543 itm = DirectCast(Tab.Tag, DetailsListView).Items(Index)
1544 post = _statuses.Item(Tab.Text, Index)
1547 ChangeItemStyleRead(Read, itm, post, DirectCast(Tab.Tag, DetailsListView))
1550 Private Sub ChangeItemStyleRead(ByVal Read As Boolean, ByVal Item As ListViewItem, ByVal Post As PostClass, ByVal DList As DetailsListView)
1555 Item.SubItems(5).Text = ""
1558 Item.SubItems(5).Text = "★"
1564 ElseIf Post.RetweetedId > 0 Then
1566 ElseIf Post.IsOwl AndAlso (Post.IsDm OrElse SettingDialog.OneWayLove) Then
1568 ElseIf Read OrElse Not SettingDialog.UseUnreadStyle Then
1573 If DList Is Nothing OrElse Item.Index = -1 Then
1575 If SettingDialog.UseUnreadStyle Then
1580 If SettingDialog.UseUnreadStyle Then
1581 DList.ChangeItemFontAndColor(Item.Index, cl, fnt)
1583 DList.ChangeItemForeColor(Item.Index, cl)
1585 'If _itemCache IsNot Nothing Then DList.RedrawItems(_itemCacheIndex, _itemCacheIndex + _itemCache.Length - 1, False)
1589 Private Sub ColorizeList()
1590 'Index:更新対象のListviewItem.Index。Colorを返す。
1591 '-1は全キャッシュ。Colorは返さない(ダミーを戻す)
1592 Dim _post As PostClass
1599 If _itemCache Is Nothing Then Exit Sub
1601 If _post Is Nothing Then Exit Sub
1604 For cnt As Integer = 0 To _itemCache.Length - 1
1605 _curList.ChangeItemBackColor(_itemCacheIndex + cnt, JudgeColor(_post, _postCache(cnt)))
1607 Catch ex As Exception
1611 Private Sub ColorizeList(ByVal Item As ListViewItem, ByVal Index As Integer)
1612 'Index:更新対象のListviewItem.Index。Colorを返す。
1613 '-1は全キャッシュ。Colorは返さない(ダミーを戻す)
1614 Dim _post As PostClass
1621 Dim tPost As PostClass = GetCurTabPost(Index)
1623 If _post Is Nothing Then Exit Sub
1625 If Item.Index = -1 Then
1626 Item.BackColor = JudgeColor(_post, tPost)
1628 _curList.ChangeItemBackColor(Item.Index, JudgeColor(_post, tPost))
1632 Private Function JudgeColor(ByVal BasePost As PostClass, ByVal TargetPost As PostClass) As Color
1634 If TargetPost.StatusId = BasePost.InReplyToStatusId Then
1637 ElseIf TargetPost.IsMe Then
1640 ElseIf TargetPost.IsReply Then
1643 ElseIf BasePost.ReplyToList.Contains(TargetPost.ScreenName.ToLower()) Then
1645 cl = _clAtFromTarget
1646 ElseIf TargetPost.ReplyToList.Contains(BasePost.ScreenName.ToLower()) Then
1649 ElseIf TargetPost.ScreenName.Equals(BasePost.ScreenName, StringComparison.OrdinalIgnoreCase) Then
1654 cl = _clListBackcolor
1659 Private Sub PostButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostButton.Click
1660 If StatusText.Text.Trim.Length = 0 Then
1661 If Not ImageSelectionPanel.Enabled Then
1667 If Me.ExistCurrentPost AndAlso StatusText.Text.Trim() = String.Format("RT @{0}: {1}", _curPost.ScreenName, _curPost.TextFromApi) Then
1668 Dim rtResult As DialogResult = MessageBox.Show(String.Format(My.Resources.PostButton_Click1, Environment.NewLine),
1670 MessageBoxButtons.YesNoCancel,
1671 MessageBoxIcon.Question)
1672 Select Case rtResult
1673 Case Windows.Forms.DialogResult.Yes
1674 doReTweetOfficial(False)
1675 StatusText.Text = ""
1677 Case Windows.Forms.DialogResult.Cancel
1682 _history(_history.Count - 1) = New PostingStatus(StatusText.Text.Trim, _reply_to_id, _reply_to_name)
1684 If SettingDialog.UrlConvertAuto Then
1685 StatusText.SelectionStart = StatusText.Text.Length
1686 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
1687 ElseIf SettingDialog.Nicoms Then
1688 StatusText.SelectionStart = StatusText.Text.Length
1689 UrlConvert(UrlConverter.Nicoms)
1691 StatusText.SelectionStart = StatusText.Text.Length
1692 Dim args As New GetWorkerArg()
1695 args.type = WORKERTYPE.PostMessage
1696 CheckReplyTo(StatusText.Text)
1699 Dim adjustCount As Integer = 0
1700 Dim tmpStatus As String = StatusText.Text.Trim
1701 If ToolStripMenuItemApiCommandEvasion.Checked Then
1703 If Regex.IsMatch(tmpStatus, _
1704 "^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", _
1705 RegexOptions.IgnoreCase) _
1706 AndAlso tmpStatus.EndsWith(" .") = False Then adjustCount += 2
1709 If ToolStripMenuItemUrlMultibyteSplit.Checked Then
1711 adjustCount += Regex.Matches(tmpStatus, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+").Count
1714 Dim isCutOff As Boolean = False
1715 Dim isRemoveFooter As Boolean = My.Computer.Keyboard.ShiftKeyDown
1716 If StatusText.Multiline AndAlso Not SettingDialog.PostCtrlEnter Then
1717 '複数行でEnter投稿の場合、Ctrlも押されていたらフッタ付加しない
1718 isRemoveFooter = My.Computer.Keyboard.CtrlKeyDown
1720 If SettingDialog.PostShiftEnter Then
1721 isRemoveFooter = My.Computer.Keyboard.CtrlKeyDown
1723 If Not isRemoveFooter AndAlso (StatusText.Text.Contains("RT @") OrElse StatusText.Text.Contains("QT @")) Then
1724 isRemoveFooter = True
1726 If GetRestStatusCount(False, Not isRemoveFooter) - adjustCount < 0 Then
1727 If MessageBox.Show(My.Resources.PostLengthOverMessage1, My.Resources.PostLengthOverMessage2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
1729 If Not SettingDialog.UrlConvertAuto Then UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
1730 If GetRestStatusCount(False, Not isRemoveFooter) - adjustCount < 0 Then
1731 isRemoveFooter = True
1738 Dim footer As String = ""
1739 Dim header As String = ""
1740 If StatusText.Text.StartsWith("D ") OrElse StatusText.Text.StartsWith("d ") Then
1745 If HashMgr.UseHash <> "" Then
1746 If HashMgr.IsHead Then
1747 header = HashMgr.UseHash + " "
1749 footer = " " + HashMgr.UseHash
1752 If Not isRemoveFooter Then
1753 If SettingDialog.UseRecommendStatus Then
1755 footer += SettingDialog.RecommendStatusText
1757 ' テキストボックスに入力されている文字列を使用する
1758 footer += " " + SettingDialog.Status.Trim
1762 args.status.status = header + StatusText.Text.Trim + footer
1764 If ToolStripMenuItemApiCommandEvasion.Checked Then
1766 If Regex.IsMatch(args.status.status, _
1767 "^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", _
1768 RegexOptions.IgnoreCase) _
1769 AndAlso args.status.status.EndsWith(" .") = False Then args.status.status += " ."
1772 If ToolStripMenuItemUrlMultibyteSplit.Checked Then
1774 Dim mc2 As Match = Regex.Match(args.status.status, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+")
1775 If mc2.Success Then args.status.status = Regex.Replace(args.status.status, "https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+", "$& ")
1778 If IdeographicSpaceToSpaceToolStripMenuItem.Checked Then
1779 ' 文中の全角スペースを半角スペース1個にする
1780 args.status.status = args.status.status.Replace(" ", " ")
1783 If isCutOff AndAlso args.status.status.Length > 140 Then
1784 args.status.status = args.status.status.Substring(0, 140)
1785 Dim AtId As String = "(@|@)[a-z0-9_/]+$"
1786 Dim HashTag As String = "(^|[^0-9A-Z&\/\?]+)(#|#)([0-9A-Z_]*[A-Z_]+)$"
1787 Dim Url As String = "https?:\/\/[a-z0-9!\*'\(\);:&=\+\$\/%#\[\]\-_\.,~?]+$" '簡易判定
1788 Dim pattern As String = String.Format("({0})|({1})|({2})", AtId, HashTag, Url)
1789 Dim mc As Match = Regex.Match(args.status.status, pattern, RegexOptions.IgnoreCase)
1791 'さらに@ID、ハッシュタグ、URLと推測される文字列をカットする
1792 args.status.status = args.status.status.Substring(0, 140 - mc.Value.Length)
1794 If MessageBox.Show(args.status.status, "Post or Cancel?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then Exit Sub
1797 args.status.inReplyToId = _reply_to_id
1798 args.status.inReplyToName = _reply_to_name
1799 If ImageSelectionPanel.Visible Then
1801 If ImageSelectedPicture.Image IsNot ImageSelectedPicture.InitialImage AndAlso _
1802 ImageServiceCombo.SelectedIndex > -1 AndAlso _
1803 ImagefilePathText.Text <> "" Then
1804 If MessageBox.Show(My.Resources.PostPictureConfirm1, _
1805 My.Resources.PostPictureConfirm2, _
1806 MessageBoxButtons.OKCancel, _
1807 MessageBoxIcon.Question, _
1808 MessageBoxDefaultButton.Button1) _
1809 = Windows.Forms.DialogResult.Cancel Then
1810 TimelinePanel.Visible = True
1811 TimelinePanel.Enabled = True
1812 ImageSelectionPanel.Visible = False
1813 ImageSelectionPanel.Enabled = False
1814 If _curList IsNot Nothing Then
1819 args.status.imageService = ImageServiceCombo.Text
1820 args.status.imagePath = ImagefilePathText.Text
1821 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
1822 ImagefilePathText.Text = ""
1823 TimelinePanel.Visible = True
1824 TimelinePanel.Enabled = True
1825 ImageSelectionPanel.Visible = False
1826 ImageSelectionPanel.Enabled = False
1827 If _curList IsNot Nothing Then
1831 MessageBox.Show(My.Resources.PostPictureWarn1, My.Resources.PostPictureWarn2)
1839 If StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) AndAlso StatusText.Text.Trim.Length > 7 Then
1840 Dim tmp As String = String.Format(My.Resources.SearchItem2Url, HttpUtility.UrlEncode(StatusText.Text.Substring(7)))
1846 StatusText.Text = ""
1847 _history.Add(New PostingStatus)
1848 _hisIdx = _history.Count - 1
1849 If Not ToolStripFocusLockMenuItem.Checked Then
1850 DirectCast(ListTab.SelectedTab.Tag, Control).Focus()
1852 urlUndoBuffer = Nothing
1853 UrlUndoToolStripMenuItem.Enabled = False 'Undoをできないように設定
1856 Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click, EndFileMenuItem.Click
1861 Private Sub Tween_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
1862 If Not SettingDialog.CloseToExit AndAlso e.CloseReason = CloseReason.UserClosing AndAlso _endingFlag = False Then
1863 '_endingFlag=False:フォームの×ボタン
1867 _hookGlobalHotkey.UnregisterAllOriginalHotkey()
1868 _ignoreConfigSave = True
1870 TimerTimeline.Enabled = False
1871 TimerRefreshIcon.Enabled = False
1875 Private Sub NotifyIcon1_BalloonTipClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyIcon1.BalloonTipClicked
1877 If Me.WindowState = FormWindowState.Minimized Then
1878 Me.WindowState = FormWindowState.Normal
1883 Private Shared Function CheckAccountValid() As Boolean
1884 Static errorCount As Integer = 0
1885 If Twitter.AccountState <> ACCOUNT_STATE.Valid Then
1887 If errorCount > 5 Then
1889 Twitter.AccountState = ACCOUNT_STATE.Valid
1898 Private Sub GetTimelineWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
1899 Dim bw As BackgroundWorker = DirectCast(sender, BackgroundWorker)
1900 If bw.CancellationPending OrElse _endingFlag Then
1905 Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.BelowNormal
1907 My.Application.InitCulture()
1909 Dim ret As String = ""
1910 Dim rslt As New GetWorkerResult()
1912 Dim read As Boolean = Not SettingDialog.UnreadManage
1913 If _initial AndAlso SettingDialog.UnreadManage Then read = SettingDialog.Readed
1915 Dim args As GetWorkerArg = DirectCast(e.Argument, GetWorkerArg)
1917 If Not CheckAccountValid() Then
1918 rslt.retMsg = "Auth error. Check your account"
1919 rslt.type = WORKERTYPE.ErrorState 'エラー表示のみ行ない、後処理キャンセル
1920 rslt.tName = args.tName
1925 If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(0, "") 'Notifyアイコンアニメーション開始
1926 Select Case args.type
1927 Case WORKERTYPE.Timeline, WORKERTYPE.Reply
1928 bw.ReportProgress(50, MakeStatusMessage(args, False))
1929 ret = tw.GetTimelineApi(read, args.type, args.page = -1, _initial)
1931 If ret = "" AndAlso args.type = WORKERTYPE.Timeline AndAlso SettingDialog.ReadOldPosts Then
1935 rslt.addCount = _statuses.DistributePosts()
1936 Case WORKERTYPE.DirectMessegeRcv '送信分もまとめて取得
1937 bw.ReportProgress(50, MakeStatusMessage(args, False))
1938 ret = tw.GetDirectMessageApi(read, WORKERTYPE.DirectMessegeRcv, args.page = -1)
1939 If ret = "" Then ret = tw.GetDirectMessageApi(read, WORKERTYPE.DirectMessegeSnt, args.page = -1)
1940 rslt.addCount = _statuses.DistributePosts()
1941 Case WORKERTYPE.FavAdd
1943 If _statuses.Tabs.ContainsKey(args.tName) Then
1944 Dim tbc As TabClass = _statuses.Tabs(args.tName)
1945 For i As Integer = 0 To args.ids.Count - 1
1946 Dim post As PostClass = Nothing
1947 If tbc.IsInnerStorageTabType Then
1948 post = tbc.Posts(args.ids(i))
1950 post = _statuses.Item(args.ids(i))
1953 bw.ReportProgress(50, MakeStatusMessage(args, False))
1954 If Not post.IsFav Then
1955 If post.RetweetedId = 0 Then
1956 ret = tw.PostFavAdd(post.StatusId)
1958 ret = tw.PostFavAdd(post.RetweetedId)
1960 If ret.Length = 0 Then
1961 args.sIds.Add(post.StatusId)
1962 post.IsFav = True 'リスト再描画必要
1963 _favTimestamps.Add(Now)
1964 If post.RelTabName = "" Then
1965 '検索,リストUserTimeline.Relatedタブからのfavは、favタブへ追加せず。それ以外は追加
1966 _statuses.GetTabByType(TabUsageType.Favorites).Add(post.StatusId, post.IsRead, False)
1968 '検索,リスト,UserTimeline.Relatedタブからのfavで、TLでも取得済みならfav反映
1969 If _statuses.ContainsKey(post.StatusId) Then
1970 Dim postTl As PostClass = _statuses.Item(post.StatusId)
1972 _statuses.GetTabByType(TabUsageType.Favorites).Add(postTl.StatusId, postTl.IsRead, False)
1975 '検索,リスト,UserTimeline,Relatedの各タブに反映
1976 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch Or TabUsageType.Lists Or TabUsageType.UserTimeline Or TabUsageType.Related)
1977 If tb.Contains(post.StatusId) Then tb.Posts(post.StatusId).IsFav = True
1983 rslt.sIds = args.sIds
1984 Case WORKERTYPE.FavRemove
1986 If _statuses.Tabs.ContainsKey(args.tName) Then
1987 Dim tbc As TabClass = _statuses.Tabs(args.tName)
1988 For i As Integer = 0 To args.ids.Count - 1
1989 Dim post As PostClass = Nothing
1990 If tbc.IsInnerStorageTabType Then
1991 post = tbc.Posts(args.ids(i))
1993 post = _statuses.Item(args.ids(i))
1996 bw.ReportProgress(50, MakeStatusMessage(args, False))
1998 If post.RetweetedId = 0 Then
1999 ret = tw.PostFavRemove(post.StatusId)
2001 ret = tw.PostFavRemove(post.RetweetedId)
2003 If ret.Length = 0 Then
2004 args.sIds.Add(post.StatusId)
2005 post.IsFav = False 'リスト再描画必要
2006 If _statuses.ContainsKey(post.StatusId) Then _statuses.Item(post.StatusId).IsFav = False
2007 '検索,リスト,UserTimeline,Relatedの各タブに反映
2008 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch Or TabUsageType.Lists Or TabUsageType.UserTimeline Or TabUsageType.Related)
2009 If tb.Contains(post.StatusId) Then tb.Posts(post.StatusId).IsFav = False
2015 rslt.sIds = args.sIds
2016 Case WORKERTYPE.PostMessage
2017 bw.ReportProgress(200)
2018 If String.IsNullOrEmpty(args.status.imagePath) Then
2019 For i As Integer = 0 To 1
2020 ret = tw.PostStatus(args.status.status, args.status.inReplyToId)
2021 If ret = "" OrElse _
2022 ret.StartsWith("OK:") OrElse _
2023 ret.StartsWith("Outputz:") OrElse _
2024 ret.StartsWith("Warn:") OrElse _
2025 ret = "Err:Status is a duplicate." OrElse _
2026 args.status.status.StartsWith("D", StringComparison.OrdinalIgnoreCase) OrElse _
2027 args.status.status.StartsWith("DM", StringComparison.OrdinalIgnoreCase) OrElse _
2028 Twitter.AccountState <> ACCOUNT_STATE.Valid Then
2033 ret = Me.pictureService(args.status.imageService).Upload(args.status.imagePath,
2036 bw.ReportProgress(300)
2037 rslt.status = args.status
2038 Case WORKERTYPE.Retweet
2039 bw.ReportProgress(200)
2040 For i As Integer = 0 To args.ids.Count - 1
2041 ret = tw.PostRetweet(args.ids(i), read)
2043 bw.ReportProgress(300)
2044 Case WORKERTYPE.Follower
2045 bw.ReportProgress(50, My.Resources.UpdateFollowersMenuItem1_ClickText1)
2046 ret = tw.GetFollowersApi()
2047 Case WORKERTYPE.OpenUri
2048 Dim myPath As String = Convert.ToString(args.url)
2051 If SettingDialog.BrowserPath <> "" Then
2052 If SettingDialog.BrowserPath.StartsWith("""") AndAlso SettingDialog.BrowserPath.Length > 2 AndAlso SettingDialog.BrowserPath.IndexOf("""", 2) > -1 Then
2053 Dim sep As Integer = SettingDialog.BrowserPath.IndexOf("""", 2)
2054 Dim browserPath As String = SettingDialog.BrowserPath.Substring(1, sep - 1)
2055 Dim arg As String = ""
2056 If sep < SettingDialog.BrowserPath.Length - 1 Then
2057 arg = SettingDialog.BrowserPath.Substring(sep + 1)
2059 myPath = arg + " " + myPath
2060 System.Diagnostics.Process.Start(browserPath, myPath)
2062 System.Diagnostics.Process.Start(SettingDialog.BrowserPath, myPath)
2065 System.Diagnostics.Process.Start(myPath)
2067 Catch ex As Exception
2068 ' MessageBox.Show("ブラウザの起動に失敗、またはタイムアウトしました。" + ex.ToString())
2070 Case WORKERTYPE.Favorites
2071 bw.ReportProgress(50, MakeStatusMessage(args, False))
2072 ret = tw.GetFavoritesApi(read, args.type)
2073 rslt.addCount = _statuses.DistributePosts()
2074 Case WORKERTYPE.PublicSearch
2075 bw.ReportProgress(50, MakeStatusMessage(args, False))
2076 If args.tName = "" Then
2077 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch)
2078 'If tb.SearchWords <> "" Then ret = tw.GetPhoenixSearch(read, tb, False)
2079 If tb.SearchWords <> "" Then ret = tw.GetSearch(read, tb, False)
2082 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2083 If tb IsNot Nothing Then
2084 'ret = tw.GetPhoenixSearch(read, tb, False)
2085 ret = tw.GetSearch(read, tb, False)
2086 If ret = "" AndAlso args.page = -1 Then
2087 'ret = tw.GetPhoenixSearch(read, tb, True)
2088 ret = tw.GetSearch(read, tb, True)
2093 rslt.addCount = _statuses.DistributePosts()
2094 Case WORKERTYPE.UserTimeline
2095 bw.ReportProgress(50, MakeStatusMessage(args, False))
2096 Dim count As Integer = 20
2097 If SettingDialog.UseAdditionalCount Then count = SettingDialog.UserTimelineCountApi
2098 If args.tName = "" Then
2099 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.UserTimeline)
2100 If tb.User <> "" Then ret = tw.GetUserTimelineApi(read, count, tb.User, tb, False)
2103 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2104 If tb IsNot Nothing Then
2105 ret = tw.GetUserTimelineApi(read, count, tb.User, tb, args.page = -1)
2109 rslt.addCount = _statuses.DistributePosts()
2110 Case WORKERTYPE.List
2111 bw.ReportProgress(50, MakeStatusMessage(args, False))
2112 If args.tName = "" Then
2114 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.Lists)
2115 If tb.ListInfo IsNot Nothing AndAlso tb.ListInfo.Id <> 0 Then ret = tw.GetListStatus(read, tb, False, _initial)
2119 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2120 If tb IsNot Nothing Then
2121 ret = tw.GetListStatus(read, tb, args.page = -1, _initial)
2125 rslt.addCount = _statuses.DistributePosts()
2126 Case WORKERTYPE.Related
2127 bw.ReportProgress(50, MakeStatusMessage(args, False))
2128 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
2129 ret = tw.GetRelatedResult(read, tb)
2130 rslt.addCount = _statuses.DistributePosts()
2133 If bw.CancellationPending Then
2139 If args.type = WORKERTYPE.FavAdd Then
2140 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2141 For i As Integer = _favTimestamps.Count - 1 To 0 Step -1
2142 If _favTimestamps(i).CompareTo(oneHour) < 0 Then
2143 _favTimestamps.RemoveAt(i)
2147 If args.type = WORKERTYPE.Timeline AndAlso Not _initial Then
2148 SyncLock _syncObject
2149 Dim tm As Date = Now
2150 If _tlTimestamps.ContainsKey(tm) Then
2151 _tlTimestamps(tm) += rslt.addCount
2153 _tlTimestamps.Add(Now, rslt.addCount)
2155 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2156 Dim keys As New List(Of Date)
2158 For Each key As Date In _tlTimestamps.Keys
2159 If key.CompareTo(oneHour) < 0 Then
2162 _tlCount += _tlTimestamps(key)
2165 For Each key As Date In keys
2166 _tlTimestamps.Remove(key)
2173 If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(100, MakeStatusMessage(args, True)) 'ステータス書き換え、Notifyアイコンアニメーション開始
2176 rslt.type = args.type
2177 rslt.tName = args.tName
2178 If args.type = WORKERTYPE.DirectMessegeRcv OrElse _
2179 args.type = WORKERTYPE.DirectMessegeSnt OrElse _
2180 args.type = WORKERTYPE.Reply OrElse _
2181 args.type = WORKERTYPE.Timeline OrElse _
2182 args.type = WORKERTYPE.Favorites Then
2183 rslt.page = args.page - 1 '値が正しいか後でチェック。10ページ毎の継続確認
2189 Private Function MakeStatusMessage(ByVal AsyncArg As GetWorkerArg, ByVal Finish As Boolean) As String
2190 Dim smsg As String = ""
2193 Select Case AsyncArg.type
2194 Case WORKERTYPE.Timeline
2195 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText5 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2196 Case WORKERTYPE.Reply
2197 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText4 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2198 Case WORKERTYPE.DirectMessegeRcv
2199 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText8 + AsyncArg.page.ToString() + My.Resources.GetTimelineWorker_RunWorkerCompletedText6
2200 Case WORKERTYPE.FavAdd
2201 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText15 + AsyncArg.page.ToString() + "/" + AsyncArg.ids.Count.ToString() + _
2202 My.Resources.GetTimelineWorker_RunWorkerCompletedText16 + (AsyncArg.page - AsyncArg.sIds.Count - 1).ToString()
2203 Case WORKERTYPE.FavRemove
2204 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText17 + AsyncArg.page.ToString() + "/" + AsyncArg.ids.Count.ToString() + _
2205 My.Resources.GetTimelineWorker_RunWorkerCompletedText18 + (AsyncArg.page - AsyncArg.sIds.Count - 1).ToString()
2206 Case WORKERTYPE.Favorites
2207 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText19
2208 Case WORKERTYPE.PublicSearch
2209 smsg = "Search refreshing..."
2210 Case WORKERTYPE.List
2211 smsg = "List refreshing..."
2212 Case WORKERTYPE.Related
2213 smsg = "Related refreshing..."
2214 Case WORKERTYPE.UserTimeline
2215 smsg = "UserTimeline refreshing..."
2219 Select Case AsyncArg.type
2220 Case WORKERTYPE.Timeline
2221 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText1
2222 Case WORKERTYPE.Reply
2223 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText9
2224 Case WORKERTYPE.DirectMessegeRcv
2225 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText11
2226 Case WORKERTYPE.DirectMessegeSnt
2227 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText13
2228 Case WORKERTYPE.FavAdd
2230 Case WORKERTYPE.FavRemove
2232 Case WORKERTYPE.Favorites
2233 smsg = My.Resources.GetTimelineWorker_RunWorkerCompletedText20
2234 Case WORKERTYPE.Follower
2235 smsg = My.Resources.UpdateFollowersMenuItem1_ClickText3
2236 Case WORKERTYPE.PublicSearch
2237 smsg = "Search refreshed"
2238 Case WORKERTYPE.List
2239 smsg = "List refreshed"
2240 Case WORKERTYPE.Related
2241 smsg = "Related refreshed"
2242 Case WORKERTYPE.UserTimeline
2243 smsg = "UserTimeline refreshed"
2249 Private Sub GetTimelineWorker_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
2250 If _endingFlag Then Exit Sub
2251 If e.ProgressPercentage > 100 Then
2253 If e.ProgressPercentage = 200 Then '開始
2254 StatusLabel.Text = "Posting..."
2256 If e.ProgressPercentage = 300 Then '終了
2257 StatusLabel.Text = My.Resources.PostWorker_RunWorkerCompletedText4
2260 Dim smsg As String = DirectCast(e.UserState, String)
2261 If smsg.Length > 0 Then StatusLabel.Text = smsg
2265 Private Sub GetTimelineWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
2267 If _endingFlag OrElse e.Cancelled Then Exit Sub 'キャンセル
2269 If e.Error IsNot Nothing Then
2270 _myStatusError = True
2271 _waitTimeline = False
2275 _waitPubSearch = False
2276 _waitUserTimeline = False
2278 Throw New Exception("BackgroundWorker Exception", e.Error)
2282 Dim rslt As GetWorkerResult = DirectCast(e.Result, GetWorkerResult)
2284 If rslt.type = WORKERTYPE.OpenUri Then Exit Sub
2287 If rslt.retMsg.Length > 0 Then
2288 _myStatusError = True
2289 StatusLabel.Text = rslt.retMsg
2292 If rslt.type = WORKERTYPE.ErrorState Then Exit Sub
2294 If rslt.type = WORKERTYPE.FavRemove Then
2295 Me.RemovePostFromFavTab(rslt.sIds.ToArray)
2299 'Dim busy As Boolean = False
2300 'For Each bw As BackgroundWorker In _bw
2301 ' If bw IsNot Nothing AndAlso bw.IsBusy Then
2306 'If Not busy Then RefreshTimeline() 'background処理なければ、リスト反映
2307 If rslt.type = WORKERTYPE.Timeline OrElse _
2308 rslt.type = WORKERTYPE.Reply OrElse _
2309 rslt.type = WORKERTYPE.List OrElse _
2310 rslt.type = WORKERTYPE.PublicSearch OrElse _
2311 rslt.type = WORKERTYPE.DirectMessegeRcv OrElse _
2312 rslt.type = WORKERTYPE.DirectMessegeSnt OrElse _
2313 rslt.type = WORKERTYPE.Favorites OrElse _
2314 rslt.type = WORKERTYPE.Follower OrElse _
2315 rslt.type = WORKERTYPE.FavAdd OrElse _
2316 rslt.type = WORKERTYPE.FavRemove OrElse _
2317 rslt.type = WORKERTYPE.Related OrElse _
2318 rslt.type = WORKERTYPE.UserTimeline Then
2319 RefreshTimeline(False) 'リスト反映
2322 Select Case rslt.type
2323 Case WORKERTYPE.Timeline
2324 _waitTimeline = False
2325 If Not _initial Then
2326 ' 'API使用時の取得調整は別途考える(カウント調整?)
2328 Case WORKERTYPE.Reply
2330 If rslt.newDM AndAlso Not _initial Then
2331 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
2333 Case WORKERTYPE.Favorites
2335 Case WORKERTYPE.DirectMessegeRcv
2337 Case WORKERTYPE.FavAdd, WORKERTYPE.FavRemove
2338 If _curList IsNot Nothing AndAlso _curTab IsNot Nothing Then
2339 _curList.BeginUpdate()
2340 If rslt.type = WORKERTYPE.FavRemove AndAlso _statuses.Tabs(_curTab.Text).TabType = TabUsageType.Favorites Then
2343 For i As Integer = 0 To rslt.sIds.Count - 1
2344 If _curTab.Text.Equals(rslt.tName) Then
2345 Dim idx As Integer = _statuses.Tabs(rslt.tName).IndexOf(rslt.sIds(i))
2347 Dim post As PostClass = Nothing
2348 Dim tb As TabClass = _statuses.Tabs(rslt.tName)
2349 If tb IsNot Nothing Then
2350 If tb.TabType = TabUsageType.Lists OrElse tb.TabType = TabUsageType.PublicSearch Then
2351 post = tb.Posts(rslt.sIds(i))
2353 post = _statuses.Item(rslt.sIds(i))
2355 ChangeCacheStyleRead(post.IsRead, idx, _curTab)
2357 If idx = _curItemIndex Then DispSelectedPost(True) '選択アイテム再表示
2362 _curList.EndUpdate()
2364 Case WORKERTYPE.PostMessage
2365 If rslt.retMsg = "" OrElse _
2366 rslt.retMsg.StartsWith("Outputz") OrElse _
2367 rslt.retMsg.StartsWith("OK:") OrElse _
2368 rslt.retMsg = "Warn:Status is a duplicate." Then
2369 _postTimestamps.Add(Now)
2370 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2371 For i As Integer = _postTimestamps.Count - 1 To 0 Step -1
2372 If _postTimestamps(i).CompareTo(oneHour) < 0 Then
2373 _postTimestamps.RemoveAt(i)
2377 If Not HashMgr.IsPermanent AndAlso HashMgr.UseHash <> "" Then
2378 HashMgr.ClearHashtag()
2379 Me.HashStripSplitButton.Text = "#[-]"
2380 Me.HashToggleMenuItem.Checked = False
2381 Me.HashToggleToolStripMenuItem.Checked = False
2383 SetMainWindowTitle()
2386 Dim retry As DialogResult
2388 retry = MessageBox.Show(String.Format("{0} ---> [ " & rslt.retMsg & " ]" & Environment.NewLine & """" & rslt.status.status & """" & Environment.NewLine & "{1}",
2389 My.Resources.StatusUpdateFailed1,
2390 My.Resources.StatusUpdateFailed2),
2391 "Failed to update status",
2392 MessageBoxButtons.RetryCancel,
2393 MessageBoxIcon.Question)
2394 Catch ex As Exception
2395 retry = Windows.Forms.DialogResult.Abort
2397 If retry = Windows.Forms.DialogResult.Retry Then
2398 Dim args As New GetWorkerArg()
2401 args.type = WORKERTYPE.PostMessage
2402 args.status = rslt.status
2405 If ToolStripFocusLockMenuItem.Checked Then
2406 '連投モードのときだけEnterイベントが起きないので強制的に背景色を戻す
2407 StatusText_Enter(StatusText, New EventArgs)
2411 If rslt.retMsg.Length = 0 AndAlso SettingDialog.PostAndGet Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2412 Case WORKERTYPE.Retweet
2413 If rslt.retMsg.Length = 0 Then
2414 _postTimestamps.Add(Now)
2415 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
2416 For i As Integer = _postTimestamps.Count - 1 To 0 Step -1
2417 If _postTimestamps(i).CompareTo(oneHour) < 0 Then
2418 _postTimestamps.RemoveAt(i)
2421 If Not _isActiveUserstream AndAlso SettingDialog.PostAndGet Then GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2423 Case WORKERTYPE.Follower
2424 '_waitFollower = False
2425 _itemCache = Nothing
2426 _postCache = Nothing
2427 If _curList IsNot Nothing Then _curList.Refresh()
2428 Case WORKERTYPE.PublicSearch
2429 _waitPubSearch = False
2430 Case WORKERTYPE.UserTimeline
2431 _waitUserTimeline = False
2432 Case WORKERTYPE.List
2434 Case WORKERTYPE.Related
2435 Dim tb As TabClass = _statuses.GetTabByType(TabUsageType.Related)
2436 If tb IsNot Nothing AndAlso tb.RelationTargetPost IsNot Nothing AndAlso tb.Contains(tb.RelationTargetPost.StatusId) Then
2437 For Each tp As TabPage In ListTab.TabPages
2438 If tp.Text = tb.TabName Then
2439 DirectCast(tp.Tag, DetailsListView).SelectedIndices.Add(tb.IndexOf(tb.RelationTargetPost.StatusId))
2440 DirectCast(tp.Tag, DetailsListView).Items(tb.IndexOf(tb.RelationTargetPost.StatusId)).Focused = True
2449 Private Sub RemovePostFromFavTab(ByVal ids As Int64())
2450 Dim favTabName As String = _statuses.GetTabByType(TabUsageType.Favorites).TabName
2452 If _curTab.Text.Equals(favTabName) Then
2453 If _curList.FocusedItem IsNot Nothing Then
2454 fidx = _curList.FocusedItem.Index
2455 ElseIf _curList.TopItem IsNot Nothing Then
2456 fidx = _curList.TopItem.Index
2462 For Each i As Long In ids
2463 _statuses.RemoveFavPost(i)
2465 If _curTab IsNot Nothing AndAlso _curTab.Text.Equals(favTabName) Then
2466 _itemCache = Nothing 'キャッシュ破棄
2467 _postCache = Nothing
2471 For Each tp As TabPage In ListTab.TabPages
2472 If tp.Text = favTabName Then
2473 DirectCast(tp.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(favTabName).AllCount
2477 If _curTab.Text.Equals(favTabName) Then
2479 _curList.SelectedIndices.Clear()
2480 Loop While _curList.SelectedIndices.Count > 0
2481 If _statuses.Tabs(favTabName).AllCount > 0 Then
2482 If _statuses.Tabs(favTabName).AllCount - 1 > fidx AndAlso fidx > -1 Then
2483 _curList.SelectedIndices.Add(fidx)
2485 _curList.SelectedIndices.Add(_statuses.Tabs(favTabName).AllCount - 1)
2487 If _curList.SelectedIndices.Count > 0 Then
2488 _curList.EnsureVisible(_curList.SelectedIndices(0))
2489 _curList.FocusedItem = _curList.Items(_curList.SelectedIndices(0))
2495 Private Sub GetTimeline(ByVal WkType As WORKERTYPE, ByVal fromPage As Integer, ByVal toPage As Integer, ByVal tabName As String)
2497 If Not IsNetworkAvailable() Then Exit Sub
2500 Dim args As New GetWorkerArg
2501 args.page = fromPage
2502 args.endPage = toPage
2504 args.tName = tabName
2506 Static lastTime As New Dictionary(Of WORKERTYPE, DateTime)
2507 If Not lastTime.ContainsKey(WkType) Then lastTime.Add(WkType, New DateTime)
2508 Dim period As Double = Now.Subtract(lastTime(WkType)).TotalSeconds
2509 If period > 1 OrElse period < -1 Then
2510 lastTime(WkType) = Now
2514 'Timeline取得モードの場合はReplyも同時に取得
2515 'If Not SettingDialog.UseAPI AndAlso _
2516 ' Not _initial AndAlso _
2517 ' WkType = WORKERTYPE.Timeline AndAlso _
2518 ' SettingDialog.CheckReply Then
2519 ' 'TimerReply.Enabled = False
2520 ' _mentionCounter = SettingDialog.ReplyPeriodInt
2521 ' Dim _args As New GetWorkerArg
2522 ' _args.page = fromPage
2523 ' _args.endPage = toPage
2524 ' _args.type = WORKERTYPE.Reply
2529 Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
2530 If e.Button = Windows.Forms.MouseButtons.Left Then
2532 If Me.WindowState = FormWindowState.Minimized Then
2533 Me.WindowState = FormWindowState.Normal
2539 Private Sub MyList_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
2540 MakeReplyOrDirectStatus()
2543 Private Sub FavAddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavAddToolStripMenuItem.Click, FavOpMenuItem.Click
2544 FavoriteChange(True)
2547 Private Sub FavRemoveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavRemoveToolStripMenuItem.Click, UnFavOpMenuItem.Click
2548 FavoriteChange(False)
2552 Private Sub FavoriteRetweetMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavoriteRetweetMenuItem.Click, FavoriteRetweetContextMenu.Click
2553 FavoritesRetweetOriginal()
2556 Private Sub FavoriteRetweetUnofficialMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FavoriteRetweetUnofficialMenuItem.Click, FavoriteRetweetUnofficialContextMenu.Click
2557 FavoritesRetweetUnofficial()
2560 Private Sub FavoriteChange(ByVal FavAdd As Boolean, Optional ByVal multiFavoriteChangeDialogEnable As Boolean = True)
2561 'TrueでFavAdd,FalseでFavRemove
2562 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage OrElse _curList.SelectedIndices.Count = 0 _
2563 OrElse Not Me.ExistCurrentPost Then Exit Sub
2566 If _curList.SelectedIndices.Count > 250 AndAlso FavAdd Then
2567 MessageBox.Show(My.Resources.FavoriteLimitCountText)
2568 _DoFavRetweetFlags = False
2570 ElseIf multiFavoriteChangeDialogEnable AndAlso _curList.SelectedIndices.Count > 1 Then
2572 Dim QuestionText As String = My.Resources.FavAddToolStripMenuItem_ClickText1
2573 If _DoFavRetweetFlags Then QuestionText = My.Resources.FavoriteRetweetQuestionText3
2574 If MessageBox.Show(QuestionText, My.Resources.FavAddToolStripMenuItem_ClickText2, _
2575 MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
2576 _DoFavRetweetFlags = False
2580 If MessageBox.Show(My.Resources.FavRemoveToolStripMenuItem_ClickText1, My.Resources.FavRemoveToolStripMenuItem_ClickText2, _
2581 MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
2587 Dim args As New GetWorkerArg
2588 args.ids = New List(Of Long)
2589 args.sIds = New List(Of Long)
2590 args.tName = _curTab.Text
2592 args.type = WORKERTYPE.FavAdd
2594 args.type = WORKERTYPE.FavRemove
2596 For Each idx As Integer In _curList.SelectedIndices
2597 Dim post As PostClass = GetCurTabPost(idx)
2599 If Not post.IsFav Then args.ids.Add(post.StatusId)
2601 If post.IsFav Then args.ids.Add(post.StatusId)
2604 If args.ids.Count = 0 Then
2606 StatusLabel.Text = My.Resources.FavAddToolStripMenuItem_ClickText4
2608 StatusLabel.Text = My.Resources.FavRemoveToolStripMenuItem_ClickText4
2616 Private Function GetCurTabPost(ByVal Index As Integer) As PostClass
2617 If _postCache IsNot Nothing AndAlso Index >= _itemCacheIndex AndAlso Index < _itemCacheIndex + _postCache.Length Then
2618 Return _postCache(Index - _itemCacheIndex)
2620 Return _statuses.Item(_curTab.Text, Index)
2625 Private Sub MoveToHomeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToHomeToolStripMenuItem.Click, OpenHomeOpMenuItem.Click
2626 If _curList.SelectedIndices.Count > 0 Then
2627 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).ScreenName)
2628 ElseIf _curList.SelectedIndices.Count = 0 Then
2629 OpenUriAsync("http://twitter.com/")
2633 Private Sub MoveToFavToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToFavToolStripMenuItem.Click, OpenFavOpMenuItem.Click
2634 If _curList.SelectedIndices.Count > 0 Then
2635 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).ScreenName + "/favorites")
2639 Private Sub Tween_ClientSizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ClientSizeChanged
2640 If (Not _initialLayout) AndAlso _
2641 Me.Visible AndAlso _
2642 Me.WindowState = FormWindowState.Normal Then
2644 'Dim colNo As Integer = 2
2645 'If _iconCol Then colNo = 1
2646 'Dim widthDiff As Integer = Me.ClientSize.Width - Me._mySize.Width
2647 'Dim listView As DetailsListView = CType(Me._curTab.Tag, DetailsListView)
2648 'Dim column As ColumnHeader = listView.Columns(colNo)
2649 'column.Width += widthDiff
2650 'Me.MyList_ColumnWidthChanged(listView, New ColumnWidthChangedEventArgs(colNo))
2652 _mySize = Me.ClientSize
2653 _mySpDis = Me.SplitContainer1.SplitterDistance
2654 _mySpDis3 = Me.SplitContainer3.SplitterDistance
2655 If StatusText.Multiline Then _mySpDis2 = Me.StatusText.Height
2656 _modifySettingLocal = True
2660 Private Sub MyList_ColumnClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs)
2661 If SettingDialog.SortOrderLock Then Exit Sub
2662 Dim mode As IdComparerClass.ComparerMode
2664 mode = IdComparerClass.ComparerMode.Id
2666 Select Case e.Column
2667 Case 0, 5, 6 '0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
2671 mode = IdComparerClass.ComparerMode.Nickname
2673 mode = IdComparerClass.ComparerMode.Data
2675 mode = IdComparerClass.ComparerMode.Id
2677 mode = IdComparerClass.ComparerMode.Name
2679 mode = IdComparerClass.ComparerMode.Source
2682 _statuses.ToggleSortOrder(mode)
2686 DirectCast(sender, DetailsListView).Columns.Item(0).Text = ColumnOrgText(0)
2687 DirectCast(sender, DetailsListView).Columns.Item(1).Text = ColumnText(2)
2689 For i As Integer = 0 To 7
2690 DirectCast(sender, DetailsListView).Columns.Item(i).Text = ColumnOrgText(i)
2692 DirectCast(sender, DetailsListView).Columns.Item(e.Column).Text = ColumnText(e.Column)
2695 _itemCache = Nothing
2696 _postCache = Nothing
2698 If _statuses.Tabs(_curTab.Text).AllCount > 0 AndAlso _curPost IsNot Nothing Then
2699 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_curPost.StatusId)
2701 SelectListItem(_curList, idx)
2702 _curList.EnsureVisible(idx)
2706 _modifySettingCommon = True
2709 Private Sub Tween_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
2710 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
2711 _myLoc = Me.DesktopLocation
2712 _modifySettingLocal = True
2716 Private Sub ContextMenuOperate_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuOperate.Opening
2717 If ListTab.SelectedTab Is Nothing Then Exit Sub
2718 If _statuses Is Nothing OrElse _statuses.Tabs Is Nothing OrElse Not _statuses.Tabs.ContainsKey(ListTab.SelectedTab.Text) Then Exit Sub
2719 If Not Me.ExistCurrentPost Then
2720 ReplyStripMenuItem.Enabled = False
2721 ReplyAllStripMenuItem.Enabled = False
2722 DMStripMenuItem.Enabled = False
2723 ShowProfileMenuItem.Enabled = False
2724 ShowUserTimelineContextMenuItem.Enabled = False
2725 ListManageUserContextToolStripMenuItem2.Enabled = False
2726 MoveToFavToolStripMenuItem.Enabled = False
2727 TabMenuItem.Enabled = False
2728 IDRuleMenuItem.Enabled = False
2729 ReadedStripMenuItem.Enabled = False
2730 UnreadStripMenuItem.Enabled = False
2732 ShowProfileMenuItem.Enabled = True
2733 ListManageUserContextToolStripMenuItem2.Enabled = True
2734 ReplyStripMenuItem.Enabled = True
2735 ReplyAllStripMenuItem.Enabled = True
2736 DMStripMenuItem.Enabled = True
2737 ShowUserTimelineContextMenuItem.Enabled = True
2738 MoveToFavToolStripMenuItem.Enabled = True
2739 TabMenuItem.Enabled = True
2740 IDRuleMenuItem.Enabled = True
2741 ReadedStripMenuItem.Enabled = True
2742 UnreadStripMenuItem.Enabled = True
2744 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage OrElse Not Me.ExistCurrentPost OrElse _curPost.IsDm Then
2745 FavAddToolStripMenuItem.Enabled = False
2746 FavRemoveToolStripMenuItem.Enabled = False
2747 StatusOpenMenuItem.Enabled = False
2748 FavorareMenuItem.Enabled = False
2749 ShowRelatedStatusesMenuItem.Enabled = False
2751 ReTweetStripMenuItem.Enabled = False
2752 ReTweetOriginalStripMenuItem.Enabled = False
2753 QuoteStripMenuItem.Enabled = False
2754 FavoriteRetweetContextMenu.Enabled = False
2755 FavoriteRetweetUnofficialContextMenu.Enabled = False
2756 If Me.ExistCurrentPost AndAlso _curPost.IsDm Then DeleteStripMenuItem.Enabled = True
2758 FavAddToolStripMenuItem.Enabled = True
2759 FavRemoveToolStripMenuItem.Enabled = True
2760 StatusOpenMenuItem.Enabled = True
2761 FavorareMenuItem.Enabled = True
2762 ShowRelatedStatusesMenuItem.Enabled = True 'PublicSearchの時問題出るかも
2764 If _curPost.IsMe Then
2765 ReTweetOriginalStripMenuItem.Enabled = False
2766 FavoriteRetweetContextMenu.Enabled = False
2767 DeleteStripMenuItem.Enabled = True
2769 DeleteStripMenuItem.Enabled = False
2770 If _curPost.IsProtect Then
2771 ReTweetOriginalStripMenuItem.Enabled = False
2772 ReTweetStripMenuItem.Enabled = False
2773 QuoteStripMenuItem.Enabled = False
2774 FavoriteRetweetContextMenu.Enabled = False
2775 FavoriteRetweetUnofficialContextMenu.Enabled = False
2777 ReTweetOriginalStripMenuItem.Enabled = True
2778 ReTweetStripMenuItem.Enabled = True
2779 QuoteStripMenuItem.Enabled = True
2780 FavoriteRetweetContextMenu.Enabled = True
2781 FavoriteRetweetUnofficialContextMenu.Enabled = True
2785 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.Favorites Then
2786 RefreshMoreStripMenuItem.Enabled = True
2788 RefreshMoreStripMenuItem.Enabled = False
2790 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch _
2791 OrElse Not Me.ExistCurrentPost _
2792 OrElse Not _curPost.InReplyToStatusId > 0 Then
2793 RepliedStatusOpenMenuItem.Enabled = False
2795 RepliedStatusOpenMenuItem.Enabled = True
2797 If Not Me.ExistCurrentPost OrElse _curPost.RetweetedBy = "" Then
2798 MoveToRTHomeMenuItem.Enabled = False
2800 MoveToRTHomeMenuItem.Enabled = True
2804 Private Sub ReplyStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReplyStripMenuItem.Click, ReplyOpMenuItem.Click
2805 MakeReplyOrDirectStatus(False, True)
2808 Private Sub DMStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DMStripMenuItem.Click, DmOpMenuItem.Click
2809 MakeReplyOrDirectStatus(False, False)
2812 Private Sub doStatusDelete()
2813 If _curTab Is Nothing OrElse _curList Is Nothing Then Exit Sub
2814 If _statuses.Tabs(_curTab.Text).TabType <> TabUsageType.DirectMessage Then
2815 Dim myPost As Boolean = False
2816 For Each idx As Integer In _curList.SelectedIndices
2817 If GetCurTabPost(idx).IsMe OrElse _
2818 GetCurTabPost(idx).RetweetedBy.ToLower = tw.Username.ToLower Then
2823 If Not myPost Then Exit Sub
2825 If _curList.SelectedIndices.Count = 0 Then
2830 Dim tmp As String = String.Format(My.Resources.DeleteStripMenuItem_ClickText1, Environment.NewLine)
2832 If MessageBox.Show(tmp, My.Resources.DeleteStripMenuItem_ClickText2, _
2833 MessageBoxButtons.OKCancel, _
2834 MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then Exit Sub
2837 If _curList.FocusedItem IsNot Nothing Then
2838 fidx = _curList.FocusedItem.Index
2839 ElseIf _curList.TopItem IsNot Nothing Then
2840 fidx = _curList.TopItem.Index
2846 Me.Cursor = Cursors.WaitCursor
2848 Dim rslt As Boolean = True
2849 For Each Id As Long In _statuses.GetId(_curTab.Text, _curList.SelectedIndices)
2850 Dim rtn As String = ""
2851 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then
2852 rtn = tw.RemoveDirectMessage(Id, _statuses.Item(Id))
2854 If _statuses.Item(Id).IsMe OrElse _statuses.Item(Id).RetweetedBy.ToLower = tw.Username.ToLower Then
2855 rtn = tw.RemoveStatus(Id)
2860 If rtn.Length > 0 Then
2864 _statuses.RemovePost(Id)
2869 StatusLabel.Text = My.Resources.DeleteStripMenuItem_ClickText3 '失敗
2871 StatusLabel.Text = My.Resources.DeleteStripMenuItem_ClickText4 '成功
2874 _itemCache = Nothing 'キャッシュ破棄
2875 _postCache = Nothing
2878 For Each tb As TabPage In ListTab.TabPages
2879 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
2880 If _curTab.Equals(tb) Then
2882 _curList.SelectedIndices.Clear()
2883 Loop While _curList.SelectedIndices.Count > 0
2884 If _statuses.Tabs(tb.Text).AllCount > 0 Then
2885 If _statuses.Tabs(tb.Text).AllCount - 1 > fidx AndAlso fidx > -1 Then
2886 _curList.SelectedIndices.Add(fidx)
2888 _curList.SelectedIndices.Add(_statuses.Tabs(tb.Text).AllCount - 1)
2890 If _curList.SelectedIndices.Count > 0 Then
2891 _curList.EnsureVisible(_curList.SelectedIndices(0))
2892 _curList.FocusedItem = _curList.Items(_curList.SelectedIndices(0))
2896 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2897 If SettingDialog.TabIconDisp Then
2898 If tb.ImageIndex = 0 Then tb.ImageIndex = -1 'タブアイコン
2902 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2904 Me.Cursor = Cursors.Default
2908 Private Sub DeleteStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteStripMenuItem.Click, DelOpMenuItem.Click
2912 Private Sub ReadedStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadedStripMenuItem.Click, ReadOpMenuItem.Click
2913 _curList.BeginUpdate()
2914 If SettingDialog.UnreadManage Then
2915 For Each idx As Integer In _curList.SelectedIndices
2916 _statuses.SetReadAllTab(True, _curTab.Text, idx)
2919 For Each idx As Integer In _curList.SelectedIndices
2920 ChangeCacheStyleRead(True, idx, _curTab)
2923 _curList.EndUpdate()
2924 For Each tb As TabPage In ListTab.TabPages
2925 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
2926 If SettingDialog.TabIconDisp Then
2927 If tb.ImageIndex = 0 Then tb.ImageIndex = -1 'タブアイコン
2931 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2934 Private Sub UnreadStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnreadStripMenuItem.Click, UnreadOpMenuItem.Click
2935 _curList.BeginUpdate()
2936 If SettingDialog.UnreadManage Then
2937 For Each idx As Integer In _curList.SelectedIndices
2938 _statuses.SetReadAllTab(False, _curTab.Text, idx)
2941 For Each idx As Integer In _curList.SelectedIndices
2942 ChangeCacheStyleRead(False, idx, _curTab)
2945 _curList.EndUpdate()
2946 For Each tb As TabPage In ListTab.TabPages
2947 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
2948 If SettingDialog.TabIconDisp Then
2949 If tb.ImageIndex = -1 Then tb.ImageIndex = 0 'タブアイコン
2953 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
2956 Private Sub RefreshStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshStripMenuItem.Click, RefreshOpMenuItem.Click
2960 Private Sub DoRefresh()
2961 If _curTab IsNot Nothing Then
2962 Select Case _statuses.Tabs(_curTab.Text).TabType
2963 Case TabUsageType.Mentions
2964 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
2965 Case TabUsageType.DirectMessage
2966 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
2967 Case TabUsageType.Favorites
2968 GetTimeline(WORKERTYPE.Favorites, 1, 0, "")
2969 'Case TabUsageType.Profile
2971 Case TabUsageType.PublicSearch
2973 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2974 If tb.SearchWords = "" Then Exit Sub
2975 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, _curTab.Text)
2976 Case TabUsageType.UserTimeline
2977 GetTimeline(WORKERTYPE.UserTimeline, 1, 0, _curTab.Text)
2978 Case TabUsageType.Lists
2980 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
2981 If tb.ListInfo Is Nothing OrElse tb.ListInfo.Id = 0 Then Exit Sub
2982 GetTimeline(WORKERTYPE.List, 1, 0, _curTab.Text)
2984 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2987 GetTimeline(WORKERTYPE.Timeline, 1, 0, "")
2991 Private Sub DoRefreshMore()
2993 If _curTab IsNot Nothing Then
2994 Select Case _statuses.Tabs(_curTab.Text).TabType
2995 Case TabUsageType.Mentions
2996 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
2997 Case TabUsageType.DirectMessage
2998 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
2999 Case TabUsageType.Favorites
3000 ' GetTimeline(WORKERTYPE.Favorites, -1, 0, "")
3001 Case TabUsageType.Profile
3003 Case TabUsageType.PublicSearch
3005 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
3006 If tb.SearchWords = "" Then Exit Sub
3007 GetTimeline(WORKERTYPE.PublicSearch, -1, 0, _curTab.Text)
3008 Case TabUsageType.UserTimeline
3009 GetTimeline(WORKERTYPE.UserTimeline, -1, 0, _curTab.Text)
3010 Case TabUsageType.Lists
3012 Dim tb As TabClass = _statuses.Tabs(_curTab.Text)
3013 If tb.ListInfo Is Nothing OrElse tb.ListInfo.Id = 0 Then Exit Sub
3014 GetTimeline(WORKERTYPE.List, -1, 0, _curTab.Text)
3016 GetTimeline(WORKERTYPE.Timeline, -1, 0, "")
3019 GetTimeline(WORKERTYPE.Timeline, -1, 0, "")
3023 Private Sub SettingStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingStripMenuItem.Click, SettingFileMenuItem.Click
3024 Dim result As DialogResult
3025 Dim uid As String = tw.Username.ToLower
3028 result = SettingDialog.ShowDialog()
3029 Catch ex As Exception
3033 If result = Windows.Forms.DialogResult.OK Then
3034 SyncLock _syncObject
3036 ' If SettingDialog.TimelinePeriodInt > 0 Then
3037 ' _homeCounterAdjuster = 0
3039 'Catch ex As Exception
3040 ' ex.Data("Instance") = "Set Timers"
3041 ' ex.Data("IsTerminatePermission") = False
3044 'tw.CountApi = SettingDialog.CountApi
3045 'tw.CountApiReply = SettingDialog.CountApiReply
3046 tw.TinyUrlResolve = SettingDialog.TinyUrlResolve
3047 tw.RestrictFavCheck = SettingDialog.RestrictFavCheck
3048 tw.ReadOwnPost = SettingDialog.ReadOwnPost
3049 tw.UseSsl = SettingDialog.UseSsl
3050 ShortUrl.IsResolve = SettingDialog.TinyUrlResolve
3051 ShortUrl.BitlyId = SettingDialog.BitlyUser
3052 ShortUrl.BitlyKey = SettingDialog.BitlyPwd
3053 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl
3054 HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl
3056 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, _
3057 SettingDialog.SelectedProxyType, _
3058 SettingDialog.ProxyAddress, _
3059 SettingDialog.ProxyPort, _
3060 SettingDialog.ProxyUser, _
3061 SettingDialog.ProxyPassword)
3063 If SettingDialog.TabIconDisp Then
3064 RemoveHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
3065 ListTab.DrawMode = TabDrawMode.Normal
3066 ListTab.ImageList = Me.TabImage
3068 RemoveHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
3069 AddHandler ListTab.DrawItem, AddressOf ListTab_DrawItem
3070 ListTab.DrawMode = TabDrawMode.OwnerDrawFixed
3071 ListTab.ImageList = Nothing
3073 Catch ex As Exception
3074 ex.Data("Instance") = "ListTab(TabIconDisp)"
3075 ex.Data("IsTerminatePermission") = False
3080 If Not SettingDialog.UnreadManage Then
3081 ReadedStripMenuItem.Enabled = False
3082 UnreadStripMenuItem.Enabled = False
3083 If SettingDialog.TabIconDisp Then
3084 For Each myTab As TabPage In ListTab.TabPages
3085 myTab.ImageIndex = -1
3089 ReadedStripMenuItem.Enabled = True
3090 UnreadStripMenuItem.Enabled = True
3092 Catch ex As Exception
3093 ex.Data("Instance") = "ListTab(UnreadManage)"
3094 ex.Data("IsTerminatePermission") = False
3099 For Each mytab As TabPage In ListTab.TabPages
3100 Dim lst As DetailsListView = DirectCast(mytab.Tag, DetailsListView)
3101 lst.GridLines = SettingDialog.ShowGrid
3103 Catch ex As Exception
3104 ex.Data("Instance") = "ListTab(ShowGrid)"
3105 ex.Data("IsTerminatePermission") = False
3109 PlaySoundMenuItem.Checked = SettingDialog.PlaySound
3110 Me.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound
3111 _fntUnread = SettingDialog.FontUnread
3112 _clUnread = SettingDialog.ColorUnread
3113 _fntReaded = SettingDialog.FontReaded
3114 _clReaded = SettingDialog.ColorReaded
3115 _clFav = SettingDialog.ColorFav
3116 _clOWL = SettingDialog.ColorOWL
3117 _clRetweet = SettingDialog.ColorRetweet
3118 _fntDetail = SettingDialog.FontDetail
3119 _clDetail = SettingDialog.ColorDetail
3120 _clDetailLink = SettingDialog.ColorDetailLink
3121 _clDetailBackcolor = SettingDialog.ColorDetailBackcolor
3122 _clSelf = SettingDialog.ColorSelf
3123 _clAtSelf = SettingDialog.ColorAtSelf
3124 _clTarget = SettingDialog.ColorTarget
3125 _clAtTarget = SettingDialog.ColorAtTarget
3126 _clAtFromTarget = SettingDialog.ColorAtFromTarget
3127 _clAtTo = SettingDialog.ColorAtTo
3128 _clListBackcolor = SettingDialog.ColorListBackcolor
3129 _clInputBackcolor = SettingDialog.ColorInputBackcolor
3130 _clInputFont = SettingDialog.ColorInputFont
3131 _fntInputFont = SettingDialog.FontInputFont
3133 If StatusText.Focused Then StatusText.BackColor = _clInputBackcolor
3134 StatusText.Font = _fntInputFont
3135 StatusText.ForeColor = _clInputFont
3136 Catch ex As Exception
3137 MessageBox.Show(ex.Message)
3140 _brsForeColorUnread.Dispose()
3141 _brsForeColorReaded.Dispose()
3142 _brsForeColorFav.Dispose()
3143 _brsForeColorOWL.Dispose()
3144 _brsForeColorRetweet.Dispose()
3145 _brsForeColorUnread = New SolidBrush(_clUnread)
3146 _brsForeColorReaded = New SolidBrush(_clReaded)
3147 _brsForeColorFav = New SolidBrush(_clFav)
3148 _brsForeColorOWL = New SolidBrush(_clOWL)
3149 _brsForeColorRetweet = New SolidBrush(_clRetweet)
3150 _brsBackColorMine.Dispose()
3151 _brsBackColorAt.Dispose()
3152 _brsBackColorYou.Dispose()
3153 _brsBackColorAtYou.Dispose()
3154 _brsBackColorAtFromTarget.Dispose()
3155 _brsBackColorAtTo.Dispose()
3156 _brsBackColorNone.Dispose()
3157 _brsBackColorMine = New SolidBrush(_clSelf)
3158 _brsBackColorAt = New SolidBrush(_clAtSelf)
3159 _brsBackColorYou = New SolidBrush(_clTarget)
3160 _brsBackColorAtYou = New SolidBrush(_clAtTarget)
3161 _brsBackColorAtFromTarget = New SolidBrush(_clAtFromTarget)
3162 _brsBackColorAtTo = New SolidBrush(_clAtTo)
3163 _brsBackColorNone = New SolidBrush(_clListBackcolor)
3165 If SettingDialog.IsMonospace Then
3166 detailHtmlFormatHeader = detailHtmlFormatMono1
3167 detailHtmlFormatFooter = detailHtmlFormatMono7
3169 detailHtmlFormatHeader = detailHtmlFormat1
3170 detailHtmlFormatFooter = detailHtmlFormat7
3172 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
3173 If SettingDialog.IsMonospace Then
3174 detailHtmlFormatHeader += detailHtmlFormatMono6
3176 detailHtmlFormatHeader += detailHtmlFormat6
3178 Catch ex As Exception
3179 ex.Data("Instance") = "Font"
3180 ex.Data("IsTerminatePermission") = False
3184 _statuses.SetUnreadManage(SettingDialog.UnreadManage)
3185 Catch ex As Exception
3186 ex.Data("Instance") = "_statuses"
3187 ex.Data("IsTerminatePermission") = False
3192 For Each tb As TabPage In ListTab.TabPages
3193 If SettingDialog.TabIconDisp Then
3194 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
3200 If tb.Tag IsNot Nothing AndAlso tb.Controls.Count > 0 Then
3201 DirectCast(tb.Tag, DetailsListView).Font = _fntReaded
3202 DirectCast(tb.Tag, DetailsListView).BackColor = _clListBackcolor
3205 Catch ex As Exception
3206 ex.Data("Instance") = "ListTab(TabIconDisp no2)"
3207 ex.Data("IsTerminatePermission") = False
3210 SetMainWindowTitle()
3213 _itemCache = Nothing
3214 _postCache = Nothing
3215 If _curList IsNot Nothing Then _curList.Refresh()
3218 Outputz.Key = SettingDialog.OutputzKey
3219 Outputz.Enabled = SettingDialog.OutputzEnabled
3220 Select Case SettingDialog.OutputzUrlmode
3221 Case OutputzUrlmode.twittercom
3222 Outputz.OutUrl = "http://twitter.com/"
3223 Case OutputzUrlmode.twittercomWithUsername
3224 Outputz.OutUrl = "http://twitter.com/" + tw.Username
3227 _hookGlobalHotkey.UnregisterAllOriginalHotkey()
3228 If SettingDialog.HotkeyEnabled Then
3229 '''グローバルホットキーの登録。設定で変更可能にするかも
3230 Dim modKey As HookGlobalHotkey.ModKeys = HookGlobalHotkey.ModKeys.None
3231 If (SettingDialog.HotkeyMod And Keys.Alt) = Keys.Alt Then modKey = modKey Or HookGlobalHotkey.ModKeys.Alt
3232 If (SettingDialog.HotkeyMod And Keys.Control) = Keys.Control Then modKey = modKey Or HookGlobalHotkey.ModKeys.Ctrl
3233 If (SettingDialog.HotkeyMod And Keys.Shift) = Keys.Shift Then modKey = modKey Or HookGlobalHotkey.ModKeys.Shift
3234 If (SettingDialog.HotkeyMod And Keys.LWin) = Keys.LWin Then modKey = modKey Or HookGlobalHotkey.ModKeys.Win
3236 _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey)
3239 If uid <> tw.Username Then Me.doGetFollowersMenu()
3241 SetImageServiceCombo()
3244 StatusText_TextChanged(Nothing, Nothing)
3245 Catch ex As Exception
3251 Twitter.AccountState = ACCOUNT_STATE.Valid
3253 Me.TopMost = SettingDialog.AlwaysTop
3254 SaveConfigsAll(False)
3257 Private Sub PostBrowser_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles PostBrowser.Navigated
3258 If e.Url.AbsoluteUri <> "about:blank" Then
3260 OpenUriAsync(e.Url.OriginalString)
3264 Private Sub PostBrowser_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles PostBrowser.Navigating
3265 If e.Url.Scheme = "data" Then
3266 StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&")
3267 ElseIf e.Url.AbsoluteUri <> "about:blank" Then
3270 If e.Url.AbsoluteUri.StartsWith("http://twitter.com/search?q=%23") OrElse _
3271 e.Url.AbsoluteUri.StartsWith("https://twitter.com/search?q=%23") Then
3273 Dim urlStr As String = HttpUtility.UrlDecode(e.Url.AbsoluteUri)
3274 Dim hash As String = urlStr.Substring(urlStr.IndexOf("#"))
3275 HashSupl.AddItem(hash)
3276 HashMgr.AddHashToHistory(hash.Trim, False)
3277 AddNewTabForSearch(hash)
3280 Dim m As Match = Regex.Match(e.Url.AbsoluteUri, "^https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)$")
3281 If m.Success AndAlso IsTwitterId(m.Result("${ScreenName}")) Then
3282 ' Ctrlを押しながらリンクをクリックした場合は設定と逆の動作をする
3283 If SettingDialog.OpenUserTimeline Then
3284 If My.Computer.Keyboard.CtrlKeyDown Then
3285 OpenUriAsync(e.Url.OriginalString)
3287 Me.AddNewTabForUserTimeline(m.Result("${ScreenName}"))
3290 If My.Computer.Keyboard.CtrlKeyDown Then
3291 Me.AddNewTabForUserTimeline(m.Result("${ScreenName}"))
3293 OpenUriAsync(e.Url.OriginalString)
3297 OpenUriAsync(e.Url.OriginalString)
3303 Public Sub AddNewTabForSearch(ByVal searchWord As String)
3304 '同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了
3305 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.PublicSearch)
3306 If tb.SearchWords = searchWord AndAlso tb.SearchLang = "" Then
3307 For Each tp As TabPage In ListTab.TabPages
3308 If tb.TabName = tp.Text Then
3309 ListTab.SelectedTab = tp
3316 Dim tabName As String = searchWord
3317 For i As Integer = 0 To 100
3318 If _statuses.ContainsTab(tabName) Then
3325 AddNewTab(tabName, False, TabUsageType.PublicSearch)
3326 _statuses.AddTab(tabName, TabUsageType.PublicSearch, Nothing)
3328 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
3330 Dim cmb As ComboBox = DirectCast(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), ComboBox)
3331 cmb.Items.Add(searchWord)
3332 cmb.Text = searchWord
3335 Me.SearchButton_Click(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), Nothing)
3338 Private Sub ShowUserTimeline()
3339 If Not Me.ExistCurrentPost Then Exit Sub
3340 AddNewTabForUserTimeline(_curPost.ScreenName)
3343 Public Sub AddNewTabForUserTimeline(ByVal user As String)
3344 '同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了
3345 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.UserTimeline)
3346 If tb.User = user Then
3347 For Each tp As TabPage In ListTab.TabPages
3348 If tb.TabName = tp.Text Then
3349 ListTab.SelectedTab = tp
3356 Dim tabName As String = "user:" + user
3357 While _statuses.ContainsTab(tabName)
3361 _statuses.AddTab(tabName, TabUsageType.UserTimeline, Nothing)
3362 _statuses.Tabs(tabName).User = user
3363 AddNewTab(tabName, False, TabUsageType.UserTimeline)
3365 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
3369 GetTimeline(WORKERTYPE.UserTimeline, 1, 0, tabName)
3372 Public Function AddNewTab(ByVal tabName As String, ByVal startup As Boolean, ByVal tabType As TabUsageType, Optional ByVal listInfo As ListElement = Nothing) As Boolean
3374 For Each tb As TabPage In ListTab.TabPages
3375 If tb.Text = tabName Then Return False
3379 If tabName = My.Resources.AddNewTabText1 Then Return False
3383 If tabType = TabUsageType.DirectMessage OrElse _
3384 tabType = TabUsageType.Favorites OrElse _
3385 tabType = TabUsageType.Home OrElse _
3386 tabType = TabUsageType.Mentions OrElse _
3387 tabType = TabUsageType.Related Then
3388 If _statuses.GetTabByType(tabType) IsNot Nothing Then Return False
3392 Dim _tabPage As TabPage = New TabPage
3393 Dim _listCustom As DetailsListView = New DetailsListView
3394 Dim _colHd1 As ColumnHeader = New ColumnHeader() 'アイコン
3395 Dim _colHd2 As ColumnHeader = New ColumnHeader() 'ニックネーム
3396 Dim _colHd3 As ColumnHeader = New ColumnHeader() '本文
3397 Dim _colHd4 As ColumnHeader = New ColumnHeader() '日付
3398 Dim _colHd5 As ColumnHeader = New ColumnHeader() 'ユーザID
3399 Dim _colHd6 As ColumnHeader = New ColumnHeader() '未読
3400 Dim _colHd7 As ColumnHeader = New ColumnHeader() 'マーク&プロテクト
3401 Dim _colHd8 As ColumnHeader = New ColumnHeader() 'ソース
3403 Dim cnt As Integer = ListTab.TabPages.Count
3405 '''ToDo:Create and set controls follow tabtypes
3407 Me.SplitContainer1.Panel1.SuspendLayout()
3408 Me.SplitContainer1.Panel2.SuspendLayout()
3409 Me.SplitContainer1.SuspendLayout()
3410 Me.ListTab.SuspendLayout()
3413 _tabPage.SuspendLayout()
3416 Dim label As Label = Nothing
3417 If tabType = TabUsageType.UserTimeline OrElse tabType = TabUsageType.Lists Then
3419 label.Dock = DockStyle.Top
3420 label.Name = "labelUser"
3421 If tabType = TabUsageType.Lists Then
3422 label.Text = listInfo.ToString()
3424 label.Text = _statuses.Tabs(tabName).User + "'s Timeline"
3426 label.TextAlign = ContentAlignment.MiddleLeft
3427 Using tmpComboBox As New ComboBox()
3428 label.Height = tmpComboBox.Height
3430 _tabPage.Controls.Add(label)
3434 Dim pnl As Panel = Nothing
3435 If tabType = TabUsageType.PublicSearch Then
3438 Dim lbl As New Label
3439 Dim cmb As New ComboBox
3440 Dim btn As New Button
3441 Dim cmbLang As New ComboBox
3445 pnl.Controls.Add(cmb)
3446 pnl.Controls.Add(cmbLang)
3447 pnl.Controls.Add(btn)
3448 pnl.Controls.Add(lbl)
3449 pnl.Name = "panelSearch"
3450 pnl.Dock = DockStyle.Top
3451 pnl.Height = cmb.Height
3452 AddHandler pnl.Enter, AddressOf SearchControls_Enter
3453 AddHandler pnl.Leave, AddressOf SearchControls_Leave
3456 cmb.Anchor = AnchorStyles.Left Or AnchorStyles.Right
3457 cmb.Dock = DockStyle.Fill
3458 cmb.Name = "comboSearch"
3459 cmb.DropDownStyle = ComboBoxStyle.DropDown
3460 cmb.ImeMode = Windows.Forms.ImeMode.NoControl
3462 cmb.AutoCompleteMode = AutoCompleteMode.None
3464 If _statuses.ContainsTab(tabName) Then
3465 cmb.Items.Add(_statuses.Tabs(tabName).SearchWords)
3466 cmb.Text = _statuses.Tabs(tabName).SearchWords
3470 cmbLang.Anchor = AnchorStyles.Left Or AnchorStyles.Right
3471 cmbLang.Dock = DockStyle.Right
3473 cmbLang.Name = "comboLang"
3474 cmbLang.DropDownStyle = ComboBoxStyle.DropDownList
3475 cmbLang.TabStop = False
3476 cmbLang.Items.Add("")
3477 cmbLang.Items.Add("ja")
3478 cmbLang.Items.Add("en")
3479 cmbLang.Items.Add("ar")
3480 cmbLang.Items.Add("da")
3481 cmbLang.Items.Add("nl")
3482 cmbLang.Items.Add("fa")
3483 cmbLang.Items.Add("fi")
3484 cmbLang.Items.Add("fr")
3485 cmbLang.Items.Add("de")
3486 cmbLang.Items.Add("hu")
3487 cmbLang.Items.Add("is")
3488 cmbLang.Items.Add("it")
3489 cmbLang.Items.Add("no")
3490 cmbLang.Items.Add("pl")
3491 cmbLang.Items.Add("pt")
3492 cmbLang.Items.Add("ru")
3493 cmbLang.Items.Add("es")
3494 cmbLang.Items.Add("sv")
3495 cmbLang.Items.Add("th")
3496 If _statuses.ContainsTab(tabName) Then cmbLang.Text = _statuses.Tabs(tabName).SearchLang
3498 lbl.Text = "Search(C-S-f)"
3500 lbl.Dock = DockStyle.Left
3502 lbl.Height = cmb.Height
3503 lbl.TextAlign = ContentAlignment.MiddleLeft
3506 btn.Name = "buttonSearch"
3507 btn.UseVisualStyleBackColor = True
3508 btn.Dock = DockStyle.Right
3510 AddHandler btn.Click, AddressOf SearchButton_Click
3513 Me.ListTab.Controls.Add(_tabPage)
3514 _tabPage.Controls.Add(_listCustom)
3516 If tabType = TabUsageType.PublicSearch Then _tabPage.Controls.Add(pnl)
3517 If tabType = TabUsageType.UserTimeline OrElse tabType = TabUsageType.Lists Then _tabPage.Controls.Add(label)
3519 _tabPage.Location = New Point(4, 4)
3520 _tabPage.Name = "CTab" + cnt.ToString()
3521 _tabPage.Size = New Size(380, 260)
3522 _tabPage.TabIndex = 2 + cnt
3523 _tabPage.Text = tabName
3524 _tabPage.UseVisualStyleBackColor = True
3526 _listCustom.AllowColumnReorder = True
3527 If Not _iconCol Then
3528 _listCustom.Columns.AddRange(New ColumnHeader() {_colHd1, _colHd2, _colHd3, _colHd4, _colHd5, _colHd6, _colHd7, _colHd8})
3530 _listCustom.Columns.AddRange(New ColumnHeader() {_colHd1, _colHd3})
3532 _listCustom.ContextMenuStrip = Me.ContextMenuOperate
3533 _listCustom.Dock = DockStyle.Fill
3534 _listCustom.FullRowSelect = True
3535 _listCustom.HideSelection = False
3536 _listCustom.Location = New Point(0, 0)
3537 _listCustom.Margin = New Padding(0)
3538 _listCustom.Name = "CList" + Environment.TickCount.ToString()
3539 _listCustom.ShowItemToolTips = True
3540 _listCustom.Size = New Size(380, 260)
3541 _listCustom.UseCompatibleStateImageBehavior = False
3542 _listCustom.View = View.Details
3543 _listCustom.OwnerDraw = True
3544 _listCustom.VirtualMode = True
3545 _listCustom.Font = _fntReaded
3546 _listCustom.BackColor = _clListBackcolor
3548 _listCustom.GridLines = SettingDialog.ShowGrid
3549 _listCustom.AllowDrop = True
3551 AddHandler _listCustom.SelectedIndexChanged, AddressOf MyList_SelectedIndexChanged
3552 AddHandler _listCustom.MouseDoubleClick, AddressOf MyList_MouseDoubleClick
3553 AddHandler _listCustom.ColumnClick, AddressOf MyList_ColumnClick
3554 AddHandler _listCustom.DrawColumnHeader, AddressOf MyList_DrawColumnHeader
3555 AddHandler _listCustom.DragDrop, AddressOf TweenMain_DragDrop
3556 AddHandler _listCustom.DragOver, AddressOf TweenMain_DragOver
3557 AddHandler _listCustom.DrawItem, AddressOf MyList_DrawItem
3558 AddHandler _listCustom.MouseClick, AddressOf MyList_MouseClick
3559 AddHandler _listCustom.ColumnReordered, AddressOf MyList_ColumnReordered
3560 AddHandler _listCustom.ColumnWidthChanged, AddressOf MyList_ColumnWidthChanged
3561 AddHandler _listCustom.CacheVirtualItems, AddressOf MyList_CacheVirtualItems
3562 AddHandler _listCustom.RetrieveVirtualItem, AddressOf MyList_RetrieveVirtualItem
3563 AddHandler _listCustom.DrawSubItem, AddressOf MyList_DrawSubItem
3564 AddHandler _listCustom.HScrolled, AddressOf MyList_HScrolled
3567 _colHd1.Text = ColumnText(0)
3569 _colHd2.Text = ColumnText(1)
3571 _colHd3.Text = ColumnText(2)
3573 _colHd4.Text = ColumnText(3)
3575 _colHd5.Text = ColumnText(4)
3577 _colHd6.Text = ColumnText(5)
3579 _colHd7.Text = ColumnText(6)
3581 _colHd8.Text = ColumnText(7)
3584 If _statuses.IsDistributableTab(tabName) Then TabDialog.AddTab(tabName)
3586 _listCustom.SmallImageList = New ImageList()
3588 _listCustom.SmallImageList.ImageSize = New Size(_iconSz, _iconSz)
3591 Dim dispOrder(7) As Integer
3593 For i As Integer = 0 To _curList.Columns.Count - 1
3594 For j As Integer = 0 To _curList.Columns.Count - 1
3595 If _curList.Columns(j).DisplayIndex = i Then
3601 For i As Integer = 0 To _curList.Columns.Count - 1
3602 _listCustom.Columns(i).Width = _curList.Columns(i).Width
3603 _listCustom.Columns(dispOrder(i)).DisplayIndex = i
3607 _listCustom.Columns(0).Width = _cfgLocal.Width1
3608 _listCustom.Columns(1).Width = _cfgLocal.Width3
3609 _listCustom.Columns(0).DisplayIndex = 0
3610 _listCustom.Columns(1).DisplayIndex = 1
3612 For i As Integer = 0 To 7
3613 If _cfgLocal.DisplayIndex1 = i Then
3615 ElseIf _cfgLocal.DisplayIndex2 = i Then
3617 ElseIf _cfgLocal.DisplayIndex3 = i Then
3619 ElseIf _cfgLocal.DisplayIndex4 = i Then
3621 ElseIf _cfgLocal.DisplayIndex5 = i Then
3623 ElseIf _cfgLocal.DisplayIndex6 = i Then
3625 ElseIf _cfgLocal.DisplayIndex7 = i Then
3627 ElseIf _cfgLocal.DisplayIndex8 = i Then
3631 _listCustom.Columns(0).Width = _cfgLocal.Width1
3632 _listCustom.Columns(1).Width = _cfgLocal.Width2
3633 _listCustom.Columns(2).Width = _cfgLocal.Width3
3634 _listCustom.Columns(3).Width = _cfgLocal.Width4
3635 _listCustom.Columns(4).Width = _cfgLocal.Width5
3636 _listCustom.Columns(5).Width = _cfgLocal.Width6
3637 _listCustom.Columns(6).Width = _cfgLocal.Width7
3638 _listCustom.Columns(7).Width = _cfgLocal.Width8
3639 For i As Integer = 0 To 7
3640 _listCustom.Columns(dispOrder(i)).DisplayIndex = i
3645 If tabType = TabUsageType.PublicSearch Then pnl.ResumeLayout(False)
3647 _tabPage.ResumeLayout(False)
3649 Me.SplitContainer1.Panel1.ResumeLayout(False)
3650 Me.SplitContainer1.Panel2.ResumeLayout(False)
3651 Me.SplitContainer1.ResumeLayout(False)
3652 Me.ListTab.ResumeLayout(False)
3653 Me.ResumeLayout(False)
3655 _tabPage.Tag = _listCustom
3659 Public Function RemoveSpecifiedTab(ByVal TabName As String, ByVal confirm As Boolean) As Boolean
3660 Dim idx As Integer = 0
3661 For idx = 0 To ListTab.TabPages.Count - 1
3662 If ListTab.TabPages(idx).Text = TabName Then Exit For
3665 If _statuses.IsDefaultTab(TabName) Then Return False
3668 Dim tmp As String = String.Format(My.Resources.RemoveSpecifiedTabText1, Environment.NewLine)
3669 If MessageBox.Show(tmp, TabName + " " + My.Resources.RemoveSpecifiedTabText2, _
3670 MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Cancel Then
3675 SetListProperty() '他のタブに列幅等を反映
3677 Dim tabType As TabUsageType = _statuses.Tabs(TabName).TabType
3680 Me.SplitContainer1.Panel1.SuspendLayout()
3681 Me.SplitContainer1.Panel2.SuspendLayout()
3682 Me.SplitContainer1.SuspendLayout()
3683 Me.ListTab.SuspendLayout()
3686 Dim _tabPage As TabPage = ListTab.TabPages(idx)
3687 Dim _listCustom As DetailsListView = DirectCast(_tabPage.Tag, DetailsListView)
3688 _tabPage.Tag = Nothing
3690 _tabPage.SuspendLayout()
3692 If Me.ListTab.SelectedTab Is Me.ListTab.TabPages(idx) Then
3693 Me.ListTab.SelectTab(If(Me._beforeSelectedTab IsNot Nothing AndAlso Me.ListTab.TabPages.Contains(Me._beforeSelectedTab), Me._beforeSelectedTab, Me.ListTab.TabPages(0)))
3695 Me.ListTab.Controls.Remove(_tabPage)
3697 Dim pnl As Control = Nothing
3698 If tabType = TabUsageType.PublicSearch Then
3699 pnl = _tabPage.Controls("panelSearch")
3700 For Each ctrl As Control In pnl.Controls
3701 If ctrl.Name = "buttonSearch" Then
3702 RemoveHandler ctrl.Click, AddressOf SearchButton_Click
3704 RemoveHandler ctrl.Enter, AddressOf SearchControls_Enter
3705 RemoveHandler ctrl.Leave, AddressOf SearchControls_Leave
3706 pnl.Controls.Remove(ctrl)
3709 _tabPage.Controls.Remove(pnl)
3712 _tabPage.Controls.Remove(_listCustom)
3713 _listCustom.Columns.Clear()
3714 _listCustom.ContextMenuStrip = Nothing
3716 RemoveHandler _listCustom.SelectedIndexChanged, AddressOf MyList_SelectedIndexChanged
3717 RemoveHandler _listCustom.MouseDoubleClick, AddressOf MyList_MouseDoubleClick
3718 RemoveHandler _listCustom.ColumnClick, AddressOf MyList_ColumnClick
3719 RemoveHandler _listCustom.DrawColumnHeader, AddressOf MyList_DrawColumnHeader
3720 RemoveHandler _listCustom.DragDrop, AddressOf TweenMain_DragDrop
3721 RemoveHandler _listCustom.DragOver, AddressOf TweenMain_DragOver
3722 RemoveHandler _listCustom.DrawItem, AddressOf MyList_DrawItem
3723 RemoveHandler _listCustom.MouseClick, AddressOf MyList_MouseClick
3724 RemoveHandler _listCustom.ColumnReordered, AddressOf MyList_ColumnReordered
3725 RemoveHandler _listCustom.ColumnWidthChanged, AddressOf MyList_ColumnWidthChanged
3726 RemoveHandler _listCustom.CacheVirtualItems, AddressOf MyList_CacheVirtualItems
3727 RemoveHandler _listCustom.RetrieveVirtualItem, AddressOf MyList_RetrieveVirtualItem
3728 RemoveHandler _listCustom.DrawSubItem, AddressOf MyList_DrawSubItem
3729 RemoveHandler _listCustom.HScrolled, AddressOf MyList_HScrolled
3731 TabDialog.RemoveTab(TabName)
3733 _listCustom.SmallImageList = Nothing
3734 _listCustom.ListViewItemSorter = Nothing
3737 If _curTab.Equals(_tabPage) Then
3743 _itemCache = Nothing
3744 _itemCacheIndex = -1
3745 _postCache = Nothing
3747 _tabPage.ResumeLayout(False)
3749 Me.SplitContainer1.Panel1.ResumeLayout(False)
3750 Me.SplitContainer1.Panel2.ResumeLayout(False)
3751 Me.SplitContainer1.ResumeLayout(False)
3752 Me.ListTab.ResumeLayout(False)
3753 Me.ResumeLayout(False)
3757 _listCustom.Dispose()
3758 _statuses.RemoveTab(TabName)
3760 For Each tp As TabPage In ListTab.TabPages
3761 Dim lst As DetailsListView = DirectCast(tp.Tag, DetailsListView)
3762 If lst.VirtualListSize <> _statuses.Tabs(tp.Text).AllCount Then
3763 lst.VirtualListSize = _statuses.Tabs(tp.Text).AllCount
3770 Private Sub ListTab_Deselected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles ListTab.Deselected
3771 _itemCache = Nothing
3772 _itemCacheIndex = -1
3773 _postCache = Nothing
3774 _beforeSelectedTab = e.TabPage
3777 Private Sub ListTab_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseMove
3779 Dim cpos As New Point(e.X, e.Y)
3781 If e.Button = Windows.Forms.MouseButtons.Left AndAlso _tabDrag Then
3782 Dim tn As String = ""
3783 Dim dragEnableRectangle As New Rectangle(CInt(_tabMouseDownPoint.X - (SystemInformation.DragSize.Width / 2)), CInt(_tabMouseDownPoint.Y - (SystemInformation.DragSize.Height / 2)), SystemInformation.DragSize.Width, SystemInformation.DragSize.Height)
3784 If Not dragEnableRectangle.Contains(e.Location) Then
3785 'タブが多段の場合にはMouseDownの前の段階で選択されたタブの段が変わっているので、このタイミングでカーソルの位置からタブを判定出来ない。
3786 tn = ListTab.SelectedTab.Text
3789 If tn = "" Then Exit Sub
3791 For Each tb As TabPage In ListTab.TabPages
3792 If tb.Text = tn Then
3793 ListTab.DoDragDrop(tb, DragDropEffects.All)
3801 For i As Integer = 0 To ListTab.TabPages.Count - 1
3802 Dim rect As Rectangle = ListTab.GetTabRect(i)
3803 If rect.Left <= cpos.X And cpos.X <= rect.Right And _
3804 rect.Top <= cpos.Y And cpos.Y <= rect.Bottom Then
3805 _rclickTabName = ListTab.TabPages(i).Text
3811 Private Sub ListTab_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListTab.SelectedIndexChanged
3814 SetMainWindowTitle()
3816 If ListTab.Focused OrElse DirectCast(ListTab.SelectedTab.Tag, Control).Focused Then Me.Tag = ListTab.Tag
3817 TabMenuControl(ListTab.SelectedTab.Text)
3820 Private Sub SetListProperty()
3822 If _curList Is Nothing Then Exit Sub
3823 If Not _isColumnChanged Then Exit Sub
3825 Dim dispOrder(_curList.Columns.Count - 1) As Integer
3826 For i As Integer = 0 To _curList.Columns.Count - 1
3827 For j As Integer = 0 To _curList.Columns.Count - 1
3828 If _curList.Columns(j).DisplayIndex = i Then
3836 For Each tb As TabPage In ListTab.TabPages
3837 If Not tb.Equals(_curTab) Then
3838 If tb.Tag IsNot Nothing AndAlso tb.Controls.Count > 0 Then
3839 Dim lst As DetailsListView = DirectCast(tb.Tag, DetailsListView)
3840 For i As Integer = 0 To lst.Columns.Count - 1
3841 lst.Columns(dispOrder(i)).DisplayIndex = i
3842 lst.Columns(i).Width = _curList.Columns(i).Width
3848 _isColumnChanged = False
3851 Private Sub PostBrowser_StatusTextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles PostBrowser.StatusTextChanged
3852 If PostBrowser.StatusText.StartsWith("http") OrElse PostBrowser.StatusText.StartsWith("ftp") _
3853 OrElse PostBrowser.StatusText.StartsWith("data") Then
3854 StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&")
3856 If PostBrowser.StatusText = "" Then
3861 Private Sub StatusText_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles StatusText.KeyPress
3862 If e.KeyChar = "@" Then
3863 If Not SettingDialog.UseAtIdSupplement Then Exit Sub
3865 ShowSuplDialog(StatusText, AtIdSupl)
3867 ElseIf e.KeyChar = "#" Then
3868 If Not SettingDialog.UseHashSupplement Then Exit Sub
3869 ShowSuplDialog(StatusText, HashSupl)
3874 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement)
3875 ShowSuplDialog(owner, dialog, 0, "")
3878 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement, ByVal offset As Integer)
3879 ShowSuplDialog(owner, dialog, offset, "")
3882 Public Overloads Sub ShowSuplDialog(ByVal owner As TextBox, ByVal dialog As AtIdSupplement, ByVal offset As Integer, ByVal startswith As String)
3883 dialog.StartsWith = startswith
3884 If dialog.Visible Then
3889 Me.TopMost = SettingDialog.AlwaysTop
3890 Dim selStart As Integer = owner.SelectionStart
3891 Dim fHalf As String = ""
3892 Dim eHalf As String = ""
3893 If dialog.DialogResult = Windows.Forms.DialogResult.OK Then
3894 If dialog.inputText <> "" Then
3895 If selStart > 0 Then
3896 fHalf = owner.Text.Substring(0, selStart - offset)
3898 If selStart < owner.Text.Length Then
3899 eHalf = owner.Text.Substring(selStart)
3901 owner.Text = fHalf + dialog.inputText + eHalf
3902 owner.SelectionStart = selStart + dialog.inputText.Length
3905 If selStart > 0 Then
3906 fHalf = owner.Text.Substring(0, selStart)
3908 If selStart < owner.Text.Length Then
3909 eHalf = owner.Text.Substring(selStart)
3911 owner.Text = fHalf + eHalf
3912 If selStart > 0 Then
3913 owner.SelectionStart = selStart
3919 Private Sub StatusText_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StatusText.KeyUp
3921 If Not e.Alt AndAlso Not e.Control AndAlso Not e.Shift Then
3922 If e.KeyCode = Keys.Space OrElse e.KeyCode = Keys.ProcessKey Then
3923 Dim isSpace As Boolean = False
3924 For Each c As Char In StatusText.Text.ToCharArray
3925 If c = " " OrElse c = " " Then
3934 StatusText.Text = ""
3935 JumpUnreadMenuItem_Click(Nothing, Nothing)
3939 Me.StatusText_TextChanged(Nothing, Nothing)
3942 Private Sub StatusText_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.TextChanged
3944 Dim pLen As Integer = GetRestStatusCount(True, False)
3945 lblLen.Text = pLen.ToString()
3947 StatusText.ForeColor = Color.Red
3949 StatusText.ForeColor = _clInputFont
3951 If StatusText.Text = "" Then
3957 Private Function GetRestStatusCount(ByVal isAuto As Boolean, ByVal isAddFooter As Boolean) As Integer
3959 Dim pLen As Integer = 140 - StatusText.Text.Length
3960 If (isAuto AndAlso Not My.Computer.Keyboard.CtrlKeyDown AndAlso SettingDialog.PostShiftEnter) OrElse _
3961 (isAuto AndAlso Not My.Computer.Keyboard.ShiftKeyDown AndAlso Not SettingDialog.PostShiftEnter) OrElse _
3962 (Not isAuto AndAlso isAddFooter) Then
3963 If SettingDialog.UseRecommendStatus Then
3964 pLen -= SettingDialog.RecommendStatusText.Length
3965 ElseIf SettingDialog.Status.Length > 0 Then
3966 pLen -= SettingDialog.Status.Length + 1
3969 If HashMgr.UseHash <> "" Then
3970 pLen -= HashMgr.UseHash.Length + 1
3975 Private Sub MyList_CacheVirtualItems(ByVal sender As System.Object, ByVal e As System.Windows.Forms.CacheVirtualItemsEventArgs)
3976 If _itemCache IsNot Nothing AndAlso _
3977 e.StartIndex >= _itemCacheIndex AndAlso _
3978 e.EndIndex < _itemCacheIndex + _itemCache.Length AndAlso _
3979 _curList.Equals(sender) Then
3980 'If the newly requested cache is a subset of the old cache,
3981 'no need to rebuild everything, so do nothing.
3985 'Now we need to rebuild the cache.
3986 If _curList.Equals(sender) Then CreateCache(e.StartIndex, e.EndIndex)
3989 Private Sub MyList_RetrieveVirtualItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.RetrieveVirtualItemEventArgs)
3990 If _itemCache IsNot Nothing AndAlso e.ItemIndex >= _itemCacheIndex AndAlso e.ItemIndex < _itemCacheIndex + _itemCache.Length AndAlso _curList.Equals(sender) Then
3991 'A cache hit, so get the ListViewItem from the cache instead of making a new one.
3992 e.Item = _itemCache(e.ItemIndex - _itemCacheIndex)
3994 'A cache miss, so create a new ListViewItem and pass it back.
3995 Dim tb As TabPage = DirectCast(DirectCast(sender, Tween.TweenCustomControl.DetailsListView).Parent, TabPage)
3997 e.Item = CreateItem(tb, _
3998 _statuses.Item(tb.Text, e.ItemIndex), _
4000 Catch ex As Exception
4002 Dim sitem() As String = {"", "", "", "", "", "", "", ""}
4003 e.Item = New ImageListViewItem(sitem, "")
4008 Private Sub CreateCache(ByVal StartIndex As Integer, ByVal EndIndex As Integer)
4010 'キャッシュ要求(要求範囲±30を作成)
4012 If StartIndex < 0 Then StartIndex = 0
4014 If EndIndex >= _statuses.Tabs(_curTab.Text).AllCount Then EndIndex = _statuses.Tabs(_curTab.Text).AllCount - 1
4015 _postCache = _statuses.Item(_curTab.Text, StartIndex, EndIndex) '配列で取得
4016 _itemCacheIndex = StartIndex
4018 _itemCache = New ListViewItem(_postCache.Length - 1) {}
4019 For i As Integer = 0 To _postCache.Length - 1
4020 _itemCache(i) = CreateItem(_curTab, _postCache(i), StartIndex + i)
4022 Catch ex As Exception
4023 'キャッシュ要求が実データとずれるため(イベントの遅延?)
4024 _postCache = Nothing
4025 _itemCache = Nothing
4029 Private Function CreateItem(ByVal Tab As TabPage, ByVal Post As PostClass, ByVal Index As Integer) As ListViewItem
4030 Dim mk As New StringBuilder
4031 If Post.IsDeleted Then mk.Append("×")
4032 If Post.IsMark Then mk.Append("♪")
4033 If Post.IsProtect Then mk.Append("Ю")
4034 If Post.InReplyToStatusId > 0 Then mk.Append("⇒")
4035 If Post.FavoritedCount > 0 Then mk.Append("+" + Post.FavoritedCount.ToString)
4036 Dim itm As ImageListViewItem
4037 If Post.RetweetedId = 0 Then
4038 Dim sitem() As String = {"",
4040 If(Post.IsDeleted, "(DELETED)", Post.TextFromApi),
4041 Post.CreatedAt.ToString(SettingDialog.DateTimeFormat),
4046 itm = New ImageListViewItem(sitem, DirectCast(Me.TIconDic, ImageDictionary), Post.ImageUrl)
4048 Dim sitem() As String = {"",
4050 If(Post.IsDeleted, "(DELETED)", Post.TextFromApi),
4051 Post.CreatedAt.ToString(SettingDialog.DateTimeFormat),
4052 Post.ScreenName + Environment.NewLine + "(RT:" + Post.RetweetedBy + ")",
4056 itm = New ImageListViewItem(sitem, DirectCast(Me.TIconDic, ImageDictionary), Post.ImageUrl)
4059 Dim read As Boolean = Post.IsRead
4060 '未読管理していなかったら既読として扱う
4061 If Not _statuses.Tabs(Tab.Text).UnreadManage OrElse _
4062 Not SettingDialog.UnreadManage Then read = True
4063 ChangeItemStyleRead(read, itm, Post, Nothing)
4064 If Tab.Equals(_curTab) Then ColorizeList(itm, Index)
4068 Private Sub MyList_DrawColumnHeader(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewColumnHeaderEventArgs)
4069 e.DrawDefault = True
4072 Private Sub MyList_HScrolled(ByVal sender As Object, ByVal e As EventArgs)
4073 Dim listView As DetailsListView = DirectCast(sender, DetailsListView)
4077 Private Sub MyList_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawListViewItemEventArgs)
4078 If e.State = 0 Then Exit Sub
4079 e.DrawDefault = False
4080 If Not e.Item.Selected Then 'e.ItemStateでうまく判定できない???
4081 Dim brs2 As SolidBrush = Nothing
4082 Select Case e.Item.BackColor
4084 brs2 = _brsBackColorMine
4086 brs2 = _brsBackColorAt
4088 brs2 = _brsBackColorYou
4090 brs2 = _brsBackColorAtYou
4091 Case _clAtFromTarget
4092 brs2 = _brsBackColorAtFromTarget
4094 brs2 = _brsBackColorAtTo
4096 brs2 = _brsBackColorNone
4098 e.Graphics.FillRectangle(brs2, e.Bounds)
4101 If DirectCast(sender, Windows.Forms.Control).Focused Then
4102 e.Graphics.FillRectangle(_brsHighLight, e.Bounds)
4104 e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds)
4107 If (e.State And ListViewItemStates.Focused) = ListViewItemStates.Focused Then e.DrawFocusRectangle()
4108 Me.DrawListViewItemIcon(e)
4111 Private Sub MyList_DrawSubItem(ByVal sender As Object, ByVal e As DrawListViewSubItemEventArgs)
4112 If e.ItemState = 0 Then Exit Sub
4114 If e.ColumnIndex > 0 Then
4116 Dim rct As RectangleF = e.Bounds
4117 Dim rctB As RectangleF = e.Bounds
4118 rct.Width = e.Header.Width
4119 rctB.Width = e.Header.Width
4121 rct.Y += e.Item.Font.Height
4122 rct.Height -= e.Item.Font.Height
4123 rctB.Height = e.Item.Font.Height
4127 Dim heightDiff As Integer
4128 Dim drawLineCount As Integer = Math.Max(1, Math.DivRem(CType(rct.Height, Integer), e.Item.Font.Height, heightDiff))
4130 'If heightDiff > e.Item.Font.Height * 0.7 Then
4131 ' rct.Height += e.Item.Font.Height
4132 ' drawLineCount += 1
4135 'フォントの高さの半分を足してるのは保険。無くてもいいかも。
4136 If Not _iconCol AndAlso drawLineCount <= 1 Then
4137 'rct.Inflate(0, CType(heightDiff / -2, Integer))
4138 'rct.Height += CType(e.Item.Font.Height / 2, Integer)
4139 ElseIf heightDiff < e.Item.Font.Height * 0.7 Then
4140 '最終行が70%以上欠けていたら、最終行は表示しない
4141 'rct.Height = CType((e.Item.Font.Height * drawLineCount) + (e.Item.Font.Height / 2), Single)
4142 rct.Height = CType((e.Item.Font.Height * drawLineCount), Single) - 1
4147 'If Not _iconCol AndAlso drawLineCount > 1 Then
4148 ' rct.Y += CType(e.Item.Font.Height * 0.2, Single)
4149 ' If heightDiff >= e.Item.Font.Height * 0.8 Then rct.Height -= CType(e.Item.Font.Height * 0.2, Single)
4151 If Not e.Item.Selected Then 'e.ItemStateでうまく判定できない???
4154 Dim brs As SolidBrush = Nothing
4155 Dim flg As Boolean = False
4156 Select Case e.Item.ForeColor
4158 brs = _brsForeColorUnread
4160 brs = _brsForeColorReaded
4162 brs = _brsForeColorFav
4164 brs = _brsForeColorOWL
4166 brs = _brsForeColorRetweet
4168 brs = New SolidBrush(e.Item.ForeColor)
4171 If rct.Width > 0 Then
4173 Using fnt As New Font(e.Item.Font, FontStyle.Bold)
4174 'e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, brs, rct, sf)
4175 '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)
4176 TextRenderer.DrawText(e.Graphics,
4177 e.Item.SubItems(2).Text,
4179 Rectangle.Round(rct),
4181 TextFormatFlags.WordBreak Or
4182 TextFormatFlags.EndEllipsis Or
4183 TextFormatFlags.GlyphOverhangPadding Or
4184 TextFormatFlags.NoPrefix)
4185 TextRenderer.DrawText(e.Graphics,
4186 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 + "]",
4188 Rectangle.Round(rctB),
4190 TextFormatFlags.SingleLine Or
4191 TextFormatFlags.EndEllipsis Or
4192 TextFormatFlags.GlyphOverhangPadding Or
4193 TextFormatFlags.NoPrefix)
4195 ElseIf drawLineCount = 1 Then
4196 TextRenderer.DrawText(e.Graphics,
4199 Rectangle.Round(rct),
4201 TextFormatFlags.SingleLine Or
4202 TextFormatFlags.EndEllipsis Or
4203 TextFormatFlags.GlyphOverhangPadding Or
4204 TextFormatFlags.NoPrefix Or
4205 TextFormatFlags.VerticalCenter)
4207 'e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, brs, rct, sf)
4208 TextRenderer.DrawText(e.Graphics,
4211 Rectangle.Round(rct),
4213 TextFormatFlags.WordBreak Or
4214 TextFormatFlags.EndEllipsis Or
4215 TextFormatFlags.GlyphOverhangPadding Or
4216 TextFormatFlags.NoPrefix)
4219 If flg Then brs.Dispose()
4221 If rct.Width > 0 Then
4223 Using fnt As New Font(e.Item.Font, FontStyle.Bold)
4224 If DirectCast(sender, Windows.Forms.Control).Focused Then
4226 'e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, _brsHighLightText, rct, sf)
4227 '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)
4228 TextRenderer.DrawText(e.Graphics,
4229 e.Item.SubItems(2).Text,
4231 Rectangle.Round(rct),
4232 _brsHighLightText.Color,
4233 TextFormatFlags.WordBreak Or
4234 TextFormatFlags.EndEllipsis Or
4235 TextFormatFlags.GlyphOverhangPadding Or
4236 TextFormatFlags.NoPrefix)
4237 TextRenderer.DrawText(e.Graphics,
4238 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 + "]",
4240 Rectangle.Round(rctB),
4241 _brsHighLightText.Color,
4242 TextFormatFlags.SingleLine Or
4243 TextFormatFlags.EndEllipsis Or
4244 TextFormatFlags.GlyphOverhangPadding Or
4245 TextFormatFlags.NoPrefix)
4246 ElseIf drawLineCount = 1 Then
4247 TextRenderer.DrawText(e.Graphics,
4250 Rectangle.Round(rct),
4251 _brsHighLightText.Color,
4252 TextFormatFlags.SingleLine Or
4253 TextFormatFlags.EndEllipsis Or
4254 TextFormatFlags.GlyphOverhangPadding Or
4255 TextFormatFlags.NoPrefix Or
4256 TextFormatFlags.VerticalCenter)
4258 'e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsHighLightText, rct, sf)
4259 TextRenderer.DrawText(e.Graphics,
4262 Rectangle.Round(rct),
4263 _brsHighLightText.Color,
4264 TextFormatFlags.WordBreak Or
4265 TextFormatFlags.EndEllipsis Or
4266 TextFormatFlags.GlyphOverhangPadding Or
4267 TextFormatFlags.NoPrefix)
4271 'e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems(2).Text, e.Item.Font, _brsForeColorUnread, rct, sf)
4272 '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)
4273 TextRenderer.DrawText(e.Graphics,
4274 e.Item.SubItems(2).Text,
4276 Rectangle.Round(rct),
4277 _brsForeColorUnread.Color,
4278 TextFormatFlags.WordBreak Or
4279 TextFormatFlags.EndEllipsis Or
4280 TextFormatFlags.GlyphOverhangPadding Or
4281 TextFormatFlags.NoPrefix)
4282 TextRenderer.DrawText(e.Graphics,
4283 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 + "]",
4285 Rectangle.Round(rctB),
4286 _brsForeColorUnread.Color,
4287 TextFormatFlags.SingleLine Or
4288 TextFormatFlags.EndEllipsis Or
4289 TextFormatFlags.GlyphOverhangPadding Or
4290 TextFormatFlags.NoPrefix)
4291 ElseIf drawLineCount = 1 Then
4292 TextRenderer.DrawText(e.Graphics,
4295 Rectangle.Round(rct),
4296 _brsForeColorUnread.Color,
4297 TextFormatFlags.SingleLine Or
4298 TextFormatFlags.EndEllipsis Or
4299 TextFormatFlags.GlyphOverhangPadding Or
4300 TextFormatFlags.NoPrefix Or
4301 TextFormatFlags.VerticalCenter)
4303 'e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsForeColorUnread, rct, sf)
4304 TextRenderer.DrawText(e.Graphics,
4307 Rectangle.Round(rct),
4308 _brsForeColorUnread.Color,
4309 TextFormatFlags.WordBreak Or
4310 TextFormatFlags.EndEllipsis Or
4311 TextFormatFlags.GlyphOverhangPadding Or
4312 TextFormatFlags.NoPrefix)
4321 Private Sub DrawListViewItemIcon(ByVal e As DrawListViewItemEventArgs)
4322 Dim item As ImageListViewItem = DirectCast(e.Item, ImageListViewItem)
4323 If item.Image IsNot Nothing Then
4324 'e.Bounds.Leftが常に0を指すから自前で計算
4325 Dim itemRect As Rectangle = item.Bounds
4326 itemRect.Width = e.Item.ListView.Columns(0).Width
4328 For Each clm As ColumnHeader In e.Item.ListView.Columns
4329 If clm.DisplayIndex < e.Item.ListView.Columns(0).DisplayIndex Then
4330 itemRect.X += clm.Width
4334 Dim iconRect As Rectangle = Rectangle.Intersect(New Rectangle(e.Item.GetBounds(ItemBoundsPortion.Icon).Location, New Size(_iconSz, _iconSz)), itemRect)
4335 iconRect.Offset(0, CType(Math.Max(0, (itemRect.Height - _iconSz) / 2), Integer))
4337 If iconRect.Width > 0 Then
4338 e.Graphics.FillRectangle(Brushes.White, iconRect)
4339 e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.High
4341 e.Graphics.DrawImage(item.Image, iconRect)
4342 Catch ex As ArgumentException
4349 Private Sub DoTabSearch(ByVal _word As String, _
4350 ByVal CaseSensitive As Boolean, _
4351 ByVal UseRegex As Boolean, _
4352 ByVal SType As SEARCHTYPE)
4353 Dim cidx As Integer = 0
4354 Dim fnd As Boolean = False
4355 Dim toIdx As Integer
4356 Dim stp As Integer = 1
4358 If _curList.VirtualListSize = 0 Then
4359 MessageBox.Show(My.Resources.DoTabSearchText2, My.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information)
4362 If _curList.SelectedIndices.Count > 0 Then
4363 cidx = _curList.SelectedIndices(0)
4365 toIdx = _curList.VirtualListSize - 1
4368 Case SEARCHTYPE.DialogSearch 'ダイアログからの検索
4369 If _curList.SelectedIndices.Count > 0 Then
4370 cidx = _curList.SelectedIndices(0)
4374 Case SEARCHTYPE.NextSearch '次を検索
4375 If _curList.SelectedIndices.Count > 0 Then
4376 cidx = _curList.SelectedIndices(0) + 1
4377 If cidx > toIdx Then cidx = toIdx
4381 Case SEARCHTYPE.PrevSearch '前を検索
4382 If _curList.SelectedIndices.Count > 0 Then
4383 cidx = _curList.SelectedIndices(0) - 1
4384 If cidx < 0 Then cidx = 0
4392 Dim regOpt As RegexOptions = RegexOptions.None
4393 Dim fndOpt As StringComparison = StringComparison.Ordinal
4394 If Not CaseSensitive Then
4395 regOpt = RegexOptions.IgnoreCase
4396 fndOpt = StringComparison.OrdinalIgnoreCase
4402 Dim _search As Regex
4404 _search = New Regex(_word)
4405 For idx As Integer = cidx To toIdx Step stp
4406 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4407 If _search.IsMatch(post.Nickname, regOpt) _
4408 OrElse _search.IsMatch(post.TextFromApi, regOpt) _
4409 OrElse _search.IsMatch(post.ScreenName, regOpt) _
4411 SelectListItem(_curList, idx)
4412 _curList.EnsureVisible(idx)
4416 Catch ex As ArgumentException
4417 MsgBox(My.Resources.DoTabSearchText1, MsgBoxStyle.Critical)
4422 For idx As Integer = cidx To toIdx Step stp
4423 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
4424 If post.Nickname.IndexOf(_word, fndOpt) > -1 _
4425 OrElse post.TextFromApi.IndexOf(_word, fndOpt) > -1 _
4426 OrElse post.ScreenName.IndexOf(_word, fndOpt) > -1 _
4428 SelectListItem(_curList, idx)
4429 _curList.EnsureVisible(idx)
4437 Case SEARCHTYPE.DialogSearch, SEARCHTYPE.NextSearch
4440 Case SEARCHTYPE.PrevSearch
4442 cidx = _curList.Items.Count - 1
4447 Catch ex As ArgumentOutOfRangeException
4450 MessageBox.Show(My.Resources.DoTabSearchText2, My.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information)
4453 Private Sub MenuItemSubSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSubSearch.Click
4455 SearchDialog.Owner = Me
4456 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4457 Me.TopMost = SettingDialog.AlwaysTop
4460 Me.TopMost = SettingDialog.AlwaysTop
4462 If SearchDialog.SWord <> "" Then
4463 DoTabSearch(SearchDialog.SWord, _
4464 SearchDialog.CheckCaseSensitive, _
4465 SearchDialog.CheckRegex, _
4466 SEARCHTYPE.DialogSearch)
4470 Private Sub MenuItemSearchNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSearchNext.Click
4472 If SearchDialog.SWord = "" Then
4473 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4474 Me.TopMost = SettingDialog.AlwaysTop
4477 Me.TopMost = SettingDialog.AlwaysTop
4478 If SearchDialog.SWord = "" Then Exit Sub
4480 DoTabSearch(SearchDialog.SWord, _
4481 SearchDialog.CheckCaseSensitive, _
4482 SearchDialog.CheckRegex, _
4483 SEARCHTYPE.DialogSearch)
4485 DoTabSearch(SearchDialog.SWord, _
4486 SearchDialog.CheckCaseSensitive, _
4487 SearchDialog.CheckRegex, _
4488 SEARCHTYPE.NextSearch)
4492 Private Sub MenuItemSearchPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemSearchPrev.Click
4494 If SearchDialog.SWord = "" Then
4495 If SearchDialog.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
4496 Me.TopMost = SettingDialog.AlwaysTop
4499 Me.TopMost = SettingDialog.AlwaysTop
4500 If SearchDialog.SWord = "" Then Exit Sub
4503 DoTabSearch(SearchDialog.SWord, _
4504 SearchDialog.CheckCaseSensitive, _
4505 SearchDialog.CheckRegex, _
4506 SEARCHTYPE.PrevSearch)
4509 Private Sub AboutMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutMenuItem.Click
4510 TweenAboutBox.ShowDialog()
4511 Me.TopMost = SettingDialog.AlwaysTop
4514 Private Sub JumpUnreadMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JumpUnreadMenuItem.Click, JumpReadOpMenuItem.Click
4515 Dim bgnIdx As Integer = ListTab.TabPages.IndexOf(_curTab)
4516 Dim idx As Integer = -1
4517 Dim lst As DetailsListView = Nothing
4519 If ImageSelectionPanel.Enabled Then
4524 For i As Integer = bgnIdx To ListTab.TabPages.Count - 1
4526 idx = _statuses.GetOldestUnreadIndex(ListTab.TabPages(i).Text)
4528 ListTab.SelectedIndex = i
4529 lst = DirectCast(ListTab.TabPages(i).Tag, DetailsListView)
4530 '_curTab = ListTab.TabPages(i)
4535 '未読みつからず&現在タブが先頭ではなかったら、先頭タブから現在タブの手前まで探索
4536 If idx = -1 AndAlso bgnIdx > 0 Then
4537 For i As Integer = 0 To bgnIdx - 1
4538 idx = _statuses.GetOldestUnreadIndex(ListTab.TabPages(i).Text)
4540 ListTab.SelectedIndex = i
4541 lst = DirectCast(ListTab.TabPages(i).Tag, DetailsListView)
4542 '_curTab = ListTab.TabPages(i)
4548 '全部調べたが未読見つからず→先頭タブの最新発言へ
4550 ListTab.SelectedIndex = 0
4551 lst = DirectCast(ListTab.TabPages(0).Tag, DetailsListView)
4552 '_curTab = ListTab.TabPages(0)
4553 If _statuses.SortOrder = SortOrder.Ascending Then
4554 idx = lst.VirtualListSize - 1
4560 If lst.VirtualListSize > 0 AndAlso idx > -1 AndAlso lst.VirtualListSize > idx Then
4561 SelectListItem(lst, idx)
4562 If _statuses.SortMode = IdComparerClass.ComparerMode.Id Then
4563 If _statuses.SortOrder = SortOrder.Ascending AndAlso lst.Items(idx).Position.Y > lst.ClientSize.Height - _iconSz - 10 OrElse _
4564 _statuses.SortOrder = SortOrder.Descending AndAlso lst.Items(idx).Position.Y < _iconSz + 10 Then
4567 lst.EnsureVisible(idx)
4570 lst.EnsureVisible(idx)
4576 Private Sub StatusOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusOpenMenuItem.Click, OpenStatusOpMenuItem.Click
4577 If _curList.SelectedIndices.Count > 0 AndAlso _statuses.Tabs(_curTab.Text).TabType <> TabUsageType.DirectMessage Then
4578 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(0))
4579 If post.RetweetedId = 0 Then
4580 OpenUriAsync("http://twitter.com/" + post.ScreenName + "/status/" + post.StatusId.ToString)
4582 OpenUriAsync("http://twitter.com/" + post.ScreenName + "/status/" + post.RetweetedId.ToString)
4587 Private Sub FavorareMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FavorareMenuItem.Click, OpenFavotterOpMenuItem.Click
4588 If _curList.SelectedIndices.Count > 0 Then
4589 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(0))
4590 OpenUriAsync(My.Resources.FavstarUrl + "users/" + post.ScreenName + "/recent")
4594 Private Sub VerUpMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VerUpMenuItem.Click
4598 Private Sub RunTweenUp()
4600 Dim pinfo As New ProcessStartInfo
4601 pinfo.UseShellExecute = True
4602 pinfo.WorkingDirectory = Application.StartupPath
4603 pinfo.FileName = Path.Combine(Application.StartupPath(), "TweenUp2.exe")
4605 Process.Start(pinfo)
4606 Catch ex As Exception
4607 MessageBox.Show("Failed to execute TweenUp2.exe.")
4611 Private Sub CheckNewVersion(Optional ByVal startup As Boolean = False)
4612 Dim retMsg As String = ""
4613 Dim strVer As String = ""
4614 Dim strDetail As String = ""
4615 Dim forceUpdate As Boolean = My.Computer.Keyboard.ShiftKeyDown
4618 retMsg = tw.GetVersionInfo()
4619 Catch ex As Exception
4620 StatusLabel.Text = My.Resources.CheckNewVersionText9
4621 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText10, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
4624 If retMsg.Length > 0 Then
4625 strVer = retMsg.Substring(0, 4)
4626 If retMsg.Length > 4 Then
4627 strDetail = retMsg.Substring(5).Trim
4629 If fileVersion <> "" AndAlso strVer.CompareTo(fileVersion.Replace(".", "")) > 0 Then
4630 Dim tmp As String = String.Format(My.Resources.CheckNewVersionText3, strVer)
4631 Using dialogAsShieldicon As New DialogAsShieldIcon
4632 If dialogAsShieldicon.Show(tmp, strDetail, My.Resources.CheckNewVersionText1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
4633 retMsg = tw.GetTweenBinary(strVer)
4634 If retMsg.Length = 0 Then
4637 dialogAsShieldicon.Dispose()
4641 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText5 + System.Environment.NewLine + retMsg, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4644 dialogAsShieldicon.Dispose()
4648 Dim tmp As String = String.Format(My.Resources.CheckNewVersionText6, strVer)
4649 Using dialogAsShieldicon As New DialogAsShieldIcon
4650 If dialogAsShieldicon.Show(tmp, strDetail, My.Resources.CheckNewVersionText1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
4651 retMsg = tw.GetTweenBinary(strVer)
4652 If retMsg.Length = 0 Then
4655 dialogAsShieldicon.Dispose()
4659 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText5 + System.Environment.NewLine + retMsg, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4662 dialogAsShieldicon.Dispose()
4664 ElseIf Not startup Then
4665 MessageBox.Show(My.Resources.CheckNewVersionText7 + fileVersion.Replace(".", "") + My.Resources.CheckNewVersionText8 + strVer, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Information)
4669 StatusLabel.Text = My.Resources.CheckNewVersionText9
4670 If Not startup Then MessageBox.Show(My.Resources.CheckNewVersionText10, My.Resources.CheckNewVersionText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
4674 Private Sub Colorize()
4678 If SettingDialog.DispLatestPost <> DispTitleEnum.None AndAlso _
4679 SettingDialog.DispLatestPost <> DispTitleEnum.Post AndAlso _
4680 SettingDialog.DispLatestPost <> DispTitleEnum.Ver AndAlso _
4681 SettingDialog.DispLatestPost <> DispTitleEnum.OwnStatus Then
4682 SetMainWindowTitle()
4684 If Not StatusLabelUrl.Text.StartsWith("http") Then SetStatusLabelUrl()
4685 For Each tb As TabPage In ListTab.TabPages
4686 If _statuses.Tabs(tb.Text).UnreadCount = 0 Then
4687 If SettingDialog.TabIconDisp Then
4688 If tb.ImageIndex = 0 Then tb.ImageIndex = -1
4692 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
4695 Public Function createDetailHtml(ByVal orgdata As String) As String
4696 Return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter
4699 Private Sub DisplayItemImage_Downloaded(ByVal sender As Object, ByVal e As EventArgs) Handles displayItem.ImageDownloaded
4700 If sender.Equals(displayItem) Then
4701 If UserPicture.Image IsNot Nothing Then UserPicture.Image.Dispose()
4702 If displayItem.Image IsNot Nothing Then
4704 UserPicture.Image = New Bitmap(displayItem.Image)
4705 Catch ex As Exception
4706 UserPicture.Image = Nothing
4709 UserPicture.Image = Nothing
4714 Private Overloads Sub DispSelectedPost()
4715 DispSelectedPost(False)
4718 Private Overloads Sub DispSelectedPost(ByVal forceupdate As Boolean)
4719 Static displaypost As New PostClass
4720 If _curList.SelectedIndices.Count = 0 OrElse _
4721 _curPost Is Nothing Then Exit Sub
4723 If Not forceupdate AndAlso _curPost.Equals(displaypost) Then
4727 displaypost = _curPost
4728 displayItem = DirectCast(_curList.Items(_curList.SelectedIndices(0)), ImageListViewItem)
4730 Dim dTxt As String = createDetailHtml(If(_curPost.IsDeleted, "(DELETED)", _curPost.Text))
4731 If _curPost.IsDm Then
4732 SourceLinkLabel.Tag = Nothing
4733 SourceLinkLabel.Text = ""
4735 Dim mc As Match = Regex.Match(_curPost.SourceHtml, "<a href=""(?<sourceurl>.+?)""")
4737 Dim src As String = mc.Groups("sourceurl").Value
4738 SourceLinkLabel.Tag = mc.Groups("sourceurl").Value
4739 mc = Regex.Match(src, "^https?://")
4740 If Not mc.Success Then
4741 src = src.Insert(0, "http://twitter.com")
4743 SourceLinkLabel.Tag = src
4745 SourceLinkLabel.Tag = Nothing
4747 If String.IsNullOrEmpty(_curPost.Source) Then
4748 SourceLinkLabel.Text = ""
4749 'SourceLinkLabel.Visible = False
4751 SourceLinkLabel.Text = _curPost.Source
4752 'SourceLinkLabel.Visible = True
4755 SourceLinkLabel.TabStop = False
4757 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage AndAlso Not _curPost.IsOwl Then
4758 NameLabel.Text = "DM TO -> "
4759 ElseIf _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then
4760 NameLabel.Text = "DM FROM <- "
4764 NameLabel.Text += _curPost.ScreenName + "/" + _curPost.Nickname
4765 NameLabel.Tag = _curPost.ScreenName
4766 If Not String.IsNullOrEmpty(_curPost.RetweetedBy) Then
4767 NameLabel.Text += " (RT:" + _curPost.RetweetedBy + ")"
4769 If UserPicture.Image IsNot Nothing Then UserPicture.Image.Dispose()
4770 If Not String.IsNullOrEmpty(_curPost.ImageUrl) AndAlso TIconDic(_curPost.ImageUrl) IsNot Nothing Then
4772 UserPicture.Image = New Bitmap(TIconDic(_curPost.ImageUrl))
4773 Catch ex As Exception
4774 UserPicture.Image = Nothing
4777 UserPicture.Image = Nothing
4780 NameLabel.ForeColor = System.Drawing.SystemColors.ControlText
4781 DateTimeLabel.Text = _curPost.CreatedAt.ToString()
4782 If _curPost.IsOwl AndAlso (SettingDialog.OneWayLove OrElse _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage) Then NameLabel.ForeColor = _clOWL
4783 If _curPost.RetweetedId > 0 Then NameLabel.ForeColor = _clRetweet
4784 If _curPost.IsFav Then NameLabel.ForeColor = _clFav
4786 If DumpPostClassToolStripMenuItem.Checked Then
4787 Dim sb As New StringBuilder(512)
4789 sb.Append("-----Start PostClass Dump<br>")
4790 sb.AppendFormat("TextFromApi : {0}<br>", _curPost.TextFromApi)
4791 sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.TextFromApi)
4792 sb.AppendFormat("StatusId : {0}<br>", _curPost.StatusId.ToString)
4793 'sb.AppendFormat("ImageIndex : {0}<br>", _curPost.ImageIndex.ToString)
4794 sb.AppendFormat("ImageUrl : {0}<br>", _curPost.ImageUrl)
4795 sb.AppendFormat("InReplyToStatusId : {0}<br>", _curPost.InReplyToStatusId.ToString)
4796 sb.AppendFormat("InReplyToUser : {0}<br>", _curPost.InReplyToUser)
4797 sb.AppendFormat("IsDM : {0}<br>", _curPost.IsDm.ToString)
4798 sb.AppendFormat("IsFav : {0}<br>", _curPost.IsFav.ToString)
4799 sb.AppendFormat("IsMark : {0}<br>", _curPost.IsMark.ToString)
4800 sb.AppendFormat("IsMe : {0}<br>", _curPost.IsMe.ToString)
4801 sb.AppendFormat("IsOwl : {0}<br>", _curPost.IsOwl.ToString)
4802 sb.AppendFormat("IsProtect : {0}<br>", _curPost.IsProtect.ToString)
4803 sb.AppendFormat("IsRead : {0}<br>", _curPost.IsRead.ToString)
4804 sb.AppendFormat("IsReply : {0}<br>", _curPost.IsReply.ToString)
4806 For Each nm As String In _curPost.ReplyToList
4807 sb.AppendFormat("ReplyToList : {0}<br>", nm)
4810 sb.AppendFormat("ScreenName : {0}<br>", _curPost.ScreenName)
4811 sb.AppendFormat("NickName : {0}<br>", _curPost.Nickname)
4812 sb.AppendFormat("Text : {0}<br>", _curPost.Text)
4813 sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.Text)
4814 sb.AppendFormat("CreatedAt : {0}<br>", _curPost.CreatedAt.ToString)
4815 sb.AppendFormat("Source : {0}<br>", _curPost.Source)
4816 sb.AppendFormat("UserId : {0}<br>", _curPost.UserId)
4817 sb.AppendFormat("FilterHit : {0}<br>", _curPost.FilterHit)
4818 sb.AppendFormat("RetweetedBy : {0}<br>", _curPost.RetweetedBy)
4819 sb.AppendFormat("RetweetedId : {0}<br>", _curPost.RetweetedId)
4820 sb.AppendFormat("SearchTabName : {0}<br>", _curPost.RelTabName)
4821 sb.Append("-----End PostClass Dump<br>")
4823 PostBrowser.Visible = False
4824 PostBrowser.DocumentText = detailHtmlFormatHeader + sb.ToString + detailHtmlFormatFooter
4825 PostBrowser.Visible = True
4828 If PostBrowser.DocumentText <> dTxt Then
4829 PostBrowser.Visible = False
4830 PostBrowser.DocumentText = dTxt
4831 Dim lnks As New List(Of String)
4832 For Each lnk As Match In Regex.Matches(dTxt, "<a target=""_self"" href=""(?<url>http[^""]+)""", RegexOptions.IgnoreCase)
4833 lnks.Add(lnk.Result("${url}"))
4835 Thumbnail.thumbnail(_curPost.StatusId, lnks)
4837 Catch ex As System.Runtime.InteropServices.COMException
4840 PostBrowser.Visible = True
4845 Private Sub MatomeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MatomeMenuItem.Click
4846 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
4849 Private Sub ShortcutKeyListMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShortcutKeyListMenuItem.Click
4850 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")
4853 Private Sub ListTab_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListTab.KeyDown
4854 If ListTab.SelectedTab IsNot Nothing Then
4855 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch Then
4856 Dim pnl As Control = ListTab.SelectedTab.Controls("panelSearch")
4857 If pnl.Controls("comboSearch").Focused OrElse _
4858 pnl.Controls("comboLang").Focused OrElse _
4859 pnl.Controls("buttonSearch").Focused Then Exit Sub
4861 Dim State As ModifierState = GetModifierState(e.Control, e.Shift, e.Alt)
4862 If State = ModifierState.NotFlags Then Exit Sub
4863 If State <> ModifierState.Non Then _anchorFlag = False
4864 If CommonKeyDown(e.KeyCode, ModifierState.ListTab, State) Then
4866 e.SuppressKeyPress = True
4872 Public Function GetModifierState(ByVal sControl As Boolean, ByVal sShift As Boolean, ByVal sAlt As Boolean) As ModifierState
4873 If Not sAlt AndAlso Not sControl AndAlso Not sShift Then Return ModifierState.Non
4875 If sShift AndAlso Not sAlt Then
4876 Return ModifierState.CShift
4877 ElseIf sAlt AndAlso Not sShift Then
4878 Return ModifierState.CAlt
4879 ElseIf Not sAlt AndAlso Not sShift Then
4880 Return ModifierState.Ctrl
4883 If sAlt AndAlso Not sControl Then
4884 Return ModifierState.AShift
4885 ElseIf Not sAlt AndAlso Not sControl Then
4886 Return ModifierState.Shift
4889 If Not sControl AndAlso Not sShift Then Return ModifierState.Alt
4891 Return ModifierState.NotFlags
4894 Public Enum ModifierState As Integer
4909 Public Function CommonKeyDown(ByVal KeyCode As System.Windows.Forms.Keys, ByVal Focused As ModifierState, ByVal Modifier As ModifierState) As Boolean
4910 Dim Pressed As Boolean = False
4913 If Modifier = ModifierState.Non Then
4914 If KeyCode = Keys.F1 Then
4916 OpenUriAsync("http://sourceforge.jp/projects/tween/wiki/FrontPage")
4917 ElseIf KeyCode = Keys.F3 Then
4919 MenuItemSearchNext_Click(Nothing, Nothing)
4920 ElseIf KeyCode = Keys.F5 Then
4923 ElseIf KeyCode = Keys.F6 Then
4925 GetTimeline(WORKERTYPE.Reply, 1, 0, "")
4926 ElseIf KeyCode = Keys.F7 Then
4928 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 0, "")
4930 If Focused <> ModifierState.StatusText AndAlso Not Pressed Then
4931 If KeyCode = Keys.Space OrElse KeyCode = Keys.ProcessKey Then
4933 If Focused = ModifierState.ListTab Then _anchorFlag = False
4934 JumpUnreadMenuItem_Click(Nothing, Nothing)
4935 ElseIf KeyCode = Keys.G Then
4937 If Focused = ModifierState.ListTab Then _anchorFlag = False
4938 ShowRelatedStatusesMenuItem_Click(Nothing, Nothing)
4941 If Focused = ModifierState.ListTab AndAlso Not Pressed Then
4942 If KeyCode = Keys.N OrElse KeyCode = Keys.Right Then
4946 ElseIf KeyCode = Keys.P OrElse KeyCode = Keys.Left Then
4950 ElseIf KeyCode = Keys.OemPeriod Then
4956 If KeyCode = Keys.Enter OrElse KeyCode = Keys.Return Then
4958 MakeReplyOrDirectStatus()
4959 ElseIf KeyCode = Keys.L Then
4962 ElseIf KeyCode = Keys.H Then
4965 ElseIf KeyCode = Keys.J Then
4967 SendKeys.Send("{DOWN}")
4968 ElseIf KeyCode = Keys.K Then
4970 SendKeys.Send("{UP}")
4972 If KeyCode = Keys.Z Or KeyCode = Keys.Oemcomma Then
4975 ElseIf KeyCode = Keys.R Then
4978 ElseIf KeyCode = Keys.S Then
4981 ElseIf KeyCode = Keys.A Then
4985 'If keycode = Keys.OemQuestion Then
4987 ' MenuItemSubSearch_Click(Nothing, Nothing) '/検索
4989 If KeyCode = Keys.F Then
4991 SendKeys.Send("{PGDN}")
4993 If KeyCode = Keys.B Then
4995 SendKeys.Send("{PGUP}")
4997 If KeyCode = Keys.I Then
4999 'SendKeys.Send("{TAB}")
5000 If Me.StatusText.Enabled Then Me.StatusText.Focus()
5002 ' ] in_reply_to参照元へ戻る
5003 If KeyCode = Keys.Oem4 Then
5005 GoInReplyToPostTree()
5007 ' [ in_reply_toへジャンプ
5008 If KeyCode = Keys.Oem6 Then
5010 GoBackInReplyToPostTree()
5012 If KeyCode = Keys.Escape Then
5013 If ListTab.SelectedTab IsNot Nothing Then
5014 Dim tabtype As TabUsageType = _statuses.Tabs(ListTab.SelectedTab.Text).TabType
5015 If tabtype = TabUsageType.Related OrElse tabtype = TabUsageType.UserTimeline Then
5016 Dim relTp As TabPage = ListTab.SelectedTab
5017 RemoveSpecifiedTab(relTp.Text, False)
5027 If Modifier = ModifierState.Ctrl Then
5028 If KeyCode = Keys.R Then
5030 MakeReplyOrDirectStatus(False, True)
5031 ElseIf KeyCode = Keys.D Then
5034 ElseIf KeyCode = Keys.M Then
5036 MakeReplyOrDirectStatus(False, False)
5037 ElseIf KeyCode = Keys.S Then
5039 FavoriteChange(True)
5040 ElseIf KeyCode = Keys.I Then
5042 doRepliedStatusOpen()
5043 ElseIf KeyCode = Keys.Q Then
5046 ElseIf KeyCode = Keys.B Then
5048 ReadedStripMenuItem_Click(Nothing, Nothing)
5049 ElseIf KeyCode = Keys.T Then
5051 HashManageMenuItem_Click(Nothing, Nothing)
5052 ElseIf KeyCode = Keys.L Then
5054 UrlConvertAutoToolStripMenuItem_Click(Nothing, Nothing)
5055 ElseIf KeyCode = Keys.Y AndAlso Not Focused = ModifierState.PostBrowser Then
5057 MultiLineMenuItem_Click(Nothing, Nothing)
5058 ElseIf KeyCode = Keys.F Then
5060 MenuItemSubSearch_Click(Nothing, Nothing)
5061 ElseIf KeyCode = Keys.U Then
5071 If _curList.SelectedIndices.Count > 0 Then
5072 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).ScreenName)
5073 ElseIf _curList.SelectedIndices.Count = 0 Then
5074 OpenUriAsync("http://twitter.com/")
5077 If _curList.SelectedIndices.Count > 0 Then
5078 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).ScreenName + "/favorites")
5081 StatusOpenMenuItem_Click(Nothing, Nothing)
5083 OpenURLMenuItem_Click(Nothing, Nothing)
5086 If Focused = ModifierState.ListTab Then
5087 If KeyCode = Keys.Home OrElse KeyCode = Keys.End Then
5090 If KeyCode = Keys.N Then
5093 ElseIf KeyCode = Keys.P Then
5096 ElseIf KeyCode = Keys.C Then
5097 Dim clstr As String = ""
5103 ' タブダイレクト選択(Ctrl+1~8,Ctrl+9)
5106 Case Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8
5107 Dim tabNo As Integer = KeyCode - Keys.D1
5108 If ListTab.TabPages.Count < tabNo Then
5111 ListTab.SelectedIndex = tabNo
5112 ListTabSelect(ListTab.TabPages(tabNo))
5115 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
5116 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
5120 ElseIf Focused = ModifierState.StatusText Then
5121 If KeyCode = Keys.A Then
5122 StatusText.SelectAll()
5124 ElseIf KeyCode = Keys.Up OrElse KeyCode = Keys.Down Then
5125 If StatusText.Text.Trim() <> "" Then
5126 _history(_hisIdx) = New PostingStatus(StatusText.Text, _reply_to_id, _reply_to_name)
5128 If KeyCode = Keys.Up Then
5130 If _hisIdx < 0 Then _hisIdx = 0
5133 If _hisIdx > _history.Count - 1 Then _hisIdx = _history.Count - 1
5135 StatusText.Text = _history(_hisIdx).status
5136 _reply_to_id = _history(_hisIdx).inReplyToId
5137 _reply_to_name = _history(_hisIdx).inReplyToName
5138 StatusText.SelectionStart = StatusText.Text.Length
5142 If KeyCode = Keys.PageUp OrElse KeyCode = Keys.P Then
5143 If ListTab.SelectedIndex = 0 Then
5144 ListTab.SelectedIndex = ListTab.TabCount - 1
5146 ListTab.SelectedIndex -= 1
5150 ElseIf KeyCode = Keys.PageDown OrElse KeyCode = Keys.N Then
5151 If ListTab.SelectedIndex = ListTab.TabCount - 1 Then
5152 ListTab.SelectedIndex = 0
5154 ListTab.SelectedIndex += 1
5160 If KeyCode = Keys.A Then
5162 PostBrowser.Document.ExecCommand("SelectAll", False, Nothing)
5163 ElseIf KeyCode = Keys.C OrElse KeyCode = Keys.Insert Then
5165 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
5166 If Not String.IsNullOrEmpty(_selText) Then
5168 Clipboard.SetDataObject(_selText, False, 5, 100)
5169 Catch ex As Exception
5170 MessageBox.Show(ex.Message)
5173 ElseIf KeyCode = Keys.Y Then
5175 MultiLineMenuItem.Checked = Not MultiLineMenuItem.Checked
5176 MultiLineMenuItem_Click(Nothing, Nothing)
5185 If Modifier = ModifierState.Shift Then
5186 If KeyCode = Keys.F3 Then
5188 MenuItemSearchPrev_Click(Nothing, Nothing)
5189 ElseIf KeyCode = Keys.F5 Then
5192 ElseIf KeyCode = Keys.F6 Then
5194 GetTimeline(WORKERTYPE.Reply, -1, 0, "")
5195 ElseIf KeyCode = Keys.F7 Then
5197 GetTimeline(WORKERTYPE.DirectMessegeRcv, -1, 0, "")
5199 If Focused <> ModifierState.StatusText Then
5200 If KeyCode = Keys.R AndAlso Not Pressed Then
5204 If Focused = ModifierState.ListTab Then
5205 If KeyCode = Keys.H Then
5208 ElseIf KeyCode = Keys.L Then
5211 ElseIf KeyCode = Keys.M Then
5214 ElseIf KeyCode = Keys.G Then
5217 ElseIf KeyCode = Keys.Z Then
5220 ElseIf KeyCode = Keys.J Then
5222 SendKeys.Send("{DOWN}")
5223 ElseIf KeyCode = Keys.K Then
5225 SendKeys.Send("{UP}")
5226 ElseIf KeyCode = Keys.Oem4 Then
5228 GoBackInReplyToPostTree(True, False)
5229 ElseIf KeyCode = Keys.Oem6 Then
5231 GoBackInReplyToPostTree(True, True)
5234 ' お気に入り前後ジャンプ(SHIFT+N←/P→)
5235 If KeyCode = Keys.N OrElse KeyCode = Keys.Right Then
5238 ElseIf KeyCode = Keys.P OrElse KeyCode = Keys.Left Then
5248 If Modifier = ModifierState.Alt Then
5249 If KeyCode = Keys.R Then
5251 doReTweetOfficial(True)
5252 ElseIf KeyCode = Keys.P AndAlso _curPost IsNot Nothing Then
5254 doShowUserStatus(_curPost.ScreenName, False)
5256 If KeyCode = Keys.Up Then
5257 ScrollDownPostBrowser(False)
5258 ElseIf KeyCode = Keys.Down Then
5259 ScrollDownPostBrowser(True)
5260 ElseIf KeyCode = Keys.PageUp Then
5261 PageDownPostBrowser(False)
5262 ElseIf KeyCode = Keys.PageDown Then
5263 PageDownPostBrowser(True)
5265 If Focused = ModifierState.ListTab AndAlso Not Pressed Then
5266 ' 別タブの同じ書き込みへ(ALT+←/→)
5267 If KeyCode = Keys.Right Then
5269 GoSamePostToAnotherTab(False)
5270 ElseIf KeyCode = Keys.Left Then
5272 GoSamePostToAnotherTab(True)
5279 If Modifier = ModifierState.CShift Then
5280 If KeyCode = Keys.R Then
5282 MakeReplyOrDirectStatus(False, True, True)
5283 ElseIf KeyCode = Keys.C Then
5284 Dim clstr As String = ""
5287 ElseIf KeyCode = Keys.F Then
5289 If ListTab.SelectedTab IsNot Nothing Then
5290 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Return Pressed
5291 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
5293 ElseIf KeyCode = Keys.S Then
5295 FavoriteChange(False)
5296 ElseIf KeyCode = Keys.B Then
5298 UnreadStripMenuItem_Click(Nothing, Nothing)
5300 If KeyCode = Keys.T Then
5302 HashToggleMenuItem_Click(Nothing, Nothing)
5303 ElseIf KeyCode = Keys.P Then
5305 ImageSelectMenuItem_Click(Nothing, Nothing)
5306 ElseIf KeyCode = Keys.H Then
5309 ElseIf KeyCode = Keys.O Then
5311 FavorareMenuItem_Click(Nothing, Nothing)
5313 If Not Pressed AndAlso Focused = ModifierState.StatusText Then
5314 If KeyCode = Keys.Up Then
5316 Dim idx As Integer = 0
5317 If _curList IsNot Nothing AndAlso _curList.Items.Count <> 0 AndAlso _
5318 _curList.SelectedIndices.Count > 0 AndAlso _curList.SelectedIndices(0) > 0 Then
5319 idx = _curList.SelectedIndices(0) - 1
5320 SelectListItem(_curList, idx)
5321 _curList.EnsureVisible(idx)
5323 ElseIf KeyCode = Keys.Down Then
5325 Dim idx As Integer = 0
5326 If _curList IsNot Nothing AndAlso _curList.Items.Count <> 0 AndAlso _curList.SelectedIndices.Count > 0 _
5327 AndAlso _curList.SelectedIndices(0) < _curList.Items.Count - 1 Then
5328 idx = _curList.SelectedIndices(0) + 1
5329 SelectListItem(_curList, idx)
5330 _curList.EnsureVisible(idx)
5332 ElseIf KeyCode = Keys.Space Then
5333 If StatusText.SelectionStart > 0 Then
5334 Dim endidx As Integer = StatusText.SelectionStart - 1
5335 Dim startstr As String = ""
5336 For i As Integer = StatusText.SelectionStart - 1 To 0 Step -1
5337 Dim c As Char = StatusText.Text.Chars(i)
5338 If Char.IsLetterOrDigit(c) OrElse c = "_" Then
5343 startstr = StatusText.Text.Substring(i + 1, endidx - i)
5344 ShowSuplDialog(StatusText, AtIdSupl, startstr.Length + 1, startstr)
5347 startstr = StatusText.Text.Substring(i + 1, endidx - i)
5348 ShowSuplDialog(StatusText, HashSupl, startstr.Length + 1, startstr)
5361 If Modifier = ModifierState.CAlt Then
5362 If KeyCode = Keys.S Then
5364 FavoritesRetweetOriginal()
5365 ElseIf KeyCode = Keys.R Then
5367 FavoritesRetweetUnofficial()
5373 If Modifier = ModifierState.AShift Then
5374 If Focused = ModifierState.PostBrowser Then
5375 If KeyCode = Keys.R Then
5376 doReTweetUnofficial()
5377 ElseIf KeyCode = Keys.C Then
5382 If KeyCode = Keys.R Then
5384 doReTweetUnofficial()
5385 ElseIf KeyCode = Keys.C Then
5388 ElseIf KeyCode = Keys.Up Then
5389 Thumbnail.ScrollThumbnail(False)
5390 ElseIf KeyCode = Keys.Down Then
5391 Thumbnail.ScrollThumbnail(True)
5393 If Focused = ModifierState.ListTab AndAlso KeyCode = Keys.Enter Then
5394 If Not Me.SplitContainer3.Panel2Collapsed Then
5395 Thumbnail.OpenPicture()
5405 Private Sub ScrollDownPostBrowser(ByVal forward As Boolean)
5406 Dim doc As HtmlDocument = PostBrowser.Document
5407 If doc Is Nothing Then Exit Sub
5408 If doc.Body Is Nothing Then Exit Sub
5411 doc.Body.ScrollTop += SettingDialog.FontDetail.Height
5413 doc.Body.ScrollTop -= SettingDialog.FontDetail.Height
5417 Private Sub PageDownPostBrowser(ByVal forward As Boolean)
5418 Dim doc As HtmlDocument = PostBrowser.Document
5419 If doc Is Nothing Then Exit Sub
5420 If doc.Body Is Nothing Then Exit Sub
5423 doc.Body.ScrollTop += PostBrowser.ClientRectangle.Height - SettingDialog.FontDetail.Height
5425 doc.Body.ScrollTop -= PostBrowser.ClientRectangle.Height - SettingDialog.FontDetail.Height
5429 Private Sub GoNextTab(ByVal forward As Boolean)
5430 Dim idx As Integer = ListTab.SelectedIndex
5433 If idx > ListTab.TabPages.Count - 1 Then idx = 0
5436 If idx < 0 Then idx = ListTab.TabPages.Count - 1
5438 ListTab.SelectedIndex = idx
5439 ListTabSelect(ListTab.TabPages(idx))
5442 Private Sub CopyStot()
5443 Dim clstr As String = ""
5444 Dim sb As New StringBuilder()
5445 Dim IsProtected As Boolean = False
5446 Dim isDm As Boolean = False
5447 If Me._curTab IsNot Nothing AndAlso Me._statuses.GetTabByName(Me._curTab.Text) IsNot Nothing Then isDm = Me._statuses.GetTabByName(Me._curTab.Text).TabType = TabUsageType.DirectMessage
5448 For Each idx As Integer In _curList.SelectedIndices
5449 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5450 If post.IsProtect Then
5454 If post.IsDeleted Then Continue For
5456 If post.RetweetedId > 0 Then
5457 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.ScreenName, post.TextFromApi, post.RetweetedId, Environment.NewLine)
5459 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.ScreenName, post.TextFromApi, post.StatusId, Environment.NewLine)
5462 sb.AppendFormat("{0}:{1} [{2}]{3}", post.ScreenName, post.TextFromApi, post.StatusId, Environment.NewLine)
5466 MessageBox.Show(My.Resources.CopyStotText1)
5468 If sb.Length > 0 Then
5469 clstr = sb.ToString()
5471 Clipboard.SetDataObject(clstr, False, 5, 100)
5472 Catch ex As Exception
5473 MessageBox.Show(ex.Message)
5478 Private Sub CopyIdUri()
5479 Dim clstr As String = ""
5480 Dim sb As New StringBuilder()
5481 If Me._curTab Is Nothing Then Exit Sub
5482 If Me._statuses.GetTabByName(Me._curTab.Text) Is Nothing Then Exit Sub
5483 If Me._statuses.GetTabByName(Me._curTab.Text).TabType = TabUsageType.DirectMessage Then Exit Sub
5484 For Each idx As Integer In _curList.SelectedIndices
5485 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5486 If post.RetweetedId > 0 Then
5487 sb.AppendFormat("http://twitter.com/{0}/status/{1}{2}", post.ScreenName, post.RetweetedId, Environment.NewLine)
5489 sb.AppendFormat("http://twitter.com/{0}/status/{1}{2}", post.ScreenName, post.StatusId, Environment.NewLine)
5492 If sb.Length > 0 Then
5493 clstr = sb.ToString()
5495 Clipboard.SetDataObject(clstr, False, 5, 100)
5496 Catch ex As Exception
5497 MessageBox.Show(ex.Message)
5502 Private Sub GoFav(ByVal forward As Boolean)
5503 If _curList.VirtualListSize = 0 Then Exit Sub
5504 Dim fIdx As Integer = 0
5505 Dim toIdx As Integer = 0
5506 Dim stp As Integer = 1
5509 If _curList.SelectedIndices.Count = 0 Then
5512 fIdx = _curList.SelectedIndices(0) + 1
5513 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
5515 toIdx = _curList.VirtualListSize - 1
5518 If _curList.SelectedIndices.Count = 0 Then
5519 fIdx = _curList.VirtualListSize - 1
5521 fIdx = _curList.SelectedIndices(0) - 1
5522 If fIdx < 0 Then Exit Sub
5528 For idx As Integer = fIdx To toIdx Step stp
5529 If _statuses.Item(_curTab.Text, idx).IsFav Then
5530 SelectListItem(_curList, idx)
5531 _curList.EnsureVisible(idx)
5537 Private Sub GoSamePostToAnotherTab(ByVal left As Boolean)
5538 If _curList.VirtualListSize = 0 Then Exit Sub
5539 Dim fIdx As Integer = 0
5540 Dim toIdx As Integer = 0
5541 Dim stp As Integer = 1
5542 Dim targetId As Long = 0
5544 If _statuses.Tabs(_curTab.Text).TabType = TabUsageType.DirectMessage Then Exit Sub ' Directタブは対象外(見つかるはずがない)
5545 If _curList.SelectedIndices.Count = 0 Then Exit Sub '未選択も処理しない
5547 targetId = GetCurTabPost(_curList.SelectedIndices(0)).StatusId
5551 If ListTab.SelectedIndex = 0 Then
5554 fIdx = ListTab.SelectedIndex - 1
5560 If ListTab.SelectedIndex = ListTab.TabCount - 1 Then
5563 fIdx = ListTab.SelectedIndex + 1
5565 toIdx = ListTab.TabCount - 1
5569 Dim found As Boolean = False
5570 For tabidx As Integer = fIdx To toIdx Step stp
5571 If _statuses.Tabs(ListTab.TabPages(tabidx).Text).TabType = TabUsageType.DirectMessage Then Continue For ' Directタブは対象外
5572 For idx As Integer = 0 To DirectCast(ListTab.TabPages(tabidx).Tag, DetailsListView).VirtualListSize - 1
5573 If _statuses.Item(ListTab.TabPages(tabidx).Text, idx).StatusId = targetId Then
5574 ListTab.SelectedIndex = tabidx
5575 ListTabSelect(ListTab.TabPages(tabidx))
5576 SelectListItem(_curList, idx)
5577 _curList.EnsureVisible(idx)
5582 If found Then Exit For
5586 Private Sub GoPost(ByVal forward As Boolean)
5587 If _curList.SelectedIndices.Count = 0 OrElse _curPost Is Nothing Then Exit Sub
5588 Dim fIdx As Integer = 0
5589 Dim toIdx As Integer = 0
5590 Dim stp As Integer = 1
5593 fIdx = _curList.SelectedIndices(0) + 1
5594 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
5595 toIdx = _curList.VirtualListSize - 1
5598 fIdx = _curList.SelectedIndices(0) - 1
5599 If fIdx < 0 Then Exit Sub
5604 Dim name As String = ""
5605 If _curPost.RetweetedId = 0 Then
5606 name = _curPost.ScreenName
5608 name = _curPost.RetweetedBy
5610 For idx As Integer = fIdx To toIdx Step stp
5611 If _statuses.Item(_curTab.Text, idx).RetweetedId = 0 Then
5612 If _statuses.Item(_curTab.Text, idx).ScreenName = name Then
5613 SelectListItem(_curList, idx)
5614 _curList.EnsureVisible(idx)
5618 If _statuses.Item(_curTab.Text, idx).RetweetedBy = name Then
5619 SelectListItem(_curList, idx)
5620 _curList.EnsureVisible(idx)
5627 Private Sub GoRelPost(ByVal forward As Boolean)
5628 If _curList.SelectedIndices.Count = 0 Then Exit Sub
5630 Dim fIdx As Integer = 0
5631 Dim toIdx As Integer = 0
5632 Dim stp As Integer = 1
5634 fIdx = _curList.SelectedIndices(0) + 1
5635 If fIdx > _curList.VirtualListSize - 1 Then Exit Sub
5636 toIdx = _curList.VirtualListSize - 1
5639 fIdx = _curList.SelectedIndices(0) - 1
5640 If fIdx < 0 Then Exit Sub
5645 If Not _anchorFlag Then
5646 If _curPost Is Nothing Then Exit Sub
5647 _anchorPost = _curPost
5650 If _anchorPost Is Nothing Then Exit Sub
5653 For idx As Integer = fIdx To toIdx Step stp
5654 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
5655 If post.ScreenName = _anchorPost.ScreenName OrElse _
5656 post.RetweetedBy = _anchorPost.ScreenName OrElse _
5657 post.ScreenName = _anchorPost.RetweetedBy OrElse _
5658 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso post.RetweetedBy = _anchorPost.RetweetedBy) OrElse _
5659 _anchorPost.ReplyToList.Contains(post.ScreenName.ToLower()) OrElse _
5660 _anchorPost.ReplyToList.Contains(post.RetweetedBy.ToLower()) OrElse _
5661 post.ReplyToList.Contains(_anchorPost.ScreenName.ToLower()) OrElse _
5662 post.ReplyToList.Contains(_anchorPost.RetweetedBy.ToLower()) Then
5663 SelectListItem(_curList, idx)
5664 _curList.EnsureVisible(idx)
5670 Private Sub GoAnchor()
5671 If _anchorPost Is Nothing Then Exit Sub
5672 Dim idx As Integer = _statuses.Tabs(_curTab.Text).IndexOf(_anchorPost.StatusId)
5673 If idx = -1 Then Exit Sub
5675 SelectListItem(_curList, idx)
5676 _curList.EnsureVisible(idx)
5679 Private Sub GoTopEnd(ByVal GoTop As Boolean)
5680 Dim _item As ListViewItem
5684 _item = _curList.GetItemAt(0, 25)
5685 If _item Is Nothing Then
5691 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
5692 If _item Is Nothing Then
5693 idx = _curList.VirtualListSize - 1
5698 SelectListItem(_curList, idx)
5701 Private Sub GoMiddle()
5702 Dim _item As ListViewItem
5707 _item = _curList.GetItemAt(0, 0)
5708 If _item Is Nothing Then
5713 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
5714 If _item Is Nothing Then
5715 idx2 = _curList.VirtualListSize - 1
5719 idx3 = (idx1 + idx2) \ 2
5721 SelectListItem(_curList, idx3)
5724 Private Sub GoLast()
5725 If _curList.VirtualListSize = 0 Then Exit Sub
5727 If _statuses.SortOrder = SortOrder.Ascending Then
5728 SelectListItem(_curList, _curList.VirtualListSize - 1)
5729 _curList.EnsureVisible(_curList.VirtualListSize - 1)
5731 SelectListItem(_curList, 0)
5732 _curList.EnsureVisible(0)
5736 Private Sub MoveTop()
5737 If _curList.SelectedIndices.Count = 0 Then Exit Sub
5738 Dim idx As Integer = _curList.SelectedIndices(0)
5739 If _statuses.SortOrder = SortOrder.Ascending Then
5740 _curList.EnsureVisible(_curList.VirtualListSize - 1)
5742 _curList.EnsureVisible(0)
5744 _curList.EnsureVisible(idx)
5747 Private Sub GoInReplyToPostTree()
5748 If _curPost Is Nothing Then Return
5750 Dim curTabClass As TabClass = _statuses.Tabs(_curTab.Text)
5752 If curTabClass.TabType = TabUsageType.PublicSearch AndAlso _curPost.InReplyToStatusId = 0 AndAlso _curPost.TextFromApi.Contains("@") Then
5753 Dim post As PostClass = Nothing
5754 Dim r As String = tw.GetStatusApi(False, _curPost.StatusId, post)
5755 If r = "" AndAlso post IsNot Nothing Then
5756 _curPost.InReplyToStatusId = post.InReplyToStatusId
5757 _curPost.InReplyToUser = post.InReplyToUser
5758 _curPost.IsReply = post.IsReply
5759 _itemCache = Nothing
5760 _curList.RedrawItems(_curItemIndex, _curItemIndex, False)
5762 Me.StatusLabel.Text = r
5766 If Not (Me.ExistCurrentPost AndAlso _curPost.InReplyToUser IsNot Nothing AndAlso _curPost.InReplyToStatusId > 0) Then Return
5768 If replyChains Is Nothing OrElse (replyChains.Count > 0 AndAlso replyChains.Peek().InReplyToId <> _curPost.StatusId) Then
5769 replyChains = New Stack(Of ReplyChain)
5771 replyChains.Push(New ReplyChain(_curPost.StatusId, _curPost.InReplyToStatusId, _curTab))
5773 Dim inReplyToIndex As Integer
5774 Dim inReplyToTabName As String
5775 Dim inReplyToId As Long = _curPost.InReplyToStatusId
5776 Dim inReplyToUser As String = _curPost.InReplyToUser
5777 Dim curTabPosts As Dictionary(Of Long, PostClass)
5779 If _statuses.Tabs(_curTab.Text).IsInnerStorageTabType Then
5780 curTabPosts = curTabClass.Posts
5782 curTabPosts = _statuses.Posts
5785 Dim inReplyToPosts = From tab In _statuses.Tabs.Values
5786 Order By tab IsNot curTabClass
5787 From post In DirectCast(IIf(tab.IsInnerStorageTabType, tab.Posts, _statuses.Posts), Dictionary(Of Long, PostClass)).Values
5788 Where post.StatusId = inReplyToId
5789 Let index = tab.IndexOf(post.StatusId)
5791 Select New With {.Tab = tab, .Index = index}
5794 Dim inReplyPost = inReplyToPosts.First()
5795 inReplyToTabName = inReplyPost.Tab.TabName
5796 inReplyToIndex = inReplyPost.Index
5797 Catch ex As InvalidOperationException
5798 Dim post As PostClass = Nothing
5799 Dim r As String = tw.GetStatusApi(False, _curPost.InReplyToStatusId, post)
5800 If r = "" AndAlso post IsNot Nothing Then
5802 _statuses.AddPost(post)
5803 _statuses.DistributePosts()
5804 '_statuses.SubmitUpdate(Nothing, Nothing, Nothing, False)
5805 Me.RefreshTimeline(False)
5807 Dim inReplyPost = inReplyToPosts.First()
5808 inReplyToTabName = inReplyPost.Tab.TabName
5809 inReplyToIndex = inReplyPost.Index
5810 Catch ex2 As InvalidOperationException
5811 OpenUriAsync("http://twitter.com/" + inReplyToUser + "/statuses/" + inReplyToId.ToString())
5815 Me.StatusLabel.Text = r
5816 OpenUriAsync("http://twitter.com/" + inReplyToUser + "/statuses/" + inReplyToId.ToString())
5821 Dim tabPage = Me.ListTab.TabPages.Cast(Of TabPage).First(Function(tp) tp.Text = inReplyToTabName)
5822 Dim listView = DirectCast(tabPage.Tag, DetailsListView)
5824 If _curTab IsNot tabPage Then
5825 Me.ListTab.SelectTab(tabPage)
5828 Me.SelectListItem(listView, inReplyToIndex)
5829 listView.EnsureVisible(inReplyToIndex)
5832 Private Sub GoBackInReplyToPostTree(Optional ByVal parallel As Boolean = False, Optional ByVal isForward As Boolean = True)
5833 If _curPost Is Nothing Then Return
5835 Dim curTabClass As TabClass = _statuses.Tabs(_curTab.Text)
5836 Dim curTabPosts As Dictionary(Of Long, PostClass) = DirectCast(IIf(curTabClass.IsInnerStorageTabType, curTabClass.Posts, _statuses.Posts), Dictionary(Of Long, PostClass))
5839 If _curPost.InReplyToStatusId <> 0 Then
5840 Dim posts = From t In _statuses.Tabs
5841 From p In DirectCast(IIf(t.Value.IsInnerStorageTabType, t.Value.Posts, _statuses.Posts), Dictionary(Of Long, PostClass))
5842 Where p.Value.StatusId <> _curPost.StatusId AndAlso p.Value.InReplyToStatusId = _curPost.InReplyToStatusId
5843 Let indexOf = t.Value.IndexOf(p.Value.StatusId)
5845 Order By IIf(isForward, indexOf, indexOf * -1)
5846 Order By t.Value IsNot curTabClass
5847 Select New With {.Tab = t.Value, .Post = p.Value, .Index = indexOf}
5849 Dim postList = posts.ToList()
5850 For i As Integer = postList.Count - 1 To 0 Step -1
5851 Dim index As Integer = i
5852 If postList.FindIndex(Function(pst) pst.Post.StatusId = postList(index).Post.StatusId) <> index Then
5853 postList.RemoveAt(index)
5856 Dim post = postList.FirstOrDefault(Function(pst) pst.Tab Is curTabClass AndAlso DirectCast(IIf(isForward, pst.Index > _curItemIndex, pst.Index < _curItemIndex), Boolean))
5857 If post Is Nothing Then post = postList.FirstOrDefault(Function(pst) pst.Tab IsNot curTabClass)
5858 If post Is Nothing Then post = postList.First()
5859 Me.ListTab.SelectTab(Me.ListTab.TabPages.Cast(Of TabPage).First(Function(tp) tp.Text = post.Tab.TabName))
5860 Dim listView = DirectCast(Me.ListTab.SelectedTab.Tag, DetailsListView)
5861 SelectListItem(listView, post.Index)
5862 listView.EnsureVisible(post.Index)
5863 Catch ex As InvalidOperationException
5868 If replyChains Is Nothing OrElse replyChains.Count < 1 Then
5869 Dim posts = From t In _statuses.Tabs
5870 From p In DirectCast(IIf(t.Value.IsInnerStorageTabType, t.Value.Posts, _statuses.Posts), Dictionary(Of Long, PostClass))
5871 Where p.Value.InReplyToStatusId = _curPost.StatusId
5872 Let indexOf = t.Value.IndexOf(p.Value.StatusId)
5875 Order By t.Value IsNot curTabClass
5876 Select New With {.Tab = t.Value, .Index = indexOf}
5878 Dim post = posts.First()
5879 Me.ListTab.SelectTab(Me.ListTab.TabPages.Cast(Of TabPage).First(Function(tp) tp.Text = post.Tab.TabName))
5880 Dim listView = DirectCast(Me.ListTab.SelectedTab.Tag, DetailsListView)
5881 SelectListItem(listView, post.Index)
5882 listView.EnsureVisible(post.Index)
5883 Catch ex As InvalidOperationException
5887 Dim chainHead As ReplyChain = replyChains.Pop()
5888 If chainHead.InReplyToId = _curPost.StatusId Then
5889 Dim idx As Integer = _statuses.Tabs(chainHead.OriginalTab.Text).IndexOf(chainHead.OriginalId)
5891 replyChains = Nothing
5894 ListTab.SelectTab(chainHead.OriginalTab)
5895 Catch ex As Exception
5896 replyChains = Nothing
5898 SelectListItem(_curList, idx)
5899 _curList.EnsureVisible(idx)
5902 replyChains = Nothing
5903 Me.GoBackInReplyToPostTree(parallel)
5909 Private Sub MyList_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
5913 Private Sub StatusText_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.Enter
5914 ' フォーカスの戻り先を StatusText に設定
5916 StatusText.BackColor = _clInputBackcolor
5919 Public Property InputBackColor() As System.Drawing.Color
5921 Return _clInputBackcolor
5923 Set(ByVal value As System.Drawing.Color)
5924 _clInputBackcolor = value
5928 Private Sub StatusText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.Leave
5929 ' フォーカスがメニューに遷移しないならばフォーカスはタブに移ることを期待
5930 If ListTab.SelectedTab IsNot Nothing AndAlso MenuStrip1.Tag Is Nothing Then Me.Tag = ListTab.SelectedTab.Tag
5931 StatusText.BackColor = Color.FromKnownColor(KnownColor.Window)
5934 Private Sub StatusText_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StatusText.KeyDown
5935 Dim State As ModifierState = GetModifierState(e.Control, e.Shift, e.Alt)
5936 If State = ModifierState.NotFlags Then Exit Sub
5937 If CommonKeyDown(e.KeyCode, ModifierState.StatusText, State) Then
5939 e.SuppressKeyPress = True
5942 Me.StatusText_TextChanged(Nothing, Nothing)
5945 Private Sub SaveConfigsAll(ByVal ifModified As Boolean)
5946 If Not ifModified Then
5949 'SaveConfigsTab(True) 'True:事前に設定ファイル削除
5952 If _modifySettingCommon Then SaveConfigsCommon()
5953 If _modifySettingLocal Then SaveConfigsLocal()
5954 If _modifySettingAtId AndAlso SettingDialog.UseAtIdSupplement AndAlso AtIdSupl IsNot Nothing Then
5955 _modifySettingAtId = False
5956 Dim cfgAtId As New SettingAtIdList(AtIdSupl.GetItemList)
5962 Private Sub SaveConfigsCommon()
5963 If _ignoreConfigSave Then Exit Sub
5965 _modifySettingCommon = False
5966 SyncLock _syncObject
5967 _cfgCommon.UserName = tw.Username
5968 _cfgCommon.Password = tw.Password
5969 _cfgCommon.IsOAuth = SettingDialog.IsOAuth
5970 _cfgCommon.Token = tw.AccessToken
5971 _cfgCommon.TokenSecret = tw.AccessTokenSecret
5972 _cfgCommon.UserstreamStartup = SettingDialog.UserstreamStartup
5973 _cfgCommon.UserstreamPeriod = SettingDialog.UserstreamPeriodInt
5974 _cfgCommon.TimelinePeriod = SettingDialog.TimelinePeriodInt
5975 _cfgCommon.ReplyPeriod = SettingDialog.ReplyPeriodInt
5976 _cfgCommon.DMPeriod = SettingDialog.DMPeriodInt
5977 _cfgCommon.PubSearchPeriod = SettingDialog.PubSearchPeriodInt
5978 _cfgCommon.ListsPeriod = SettingDialog.ListsPeriodInt
5979 _cfgCommon.UserTimelinePeriod = SettingDialog.UserTimelinePeriodInt
5980 _cfgCommon.Read = SettingDialog.Readed
5981 _cfgCommon.IconSize = SettingDialog.IconSz
5982 _cfgCommon.UnreadManage = SettingDialog.UnreadManage
5983 _cfgCommon.PlaySound = SettingDialog.PlaySound
5984 _cfgCommon.OneWayLove = SettingDialog.OneWayLove
5986 _cfgCommon.NameBalloon = SettingDialog.NameBalloon
5987 _cfgCommon.PostCtrlEnter = SettingDialog.PostCtrlEnter
5988 _cfgCommon.PostShiftEnter = SettingDialog.PostShiftEnter
5989 _cfgCommon.CountApi = SettingDialog.CountApi
5990 _cfgCommon.CountApiReply = SettingDialog.CountApiReply
5991 _cfgCommon.PostAndGet = SettingDialog.PostAndGet
5992 _cfgCommon.DispUsername = SettingDialog.DispUsername
5993 _cfgCommon.MinimizeToTray = SettingDialog.MinimizeToTray
5994 _cfgCommon.CloseToExit = SettingDialog.CloseToExit
5995 _cfgCommon.DispLatestPost = SettingDialog.DispLatestPost
5996 _cfgCommon.SortOrderLock = SettingDialog.SortOrderLock
5997 _cfgCommon.TinyUrlResolve = SettingDialog.TinyUrlResolve
5998 _cfgCommon.PeriodAdjust = SettingDialog.PeriodAdjust
5999 _cfgCommon.StartupVersion = SettingDialog.StartupVersion
6000 _cfgCommon.StartupFollowers = SettingDialog.StartupFollowers
6001 _cfgCommon.RestrictFavCheck = SettingDialog.RestrictFavCheck
6002 _cfgCommon.AlwaysTop = SettingDialog.AlwaysTop
6003 _cfgCommon.UrlConvertAuto = SettingDialog.UrlConvertAuto
6004 _cfgCommon.Outputz = SettingDialog.OutputzEnabled
6005 _cfgCommon.OutputzKey = SettingDialog.OutputzKey
6006 _cfgCommon.OutputzUrlMode = SettingDialog.OutputzUrlmode
6007 _cfgCommon.UseUnreadStyle = SettingDialog.UseUnreadStyle
6008 _cfgCommon.DateTimeFormat = SettingDialog.DateTimeFormat
6009 _cfgCommon.DefaultTimeOut = SettingDialog.DefaultTimeOut
6010 _cfgCommon.RetweetNoConfirm = SettingDialog.RetweetNoConfirm
6011 _cfgCommon.LimitBalloon = SettingDialog.LimitBalloon
6012 _cfgCommon.EventNotifyEnabled = SettingDialog.EventNotifyEnabled
6013 _cfgCommon.EventNotifyFlag = SettingDialog.EventNotifyFlag
6014 _cfgCommon.IsMyEventNotifyFlag = SettingDialog.IsMyEventNotifyFlag
6015 _cfgCommon.ForceEventNotify = SettingDialog.ForceEventNotify
6016 _cfgCommon.FavEventUnread = SettingDialog.FavEventUnread
6017 _cfgCommon.TranslateLanguage = SettingDialog.TranslateLanguage
6018 _cfgCommon.EventSoundFile = SettingDialog.EventSoundFile
6019 _cfgCommon.AutoShortUrlFirst = SettingDialog.AutoShortUrlFirst
6020 _cfgCommon.TabIconDisp = SettingDialog.TabIconDisp
6021 _cfgCommon.ReplyIconState = SettingDialog.ReplyIconState
6022 _cfgCommon.ReadOwnPost = SettingDialog.ReadOwnPost
6023 _cfgCommon.GetFav = SettingDialog.GetFav
6024 _cfgCommon.IsMonospace = SettingDialog.IsMonospace
6025 If IdeographicSpaceToSpaceToolStripMenuItem IsNot Nothing AndAlso _
6026 IdeographicSpaceToSpaceToolStripMenuItem.IsDisposed = False Then
6027 _cfgCommon.WideSpaceConvert = Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked
6029 _cfgCommon.ReadOldPosts = SettingDialog.ReadOldPosts
6030 _cfgCommon.UseSsl = SettingDialog.UseSsl
6031 _cfgCommon.BilyUser = SettingDialog.BitlyUser
6032 _cfgCommon.BitlyPwd = SettingDialog.BitlyPwd
6033 _cfgCommon.ShowGrid = SettingDialog.ShowGrid
6034 _cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement
6035 _cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement
6036 _cfgCommon.PreviewEnable = SettingDialog.PreviewEnable
6037 _cfgCommon.Language = SettingDialog.Language
6039 _cfgCommon.SortOrder = _statuses.SortOrder
6040 Select Case _statuses.SortMode
6041 Case IdComparerClass.ComparerMode.Nickname 'ニックネーム
6042 _cfgCommon.SortColumn = 1
6043 Case IdComparerClass.ComparerMode.Data '本文
6044 _cfgCommon.SortColumn = 2
6045 Case IdComparerClass.ComparerMode.Id '時刻=発言Id
6046 _cfgCommon.SortColumn = 3
6047 Case IdComparerClass.ComparerMode.Name '名前
6048 _cfgCommon.SortColumn = 4
6049 Case IdComparerClass.ComparerMode.Source 'Source
6050 _cfgCommon.SortColumn = 7
6053 _cfgCommon.Nicoms = SettingDialog.Nicoms
6054 _cfgCommon.HashTags = HashMgr.HashHistories
6055 If HashMgr.IsPermanent Then
6056 _cfgCommon.HashSelected = HashMgr.UseHash
6058 _cfgCommon.HashSelected = ""
6060 _cfgCommon.HashIsHead = HashMgr.IsHead
6061 _cfgCommon.HashIsPermanent = HashMgr.IsPermanent
6062 _cfgCommon.TwitterUrl = SettingDialog.TwitterApiUrl
6063 _cfgCommon.TwitterSearchUrl = SettingDialog.TwitterSearchApiUrl
6064 _cfgCommon.HotkeyEnabled = SettingDialog.HotkeyEnabled
6065 _cfgCommon.HotkeyModifier = SettingDialog.HotkeyMod
6066 _cfgCommon.HotkeyKey = SettingDialog.HotkeyKey
6067 _cfgCommon.HotkeyValue = SettingDialog.HotkeyValue
6068 _cfgCommon.BlinkNewMentions = SettingDialog.BlinkNewMentions
6069 If ToolStripFocusLockMenuItem IsNot Nothing AndAlso _
6070 ToolStripFocusLockMenuItem.IsDisposed = False Then
6071 _cfgCommon.FocusLockToStatusText = Me.ToolStripFocusLockMenuItem.Checked
6073 _cfgCommon.UseAdditionalCount = SettingDialog.UseAdditionalCount
6074 _cfgCommon.MoreCountApi = SettingDialog.MoreCountApi
6075 _cfgCommon.FirstCountApi = SettingDialog.FirstCountApi
6076 _cfgCommon.SearchCountApi = SettingDialog.SearchCountApi
6077 _cfgCommon.FavoritesCountApi = SettingDialog.FavoritesCountApi
6078 _cfgCommon.UserTimelineCountApi = SettingDialog.UserTimelineCountApi
6079 _cfgCommon.TrackWord = tw.TrackWord
6080 _cfgCommon.AllAtReply = tw.AllAtReply
6081 _cfgCommon.OpenUserTimeline = SettingDialog.OpenUserTimeline
6082 _cfgCommon.ListCountApi = SettingDialog.ListCountApi
6083 _cfgCommon.UseImageService = ImageServiceCombo.SelectedIndex
6089 Private Sub SaveConfigsLocal()
6090 If _ignoreConfigSave Then Exit Sub
6091 SyncLock _syncObject
6092 _modifySettingLocal = False
6093 _cfgLocal.FormSize = _mySize
6094 _cfgLocal.FormLocation = _myLoc
6095 _cfgLocal.SplitterDistance = _mySpDis
6096 _cfgLocal.PreviewDistance = _mySpDis3
6097 _cfgLocal.StatusMultiline = StatusText.Multiline
6098 _cfgLocal.StatusTextHeight = _mySpDis2
6099 _cfgLocal.StatusText = SettingDialog.Status
6101 _cfgLocal.FontUnread = _fntUnread
6102 _cfgLocal.ColorUnread = _clUnread
6103 _cfgLocal.FontRead = _fntReaded
6104 _cfgLocal.ColorRead = _clReaded
6105 _cfgLocal.FontDetail = _fntDetail
6106 _cfgLocal.ColorDetail = _clDetail
6107 _cfgLocal.ColorDetailBackcolor = _clDetailBackcolor
6108 _cfgLocal.ColorDetailLink = _clDetailLink
6109 _cfgLocal.ColorFav = _clFav
6110 _cfgLocal.ColorOWL = _clOWL
6111 _cfgLocal.ColorRetweet = _clRetweet
6112 _cfgLocal.ColorSelf = _clSelf
6113 _cfgLocal.ColorAtSelf = _clAtSelf
6114 _cfgLocal.ColorTarget = _clTarget
6115 _cfgLocal.ColorAtTarget = _clAtTarget
6116 _cfgLocal.ColorAtFromTarget = _clAtFromTarget
6117 _cfgLocal.ColorAtTo = _clAtTo
6118 _cfgLocal.ColorListBackcolor = _clListBackcolor
6119 _cfgLocal.ColorInputBackcolor = _clInputBackcolor
6120 _cfgLocal.ColorInputFont = _clInputFont
6121 _cfgLocal.FontInputFont = _fntInputFont
6123 _cfgLocal.BrowserPath = SettingDialog.BrowserPath
6124 _cfgLocal.UseRecommendStatus = SettingDialog.UseRecommendStatus
6125 _cfgLocal.ProxyType = SettingDialog.SelectedProxyType
6126 _cfgLocal.ProxyAddress = SettingDialog.ProxyAddress
6127 _cfgLocal.ProxyPort = SettingDialog.ProxyPort
6128 _cfgLocal.ProxyUser = SettingDialog.ProxyUser
6129 _cfgLocal.ProxyPassword = SettingDialog.ProxyPassword
6130 If _ignoreConfigSave Then Exit Sub
6135 Private Sub SaveConfigsTabs()
6136 Dim tabSetting As New SettingTabs
6137 For i As Integer = 0 To ListTab.TabPages.Count - 1
6138 If _statuses.Tabs(ListTab.TabPages(i).Text).TabType <> TabUsageType.Related Then tabSetting.Tabs.Add(_statuses.Tabs(ListTab.TabPages(i).Text))
6143 Private Sub SaveLogMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveLogMenuItem.Click, SaveFileMenuItem.Click
6144 Dim rslt As DialogResult = MessageBox.Show(String.Format(My.Resources.SaveLogMenuItem_ClickText1, Environment.NewLine), _
6145 My.Resources.SaveLogMenuItem_ClickText2, _
6146 MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
6147 If rslt = Windows.Forms.DialogResult.Cancel Then Exit Sub
6149 SaveFileDialog1.FileName = "TweenPosts" + Format(Now, "yyMMdd-HHmmss") + ".tsv"
6150 SaveFileDialog1.InitialDirectory = My.Application.Info.DirectoryPath
6151 SaveFileDialog1.Filter = My.Resources.SaveLogMenuItem_ClickText3
6152 SaveFileDialog1.FilterIndex = 0
6153 SaveFileDialog1.Title = My.Resources.SaveLogMenuItem_ClickText4
6154 SaveFileDialog1.RestoreDirectory = True
6156 If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
6157 If Not SaveFileDialog1.ValidateNames Then Exit Sub
6158 Using sw As StreamWriter = New StreamWriter(SaveFileDialog1.FileName, False, Encoding.UTF8)
6159 If rslt = Windows.Forms.DialogResult.Yes Then
6161 For idx As Integer = 0 To _curList.VirtualListSize - 1
6162 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
6163 Dim protect As String = ""
6164 If post.IsProtect Then protect = "Protect"
6165 sw.WriteLine(post.Nickname & vbTab & _
6166 """" & post.TextFromApi.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6167 post.CreatedAt.ToString() & vbTab & _
6168 post.ScreenName & vbTab & _
6169 post.StatusId.ToString() & vbTab & _
6170 post.ImageUrl & vbTab & _
6171 """" & post.Text.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6175 For Each idx As Integer In _curList.SelectedIndices
6176 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
6177 Dim protect As String = ""
6178 If post.IsProtect Then protect = "Protect"
6179 sw.WriteLine(post.Nickname & vbTab & _
6180 """" & post.TextFromApi.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6181 post.CreatedAt.ToString() & vbTab & _
6182 post.ScreenName & vbTab & _
6183 post.StatusId.ToString() & vbTab & _
6184 post.ImageUrl & vbTab & _
6185 """" & post.Text.Replace(vbLf, "").Replace("""", """""") + """" & vbTab & _
6193 Me.TopMost = SettingDialog.AlwaysTop
6196 Private Sub PostBrowser_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles PostBrowser.PreviewKeyDown
6197 Dim State As ModifierState = GetModifierState(e.Control, e.Shift, e.Alt)
6198 If State = ModifierState.NotFlags Then Exit Sub
6199 Dim KeyRes As Boolean = CommonKeyDown(e.KeyCode, ModifierState.PostBrowser, State)
6204 Public Function TabRename(ByRef tabName As String) As Boolean
6206 Dim newTabText As String = Nothing
6207 Using inputName As New InputTabName()
6208 inputName.TabName = tabName
6209 inputName.ShowDialog()
6210 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Return False
6211 newTabText = inputName.TabName
6214 Me.TopMost = SettingDialog.AlwaysTop
6215 If Not String.IsNullOrEmpty(newTabText) Then
6217 For i As Integer = 0 To ListTab.TabCount - 1
6218 If ListTab.TabPages(i).Text = newTabText Then
6219 Dim tmp As String = String.Format(My.Resources.Tabs_DoubleClickText1, newTabText)
6220 MessageBox.Show(tmp, My.Resources.Tabs_DoubleClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
6224 'タブ名のリスト作り直し(デフォルトタブ以外は再作成)
6225 For i As Integer = 0 To ListTab.TabCount - 1
6226 If _statuses.IsDistributableTab(ListTab.TabPages(i).Text) Then
6227 TabDialog.RemoveTab(ListTab.TabPages(i).Text)
6229 If ListTab.TabPages(i).Text = tabName Then
6230 ListTab.TabPages(i).Text = newTabText
6233 _statuses.RenameTab(tabName, newTabText)
6235 For i As Integer = 0 To ListTab.TabCount - 1
6236 If _statuses.IsDistributableTab(ListTab.TabPages(i).Text) Then
6237 If ListTab.TabPages(i).Text = tabName Then
6238 ListTab.TabPages(i).Text = newTabText
6240 TabDialog.AddTab(ListTab.TabPages(i).Text)
6245 _rclickTabName = newTabText
6246 tabName = newTabText
6253 Private Sub ListTab_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseClick
6254 If e.Button = Windows.Forms.MouseButtons.Middle Then
6255 For i As Integer = 0 To Me.ListTab.TabPages.Count - 1
6256 If Me.ListTab.GetTabRect(i).Contains(e.Location) Then
6257 Me.RemoveSpecifiedTab(Me.ListTab.TabPages(i).Text, True)
6258 Me.SaveConfigsTabs()
6265 Private Sub Tabs_DoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDoubleClick
6266 Dim tn As String = ListTab.SelectedTab.Text
6270 Private Sub Tabs_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseDown
6271 Dim cpos As New Point(e.X, e.Y)
6272 If e.Button = Windows.Forms.MouseButtons.Left Then
6273 For i As Integer = 0 To ListTab.TabPages.Count - 1
6274 If Me.ListTab.GetTabRect(i).Contains(e.Location) Then
6276 _tabMouseDownPoint = e.Location
6285 Private Sub Tabs_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListTab.DragEnter
6286 If e.Data.GetDataPresent(GetType(TabPage)) Then
6287 e.Effect = DragDropEffects.Move
6289 e.Effect = DragDropEffects.None
6293 Private Sub Tabs_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListTab.DragDrop
6294 If Not e.Data.GetDataPresent(GetType(TabPage)) Then Exit Sub
6297 Dim tn As String = ""
6299 Dim cpos As New Point(e.X, e.Y)
6300 Dim spos As Point = ListTab.PointToClient(cpos)
6302 For i = 0 To ListTab.TabPages.Count - 1
6303 Dim rect As Rectangle = ListTab.GetTabRect(i)
6304 If rect.Left <= spos.X AndAlso spos.X <= rect.Right AndAlso _
6305 rect.Top <= spos.Y AndAlso spos.Y <= rect.Bottom Then
6306 tn = ListTab.TabPages(i).Text
6307 If spos.X <= (rect.Left + rect.Right) / 2 Then
6316 'タブのないところにドロップ->最後尾へ移動
6317 If String.IsNullOrEmpty(tn) Then
6318 tn = ListTab.TabPages(ListTab.TabPages.Count - 1).Text
6320 i = ListTab.TabPages.Count - 1
6323 Dim tp As TabPage = DirectCast(e.Data.GetData(GetType(TabPage)), TabPage)
6324 If tp.Text = tn Then Exit Sub
6326 ReOrderTab(tp.Text, tn, bef)
6329 Public Sub ReOrderTab(ByVal targetTabText As String, ByVal baseTabText As String, ByVal isBeforeBaseTab As Boolean)
6330 Dim baseIndex As Integer = 0
6331 For baseIndex = 0 To ListTab.TabPages.Count - 1
6332 If ListTab.TabPages(baseIndex).Text = baseTabText Then Exit For
6335 ListTab.SuspendLayout()
6337 Dim mTp As TabPage = Nothing
6338 For j As Integer = 0 To ListTab.TabPages.Count - 1
6339 If ListTab.TabPages(j).Text = targetTabText Then
6340 mTp = ListTab.TabPages(j)
6341 ListTab.TabPages.Remove(mTp)
6342 If j < baseIndex Then baseIndex -= 1
6346 If isBeforeBaseTab Then
6347 ListTab.TabPages.Insert(baseIndex, mTp)
6349 ListTab.TabPages.Insert(baseIndex + 1, mTp)
6352 ListTab.ResumeLayout()
6357 Private Sub MakeReplyOrDirectStatus(Optional ByVal isAuto As Boolean = True, Optional ByVal isReply As Boolean = True, Optional ByVal isAll As Boolean = False)
6358 'isAuto:True=先頭に挿入、False=カーソル位置に挿入
6359 'isReply:True=@,False=DM
6360 If Not StatusText.Enabled Then Exit Sub
6361 If _curList Is Nothing Then Exit Sub
6362 If _curTab Is Nothing Then Exit Sub
6363 If Not Me.ExistCurrentPost Then Exit Sub
6365 ' 複数あてリプライはReplyではなく通常ポスト
6366 '↑仕様変更で全部リプライ扱いでOK(先頭ドット付加しない)
6367 '090403暫定でドットを付加しないようにだけ修正。単独と複数の処理は統合できると思われる。
6368 '090513 all @ replies 廃止の仕様変更によりドット付加に戻し(syo68k)
6370 If _curList.SelectedIndices.Count > 0 Then
6372 If _curList.SelectedIndices.Count = 1 AndAlso Not isAll AndAlso Me.ExistCurrentPost Then
6374 If (_statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage AndAlso isAuto) OrElse (Not isAuto AndAlso Not isReply) Then
6376 StatusText.Text = "D " + _curPost.ScreenName + " " + StatusText.Text
6377 StatusText.SelectionStart = StatusText.Text.Length
6383 If String.IsNullOrEmpty(StatusText.Text) Then
6386 ' ステータステキストが入力されていない場合先頭に@ユーザー名を追加する
6387 StatusText.Text = "@" + _curPost.ScreenName + " "
6388 If _curPost.RetweetedId > 0 Then
6389 _reply_to_id = _curPost.RetweetedId
6391 _reply_to_id = _curPost.StatusId
6393 _reply_to_name = _curPost.ScreenName
6398 '1件選んでEnter or DoubleClick
6399 If StatusText.Text.Contains("@" + _curPost.ScreenName + " ") Then
6400 If _reply_to_id > 0 AndAlso _reply_to_name = _curPost.ScreenName Then
6402 If _curPost.RetweetedId > 0 Then
6403 _reply_to_id = _curPost.RetweetedId
6405 _reply_to_id = _curPost.StatusId
6407 _reply_to_name = _curPost.ScreenName
6411 If Not StatusText.Text.StartsWith("@") Then
6413 If StatusText.Text.StartsWith(". ") Then
6415 StatusText.Text = StatusText.Text.Insert(2, "@" + _curPost.ScreenName + " ")
6420 StatusText.Text = "@" + _curPost.ScreenName + " " + StatusText.Text
6421 If _curPost.RetweetedId > 0 Then
6422 _reply_to_id = _curPost.RetweetedId
6424 _reply_to_id = _curPost.StatusId
6426 _reply_to_name = _curPost.ScreenName
6431 StatusText.Text = ". @" + _curPost.ScreenName + " " + StatusText.Text
6432 'StatusText.Text = "@" + _curPost.ScreenName + " " + StatusText.Text
6437 '1件選んでCtrl-Rの場合(返信先操作せず)
6438 Dim sidx As Integer = StatusText.SelectionStart
6439 Dim id As String = "@" + _curPost.ScreenName + " "
6441 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6445 StatusText.Text = StatusText.Text.Insert(sidx, id)
6447 'If StatusText.Text.StartsWith("@") Then
6449 ' StatusText.Text = ". " + StatusText.Text.Insert(sidx, " @" + _curPost.ScreenName + " ")
6450 ' sidx += 5 + _curPost.ScreenName.Length
6453 ' StatusText.Text = StatusText.Text.Insert(sidx, " @" + _curPost.ScreenName + " ")
6454 ' sidx += 3 + _curPost.ScreenName.Length
6456 StatusText.SelectionStart = sidx
6459 '_reply_to_name = Nothing
6465 If Not isAuto AndAlso Not isReply Then Exit Sub
6467 'C-S-rか、複数の宛先を選択中にEnter/DoubleClick/C-r/C-S-r
6470 'Enter or DoubleClick
6472 Dim sTxt As String = StatusText.Text
6473 If Not sTxt.StartsWith(". ") Then
6478 For cnt As Integer = 0 To _curList.SelectedIndices.Count - 1
6479 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(cnt))
6480 If Not sTxt.Contains("@" + post.ScreenName + " ") Then
6481 sTxt = sTxt.Insert(2, "@" + post.ScreenName + " ")
6482 'sTxt = "@" + post.ScreenName + " " + sTxt
6485 StatusText.Text = sTxt
6488 If _curList.SelectedIndices.Count > 1 Then
6491 Dim ids As String = ""
6492 Dim sidx As Integer = StatusText.SelectionStart
6493 For cnt As Integer = 0 To _curList.SelectedIndices.Count - 1
6494 Dim post As PostClass = _statuses.Item(_curTab.Text, _curList.SelectedIndices(cnt))
6495 If Not ids.Contains("@" + post.ScreenName + " ") AndAlso _
6496 Not post.ScreenName.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6497 ids += "@" + post.ScreenName + " "
6500 For Each nm As String In post.ReplyToList
6501 If Not ids.Contains("@" + nm + " ") AndAlso _
6502 Not nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6503 Dim m As Match = Regex.Match(post.TextFromApi, "[@@](?<id>" + nm + ")([^a-zA-Z0-9]|$)", RegexOptions.IgnoreCase)
6505 ids += "@" + m.Result("${id}") + " "
6507 ids += "@" + nm + " "
6513 If ids.Length = 0 Then Exit Sub
6514 If Not StatusText.Text.StartsWith(". ") Then
6515 StatusText.Text = ". " + StatusText.Text
6521 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6525 StatusText.Text = StatusText.Text.Insert(sidx, ids)
6527 'If StatusText.Text.StartsWith("@") Then
6528 ' StatusText.Text = ". " + StatusText.Text.Insert(sidx, ids)
6529 ' sidx += 2 + ids.Length
6531 ' StatusText.Text = StatusText.Text.Insert(sidx, ids)
6532 ' sidx += 1 + ids.Length
6534 StatusText.SelectionStart = sidx
6538 '1件のみ選択のC-S-r(返信元付加する可能性あり)
6540 Dim ids As String = ""
6541 Dim sidx As Integer = StatusText.SelectionStart
6542 Dim post As PostClass = _curPost
6543 If Not ids.Contains("@" + post.ScreenName + " ") AndAlso _
6544 Not post.ScreenName.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6545 ids += "@" + post.ScreenName + " "
6547 For Each nm As String In post.ReplyToList
6548 If Not ids.Contains("@" + nm + " ") AndAlso _
6549 Not nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6550 Dim m As Match = Regex.Match(post.TextFromApi, "[@@](?<id>" + nm + ")([^a-zA-Z0-9]|$)", RegexOptions.IgnoreCase)
6552 ids += "@" + m.Result("${id}") + " "
6554 ids += "@" + nm + " "
6558 If Not String.IsNullOrEmpty(post.RetweetedBy) Then
6559 If Not ids.Contains("@" + post.RetweetedBy + " ") AndAlso _
6560 Not post.RetweetedBy.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase) Then
6561 ids += "@" + post.RetweetedBy + " "
6564 If ids.Length = 0 Then Exit Sub
6565 If String.IsNullOrEmpty(StatusText.Text) Then
6567 StatusText.Text = ids
6568 StatusText.SelectionStart = ids.Length
6570 If post.RetweetedId > 0 Then
6571 _reply_to_id = post.RetweetedId
6573 _reply_to_id = post.StatusId
6575 _reply_to_name = post.ScreenName
6580 If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
6584 StatusText.Text = StatusText.Text.Insert(sidx, ids)
6586 StatusText.SelectionStart = sidx
6592 StatusText.SelectionStart = StatusText.Text.Length
6597 Private Sub ListTab_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListTab.MouseUp
6601 Private Sub RefreshTasktrayIcon(ByVal forceRefresh As Boolean)
6602 If _colorize Then Colorize()
6603 If Not TimerRefreshIcon.Enabled Then Exit Sub
6604 Static iconCnt As Integer = 0
6605 Static blinkCnt As Integer = 0
6606 Static blink As Boolean = False
6607 Static idle As Boolean = False
6608 'Static usCheckCnt As Integer = 0
6610 'Static iconDlListTopItem As ListViewItem = Nothing
6612 If forceRefresh Then idle = False
6614 'If DirectCast(ListTab.SelectedTab.Tag, ListView).TopItem Is iconDlListTopItem Then
6615 ' DirectCast(Me.TIconDic, ImageDictionary).PauseGetImage = False
6617 ' DirectCast(Me.TIconDic, ImageDictionary).PauseGetImage = True
6619 'iconDlListTopItem = DirectCast(ListTab.SelectedTab.Tag, ListView).TopItem
6625 'If usCheckCnt > 300 Then '1min
6627 ' If Not Me.IsReceivedUserStream Then
6628 ' TraceOut("ReconnectUserStream")
6629 ' tw.ReconnectUserStream()
6633 Dim busy As Boolean = False
6634 For Each bw As BackgroundWorker In Me._bw
6635 If bw IsNot Nothing AndAlso bw.IsBusy Then
6644 If blinkCnt > 10 Then
6647 SaveConfigsAll(True)
6651 NotifyIcon1.Icon = NIconRefresh(iconCnt)
6653 _myStatusError = False
6657 Dim tb As TabClass = _statuses.GetTabByType(TabUsageType.Mentions)
6658 If SettingDialog.ReplyIconState <> REPLY_ICONSTATE.None AndAlso tb IsNot Nothing AndAlso tb.UnreadCount > 0 Then
6659 If blinkCnt > 0 Then Exit Sub
6661 If blink OrElse SettingDialog.ReplyIconState = REPLY_ICONSTATE.StaticIcon Then
6662 NotifyIcon1.Icon = ReplyIcon
6664 NotifyIcon1.Icon = ReplyIconBlink
6670 If idle Then Exit Sub
6674 If _myStatusError Then
6675 NotifyIcon1.Icon = NIconAtRed
6678 If _myStatusOnline Then
6679 NotifyIcon1.Icon = NIconAt
6681 NotifyIcon1.Icon = NIconAtSmoke
6685 Private Sub TimerRefreshIcon_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerRefreshIcon.Tick
6687 Me.RefreshTasktrayIcon(False)
6690 Private Sub ContextMenuTabProperty_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuTabProperty.Opening
6691 '右クリックの場合はタブ名が設定済。アプリケーションキーの場合は現在のタブを対象とする
6692 If String.IsNullOrEmpty(_rclickTabName) OrElse sender IsNot ContextMenuTabProperty Then
6693 If ListTab IsNot Nothing AndAlso ListTab.SelectedTab IsNot Nothing Then
6694 _rclickTabName = ListTab.SelectedTab.Text
6700 If _statuses Is Nothing Then Exit Sub
6701 If _statuses.Tabs Is Nothing Then Exit Sub
6703 Dim tb As TabClass = _statuses.Tabs(_rclickTabName)
6704 If tb Is Nothing Then Exit Sub
6706 NotifyDispMenuItem.Checked = tb.Notify
6707 Me.NotifyTbMenuItem.Checked = tb.Notify
6709 soundfileListup = True
6710 SoundFileComboBox.Items.Clear()
6711 Me.SoundFileTbComboBox.Items.Clear()
6712 SoundFileComboBox.Items.Add("")
6713 Me.SoundFileTbComboBox.Items.Add("")
6714 Dim oDir As IO.DirectoryInfo = New IO.DirectoryInfo(My.Application.Info.DirectoryPath + IO.Path.DirectorySeparatorChar)
6715 If IO.Directory.Exists(IO.Path.Combine(My.Application.Info.DirectoryPath, "Sounds")) Then
6716 oDir = oDir.GetDirectories("Sounds")(0)
6718 For Each oFile As IO.FileInfo In oDir.GetFiles("*.wav")
6719 SoundFileComboBox.Items.Add(oFile.Name)
6720 Me.SoundFileTbComboBox.Items.Add(oFile.Name)
6722 Dim idx As Integer = SoundFileComboBox.Items.IndexOf(tb.SoundFile)
6723 If idx = -1 Then idx = 0
6724 SoundFileComboBox.SelectedIndex = idx
6725 Me.SoundFileTbComboBox.SelectedIndex = idx
6726 soundfileListup = False
6727 UreadManageMenuItem.Checked = tb.UnreadManage
6728 Me.UnreadMngTbMenuItem.Checked = tb.UnreadManage
6730 TabMenuControl(_rclickTabName)
6733 Private Sub TabMenuControl(ByVal tabName As String)
6734 If _statuses.Tabs(tabName).TabType <> TabUsageType.Mentions AndAlso _statuses.IsDefaultTab(tabName) Then
6735 FilterEditMenuItem.Enabled = True
6736 Me.EditRuleTbMenuItem.Enabled = True
6737 DeleteTabMenuItem.Enabled = False
6738 Me.DeleteTbMenuItem.Enabled = False
6739 ElseIf _statuses.Tabs(tabName).TabType = TabUsageType.Mentions Then
6740 FilterEditMenuItem.Enabled = True
6741 Me.EditRuleTbMenuItem.Enabled = True
6742 DeleteTabMenuItem.Enabled = False
6743 Me.DeleteTbMenuItem.Enabled = False
6745 FilterEditMenuItem.Enabled = True
6746 Me.EditRuleTbMenuItem.Enabled = True
6747 DeleteTabMenuItem.Enabled = True
6748 Me.DeleteTbMenuItem.Enabled = True
6752 Private Sub UreadManageMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UreadManageMenuItem.Click, UnreadMngTbMenuItem.Click
6753 UreadManageMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
6754 Me.UnreadMngTbMenuItem.Checked = UreadManageMenuItem.Checked
6756 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6757 ChangeTabUnreadManage(_rclickTabName, UreadManageMenuItem.Checked)
6762 Public Sub ChangeTabUnreadManage(ByVal tabName As String, ByVal isManage As Boolean)
6765 For idx = 0 To ListTab.TabCount
6766 If ListTab.TabPages(idx).Text = tabName Then Exit For
6769 _statuses.SetTabUnreadManage(tabName, isManage)
6770 If SettingDialog.TabIconDisp Then
6771 If _statuses.Tabs(tabName).UnreadCount > 0 Then
6772 ListTab.TabPages(idx).ImageIndex = 0
6774 ListTab.TabPages(idx).ImageIndex = -1
6778 If _curTab.Text = tabName Then
6779 _itemCache = Nothing
6780 _postCache = Nothing
6784 SetMainWindowTitle()
6786 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6789 Private Sub NotifyDispMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyDispMenuItem.Click, NotifyTbMenuItem.Click
6790 NotifyDispMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
6791 Me.NotifyTbMenuItem.Checked = NotifyDispMenuItem.Checked
6793 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
6795 _statuses.Tabs(_rclickTabName).Notify = NotifyDispMenuItem.Checked
6800 Private Sub SoundFileComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SoundFileComboBox.SelectedIndexChanged, SoundFileTbComboBox.SelectedIndexChanged
6801 If soundfileListup OrElse _rclickTabName = "" Then Exit Sub
6803 _statuses.Tabs(_rclickTabName).SoundFile = DirectCast(DirectCast(sender, ToolStripComboBox).SelectedItem, String)
6808 Private Sub DeleteTabMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteTabMenuItem.Click, DeleteTbMenuItem.Click
6809 If String.IsNullOrEmpty(_rclickTabName) OrElse sender Is Me.DeleteTbMenuItem Then _rclickTabName = ListTab.SelectedTab.Text
6811 RemoveSpecifiedTab(_rclickTabName, True)
6815 Private Sub FilterEditMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilterEditMenuItem.Click, EditRuleTbMenuItem.Click
6817 If String.IsNullOrEmpty(_rclickTabName) Then _rclickTabName = _statuses.GetTabByType(TabUsageType.Home).TabName
6818 fltDialog.SetCurrent(_rclickTabName)
6819 fltDialog.ShowDialog()
6820 Me.TopMost = SettingDialog.AlwaysTop
6823 Me.Cursor = Cursors.WaitCursor
6824 _itemCache = Nothing
6825 _postCache = Nothing
6828 _statuses.FilterAll()
6829 For Each tb As TabPage In ListTab.TabPages
6830 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6831 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6832 If SettingDialog.TabIconDisp Then
6836 If SettingDialog.TabIconDisp Then
6841 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6843 Me.Cursor = Cursors.Default
6848 Private Sub AddTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabMenuItem.Click, CreateTbMenuItem.Click
6849 Dim tabName As String = Nothing
6850 Dim tabUsage As TabUsageType
6851 Using inputName As New InputTabName()
6852 inputName.TabName = _statuses.GetUniqueTabName
6853 inputName.IsShowUsage = True
6854 inputName.ShowDialog()
6855 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Exit Sub
6856 tabName = inputName.TabName
6857 tabUsage = inputName.Usage
6860 Me.TopMost = SettingDialog.AlwaysTop
6861 If Not String.IsNullOrEmpty(tabName) Then
6863 Dim list As ListElement = Nothing
6864 If tabUsage = TabUsageType.Lists Then
6865 Using listAvail As New ListAvailable
6866 If listAvail.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then Exit Sub
6867 If listAvail.SelectedList Is Nothing Then Exit Sub
6868 list = listAvail.SelectedList
6871 If Not AddNewTab(tabName, False, tabUsage, list) Then
6872 Dim tmp As String = String.Format(My.Resources.AddTabMenuItem_ClickText1, tabName)
6873 MessageBox.Show(tmp, My.Resources.AddTabMenuItem_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
6876 _statuses.AddTab(tabName, tabUsage, list)
6878 If tabUsage = TabUsageType.PublicSearch Then
6879 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
6880 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
6881 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
6883 If tabUsage = TabUsageType.Lists Then
6884 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
6885 ListTabSelect(ListTab.TabPages(ListTab.TabPages.Count - 1))
6886 GetTimeline(WORKERTYPE.List, 1, 0, tabName)
6892 Private Sub TabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabMenuItem.Click, CreateTabRuleOpMenuItem.Click
6894 For Each idx As Integer In _curList.SelectedIndices
6895 Dim tabName As String = ""
6897 If Not SelectTab(tabName) Then Exit Sub
6899 fltDialog.SetCurrent(tabName)
6900 If _statuses.Item(_curTab.Text, idx).RetweetedId = 0 Then
6901 fltDialog.AddNewFilter(_statuses.Item(_curTab.Text, idx).ScreenName, _statuses.Item(_curTab.Text, idx).TextFromApi)
6903 fltDialog.AddNewFilter(_statuses.Item(_curTab.Text, idx).RetweetedBy, _statuses.Item(_curTab.Text, idx).TextFromApi)
6905 fltDialog.ShowDialog()
6906 Me.TopMost = SettingDialog.AlwaysTop
6910 Me.Cursor = Cursors.WaitCursor
6911 _itemCache = Nothing
6912 _postCache = Nothing
6915 _statuses.FilterAll()
6916 For Each tb As TabPage In ListTab.TabPages
6917 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
6918 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
6919 If SettingDialog.TabIconDisp Then
6923 If SettingDialog.TabIconDisp Then
6928 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
6930 Me.Cursor = Cursors.Default
6933 If Me.ListTab.SelectedTab IsNot Nothing AndAlso
6934 DirectCast(Me.ListTab.SelectedTab.Tag, DetailsListView).SelectedIndices.Count > 0 Then
6935 _curPost = _statuses.Item(Me.ListTab.SelectedTab.Text, DirectCast(Me.ListTab.SelectedTab.Tag, DetailsListView).SelectedIndices(0))
6939 Protected Overrides Function ProcessDialogKey( _
6940 ByVal keyData As Keys) As Boolean
6941 'TextBox1でEnterを押してもビープ音が鳴らないようにする
6942 If (keyData And Keys.KeyCode) = Keys.Enter Then
6943 If StatusText.Focused Then
6944 Dim _NewLine As Boolean = False
6945 Dim _Post As Boolean = False
6947 If SettingDialog.PostCtrlEnter Then 'Ctrl+Enter投稿時
6948 If StatusText.Multiline Then
6949 If (keyData And Keys.Shift) = Keys.Shift AndAlso (keyData And Keys.Control) <> Keys.Control Then _NewLine = True
6951 If (keyData And Keys.Control) = Keys.Control Then _Post = True
6953 If ((keyData And Keys.Control) = Keys.Control) Then _Post = True
6956 ElseIf SettingDialog.PostShiftEnter Then 'SHift+Enter投稿時
6957 If StatusText.Multiline Then
6958 If (keyData And Keys.Control) = Keys.Control AndAlso (keyData And Keys.Shift) <> Keys.Shift Then _NewLine = True
6960 If (keyData And Keys.Shift) = Keys.Shift Then _Post = True
6962 If ((keyData And Keys.Shift) = Keys.Shift) Then _Post = True
6966 If StatusText.Multiline Then
6967 If (keyData And Keys.Shift) = Keys.Shift AndAlso (keyData And Keys.Control) <> Keys.Control Then _NewLine = True
6969 If ((keyData And Keys.Control) <> Keys.Control AndAlso (keyData And Keys.Shift) <> Keys.Shift) OrElse _
6970 ((keyData And Keys.Control) = Keys.Control AndAlso (keyData And Keys.Shift) = Keys.Shift) Then _Post = True
6972 If ((keyData And Keys.Shift) = Keys.Shift) OrElse _
6973 (((keyData And Keys.Control) <> Keys.Control) AndAlso _
6974 ((keyData And Keys.Shift) <> Keys.Shift)) Then _Post = True
6979 Dim pos1 As Integer = StatusText.SelectionStart
6980 If StatusText.SelectionLength > 0 Then
6981 StatusText.Text = StatusText.Text.Remove(pos1, StatusText.SelectionLength) '選択状態文字列削除
6983 StatusText.Text = StatusText.Text.Insert(pos1, Environment.NewLine) '改行挿入
6984 StatusText.SelectionStart = pos1 + Environment.NewLine.Length 'カーソルを改行の次の文字へ移動
6987 PostButton_Click(Nothing, Nothing)
6990 ElseIf _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch AndAlso _
6991 (ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focused OrElse _
6992 ListTab.SelectedTab.Controls("panelSearch").Controls("comboLang").Focused) Then
6993 Me.SearchButton_Click(ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch"), Nothing)
6998 Return MyBase.ProcessDialogKey(keyData)
7001 Private Sub ReplyAllStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReplyAllStripMenuItem.Click, ReplyAllOpMenuItem.Click
7002 MakeReplyOrDirectStatus(False, True, True)
7005 Private Sub IDRuleMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IDRuleMenuItem.Click, CreateIdRuleOpMenuItem.Click
7006 Dim tabName As String = ""
7009 If _curList.SelectedIndices.Count = 0 Then Exit Sub
7012 If Not SelectTab(tabName) Then Exit Sub
7014 Dim mv As Boolean = False
7015 Dim mk As Boolean = False
7018 Dim ids As New List(Of String)
7019 For Each idx As Integer In _curList.SelectedIndices
7020 Dim post As PostClass = _statuses.Item(_curTab.Text, idx)
7021 If Not ids.Contains(post.ScreenName) Then
7022 Dim fc As New FiltersClass
7023 ids.Add(post.ScreenName)
7024 If post.RetweetedId = 0 Then
7025 fc.NameFilter = post.ScreenName
7027 fc.NameFilter = post.RetweetedBy
7029 fc.SearchBoth = True
7033 fc.SearchUrl = False
7034 _statuses.Tabs(tabName).AddFilter(fc)
7037 If ids.Count <> 0 Then
7038 Dim atids As New List(Of String)
7039 For Each id As String In ids
7042 Dim cnt As Integer = AtIdSupl.ItemCount
7043 AtIdSupl.AddRangeItem(atids.ToArray)
7044 If AtIdSupl.ItemCount <> cnt Then _modifySettingAtId = True
7048 Me.Cursor = Cursors.WaitCursor
7049 _itemCache = Nothing
7050 _postCache = Nothing
7053 _statuses.FilterAll()
7054 For Each tb As TabPage In ListTab.TabPages
7055 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
7056 If _statuses.ContainsTab(tb.Text) Then
7057 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
7058 If SettingDialog.TabIconDisp Then
7062 If SettingDialog.TabIconDisp Then
7068 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
7070 Me.Cursor = Cursors.Default
7075 Private Function SelectTab(ByRef tabName As String) As Boolean
7078 If TabDialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
7079 Me.TopMost = SettingDialog.AlwaysTop
7082 Me.TopMost = SettingDialog.AlwaysTop
7083 tabName = TabDialog.SelectedTabName
7085 ListTab.SelectedTab.Focus()
7087 If tabName = My.Resources.IDRuleMenuItem_ClickText1 Then
7088 Using inputName As New InputTabName()
7089 inputName.TabName = _statuses.GetUniqueTabName
7090 inputName.ShowDialog()
7091 If inputName.DialogResult = Windows.Forms.DialogResult.Cancel Then Return False
7092 tabName = inputName.TabName
7095 Me.TopMost = SettingDialog.AlwaysTop
7096 If Not String.IsNullOrEmpty(tabName) Then
7097 If Not AddNewTab(tabName, False, TabUsageType.UserDefined) Then
7098 Dim tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText2, tabName)
7099 MessageBox.Show(tmp, My.Resources.IDRuleMenuItem_ClickText3, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
7102 _statuses.AddTab(tabName, TabUsageType.UserDefined, Nothing)
7114 Private Sub MoveOrCopy(ByRef move As Boolean, ByRef mark As Boolean)
7117 Dim _tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText4, Environment.NewLine)
7118 If MessageBox.Show(_tmp, My.Resources.IDRuleMenuItem_ClickText5, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
7126 Dim _tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText6, vbCrLf)
7127 If MessageBox.Show(_tmp, My.Resources.IDRuleMenuItem_ClickText7, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
7134 Private Sub CopySTOTMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopySTOTMenuItem.Click
7138 Private Sub CopyURLMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyURLMenuItem.Click
7142 Private Sub SelectAllMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllMenuItem.Click, SelAllOpMenuItem.Click
7143 If StatusText.Focused Then
7145 StatusText.SelectAll()
7148 For i As Integer = 0 To _curList.VirtualListSize - 1
7149 _curList.SelectedIndices.Add(i)
7154 Private Sub MoveMiddle()
7155 Dim _item As ListViewItem
7159 If _curList.SelectedIndices.Count = 0 Then Exit Sub
7161 Dim idx As Integer = _curList.SelectedIndices(0)
7163 _item = _curList.GetItemAt(0, 25)
7164 If _item Is Nothing Then
7169 _item = _curList.GetItemAt(0, _curList.ClientSize.Height - 1)
7170 If _item Is Nothing Then
7171 idx2 = _curList.VirtualListSize - 1
7176 idx -= Math.Abs(idx1 - idx2) \ 2
7177 If idx < 0 Then idx = 0
7179 _curList.EnsureVisible(_curList.VirtualListSize - 1)
7180 _curList.EnsureVisible(idx)
7183 Private Sub OpenURLMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenURLMenuItem.Click, OpenUrlOpMenuItem.Click
7184 If PostBrowser.Document.Links.Count > 0 Then
7185 UrlDialog.ClearUrl()
7187 Dim openUrlStr As String = ""
7189 If PostBrowser.Document.Links.Count = 1 Then
7190 Dim urlStr As String = ""
7192 urlStr = IDNDecode(PostBrowser.Document.Links(0).GetAttribute("href"))
7193 Catch ex As ArgumentException
7197 If String.IsNullOrEmpty(urlStr) Then Exit Sub
7198 openUrlStr = urlEncodeMultibyteChar(urlStr)
7200 For Each linkElm As HtmlElement In PostBrowser.Document.Links
7201 Dim urlStr As String = ""
7202 Dim linkText As String = ""
7204 urlStr = IDNDecode(linkElm.GetAttribute("href"))
7205 linkText = linkElm.InnerText
7206 If Not linkText.StartsWith("http") AndAlso Not linkText.StartsWith("#") Then
7207 linkText = "@" + linkText
7209 Catch ex As ArgumentException
7213 If String.IsNullOrEmpty(urlStr) Then Continue For
7214 UrlDialog.AddUrl(New OpenUrlItem(linkText, urlEncodeMultibyteChar(urlStr)))
7217 If UrlDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
7218 openUrlStr = UrlDialog.SelectedUrl
7220 Catch ex As Exception
7223 Me.TopMost = SettingDialog.AlwaysTop
7225 If String.IsNullOrEmpty(openUrlStr) Then Exit Sub
7227 If openUrlStr.StartsWith("http://twitter.com/search?q=%23") OrElse _
7228 openUrlStr.StartsWith("https://twitter.com/search?q=%23") Then
7230 Dim urlStr As String = HttpUtility.UrlDecode(openUrlStr)
7231 Dim hash As String = urlStr.Substring(urlStr.IndexOf("#"))
7232 HashSupl.AddItem(hash)
7233 HashMgr.AddHashToHistory(hash.Trim, False)
7234 AddNewTabForSearch(hash)
7237 Dim m As Match = Regex.Match(openUrlStr, "^https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)$")
7238 If SettingDialog.OpenUserTimeline AndAlso m.Success AndAlso IsTwitterId(m.Result("${ScreenName}")) Then
7239 Me.AddNewTabForUserTimeline(m.Result("${ScreenName}"))
7241 OpenUriAsync(openUrlStr)
7246 openUrlStr = openUrlStr.Replace("://twitter.com/search?q=#", "://twitter.com/search?q=%23")
7247 OpenUriAsync(openUrlStr)
7251 Private Sub ClearTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearTabMenuItem.Click, ClearTbMenuItem.Click
7252 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
7253 ClearTab(_rclickTabName, True)
7256 Private Sub ClearTab(ByVal tabName As String, ByVal showWarning As Boolean)
7258 Dim tmp As String = String.Format(My.Resources.ClearTabMenuItem_ClickText1, Environment.NewLine)
7259 If MessageBox.Show(tmp, tabName + " " + My.Resources.ClearTabMenuItem_ClickText2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
7264 _statuses.ClearTabIds(tabName)
7265 If ListTab.SelectedTab.Text = tabName Then
7266 _anchorPost = Nothing
7268 _itemCache = Nothing
7269 _postCache = Nothing
7270 _itemCacheIndex = -1
7274 For Each tb As TabPage In ListTab.TabPages
7275 If tb.Text = tabName Then
7277 DirectCast(tb.Tag, DetailsListView).VirtualListSize = 0
7281 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
7283 SetMainWindowTitle()
7287 Private Sub SetMainWindowTitle()
7289 Dim ttl As New StringBuilder(256)
7290 Dim ur As Integer = 0
7291 Dim al As Integer = 0
7292 Static myVer As String = fileVersion
7293 Static followers As Long = 0
7294 If SettingDialog.DispLatestPost <> DispTitleEnum.None AndAlso _
7295 SettingDialog.DispLatestPost <> DispTitleEnum.Post AndAlso _
7296 SettingDialog.DispLatestPost <> DispTitleEnum.Ver AndAlso _
7297 SettingDialog.DispLatestPost <> DispTitleEnum.OwnStatus Then
7298 For Each key As String In _statuses.Tabs.Keys
7299 ur += _statuses.Tabs(key).UnreadCount
7300 al += _statuses.Tabs(key).AllCount
7304 If SettingDialog.DispUsername Then ttl.Append(tw.Username).Append(" - ")
7305 ttl.Append("Tween ")
7306 Select Case SettingDialog.DispLatestPost
7307 Case DispTitleEnum.Ver
7308 ttl.Append("Ver:").Append(myVer)
7309 Case DispTitleEnum.Post
7310 If _history IsNot Nothing AndAlso _history.Count > 1 Then
7311 ttl.Append(_history(_history.Count - 2).status.Replace(vbCrLf, ""))
7313 Case DispTitleEnum.UnreadRepCount
7314 ttl.AppendFormat(My.Resources.SetMainWindowTitleText1, _statuses.GetTabByType(TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(TabUsageType.DirectMessage).UnreadCount)
7315 Case DispTitleEnum.UnreadAllCount
7316 ttl.AppendFormat(My.Resources.SetMainWindowTitleText2, ur)
7317 Case DispTitleEnum.UnreadAllRepCount
7318 ttl.AppendFormat(My.Resources.SetMainWindowTitleText3, ur, _statuses.GetTabByType(TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(TabUsageType.DirectMessage).UnreadCount)
7319 Case DispTitleEnum.UnreadCountAllCount
7320 ttl.AppendFormat(My.Resources.SetMainWindowTitleText4, ur, al)
7321 Case DispTitleEnum.OwnStatus
7322 If followers = 0 AndAlso tw.FollowersCount > 0 Then followers = tw.FollowersCount
7323 ttl.AppendFormat(My.Resources.OwnStatusTitle, tw.StatusesCount, tw.FriendsCount, tw.FollowersCount, tw.FollowersCount - followers)
7327 Me.Text = ttl.ToString()
7328 Catch ex As AccessViolationException
7329 '原因不明。ポスト内容に依存か?たまーに発生するが再現せず。
7333 Private Function GetStatusLabelText() As String
7335 'タブ未読数/タブ発言数 全未読数/総発言数 (未読@+未読DM数)
7336 If _statuses Is Nothing Then Return ""
7337 Dim tbRep As TabClass = _statuses.GetTabByType(TabUsageType.Mentions)
7338 Dim tbDm As TabClass = _statuses.GetTabByType(TabUsageType.DirectMessage)
7339 If tbRep Is Nothing OrElse tbDm Is Nothing Then Return ""
7340 Dim urat As Integer = tbRep.UnreadCount + tbDm.UnreadCount
7341 Dim ur As Integer = 0
7342 Dim al As Integer = 0
7343 Dim tur As Integer = 0
7344 Dim tal As Integer = 0
7345 Dim slbl As StringBuilder = New StringBuilder(256)
7347 For Each key As String In _statuses.Tabs.Keys
7348 ur += _statuses.Tabs(key).UnreadCount
7349 al += _statuses.Tabs(key).AllCount
7350 If key.Equals(_curTab.Text) Then
7351 tur = _statuses.Tabs(key).UnreadCount
7352 tal = _statuses.Tabs(key).AllCount
7355 Catch ex As Exception
7360 UnreadAtCounter = urat
7362 slbl.AppendFormat(My.Resources.SetStatusLabelText1, tur, tal, ur, al, urat, _postTimestamps.Count, _favTimestamps.Count, _tlCount)
7363 If SettingDialog.TimelinePeriodInt = 0 Then
7364 slbl.Append(My.Resources.SetStatusLabelText2)
7366 slbl.Append(SettingDialog.TimelinePeriodInt.ToString() + My.Resources.SetStatusLabelText3)
7368 Return slbl.ToString()
7371 Delegate Sub SetStatusLabelApiDelegate()
7373 Private Sub SetStatusLabelApiHandler(ByVal sender As Object, ByVal e As ApiInformationChangedEventArgs)
7374 If InvokeRequired AndAlso Not IsDisposed Then
7375 Invoke(New SetStatusLabelApiDelegate(AddressOf SetStatusLabelApi))
7381 Private Sub SetStatusLabelApi()
7382 Me._apiGauge.RemainCount = TwitterApiInfo.RemainCount
7383 Me._apiGauge.MaxCount = TwitterApiInfo.MaxCount
7384 Me._apiGauge.ResetTime = TwitterApiInfo.ResetTime
7387 Private Sub SetStatusLabelUrl()
7388 StatusLabelUrl.Text = GetStatusLabelText()
7391 Public Sub SetStatusLabel(ByVal text As String)
7392 StatusLabel.Text = text
7395 Private Sub SetNotifyIconText()
7396 ' タスクトレイアイコンのツールチップテキスト書き換え
7398 Static ur As New StringBuilder(64)
7399 ur.Remove(0, ur.Length)
7400 If SettingDialog.DispUsername Then
7401 ur.Append(tw.Username)
7406 ur.Append("(Debug Build)")
7408 If UnreadCounter <> -1 AndAlso UnreadAtCounter <> -1 Then
7410 ur.Append(UnreadCounter)
7412 ur.Append(UnreadAtCounter)
7415 NotifyIcon1.Text = ur.ToString()
7418 Friend Sub CheckReplyTo(ByVal StatusText As String)
7419 Dim m As MatchCollection
7421 m = Regex.Matches(StatusText, "(^|[^a-zA-Z0-9_/])(#|#)(?<hash>[a-zA-Z0-9_]+)")
7422 Dim hstr As String = ""
7423 For Each hm As Match In m
7424 If Not IsNumeric(hm.Result("${hash}")) Then
7425 If Not hstr.Contains("#" + hm.Result("${hash}") + " ") Then
7426 hstr += "#" + hm.Result("${hash}") + " "
7427 HashSupl.AddItem("#" + hm.Result("${hash}"))
7431 If Not String.IsNullOrEmpty(HashMgr.UseHash) AndAlso Not hstr.Contains(HashMgr.UseHash + " ") Then
7432 hstr += HashMgr.UseHash
7434 If Not String.IsNullOrEmpty(hstr) Then HashMgr.AddHashToHistory(hstr.Trim, False)
7436 ' 本当にリプライ先指定すべきかどうかの判定
7437 m = Regex.Matches(StatusText, "(^|[ -/:-@[-^`{-~])(?<id>@[a-zA-Z0-9_]+)")
7439 If SettingDialog.UseAtIdSupplement Then
7440 Dim bCnt As Integer = AtIdSupl.ItemCount
7441 For Each mid As Match In m
7442 AtIdSupl.AddItem(mid.Result("${id}"))
7444 If bCnt <> AtIdSupl.ItemCount Then _modifySettingAtId = True
7447 ' リプライ先ステータスIDの指定がない場合は指定しない
7448 If _reply_to_id = 0 Then Exit Sub
7450 ' リプライ先ユーザー名がない場合も指定しない
7451 If String.IsNullOrEmpty(_reply_to_name) Then
7457 ' 次の条件を満たす場合に in_reply_to_status_id 指定
7458 ' 1. Twitterによりリンクと判定される @idが文中に1つ含まれる (2009/5/28 リンク化される@IDのみカウントするように修正)
7459 ' 2. リプライ先ステータスIDが設定されている(リストをダブルクリックで返信している)
7460 ' 3. 文中に含まれた@idがリプライ先のポスト者のIDと一致する
7462 If m IsNot Nothing Then
7463 If StatusText.StartsWith("@") Then
7464 If StatusText.StartsWith("@" + _reply_to_name) Then Exit Sub
7466 For Each mid As Match In m
7467 If StatusText.Contains("QT " + mid.Result("${id}") + ":") AndAlso mid.Result("${id}") = "@" + _reply_to_name Then Exit Sub
7477 Private Sub TweenMain_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
7478 If Not _initialLayout AndAlso SettingDialog.MinimizeToTray AndAlso WindowState = FormWindowState.Minimized Then
7481 If _initialLayout AndAlso _cfgLocal IsNot Nothing AndAlso Me.WindowState = FormWindowState.Normal AndAlso Me.Visible Then
7482 Me.ClientSize = _cfgLocal.FormSize
7483 '_mySize = Me.ClientSize 'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
7484 Me.DesktopLocation = _cfgLocal.FormLocation
7485 '_myLoc = Me.DesktopLocation '位置保持(最小化・最大化されたまま終了した場合の対応用)
7486 If _cfgLocal.SplitterDistance > Me.SplitContainer1.Panel1MinSize AndAlso _cfgLocal.SplitterDistance < Me.SplitContainer1.Height - Me.SplitContainer1.Panel2MinSize - Me.SplitContainer1.SplitterWidth Then
7487 Me.SplitContainer1.SplitterDistance = _cfgLocal.SplitterDistance 'Splitterの位置設定
7490 StatusText.Multiline = _cfgLocal.StatusMultiline
7491 If StatusText.Multiline Then
7492 Dim dis As Integer = SplitContainer2.Height - _cfgLocal.StatusTextHeight - SplitContainer2.SplitterWidth
7493 If dis > SplitContainer2.Panel1MinSize AndAlso dis < SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth Then
7494 SplitContainer2.SplitterDistance = SplitContainer2.Height - _cfgLocal.StatusTextHeight - SplitContainer2.SplitterWidth
7496 StatusText.Height = _cfgLocal.StatusTextHeight
7498 If SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth > 0 Then
7499 SplitContainer2.SplitterDistance = SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth
7502 If _cfgLocal.PreviewDistance > Me.SplitContainer3.Panel1MinSize AndAlso _cfgLocal.PreviewDistance < Me.SplitContainer3.Width - Me.SplitContainer3.Panel2MinSize - Me.SplitContainer3.SplitterWidth Then
7503 Me.SplitContainer3.SplitterDistance = _cfgLocal.PreviewDistance
7505 _initialLayout = False
7509 Private Sub PlaySoundMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlaySoundMenuItem.CheckedChanged, PlaySoundFileMenuItem.CheckStateChanged
7510 PlaySoundMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7511 Me.PlaySoundFileMenuItem.Checked = PlaySoundMenuItem.Checked
7512 If PlaySoundMenuItem.Checked Then
7513 SettingDialog.PlaySound = True
7515 SettingDialog.PlaySound = False
7517 _modifySettingCommon = True
7520 Private Sub SplitContainer1_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved
7521 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
7522 _mySpDis = SplitContainer1.SplitterDistance
7523 If StatusText.Multiline Then _mySpDis2 = StatusText.Height
7524 _modifySettingLocal = True
7528 Private Sub doRepliedStatusOpen()
7529 If Me.ExistCurrentPost AndAlso _curPost.InReplyToUser IsNot Nothing AndAlso _curPost.InReplyToStatusId > 0 Then
7530 If My.Computer.Keyboard.ShiftKeyDown Then
7531 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/status/" + _curPost.InReplyToStatusId.ToString())
7534 If _statuses.ContainsKey(_curPost.InReplyToStatusId) Then
7535 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToStatusId)
7536 MessageBox.Show(repPost.ScreenName + " / " + repPost.Nickname + " (" + repPost.CreatedAt.ToString() + ")" + Environment.NewLine + repPost.TextFromApi)
7538 For Each tb As TabClass In _statuses.GetTabsByType(TabUsageType.Lists Or TabUsageType.PublicSearch)
7539 If tb Is Nothing OrElse Not tb.Contains(_curPost.InReplyToStatusId) Then Exit For
7540 Dim repPost As PostClass = _statuses.Item(_curPost.InReplyToStatusId)
7541 MessageBox.Show(repPost.ScreenName + " / " + repPost.Nickname + " (" + repPost.CreatedAt.ToString() + ")" + Environment.NewLine + repPost.TextFromApi)
7544 OpenUriAsync("http://twitter.com/" + _curPost.InReplyToUser + "/status/" + _curPost.InReplyToStatusId.ToString())
7549 Private Sub RepliedStatusOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RepliedStatusOpenMenuItem.Click, OpenRepSourceOpMenuItem.Click
7550 doRepliedStatusOpen()
7553 Private Sub ContextMenuUserPicture_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuUserPicture.Opening
7554 '発言詳細のアイコン右クリック時のメニュー制御
7555 If _curList.SelectedIndices.Count > 0 AndAlso _curPost IsNot Nothing Then
7556 Dim name As String = _curPost.ImageUrl
7557 If name IsNot Nothing AndAlso name.Length > 0 Then
7558 Dim idx As Integer = name.LastIndexOf("/"c)
7560 name = IO.Path.GetFileName(name.Substring(idx))
7561 If name.Contains("_normal.") Then
7562 name = name.Replace("_normal", "")
7563 Me.IconNameToolStripMenuItem.Text = name
7564 Me.IconNameToolStripMenuItem.Enabled = True
7566 Me.IconNameToolStripMenuItem.Enabled = False
7567 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7570 Me.IconNameToolStripMenuItem.Enabled = False
7571 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7573 If Me.TIconDic(_curPost.ImageUrl) IsNot Nothing Then
7574 Me.SaveIconPictureToolStripMenuItem.Enabled = True
7576 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7579 Me.IconNameToolStripMenuItem.Enabled = False
7580 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7581 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText1
7584 Me.IconNameToolStripMenuItem.Enabled = False
7585 Me.SaveIconPictureToolStripMenuItem.Enabled = False
7586 Me.IconNameToolStripMenuItem.Text = My.Resources.ContextMenuStrip3_OpeningText2
7588 If NameLabel.Tag IsNot Nothing Then
7589 Dim id As String = DirectCast(NameLabel.Tag, String)
7590 If id = tw.Username Then
7591 FollowToolStripMenuItem.Enabled = False
7592 UnFollowToolStripMenuItem.Enabled = False
7593 ShowFriendShipToolStripMenuItem.Enabled = False
7594 ShowUserStatusToolStripMenuItem.Enabled = True
7595 SearchPostsDetailNameToolStripMenuItem.Enabled = True
7596 SearchAtPostsDetailNameToolStripMenuItem.Enabled = False
7597 ListManageUserContextToolStripMenuItem3.Enabled = True
7599 FollowToolStripMenuItem.Enabled = True
7600 UnFollowToolStripMenuItem.Enabled = True
7601 ShowFriendShipToolStripMenuItem.Enabled = True
7602 ShowUserStatusToolStripMenuItem.Enabled = True
7603 SearchPostsDetailNameToolStripMenuItem.Enabled = True
7604 SearchAtPostsDetailNameToolStripMenuItem.Enabled = True
7605 ListManageUserContextToolStripMenuItem3.Enabled = True
7608 FollowToolStripMenuItem.Enabled = False
7609 UnFollowToolStripMenuItem.Enabled = False
7610 ShowFriendShipToolStripMenuItem.Enabled = False
7611 ShowUserStatusToolStripMenuItem.Enabled = False
7612 SearchPostsDetailNameToolStripMenuItem.Enabled = False
7613 SearchAtPostsDetailNameToolStripMenuItem.Enabled = False
7614 ListManageUserContextToolStripMenuItem3.Enabled = False
7618 Private Sub IconNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IconNameToolStripMenuItem.Click
7619 If _curPost Is Nothing Then Exit Sub
7620 Dim name As String = _curPost.ImageUrl
7621 OpenUriAsync(name.Remove(name.LastIndexOf("_normal"), 7)) ' "_normal".Length
7624 Private Sub SaveOriginalSizeIconPictureToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
7625 If _curPost Is Nothing Then Exit Sub
7626 Dim name As String = _curPost.ImageUrl
7627 name = IO.Path.GetFileNameWithoutExtension(name.Substring(name.LastIndexOf("/"c)))
7629 Me.SaveFileDialog1.FileName = name.Substring(0, name.Length - 8) ' "_normal".Length + 1
7631 If Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
7636 Private Sub SaveIconPictureToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveIconPictureToolStripMenuItem.Click
7637 If _curPost Is Nothing Then Exit Sub
7638 Dim name As String = _curPost.ImageUrl
7640 Me.SaveFileDialog1.FileName = name.Substring(name.LastIndexOf("/"c) + 1)
7642 If Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
7644 Using orgBmp As Image = New Bitmap(TIconDic(name))
7645 Using bmp2 As New Bitmap(orgBmp.Size.Width, orgBmp.Size.Height)
7646 Using g As Graphics = Graphics.FromImage(bmp2)
7647 g.InterpolationMode = Drawing2D.InterpolationMode.High
7648 g.DrawImage(orgBmp, 0, 0, orgBmp.Size.Width, orgBmp.Size.Height)
7651 bmp2.Save(Me.SaveFileDialog1.FileName)
7656 Catch ex As Exception
7657 '処理中にキャッシュアウトする可能性あり
7662 Private Sub SplitContainer2_Panel2_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitContainer2.Panel2.Resize
7663 Me.StatusText.Multiline = Me.SplitContainer2.Panel2.Height > Me.SplitContainer2.Panel2MinSize + 2
7664 MultiLineMenuItem.Checked = Me.StatusText.Multiline
7665 _modifySettingLocal = True
7668 Private Sub StatusText_MultilineChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusText.MultilineChanged
7669 If Me.StatusText.Multiline Then
7670 Me.StatusText.ScrollBars = ScrollBars.Vertical
7672 Me.StatusText.ScrollBars = ScrollBars.None
7674 _modifySettingLocal = True
7677 Private Sub MultiLineMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MultiLineMenuItem.Click
7679 StatusText.Multiline = MultiLineMenuItem.Checked
7680 _cfgLocal.StatusMultiline = MultiLineMenuItem.Checked
7681 If MultiLineMenuItem.Checked Then
7682 If SplitContainer2.Height - _mySpDis2 - SplitContainer2.SplitterWidth < 0 Then
7683 SplitContainer2.SplitterDistance = 0
7685 SplitContainer2.SplitterDistance = SplitContainer2.Height - _mySpDis2 - SplitContainer2.SplitterWidth
7688 SplitContainer2.SplitterDistance = SplitContainer2.Height - SplitContainer2.Panel2MinSize - SplitContainer2.SplitterWidth
7690 _modifySettingLocal = True
7693 Private Function UrlConvert(ByVal Converter_Type As UrlConverter) As Boolean
7694 'Converter_Type=Nicomsの場合は、nicovideoのみ短縮する
7695 '参考資料 RFC3986 Uniform Resource Identifier (URI): Generic Syntax
7696 'Appendix A. Collected ABNF for URI
7697 'http://www.ietf.org/rfc/rfc3986.txt
7699 Dim result As String = ""
7700 Const url As String = "(?<before>(?:[^\""':!=]|^|\:))" + _
7701 "(?<url>(?<protocol>https?://)" + _
7702 "(?<domain>(?:[\.-]|[^\p{P}\s])+\.[a-z]{2,}(?::[0-9]+)?)" + _
7703 "(?<path>/[a-z0-9!*'();:&=+$/%#\-_.,~@]*[a-z0-9)=#/]?)?" + _
7704 "(?<query>\?[a-z0-9!*'();:&=+$/%#\-_.,~@?]*[a-z0-9_&=#/])?)"
7706 Const nico As String = "^https?://[a-z]+\.(nicovideo|niconicommons|nicolive)\.jp/[a-z]+/[a-z0-9]+$"
7708 If StatusText.SelectionLength > 0 Then
7709 Dim tmp As String = StatusText.SelectedText
7710 ' httpから始まらない場合、ExcludeStringで指定された文字列で始まる場合は対象としない
7711 If tmp.StartsWith("http") Then
7712 ' 文字列が選択されている場合はその文字列について処理
7714 'nico.ms使用、nicovideoにマッチしたら変換
7715 If SettingDialog.Nicoms AndAlso Regex.IsMatch(tmp, nico) Then
7716 result = nicoms.Shorten(tmp)
7717 ElseIf Converter_Type <> UrlConverter.Nicoms Then
7718 '短縮URL変換 日本語を含むかもしれないのでURLエンコードする
7719 result = ShortUrl.Make(Converter_Type, tmp)
7720 If result.Equals("Can't convert") Then
7721 StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":")
7728 If Not String.IsNullOrEmpty(result) Then
7729 Dim undotmp As New urlUndo
7731 StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length)
7732 StatusText.SelectedText = result
7735 undotmp.Before = tmp
7736 undotmp.After = result
7738 If urlUndoBuffer Is Nothing Then
7739 urlUndoBuffer = New List(Of urlUndo)
7740 UrlUndoToolStripMenuItem.Enabled = True
7743 urlUndoBuffer.Add(undotmp)
7747 ' 正規表現にマッチしたURL文字列をtinyurl化
7748 For Each mt As Match In Regex.Matches(StatusText.Text, url, RegexOptions.IgnoreCase)
7749 If StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal) = -1 Then Continue For
7750 Dim tmp As String = mt.Result("${url}")
7751 If tmp.StartsWith("w", StringComparison.OrdinalIgnoreCase) Then tmp = "http://" + tmp
7752 Dim undotmp As New urlUndo
7755 StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length)
7757 'nico.ms使用、nicovideoにマッチしたら変換
7758 If SettingDialog.Nicoms AndAlso Regex.IsMatch(tmp, nico) Then
7759 result = nicoms.Shorten(tmp)
7760 ElseIf Converter_Type <> UrlConverter.Nicoms Then
7761 '短縮URL変換 日本語を含むかもしれないのでURLエンコードする
7762 result = ShortUrl.Make(Converter_Type, tmp)
7763 If result.Equals("Can't convert") Then
7764 StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":")
7771 If Not String.IsNullOrEmpty(result) Then
7772 StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length)
7773 StatusText.SelectedText = result
7775 undotmp.Before = mt.Result("${url}")
7776 undotmp.After = result
7778 If urlUndoBuffer Is Nothing Then
7779 urlUndoBuffer = New List(Of urlUndo)
7780 UrlUndoToolStripMenuItem.Enabled = True
7783 urlUndoBuffer.Add(undotmp)
7792 Private Sub doUrlUndo()
7793 If urlUndoBuffer IsNot Nothing Then
7794 Dim tmp As String = StatusText.Text
7795 For Each data As urlUndo In urlUndoBuffer
7796 tmp = tmp.Replace(data.After, data.Before)
7798 StatusText.Text = tmp
7799 urlUndoBuffer = Nothing
7800 UrlUndoToolStripMenuItem.Enabled = False
7804 Private Sub TinyURLToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TinyURLToolStripMenuItem.Click
7805 UrlConvert(UrlConverter.TinyUrl)
7808 Private Sub IsgdToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IsgdToolStripMenuItem.Click
7809 UrlConvert(UrlConverter.Isgd)
7812 Private Sub TwurlnlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TwurlnlToolStripMenuItem.Click
7813 UrlConvert(UrlConverter.Twurl)
7816 Private Sub UxnuMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UxnuMenuItem.Click
7817 UrlConvert(UrlConverter.Uxnu)
7820 Private Sub UrlConvertAutoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlConvertAutoToolStripMenuItem.Click
7821 If Not UrlConvert(SettingDialog.AutoShortUrlFirst) Then
7822 Dim svc As UrlConverter = SettingDialog.AutoShortUrlFirst
7823 Dim rnd As New Random()
7824 ' 前回使用した短縮URLサービス以外を選択する
7826 svc = CType(rnd.Next(System.Enum.GetNames(GetType(UrlConverter)).Length), UrlConverter)
7827 Loop Until svc <> SettingDialog.AutoShortUrlFirst AndAlso svc <> UrlConverter.Nicoms AndAlso svc <> UrlConverter.Unu
7832 Private Sub UrlUndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlUndoToolStripMenuItem.Click
7836 Private Sub NewPostPopMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewPostPopMenuItem.CheckStateChanged, NotifyFileMenuItem.CheckStateChanged
7837 Me.NotifyFileMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7838 Me.NewPostPopMenuItem.Checked = Me.NotifyFileMenuItem.Checked
7839 _cfgCommon.NewAllPop = NewPostPopMenuItem.Checked
7840 _modifySettingCommon = True
7843 Private Sub ListLockMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListLockMenuItem.CheckStateChanged, LockListFileMenuItem.CheckStateChanged
7844 ListLockMenuItem.Checked = DirectCast(sender, ToolStripMenuItem).Checked
7845 Me.LockListFileMenuItem.Checked = ListLockMenuItem.Checked
7846 _cfgCommon.ListLock = ListLockMenuItem.Checked
7847 _modifySettingCommon = True
7850 Private Sub MenuStrip1_MenuActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuStrip1.MenuActivate
7851 ' フォーカスがメニューに移る (MenuStrip1.Tag フラグを立てる)
7852 MenuStrip1.Tag = New Object()
7853 MenuStrip1.Select() ' StatusText がフォーカスを持っている場合 Leave が発生
7856 Private Sub MenuStrip1_MenuDeactivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuStrip1.MenuDeactivate
7857 If Me.Tag IsNot Nothing Then ' 設定された戻り先へ遷移
7858 If Me.Tag Is Me.ListTab.SelectedTab Then
7859 DirectCast(Me.ListTab.SelectedTab.Tag, Control).Select()
7861 DirectCast(Me.Tag, Control).Select()
7863 Else ' 戻り先が指定されていない (初期状態) 場合はタブに遷移
7864 If ListTab.SelectedIndex > -1 AndAlso ListTab.SelectedTab.HasChildren Then
7865 Me.Tag = ListTab.SelectedTab.Tag
7866 DirectCast(Me.Tag, Control).Select()
7869 ' フォーカスがメニューに遷移したかどうかを表すフラグを降ろす
7870 MenuStrip1.Tag = Nothing
7873 Private Sub MyList_ColumnReordered(ByVal sender As System.Object, ByVal e As ColumnReorderedEventArgs)
7874 Dim lst As DetailsListView = DirectCast(sender, DetailsListView)
7875 If _cfgLocal Is Nothing Then Exit Sub
7878 _cfgLocal.Width1 = lst.Columns(0).Width
7879 _cfgLocal.Width3 = lst.Columns(1).Width
7881 Dim darr(lst.Columns.Count - 1) As Integer
7882 For i As Integer = 0 To lst.Columns.Count - 1
7883 darr(lst.Columns(i).DisplayIndex) = i
7885 MoveArrayItem(darr, e.OldDisplayIndex, e.NewDisplayIndex)
7887 For i As Integer = 0 To lst.Columns.Count - 1
7890 _cfgLocal.DisplayIndex1 = i
7892 _cfgLocal.DisplayIndex2 = i
7894 _cfgLocal.DisplayIndex3 = i
7896 _cfgLocal.DisplayIndex4 = i
7898 _cfgLocal.DisplayIndex5 = i
7900 _cfgLocal.DisplayIndex6 = i
7902 _cfgLocal.DisplayIndex7 = i
7904 _cfgLocal.DisplayIndex8 = i
7907 _cfgLocal.Width1 = lst.Columns(0).Width
7908 _cfgLocal.Width2 = lst.Columns(1).Width
7909 _cfgLocal.Width3 = lst.Columns(2).Width
7910 _cfgLocal.Width4 = lst.Columns(3).Width
7911 _cfgLocal.Width5 = lst.Columns(4).Width
7912 _cfgLocal.Width6 = lst.Columns(5).Width
7913 _cfgLocal.Width7 = lst.Columns(6).Width
7914 _cfgLocal.Width8 = lst.Columns(7).Width
7916 _modifySettingLocal = True
7917 _isColumnChanged = True
7920 Private Sub MyList_ColumnWidthChanged(ByVal sender As System.Object, ByVal e As ColumnWidthChangedEventArgs)
7921 Dim lst As DetailsListView = DirectCast(sender, DetailsListView)
7922 If _cfgLocal Is Nothing Then Exit Sub
7924 If _cfgLocal.Width1 <> lst.Columns(0).Width Then
7925 _cfgLocal.Width1 = lst.Columns(0).Width
7926 _modifySettingLocal = True
7927 _isColumnChanged = True
7929 If _cfgLocal.Width3 <> lst.Columns(1).Width Then
7930 _cfgLocal.Width3 = lst.Columns(1).Width
7931 _modifySettingLocal = True
7932 _isColumnChanged = True
7935 If _cfgLocal.Width1 <> lst.Columns(0).Width Then
7936 _cfgLocal.Width1 = lst.Columns(0).Width
7937 _modifySettingLocal = True
7938 _isColumnChanged = True
7940 If _cfgLocal.Width2 <> lst.Columns(1).Width Then
7941 _cfgLocal.Width2 = lst.Columns(1).Width
7942 _modifySettingLocal = True
7943 _isColumnChanged = True
7945 If _cfgLocal.Width3 <> lst.Columns(2).Width Then
7946 _cfgLocal.Width3 = lst.Columns(2).Width
7947 _modifySettingLocal = True
7948 _isColumnChanged = True
7950 If _cfgLocal.Width4 <> lst.Columns(3).Width Then
7951 _cfgLocal.Width4 = lst.Columns(3).Width
7952 _modifySettingLocal = True
7953 _isColumnChanged = True
7955 If _cfgLocal.Width5 <> lst.Columns(4).Width Then
7956 _cfgLocal.Width5 = lst.Columns(4).Width
7957 _modifySettingLocal = True
7958 _isColumnChanged = True
7960 If _cfgLocal.Width6 <> lst.Columns(5).Width Then
7961 _cfgLocal.Width6 = lst.Columns(5).Width
7962 _modifySettingLocal = True
7963 _isColumnChanged = True
7965 If _cfgLocal.Width7 <> lst.Columns(6).Width Then
7966 _cfgLocal.Width7 = lst.Columns(6).Width
7967 _modifySettingLocal = True
7968 _isColumnChanged = True
7970 If _cfgLocal.Width8 <> lst.Columns(7).Width Then
7971 _cfgLocal.Width8 = lst.Columns(7).Width
7972 _modifySettingLocal = True
7973 _isColumnChanged = True
7976 ' 非表示の時にColumnChangedが呼ばれた場合はForm初期化処理中なので保存しない
7978 ' SaveConfigsLocal()
7982 Public Function WebBrowser_GetSelectionText(ByRef ComponentInstance As WebBrowser) As String
7983 '発言詳細で「選択文字列をコピー」を行う
7984 'WebBrowserコンポーネントのインスタンスを渡す
7985 Dim typ As Type = ComponentInstance.ActiveXInstance.GetType()
7986 Dim _SelObj As Object = typ.InvokeMember("selection", BindingFlags.GetProperty, Nothing, ComponentInstance.Document.DomDocument, Nothing)
7987 Dim _objRange As Object = _SelObj.GetType().InvokeMember("createRange", BindingFlags.InvokeMethod, Nothing, _SelObj, Nothing)
7988 Return DirectCast(_objRange.GetType().InvokeMember("text", BindingFlags.GetProperty, Nothing, _objRange, Nothing), String)
7991 Private Sub SelectionCopyContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionCopyContextMenuItem.Click
7993 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
7995 Clipboard.SetDataObject(_selText, False, 5, 100)
7996 Catch ex As Exception
7997 MessageBox.Show(ex.Message)
8001 Private Sub doSearchToolStrip(ByVal url As String)
8002 '発言詳細で「選択文字列で検索」(選択文字列取得)
8003 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
8005 If _selText IsNot Nothing Then
8006 If url = My.Resources.SearchItem4Url Then
8008 AddNewTabForSearch(_selText)
8012 Dim tmp As String = String.Format(url, HttpUtility.UrlEncode(_selText))
8017 Private Sub SelectionAllContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionAllContextMenuItem.Click
8019 PostBrowser.Document.ExecCommand("SelectAll", False, Nothing)
8022 Private Sub SearchWikipediaContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchWikipediaContextMenuItem.Click
8023 doSearchToolStrip(My.Resources.SearchItem1Url)
8026 Private Sub SearchGoogleContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchGoogleContextMenuItem.Click
8027 doSearchToolStrip(My.Resources.SearchItem2Url)
8030 Private Sub SearchYatsContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchYatsContextMenuItem.Click
8031 doSearchToolStrip(My.Resources.SearchItem3Url)
8034 Private Sub SearchPublicSearchContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPublicSearchContextMenuItem.Click
8035 doSearchToolStrip(My.Resources.SearchItem4Url)
8038 Private Sub UrlCopyContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlCopyContextMenuItem.Click
8040 Clipboard.SetDataObject(Me._postBrowserStatusText, False, 5, 100)
8041 Catch ex As Exception
8042 MessageBox.Show(ex.Message)
8046 Private Sub ContextMenuPostBrowser_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuPostBrowser.Opening
8048 If PostBrowser.StatusText.StartsWith("http") Then
8049 Me._postBrowserStatusText = PostBrowser.StatusText
8050 Dim name As String = GetUserId()
8051 UrlCopyContextMenuItem.Enabled = True
8052 If name IsNot Nothing Then
8053 FollowContextMenuItem.Enabled = True
8054 RemoveContextMenuItem.Enabled = True
8055 FriendshipContextMenuItem.Enabled = True
8056 ShowUserStatusContextMenuItem.Enabled = True
8057 SearchPostsDetailToolStripMenuItem.Enabled = True
8058 IdFilterAddMenuItem.Enabled = True
8059 ListManageUserContextToolStripMenuItem.Enabled = True
8060 SearchAtPostsDetailToolStripMenuItem.Enabled = True
8062 FollowContextMenuItem.Enabled = False
8063 RemoveContextMenuItem.Enabled = False
8064 FriendshipContextMenuItem.Enabled = False
8065 ShowUserStatusContextMenuItem.Enabled = False
8066 SearchPostsDetailToolStripMenuItem.Enabled = False
8067 IdFilterAddMenuItem.Enabled = False
8068 ListManageUserContextToolStripMenuItem.Enabled = False
8069 SearchAtPostsDetailToolStripMenuItem.Enabled = False
8072 If Regex.IsMatch(Me._postBrowserStatusText, "^https?://twitter.com/search\?q=%23") Then
8073 UseHashtagMenuItem.Enabled = True
8075 UseHashtagMenuItem.Enabled = False
8078 Me._postBrowserStatusText = ""
8079 UrlCopyContextMenuItem.Enabled = False
8080 FollowContextMenuItem.Enabled = False
8081 RemoveContextMenuItem.Enabled = False
8082 FriendshipContextMenuItem.Enabled = False
8083 ShowUserStatusContextMenuItem.Enabled = False
8084 SearchPostsDetailToolStripMenuItem.Enabled = False
8085 SearchAtPostsDetailToolStripMenuItem.Enabled = False
8086 UseHashtagMenuItem.Enabled = False
8087 IdFilterAddMenuItem.Enabled = False
8088 ListManageUserContextToolStripMenuItem.Enabled = False
8090 ' 文字列選択されていないときは選択文字列関係の項目を非表示に
8091 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
8092 If _selText Is Nothing Then
8093 SelectionSearchContextMenuItem.Enabled = False
8094 SelectionCopyContextMenuItem.Enabled = False
8095 SelectionTranslationToolStripMenuItem.Enabled = False
8097 SelectionSearchContextMenuItem.Enabled = True
8098 SelectionCopyContextMenuItem.Enabled = True
8099 SelectionTranslationToolStripMenuItem.Enabled = True
8101 '発言内に自分以外のユーザーが含まれてればフォロー状態全表示を有効に
8102 Dim ma As MatchCollection = Regex.Matches(Me.PostBrowser.DocumentText, "href=""https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)(/status(es)?/[0-9]+)?""")
8103 Dim fAllFlag As Boolean = False
8104 For Each mu As Match In ma
8105 If mu.Result("${ScreenName}").ToLower <> tw.Username.ToLower Then
8110 Me.FriendshipAllMenuItem.Enabled = fAllFlag
8112 If _curPost Is Nothing Then
8113 TranslationToolStripMenuItem.Enabled = False
8115 TranslationToolStripMenuItem.Enabled = True
8121 Private Sub CurrentTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurrentTabToolStripMenuItem.Click
8122 '発言詳細の選択文字列で現在のタブを検索
8123 Dim _selText As String = WebBrowser_GetSelectionText(PostBrowser)
8125 If _selText IsNot Nothing Then
8126 SearchDialog.SWord = _selText
8127 SearchDialog.CheckCaseSensitive = False
8128 SearchDialog.CheckRegex = False
8130 DoTabSearch(SearchDialog.SWord, _
8131 SearchDialog.CheckCaseSensitive, _
8132 SearchDialog.CheckRegex, _
8133 SEARCHTYPE.NextSearch)
8137 Private Sub SplitContainer2_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer2.SplitterMoved
8138 If StatusText.Multiline Then _mySpDis2 = StatusText.Height
8139 _modifySettingLocal = True
8142 Private Sub TweenMain_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
8143 If e.Data.GetDataPresent(DataFormats.FileDrop) Then
8144 ImageSelectionPanel.Visible = True
8145 ImageSelectionPanel.Enabled = True
8146 TimelinePanel.Visible = False
8147 TimelinePanel.Enabled = False
8148 ImagefilePathText.Text = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
8149 ImageFromSelectedFile()
8152 ElseIf e.Data.GetDataPresent(DataFormats.StringFormat) Then
8153 Dim data As String = TryCast(e.Data.GetData(DataFormats.StringFormat, True), String)
8154 If data IsNot Nothing Then StatusText.Text += data
8158 Private Sub TweenMain_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragOver
8159 If e.Data.GetDataPresent(DataFormats.FileDrop) Then
8160 Dim filename As String = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
8161 Dim fl As New FileInfo(filename)
8162 Dim ext As String = fl.Extension
8164 If Not String.IsNullOrEmpty(Me.ImageService) AndAlso Me.pictureService(Me.ImageService).CheckValidFilesize(ext, fl.Length) Then
8165 e.Effect = DragDropEffects.Copy
8168 For Each svc As String In ImageServiceCombo.Items
8169 If String.IsNullOrEmpty(svc) Then Continue For
8170 If Me.pictureService(svc).CheckValidFilesize(ext, fl.Length) Then
8171 ImageServiceCombo.SelectedItem = svc
8172 e.Effect = DragDropEffects.Copy
8176 e.Effect = DragDropEffects.None
8177 ElseIf e.Data.GetDataPresent(DataFormats.StringFormat) Then
8178 e.Effect = DragDropEffects.Copy
8180 e.Effect = DragDropEffects.None
8184 Public Function IsNetworkAvailable() As Boolean
8185 Dim nw As Boolean = True
8187 nw = My.Computer.Network.IsAvailable
8188 Catch ex As Exception
8191 _myStatusOnline = nw
8195 Public Sub OpenUriAsync(ByVal UriString As String)
8196 Dim args As New GetWorkerArg
8197 args.type = WORKERTYPE.OpenUri
8198 args.url = UriString
8203 Private Sub ListTabSelect(ByVal _tab As TabPage)
8206 _itemCache = Nothing
8207 _itemCacheIndex = -1
8208 _postCache = Nothing
8211 _curList = DirectCast(_tab.Tag, DetailsListView)
8212 If _curList.SelectedIndices.Count > 0 Then
8213 _curItemIndex = _curList.SelectedIndices(0)
8214 _curPost = GetCurTabPost(_curItemIndex)
8220 _anchorPost = Nothing
8224 DirectCast(_tab.Tag, DetailsListView).Columns.Item(1).Text = ColumnText(2)
8226 For i As Integer = 0 To _curList.Columns.Count - 1
8227 DirectCast(_tab.Tag, DetailsListView).Columns.Item(i).Text = ColumnText(i)
8232 Private Sub ListTab_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles ListTab.Selecting
8233 ListTabSelect(e.TabPage)
8236 Private Sub SelectListItem(ByVal LView As DetailsListView, ByVal Index As Integer)
8238 Dim bnd As Rectangle
8239 Dim flg As Boolean = False
8240 If LView.FocusedItem IsNot Nothing Then
8241 bnd = LView.FocusedItem.Bounds
8246 LView.SelectedIndices.Clear()
8247 Loop While LView.SelectedIndices.Count > 0
8248 LView.Items(Index).Selected = True
8249 'LView.SelectedIndices.Add(Index)
8250 LView.Items(Index).Focused = True
8252 If flg Then LView.Invalidate(bnd)
8255 Private Sub SelectListItem(ByVal LView As DetailsListView, ByVal Index() As Integer, ByVal FocusedIndex As Integer)
8257 Dim bnd As Rectangle
8258 Dim flg As Boolean = False
8259 If LView.FocusedItem IsNot Nothing Then
8260 bnd = LView.FocusedItem.Bounds
8264 Dim fIdx As Integer = -1
8265 If Index IsNot Nothing AndAlso Not (Index.Count = 1 AndAlso Index(0) = -1) Then
8267 LView.SelectedIndices.Clear()
8268 Loop While LView.SelectedIndices.Count > 0
8269 For Each idx As Integer In Index
8270 If idx > -1 AndAlso LView.VirtualListSize > idx Then
8271 LView.SelectedIndices.Add(idx)
8272 If fIdx = -1 Then fIdx = idx
8276 If FocusedIndex > -1 AndAlso LView.VirtualListSize > FocusedIndex Then
8277 LView.Items(FocusedIndex).Focused = True
8278 ElseIf fIdx > -1 Then
8279 LView.Items(fIdx).Focused = True
8281 If flg Then LView.Invalidate(bnd)
8284 Private Sub RunAsync(ByVal args As GetWorkerArg)
8285 Dim bw As BackgroundWorker = Nothing
8286 If args.type <> WORKERTYPE.Follower Then
8287 For i As Integer = 0 To _bw.Length - 1
8288 If _bw(i) IsNot Nothing AndAlso Not _bw(i).IsBusy Then
8293 If bw Is Nothing Then
8294 For i As Integer = 0 To _bw.Length - 1
8295 If _bw(i) Is Nothing Then
8296 _bw(i) = New BackgroundWorker
8298 bw.WorkerReportsProgress = True
8299 bw.WorkerSupportsCancellation = True
8300 AddHandler bw.DoWork, AddressOf GetTimelineWorker_DoWork
8301 AddHandler bw.ProgressChanged, AddressOf GetTimelineWorker_ProgressChanged
8302 AddHandler bw.RunWorkerCompleted, AddressOf GetTimelineWorker_RunWorkerCompleted
8308 If _bwFollower Is Nothing Then
8309 _bwFollower = New BackgroundWorker
8311 bw.WorkerReportsProgress = True
8312 bw.WorkerSupportsCancellation = True
8313 AddHandler bw.DoWork, AddressOf GetTimelineWorker_DoWork
8314 AddHandler bw.ProgressChanged, AddressOf GetTimelineWorker_ProgressChanged
8315 AddHandler bw.RunWorkerCompleted, AddressOf GetTimelineWorker_RunWorkerCompleted
8317 If _bwFollower.IsBusy = False Then
8322 If bw Is Nothing Then Exit Sub
8324 bw.RunWorkerAsync(args)
8327 Private Sub StartUserStream()
8328 AddHandler tw.NewPostFromStream, AddressOf tw_NewPostFromStream
8329 AddHandler tw.UserStreamStarted, AddressOf tw_UserStreamStarted
8330 AddHandler tw.UserStreamStopped, AddressOf tw_UserStreamStopped
8331 AddHandler tw.PostDeleted, AddressOf tw_PostDeleted
8332 AddHandler tw.UserStreamEventReceived, AddressOf tw_UserStreamEventArrived
8334 MenuItemUserStream.Text = "&UserStream ■"
8335 MenuItemUserStream.Enabled = True
8336 StopToolStripMenuItem.Text = "&Start"
8337 StopToolStripMenuItem.Enabled = True
8338 If SettingDialog.UserstreamStartup Then tw.StartUserStream()
8341 Private Sub TweenMain_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
8343 PostBrowser.Url = New Uri("about:blank")
8344 PostBrowser.DocumentText = "" '発言詳細部初期化
8345 Catch ex As Exception
8349 NotifyIcon1.Visible = True
8351 If IsNetworkAvailable() Then
8352 If SettingDialog.StartupFollowers Then
8353 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
8356 _waitTimeline = True
8357 GetTimeline(WORKERTYPE.Timeline, 1, 1, "")
8359 GetTimeline(WORKERTYPE.Reply, 1, 1, "")
8361 GetTimeline(WORKERTYPE.DirectMessegeRcv, 1, 1, "")
8362 If SettingDialog.GetFav Then
8364 GetTimeline(WORKERTYPE.Favorites, 1, 1, "")
8366 _waitPubSearch = True
8367 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, "") 'tabname="":全タブ
8368 _waitUserTimeline = True
8369 GetTimeline(WORKERTYPE.UserTimeline, 1, 0, "") 'tabname="":全タブ
8371 GetTimeline(WORKERTYPE.List, 1, 0, "") 'tabname="":全タブ
8372 Dim i As Integer = 0
8373 Dim j As Integer = 0
8374 Do While (IsInitialRead()) AndAlso Not _endingFlag
8375 System.Threading.Thread.Sleep(100)
8376 My.Application.DoEvents()
8379 If j > 1200 Then Exit Do ' 120秒間初期処理が終了しなかったら強制的に打ち切る
8388 If _endingFlag Then Exit Sub
8390 'バージョンチェック(引数:起動時チェックの場合はTrue・・・チェック結果のメッセージを表示しない)
8391 If SettingDialog.StartupVersion Then
8392 CheckNewVersion(True)
8396 If Not tw.GetFollowersSuccess AndAlso SettingDialog.StartupFollowers Then
8397 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
8402 TimerTimeline.Enabled = True
8405 Private Function IsInitialRead() As Boolean
8406 Return _waitTimeline OrElse _waitReply OrElse _waitDm OrElse _waitFav OrElse _waitPubSearch OrElse _waitUserTimeline OrElse _waitLists
8409 Private Sub doGetFollowersMenu()
8410 GetTimeline(WORKERTYPE.Follower, 1, 0, "")
8411 DispSelectedPost(True)
8414 Private Sub GetFollowersAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateFollowersMenuItem1.Click
8415 doGetFollowersMenu()
8418 Private Sub doReTweetUnofficial()
8420 If Me.ExistCurrentPost Then
8421 If _curPost.IsDm OrElse _
8422 Not StatusText.Enabled Then Exit Sub
8424 If _curPost.IsProtect Then
8425 MessageBox.Show("Protected.")
8428 Dim rtdata As String = _curPost.Text
8429 rtdata = CreateRetweetUnofficial(rtdata)
8431 StatusText.Text = "RT @" + _curPost.ScreenName + ": " + HttpUtility.HtmlDecode(rtdata)
8433 StatusText.SelectionStart = 0
8438 Private Sub ReTweetStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReTweetStripMenuItem.Click, RtUnOpMenuItem.Click
8439 doReTweetUnofficial()
8442 Private Sub doReTweetOfficial(ByVal isConfirm As Boolean)
8444 If Me.ExistCurrentPost Then
8445 If _curPost.IsProtect Then
8446 MessageBox.Show("Protected.")
8447 _DoFavRetweetFlags = False
8450 If _curList.SelectedIndices.Count > 15 Then
8451 MessageBox.Show(My.Resources.RetweetLimitText)
8452 _DoFavRetweetFlags = False
8454 ElseIf _curList.SelectedIndices.Count > 1 Then
8455 Dim QuestionText As String = My.Resources.RetweetQuestion2
8456 If _DoFavRetweetFlags Then QuestionText = My.Resources.FavoriteRetweetQuestionText1
8457 Select Case MessageBox.Show(QuestionText, "Retweet", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
8458 Case Windows.Forms.DialogResult.Cancel, Windows.Forms.DialogResult.No
8459 _DoFavRetweetFlags = False
8463 If _curPost.IsDm OrElse _curPost.IsMe Then
8464 _DoFavRetweetFlags = False
8467 If Not SettingDialog.RetweetNoConfirm Then
8468 Dim Questiontext As String = My.Resources.RetweetQuestion1
8469 If _DoFavRetweetFlags Then Questiontext = My.Resources.FavoritesRetweetQuestionText2
8470 If isConfirm AndAlso MessageBox.Show(Questiontext, "Retweet", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
8471 _DoFavRetweetFlags = False
8476 Dim args As New GetWorkerArg
8477 args.ids = New List(Of Long)
8478 args.sIds = New List(Of Long)
8479 args.tName = _curTab.Text
8480 args.type = WORKERTYPE.Retweet
8481 For Each idx As Integer In _curList.SelectedIndices
8482 Dim post As PostClass = GetCurTabPost(idx)
8483 If Not post.IsMe AndAlso Not post.IsProtect AndAlso Not post.IsDm Then args.ids.Add(post.StatusId)
8489 Private Sub ReTweetOriginalStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReTweetOriginalStripMenuItem.Click, RtOpMenuItem.Click
8490 doReTweetOfficial(True)
8493 Private Sub FavoritesRetweetOriginal()
8494 If Not Me.ExistCurrentPost Then Exit Sub
8495 _DoFavRetweetFlags = True
8496 doReTweetOfficial(True)
8497 If _DoFavRetweetFlags Then
8498 _DoFavRetweetFlags = False
8499 FavoriteChange(True, False)
8503 Private Sub FavoritesRetweetUnofficial()
8504 If Me.ExistCurrentPost AndAlso Not _curPost.IsDm Then
8505 _DoFavRetweetFlags = True
8506 FavoriteChange(True)
8507 If Not _curPost.IsProtect AndAlso _DoFavRetweetFlags Then
8508 _DoFavRetweetFlags = False
8509 doReTweetUnofficial()
8514 Private Function CreateRetweetUnofficial(ByVal status As String) As String
8516 ' Twitterにより省略されているURLを含むaタグをキャプチャしてリンク先URLへ置き換える
8519 Dim isUrl As Boolean = False
8520 Dim ms As MatchCollection = Regex.Matches(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>")
8521 For Each m As Match In ms
8522 If m.Result("${link}").EndsWith("...") Then
8528 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>", "${url}")
8530 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>(https?|shttp|ftps?)://[^<]+)</a>", "${link}")
8533 'その他のリンク(@IDなど)を置き換える
8534 status = Regex.Replace(status, "@<a target=""_self"" href=""https?://twitter.com/(#!/)?(?<url>[^""]+)""[^>]*>(?<link>[^<]+)</a>", "@${url}")
8536 status = Regex.Replace(status, "<a target=""_self"" href=""(?<url>[^""]+)""[^>]*>(?<link>[^<]+)</a>", "${link}")
8538 If StatusText.Multiline Then
8539 status = Regex.Replace(status, "(\r\n|\n|\r)?<br>", vbCrLf, RegexOptions.IgnoreCase Or RegexOptions.Multiline)
8541 status = Regex.Replace(status, "(\r\n|\n|\r)?<br>", "", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
8546 status = status.Replace(" ", " ")
8551 Private Sub DumpPostClassToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DumpPostClassToolStripMenuItem.Click
8552 If _curPost IsNot Nothing Then
8553 DispSelectedPost(True)
8557 Private Sub MenuItemHelp_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemHelp.DropDownOpening
8558 If DebugBuild OrElse My.Computer.Keyboard.CapsLock AndAlso My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.ShiftKeyDown Then
8559 DebugModeToolStripMenuItem.Visible = True
8561 DebugModeToolStripMenuItem.Visible = False
8565 Private Sub ToolStripMenuItemUrlAutoShorten_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemUrlAutoShorten.CheckedChanged
8566 SettingDialog.UrlConvertAuto = ToolStripMenuItemUrlAutoShorten.Checked
8569 Private Sub ContextMenuPostMode_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuPostMode.Opening
8570 ToolStripMenuItemUrlAutoShorten.Checked = SettingDialog.UrlConvertAuto
8573 Private Sub TraceOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraceOutToolStripMenuItem.Click
8574 If TraceOutToolStripMenuItem.Checked Then
8581 Private Sub TweenMain_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
8582 '画面が非アクティブになったら、発言欄の背景色をデフォルトへ
8583 Me.StatusText_Leave(StatusText, System.EventArgs.Empty)
8586 Private Sub TabRenameMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabRenameMenuItem.Click, RenameTbMenuItem.Click
8587 If String.IsNullOrEmpty(_rclickTabName) Then Exit Sub
8588 TabRename(_rclickTabName)
8591 Private Sub BitlyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BitlyToolStripMenuItem.Click
8592 UrlConvert(UrlConverter.Bitly)
8595 Private Sub JmpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JmpStripMenuItem.Click
8596 UrlConvert(UrlConverter.Jmp)
8600 Private Class GetApiInfoArgs
8601 Public tw As Twitter
8602 Public info As ApiInfo
8605 Private Sub GetApiInfo_Dowork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8606 Dim args As GetApiInfoArgs = DirectCast(e.Argument, GetApiInfoArgs)
8607 e.Result = tw.GetInfoApi(args.info)
8610 Private Sub ApiInfoMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApiInfoMenuItem.Click
8611 Dim info As New ApiInfo
8613 Dim args As New GetApiInfoArgs With {.tw = tw, .info = info}
8615 Using dlg As New FormInfo(Me, My.Resources.ApiInfo6, AddressOf GetApiInfo_Dowork, Nothing, args)
8617 If CBool(dlg.Result) Then
8618 tmp = My.Resources.ApiInfo1 + args.info.MaxCount.ToString() + Environment.NewLine + _
8619 My.Resources.ApiInfo2 + args.info.RemainCount.ToString() + Environment.NewLine + _
8620 My.Resources.ApiInfo3 + args.info.ResetTime.ToString() + Environment.NewLine + _
8621 My.Resources.ApiInfo7 + IIf(tw.UserStreamEnabled, My.Resources.Enable, My.Resources.Disable).ToString()
8624 tmp = My.Resources.ApiInfo5
8628 MessageBox.Show(tmp, My.Resources.ApiInfo4, MessageBoxButtons.OK, MessageBoxIcon.Information)
8631 Private Sub FollowCommandMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowCommandMenuItem.Click
8632 Dim id As String = ""
8633 If _curPost IsNot Nothing Then id = _curPost.ScreenName
8637 Private Sub FollowCommand_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8638 Dim arg As FollowRemoveCommandArgs = DirectCast(e.Argument, FollowRemoveCommandArgs)
8639 e.Result = arg.tw.PostFollowCommand(arg.id)
8642 Private Sub FollowCommand(ByVal id As String)
8643 Using inputName As New InputTabName()
8644 inputName.FormTitle = "Follow"
8645 inputName.FormDescription = My.Resources.FRMessage1
8646 inputName.TabName = id
8647 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8648 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8649 Dim arg As New FollowRemoveCommandArgs
8651 arg.id = inputName.TabName.Trim()
8652 Using _info As New FormInfo(Me, My.Resources.FollowCommandText1, _
8653 AddressOf FollowCommand_DoWork, _
8657 Dim ret As String = DirectCast(_info.Result, String)
8658 If Not String.IsNullOrEmpty(ret) Then
8659 MessageBox.Show(My.Resources.FRMessage2 + ret)
8661 MessageBox.Show(My.Resources.FRMessage3)
8668 Private Sub RemoveCommandMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveCommandMenuItem.Click
8669 Dim id As String = ""
8670 If _curPost IsNot Nothing Then id = _curPost.ScreenName
8671 RemoveCommand(id, False)
8674 Private Class FollowRemoveCommandArgs
8675 Public tw As Tween.Twitter
8679 Private Sub RemoveCommand_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8680 Dim arg As FollowRemoveCommandArgs = DirectCast(e.Argument, FollowRemoveCommandArgs)
8681 e.Result = arg.tw.PostRemoveCommand(arg.id)
8684 Private Sub RemoveCommand(ByVal id As String, ByVal skipInput As Boolean)
8685 Dim arg As New FollowRemoveCommandArgs
8688 If Not skipInput Then
8689 Using inputName As New InputTabName()
8690 inputName.FormTitle = "Unfollow"
8691 inputName.FormDescription = My.Resources.FRMessage1
8692 inputName.TabName = id
8693 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8694 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8696 arg.id = inputName.TabName.Trim()
8703 Using _info As New FormInfo(Me, My.Resources.RemoveCommandText1, _
8704 AddressOf RemoveCommand_DoWork, _
8708 Dim ret As String = DirectCast(_info.Result, String)
8709 If Not String.IsNullOrEmpty(ret) Then
8710 MessageBox.Show(My.Resources.FRMessage2 + ret)
8712 MessageBox.Show(My.Resources.FRMessage3)
8717 Private Sub FriendshipMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipMenuItem.Click
8718 Dim id As String = ""
8719 If _curPost IsNot Nothing Then
8720 id = _curPost.ScreenName
8725 Private Class ShowFriendshipArgs
8726 Public tw As Tween.Twitter
8727 Public Class FriendshipInfo
8728 Public id As String = ""
8729 Public isFollowing As Boolean = False
8730 Public isFollowed As Boolean = False
8731 Public isError As Boolean = False
8732 Public Sub New(ByVal id As String)
8736 Public ids As New List(Of FriendshipInfo)
8739 Private Sub ShowFriendship_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
8740 Dim arg As ShowFriendshipArgs = DirectCast(e.Argument, ShowFriendshipArgs)
8741 Dim result As String = ""
8742 For Each fInfo As ShowFriendshipArgs.FriendshipInfo In arg.ids
8743 Dim rt As String = arg.tw.GetFriendshipInfo(fInfo.id, fInfo.isFollowing, fInfo.isFollowed)
8744 If Not String.IsNullOrEmpty(rt) Then
8745 If String.IsNullOrEmpty(result) Then result = rt
8746 fInfo.isError = True
8752 Private Sub ShowFriendship(ByVal id As String)
8753 Dim args As New ShowFriendshipArgs
8755 Using inputName As New InputTabName()
8756 inputName.FormTitle = "Show Friendships"
8757 inputName.FormDescription = My.Resources.FRMessage1
8758 inputName.TabName = id
8759 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
8760 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
8761 Dim ret As String = ""
8762 args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(inputName.TabName.Trim))
8763 Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
8764 AddressOf ShowFriendship_DoWork, _
8768 ret = DirectCast(_info.Result, String)
8770 Dim result As String = ""
8771 If String.IsNullOrEmpty(ret) Then
8772 If args.ids(0).isFollowing Then
8773 result = My.Resources.GetFriendshipInfo1 + System.Environment.NewLine
8775 result = My.Resources.GetFriendshipInfo2 + System.Environment.NewLine
8777 If args.ids(0).isFollowed Then
8778 result += My.Resources.GetFriendshipInfo3
8780 result += My.Resources.GetFriendshipInfo4
8782 result = args.ids(0).id + My.Resources.GetFriendshipInfo5 + System.Environment.NewLine + result
8786 MessageBox.Show(result)
8791 Private Sub ShowFriendship(ByVal ids() As String)
8792 For Each id As String In ids
8793 Dim ret As String = ""
8794 Dim args As New ShowFriendshipArgs
8796 args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(id.Trim))
8797 Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
8798 AddressOf ShowFriendship_DoWork, _
8802 ret = DirectCast(_info.Result, String)
8804 Dim result As String = ""
8805 Dim fInfo As ShowFriendshipArgs.FriendshipInfo = args.ids(0)
8806 Dim ff As String = ""
8807 If String.IsNullOrEmpty(ret) Then
8809 If fInfo.isFollowing Then
8810 ff += My.Resources.GetFriendshipInfo1
8812 ff += My.Resources.GetFriendshipInfo2
8814 ff += System.Environment.NewLine + " "
8815 If fInfo.isFollowed Then
8816 ff += My.Resources.GetFriendshipInfo3
8818 ff += My.Resources.GetFriendshipInfo4
8820 result += fInfo.id + My.Resources.GetFriendshipInfo5 + System.Environment.NewLine + ff
8821 If fInfo.isFollowing Then
8822 If MessageBox.Show( _
8823 My.Resources.GetFriendshipInfo7 + System.Environment.NewLine + result, My.Resources.GetFriendshipInfo8, _
8824 MessageBoxButtons.YesNo, _
8825 MessageBoxIcon.Question, _
8826 MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
8827 RemoveCommand(fInfo.id, True)
8830 MessageBox.Show(result)
8833 MessageBox.Show(ret)
8838 Private Sub OwnStatusMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OwnStatusMenuItem.Click
8839 doShowUserStatus(tw.Username, False)
8840 'If Not String.IsNullOrEmpty(tw.UserInfoXml) Then
8841 ' doShowUserStatus(tw.Username, False)
8843 ' MessageBox.Show(My.Resources.ShowYourProfileText1, "Your status", MessageBoxButtons.OK, MessageBoxIcon.Information)
8848 ' TwitterIDでない固定文字列を調べる(文字列検証のみ 実際に取得はしない)
8851 Public Function IsTwitterId(ByVal name As String) As Boolean
8852 Return Not Regex.Match(name, "^(about|jobs|tos|privacy)$").Success
8855 Private Function GetUserId() As String
8856 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)(/status(es)?/[0-9]+)?$")
8857 If m.Success AndAlso IsTwitterId(m.Result("${ScreenName}")) Then
8858 Return m.Result("${ScreenName}")
8864 Private Sub FollowContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowContextMenuItem.Click
8865 Dim name As String = GetUserId()
8866 If name IsNot Nothing Then FollowCommand(name)
8869 Private Sub RemoveContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveContextMenuItem.Click
8870 Dim name As String = GetUserId()
8871 If name IsNot Nothing Then RemoveCommand(name, False)
8874 Private Sub FriendshipContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipContextMenuItem.Click
8875 Dim name As String = GetUserId()
8876 If name IsNot Nothing Then ShowFriendship(name)
8879 Private Sub FriendshipAllMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendshipAllMenuItem.Click
8880 Dim ma As MatchCollection = Regex.Matches(Me.PostBrowser.DocumentText, "href=""https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)(/status(es)?/[0-9]+)?""")
8881 Dim ids As New List(Of String)
8882 For Each mu As Match In ma
8883 If mu.Result("${ScreenName}").ToLower <> tw.Username.ToLower Then
8884 ids.Add(mu.Result("${ScreenName}"))
8887 ShowFriendship(ids.ToArray)
8890 Private Sub ShowUserStatusContextMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowUserStatusContextMenuItem.Click
8891 Dim name As String = GetUserId()
8892 If name IsNot Nothing Then ShowUserStatus(name)
8895 Private Sub SearchPostsDetailToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPostsDetailToolStripMenuItem.Click
8896 Dim name As String = GetUserId()
8897 If name IsNot Nothing Then AddNewTabForUserTimeline(name)
8900 Private Sub SearchAtPostsDetailToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchAtPostsDetailToolStripMenuItem.Click
8901 Dim name As String = GetUserId()
8902 If name IsNot Nothing Then AddNewTabForSearch("@" + name)
8905 Private Sub IdeographicSpaceToSpaceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IdeographicSpaceToSpaceToolStripMenuItem.Click
8906 _modifySettingCommon = True
8909 Private Sub ToolStripFocusLockMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripFocusLockMenuItem.Click
8910 _modifySettingCommon = True
8913 Private Sub doQuote()
8916 If Me.ExistCurrentPost Then
8917 If _curPost.IsDm OrElse _
8918 Not StatusText.Enabled Then Exit Sub
8920 If _curPost.IsProtect Then
8921 MessageBox.Show("Protected.")
8924 Dim rtdata As String = _curPost.Text
8925 rtdata = CreateRetweetUnofficial(rtdata)
8927 StatusText.Text = " QT @" + _curPost.ScreenName + ": " + HttpUtility.HtmlDecode(rtdata)
8928 If _curPost.RetweetedId = 0 Then
8929 _reply_to_id = _curPost.StatusId
8931 _reply_to_id = _curPost.RetweetedId
8933 _reply_to_name = _curPost.ScreenName
8935 StatusText.SelectionStart = 0
8940 Private Sub QuoteStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuoteStripMenuItem.Click, QtOpMenuItem.Click
8944 Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
8946 Dim pnl As Control = DirectCast(sender, Control).Parent
8947 If pnl Is Nothing Then Exit Sub
8948 Dim tbName As String = pnl.Parent.Text
8949 Dim tb As TabClass = _statuses.Tabs(tbName)
8950 Dim cmb As ComboBox = DirectCast(pnl.Controls("comboSearch"), ComboBox)
8951 Dim cmbLang As ComboBox = DirectCast(pnl.Controls("comboLang"), ComboBox)
8952 Dim cmbusline As ComboBox = DirectCast(pnl.Controls("comboUserline"), ComboBox)
8953 cmb.Text = cmb.Text.Trim
8954 ' 検索式演算子 OR についてのみ大文字しか認識しないので強制的に大文字とする
8955 Dim Quote As Boolean = False
8956 Dim buf As New StringBuilder()
8957 Dim c As Char() = cmb.Text.ToCharArray()
8958 For cnt As Integer = 0 To cmb.Text.Length - 1
8959 If cnt > cmb.Text.Length - 4 Then
8960 buf.Append(cmb.Text.Substring(cnt))
8963 If c(cnt) = CChar("""") Then
8966 If Not Quote AndAlso cmb.Text.Substring(cnt, 4).Equals(" or ", StringComparison.OrdinalIgnoreCase) Then
8974 cmb.Text = buf.ToString()
8976 tb.SearchWords = cmb.Text
8977 tb.SearchLang = cmbLang.Text
8978 If cmb.Text = "" Then
8979 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
8983 If tb.IsQueryChanged Then
8984 Dim idx As Integer = DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.IndexOf(tb.SearchWords)
8985 If idx > -1 Then DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.RemoveAt(idx)
8986 DirectCast(pnl.Controls("comboSearch"), ComboBox).Items.Insert(0, tb.SearchWords)
8987 cmb.Text = tb.SearchWords
8989 Dim lst As DetailsListView = DirectCast(pnl.Parent.Tag, DetailsListView)
8990 lst.VirtualListSize = 0
8992 _statuses.ClearTabIds(tbName)
8993 SaveConfigsTabs() '検索条件の保存
8996 GetTimeline(WORKERTYPE.PublicSearch, 1, 0, tbName)
8997 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9000 Private Sub RefreshMoreStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshMoreStripMenuItem.Click, RefreshPrevOpMenuItem.Click
9005 Private Sub UndoRemoveTabMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoRemoveTabMenuItem.Click
9006 If _statuses.RemovedTab.Count = 0 Then
9007 MessageBox.Show("There isn't removed tab.", "Undo", MessageBoxButtons.OK, MessageBoxIcon.Information)
9010 Dim tb As TabClass = _statuses.RemovedTab.Pop()
9011 Dim renamed As String = tb.TabName
9012 For i As Integer = 1 To Integer.MaxValue
9013 If Not _statuses.ContainsTab(renamed) Then Exit For
9014 renamed = tb.TabName + "(" + i.ToString + ")"
9016 tb.TabName = renamed
9017 _statuses.Tabs.Add(renamed, tb)
9018 AddNewTab(renamed, False, tb.TabType, tb.ListInfo)
9019 ListTab.SelectedIndex = ListTab.TabPages.Count - 1
9024 Private Sub doMoveToRTHome()
9025 If _curList.SelectedIndices.Count > 0 Then
9026 Dim post As PostClass = GetCurTabPost(_curList.SelectedIndices(0))
9027 If post.RetweetedId > 0 Then
9028 OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices(0)).RetweetedBy)
9033 Private Sub MoveToRTHomeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveToRTHomeMenuItem.Click, OpenRterHomeMenuItem.Click
9037 Private Sub IdFilterAddMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IdFilterAddMenuItem.Click
9038 Dim name As String = GetUserId()
9039 If name IsNot Nothing Then
9040 Dim tabName As String = ""
9043 If _curList.SelectedIndices.Count = 0 Then Exit Sub
9046 If Not SelectTab(tabName) Then Exit Sub
9048 Dim mv As Boolean = False
9049 Dim mk As Boolean = False
9052 Dim fc As New FiltersClass
9053 fc.NameFilter = name
9054 fc.SearchBoth = True
9058 fc.SearchUrl = False
9059 _statuses.Tabs(tabName).AddFilter(fc)
9062 Me.Cursor = Cursors.WaitCursor
9063 _itemCache = Nothing
9064 _postCache = Nothing
9067 _statuses.FilterAll()
9068 For Each tb As TabPage In ListTab.TabPages
9069 DirectCast(tb.Tag, DetailsListView).VirtualListSize = _statuses.Tabs(tb.Text).AllCount
9070 If _statuses.Tabs(tb.Text).UnreadCount > 0 Then
9071 If SettingDialog.TabIconDisp Then
9075 If SettingDialog.TabIconDisp Then
9080 If Not SettingDialog.TabIconDisp Then ListTab.Refresh()
9082 Me.Cursor = Cursors.Default
9088 Private Sub ListManageUserContextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListManageUserContextToolStripMenuItem.Click, ListManageMenuItem.Click, ListManageUserContextToolStripMenuItem2.Click, ListManageUserContextToolStripMenuItem3.Click
9091 Dim menuItem As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
9093 If menuItem.Owner Is Me.ContextMenuPostBrowser Then
9095 If user Is Nothing Then Return
9096 ElseIf Me._curPost IsNot Nothing Then
9097 user = Me._curPost.ScreenName
9102 Dim list As ListElement = Nothing
9104 If TabInformations.GetInstance().SubscribableLists.Count = 0 Then
9105 Dim res As String = Me.tw.GetListsApi()
9108 MessageBox.Show("Failed to get lists. (" + res + ")")
9113 Using listSelectForm As New MyLists(user, Me.tw)
9114 listSelectForm.ShowDialog(Me)
9118 Private Sub SearchControls_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
9119 Dim pnl As Control = DirectCast(sender, Control)
9120 For Each ctl As Control In pnl.Controls
9125 Private Sub SearchControls_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
9126 Dim pnl As Control = DirectCast(sender, Control)
9127 For Each ctl As Control In pnl.Controls
9132 Private Sub PublicSearchQueryMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PublicSearchQueryMenuItem.Click
9133 If ListTab.SelectedTab IsNot Nothing Then
9134 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.PublicSearch Then Exit Sub
9135 ListTab.SelectedTab.Controls("panelSearch").Controls("comboSearch").Focus()
9139 Private Sub UseHashtagMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UseHashtagMenuItem.Click
9140 Dim m As Match = Regex.Match(Me._postBrowserStatusText, "^https?://twitter.com/search\?q=%23(?<hash>[a-zA-Z0-9_]+)$")
9142 HashMgr.SetPermanentHash("#" + m.Result("${hash}"))
9143 HashStripSplitButton.Text = HashMgr.UseHash
9144 HashToggleMenuItem.Checked = True
9145 HashToggleToolStripMenuItem.Checked = True
9147 _modifySettingCommon = True
9151 Private Sub StatusLabel_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusLabel.DoubleClick
9152 MessageBox.Show(StatusLabel.TextHistory, "Logs", MessageBoxButtons.OK, MessageBoxIcon.None)
9155 Private Sub HashManageMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HashManageMenuItem.Click, HashManageToolStripMenuItem.Click
9156 Dim rslt As DialogResult
9158 rslt = HashMgr.ShowDialog()
9159 Catch ex As Exception
9162 Me.TopMost = SettingDialog.AlwaysTop
9163 If rslt = Windows.Forms.DialogResult.Cancel Then Exit Sub
9164 If HashMgr.UseHash <> "" Then
9165 HashStripSplitButton.Text = HashMgr.UseHash
9166 HashToggleMenuItem.Checked = True
9167 HashToggleToolStripMenuItem.Checked = True
9169 HashStripSplitButton.Text = "#[-]"
9170 HashToggleMenuItem.Checked = False
9171 HashToggleToolStripMenuItem.Checked = False
9173 'If HashMgr.IsInsert AndAlso HashMgr.UseHash <> "" Then
9174 ' Dim sidx As Integer = StatusText.SelectionStart
9175 ' Dim hash As String = HashMgr.UseHash + " "
9177 ' If StatusText.Text.Substring(sidx - 1, 1) <> " " Then
9181 ' StatusText.Text = StatusText.Text.Insert(sidx, hash)
9182 ' sidx += hash.Length
9183 ' StatusText.SelectionStart = sidx
9184 ' StatusText.Focus()
9186 _modifySettingCommon = True
9187 Me.StatusText_TextChanged(Nothing, Nothing)
9190 Private Sub HashToggleMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles HashToggleMenuItem.Click, HashToggleToolStripMenuItem.Click
9191 HashMgr.ToggleHash()
9192 If HashMgr.UseHash <> "" Then
9193 HashStripSplitButton.Text = HashMgr.UseHash
9194 HashToggleMenuItem.Checked = True
9195 HashToggleToolStripMenuItem.Checked = True
9197 HashStripSplitButton.Text = "#[-]"
9198 HashToggleMenuItem.Checked = False
9199 HashToggleToolStripMenuItem.Checked = False
9201 _modifySettingCommon = True
9202 Me.StatusText_TextChanged(Nothing, Nothing)
9205 Private Sub HashStripSplitButton_ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles HashStripSplitButton.ButtonClick
9206 HashToggleMenuItem_Click(Nothing, Nothing)
9209 Private Sub MenuItemOperate_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemOperate.DropDownOpening
9210 If ListTab.SelectedTab Is Nothing Then Exit Sub
9211 If _statuses Is Nothing OrElse _statuses.Tabs Is Nothing OrElse Not _statuses.Tabs.ContainsKey(ListTab.SelectedTab.Text) Then Exit Sub
9212 If Not Me.ExistCurrentPost Then
9213 Me.ReplyOpMenuItem.Enabled = False
9214 Me.ReplyAllOpMenuItem.Enabled = False
9215 Me.DmOpMenuItem.Enabled = False
9216 Me.ShowProfMenuItem.Enabled = False
9217 Me.ShowUserTimelineToolStripMenuItem.Enabled = False
9218 Me.ListManageMenuItem.Enabled = False
9219 Me.OpenFavOpMenuItem.Enabled = False
9220 Me.CreateTabRuleOpMenuItem.Enabled = False
9221 Me.CreateIdRuleOpMenuItem.Enabled = False
9222 Me.ReadOpMenuItem.Enabled = False
9223 Me.UnreadOpMenuItem.Enabled = False
9225 Me.ReplyOpMenuItem.Enabled = True
9226 Me.ReplyAllOpMenuItem.Enabled = True
9227 Me.DmOpMenuItem.Enabled = True
9228 Me.ShowProfMenuItem.Enabled = True
9229 Me.ShowUserTimelineToolStripMenuItem.Enabled = True
9230 Me.ListManageMenuItem.Enabled = True
9231 Me.OpenFavOpMenuItem.Enabled = True
9232 Me.CreateTabRuleOpMenuItem.Enabled = True
9233 Me.CreateIdRuleOpMenuItem.Enabled = True
9234 Me.ReadOpMenuItem.Enabled = True
9235 Me.UnreadOpMenuItem.Enabled = True
9238 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.DirectMessage OrElse Not Me.ExistCurrentPost OrElse _curPost.IsDm Then
9239 Me.FavOpMenuItem.Enabled = False
9240 Me.UnFavOpMenuItem.Enabled = False
9241 Me.OpenStatusOpMenuItem.Enabled = False
9242 Me.OpenFavotterOpMenuItem.Enabled = False
9243 Me.ShowRelatedStatusesMenuItem2.Enabled = False
9244 Me.RtOpMenuItem.Enabled = False
9245 Me.RtUnOpMenuItem.Enabled = False
9246 Me.QtOpMenuItem.Enabled = False
9247 Me.FavoriteRetweetMenuItem.Enabled = False
9248 Me.FavoriteRetweetUnofficialMenuItem.Enabled = False
9249 If Me.ExistCurrentPost AndAlso _curPost.IsDm Then Me.DelOpMenuItem.Enabled = True
9251 Me.FavOpMenuItem.Enabled = True
9252 Me.UnFavOpMenuItem.Enabled = True
9253 Me.OpenStatusOpMenuItem.Enabled = True
9254 Me.OpenFavotterOpMenuItem.Enabled = True
9255 Me.ShowRelatedStatusesMenuItem2.Enabled = True 'PublicSearchの時問題出るかも
9257 If _curPost.IsMe Then
9258 Me.RtOpMenuItem.Enabled = False
9259 Me.FavoriteRetweetMenuItem.Enabled = False
9260 Me.DelOpMenuItem.Enabled = True
9262 Me.DelOpMenuItem.Enabled = False
9263 If _curPost.IsProtect Then
9264 Me.RtOpMenuItem.Enabled = False
9265 Me.RtUnOpMenuItem.Enabled = False
9266 Me.QtOpMenuItem.Enabled = False
9267 Me.FavoriteRetweetMenuItem.Enabled = False
9268 Me.FavoriteRetweetUnofficialMenuItem.Enabled = False
9270 Me.RtOpMenuItem.Enabled = True
9271 Me.RtUnOpMenuItem.Enabled = True
9272 Me.QtOpMenuItem.Enabled = True
9273 Me.FavoriteRetweetMenuItem.Enabled = True
9274 Me.FavoriteRetweetUnofficialMenuItem.Enabled = True
9279 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType <> TabUsageType.Favorites Then
9280 Me.RefreshPrevOpMenuItem.Enabled = True
9282 Me.RefreshPrevOpMenuItem.Enabled = False
9284 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch _
9285 OrElse Not Me.ExistCurrentPost _
9286 OrElse Not _curPost.InReplyToStatusId > 0 Then
9287 OpenRepSourceOpMenuItem.Enabled = False
9289 OpenRepSourceOpMenuItem.Enabled = True
9291 If Not Me.ExistCurrentPost OrElse _curPost.RetweetedBy = "" Then
9292 OpenRterHomeMenuItem.Enabled = False
9294 OpenRterHomeMenuItem.Enabled = True
9298 Private Sub MenuItemTab_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemTab.DropDownOpening
9299 ContextMenuTabProperty_Opening(sender, Nothing)
9302 Public ReadOnly Property TwitterInstance() As Twitter
9309 Private Sub SplitContainer3_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer3.SplitterMoved
9310 If Me.WindowState = FormWindowState.Normal AndAlso Not _initialLayout Then
9311 _mySpDis3 = SplitContainer3.SplitterDistance
9312 _modifySettingLocal = True
9316 Private Sub MenuItemEdit_DropDownOpening(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemEdit.DropDownOpening
9317 If _statuses.RemovedTab.Count = 0 Then
9318 UndoRemoveTabMenuItem.Enabled = False
9320 UndoRemoveTabMenuItem.Enabled = True
9322 If ListTab.SelectedTab IsNot Nothing Then
9323 If _statuses.Tabs(ListTab.SelectedTab.Text).TabType = TabUsageType.PublicSearch Then
9324 PublicSearchQueryMenuItem.Enabled = True
9326 PublicSearchQueryMenuItem.Enabled = False
9329 PublicSearchQueryMenuItem.Enabled = False
9331 If Not Me.ExistCurrentPost Then
9332 Me.CopySTOTMenuItem.Enabled = False
9333 Me.CopyURLMenuItem.Enabled = False
9334 Me.CopyUserIdStripMenuItem.Enabled = False
9336 Me.CopySTOTMenuItem.Enabled = True
9337 Me.CopyURLMenuItem.Enabled = True
9338 Me.CopyUserIdStripMenuItem.Enabled = True
9339 If _curPost.IsDm Then Me.CopyURLMenuItem.Enabled = False
9340 If _curPost.IsProtect Then Me.CopySTOTMenuItem.Enabled = False
9344 Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
9348 Private Sub UserStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserStatusToolStripMenuItem.Click
9349 Dim id As String = ""
9350 If _curPost IsNot Nothing Then
9351 id = _curPost.ScreenName
9356 Private Class GetUserInfoArgs
9357 Public tw As Tween.Twitter
9359 Public user As TwitterDataModel.User
9362 Private Sub GetUserInfo_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
9363 Dim args As GetUserInfoArgs = DirectCast(e.Argument, GetUserInfoArgs)
9364 e.Result = args.tw.GetUserInfo(args.id, args.user)
9367 Private Overloads Sub doShowUserStatus(ByVal id As String, ByVal ShowInputDialog As Boolean)
9368 Dim result As String = ""
9369 Dim user As TwitterDataModel.User = Nothing
9370 Dim args As New GetUserInfoArgs
9371 If ShowInputDialog Then
9372 Using inputName As New InputTabName()
9373 inputName.FormTitle = "Show UserStatus"
9374 inputName.FormDescription = My.Resources.FRMessage1
9375 inputName.TabName = id
9376 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
9377 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
9378 id = inputName.TabName.Trim
9382 Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
9383 AddressOf GetUserInfo_DoWork, _
9387 Dim ret As String = DirectCast(_info.Result, String)
9388 If String.IsNullOrEmpty(ret) Then
9389 doShowUserStatus(args.user)
9391 MessageBox.Show(ret)
9400 Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
9401 AddressOf GetUserInfo_DoWork, _
9405 Dim ret As String = DirectCast(_info.Result, String)
9406 If String.IsNullOrEmpty(ret) Then
9407 doShowUserStatus(args.user)
9409 MessageBox.Show(ret)
9415 Private Overloads Sub doShowUserStatus(ByVal user As TwitterDataModel.User)
9416 Using userinfo As New ShowUserInfo()
9418 userinfo.User = user
9419 userinfo.ShowDialog(Me)
9424 Private Overloads Sub ShowUserStatus(ByVal id As String, ByVal ShowInputDialog As Boolean)
9425 doShowUserStatus(id, ShowInputDialog)
9428 Private Overloads Sub ShowUserStatus(ByVal id As String)
9429 doShowUserStatus(id, True)
9432 Private Sub FollowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FollowToolStripMenuItem.Click
9433 If NameLabel.Tag IsNot Nothing Then
9434 Dim id As String = DirectCast(NameLabel.Tag, String)
9435 If id <> tw.Username Then
9441 Private Sub UnFollowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnFollowToolStripMenuItem.Click
9442 If NameLabel.Tag IsNot Nothing Then
9443 Dim id As String = DirectCast(NameLabel.Tag, String)
9444 If id <> tw.Username Then
9445 RemoveCommand(id, False)
9450 Private Sub ShowFriendShipToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowFriendShipToolStripMenuItem.Click
9451 If NameLabel.Tag IsNot Nothing Then
9452 Dim id As String = DirectCast(NameLabel.Tag, String)
9453 If id <> tw.Username Then
9459 Private Sub ShowUserStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowUserStatusToolStripMenuItem.Click
9460 If NameLabel.Tag IsNot Nothing Then
9461 Dim id As String = DirectCast(NameLabel.Tag, String)
9462 ShowUserStatus(id, False)
9466 Private Sub SearchPostsDetailNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchPostsDetailNameToolStripMenuItem.Click
9467 If NameLabel.Tag IsNot Nothing Then
9468 Dim id As String = DirectCast(NameLabel.Tag, String)
9469 AddNewTabForUserTimeline(id)
9473 Private Sub SearchAtPostsDetailNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchAtPostsDetailNameToolStripMenuItem.Click
9474 If NameLabel.Tag IsNot Nothing Then
9475 Dim id As String = DirectCast(NameLabel.Tag, String)
9476 AddNewTabForSearch("@" + id)
9480 Private Sub ShowProfileMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowProfileMenuItem.Click, ShowProfMenuItem.Click
9481 If _curPost IsNot Nothing Then
9482 ShowUserStatus(_curPost.ScreenName, False)
9486 Private Sub GetRetweet_DoWork(ByVal sender As Object, ByVal e As ComponentModel.DoWorkEventArgs)
9487 Dim counter As Integer = 0
9489 Dim statusid As Long
9490 If _curPost.RetweetedId > 0 Then
9491 statusid = _curPost.RetweetedId
9493 statusid = _curPost.StatusId
9495 tw.GetStatus_Retweeted_Count(statusid, counter)
9500 Private Sub RtCountMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtCountMenuItem.Click
9501 If Me.ExistCurrentPost Then
9502 Using _info As New FormInfo(Me, My.Resources.RtCountMenuItem_ClickText1, _
9503 AddressOf GetRetweet_DoWork)
9504 Dim retweet_count As Integer = 0
9508 retweet_count = CType(_info.Result, Integer)
9509 If retweet_count < 0 Then
9510 MessageBox.Show(My.Resources.RtCountText2)
9512 MessageBox.Show(retweet_count.ToString + My.Resources.RtCountText1)
9518 Private WithEvents _hookGlobalHotkey As HookGlobalHotkey
9521 _hookGlobalHotkey = New HookGlobalHotkey(Me)
9522 ' この呼び出しは、Windows フォーム デザイナで必要です。
9523 InitializeComponent()
9525 ' InitializeComponent() 呼び出しの後で初期化を追加します。
9527 Me._apiGauge.Control.Size = New Size(70, 22)
9528 Me._apiGauge.Control.Margin = New Padding(0, 3, 0, 2)
9529 Me._apiGauge.GaugeHeight = 8
9530 AddHandler Me._apiGauge.Control.DoubleClick, AddressOf Me.ApiInfoMenuItem_Click
9531 Me.StatusStrip1.Items.Insert(2, Me._apiGauge)
9534 Private Sub _hookGlobalHotkey_HotkeyPressed(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _hookGlobalHotkey.HotkeyPressed
9535 If (Me.WindowState = FormWindowState.Normal OrElse Me.WindowState = FormWindowState.Maximized) AndAlso Me.Visible AndAlso Form.ActiveForm Is Me Then
9538 ElseIf Form.ActiveForm Is Nothing Then
9540 If Me.WindowState = FormWindowState.Minimized Then Me.WindowState = FormWindowState.Normal
9542 Me.StatusText.Focus()
9546 Private Sub UserPicture_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.MouseEnter
9547 Me.UserPicture.Cursor = Cursors.Hand
9550 Private Sub UserPicture_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.MouseLeave
9551 Me.UserPicture.Cursor = Cursors.Default
9554 Private Sub UserPicture_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserPicture.DoubleClick
9555 If NameLabel.Tag IsNot Nothing Then
9556 OpenUriAsync("http://twitter.com/" + NameLabel.Tag.ToString)
9560 Private Sub SplitContainer2_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SplitContainer2.MouseDoubleClick
9561 Me.MultiLineMenuItem.PerformClick()
9564 Public ReadOnly Property CurPost As PostClass
9570 Public ReadOnly Property IsPreviewEnable As Boolean
9572 Return SettingDialog.PreviewEnable
9577 Private Sub ImageSelectMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageSelectMenuItem.Click
9578 If ImageSelectionPanel.Visible = True Then
9579 ImagefilePathText.CausesValidation = False
9580 TimelinePanel.Visible = True
9581 TimelinePanel.Enabled = True
9582 ImageSelectionPanel.Visible = False
9583 ImageSelectionPanel.Enabled = False
9584 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9585 ImagefilePathText.CausesValidation = True
9587 ImageSelectionPanel.Visible = True
9588 ImageSelectionPanel.Enabled = True
9589 TimelinePanel.Visible = False
9590 TimelinePanel.Enabled = False
9591 ImagefilePathText.Focus()
9595 Private Sub FilePickButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilePickButton.Click
9596 If String.IsNullOrEmpty(Me.ImageService) Then Exit Sub
9597 OpenFileDialog1.Filter = Me.pictureService(Me.ImageService).GetFileOpenDialogFilter()
9598 OpenFileDialog1.Title = My.Resources.PickPictureDialog1
9599 OpenFileDialog1.FileName = ""
9602 Me.AllowDrop = False
9603 If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub
9608 ImagefilePathText.Text = OpenFileDialog1.FileName
9609 ImageFromSelectedFile()
9612 Private Sub ImagefilePathText_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ImagefilePathText.Validating
9613 If ImageCancelButton.Focused Then
9614 ImagefilePathText.CausesValidation = False
9617 ImagefilePathText.Text = Trim(ImagefilePathText.Text)
9618 If ImagefilePathText.Text = "" Then
9619 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9620 ImageSelectedPicture.Tag = UploadFileType.Invalid
9622 ImageFromSelectedFile()
9626 Private Sub ImageFromSelectedFile()
9628 If String.IsNullOrEmpty(Trim(ImagefilePathText.Text)) OrElse String.IsNullOrEmpty(Me.ImageService) Then
9629 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9630 ImageSelectedPicture.Tag = UploadFileType.Invalid
9631 ImagefilePathText.Text = ""
9635 Dim fl As New FileInfo(Trim(ImagefilePathText.Text))
9636 If Not Me.pictureService(Me.ImageService).CheckValidExtension(fl.Extension) Then
9638 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9639 ImageSelectedPicture.Tag = UploadFileType.Invalid
9640 ImagefilePathText.Text = ""
9644 If Not Me.pictureService(Me.ImageService).CheckValidFilesize(fl.Extension, fl.Length) Then
9646 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9647 ImageSelectedPicture.Tag = UploadFileType.Invalid
9648 ImagefilePathText.Text = ""
9649 MessageBox.Show("File is too large.")
9653 Select Case Me.pictureService(Me.ImageService).GetFileType(fl.Extension)
9654 Case UploadFileType.Invalid
9655 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9656 ImageSelectedPicture.Tag = UploadFileType.Invalid
9657 ImagefilePathText.Text = ""
9658 Case UploadFileType.Picture
9659 Dim img As Image = Nothing
9660 Using fs As New FileStream(ImagefilePathText.Text, FileMode.Open, FileAccess.Read)
9661 img = Image.FromStream(fs)
9664 ImageSelectedPicture.Image = (New HttpVarious).CheckValidImage( _
9668 ImageSelectedPicture.Tag = UploadFileType.Picture
9669 Case UploadFileType.MultiMedia
9670 ImageSelectedPicture.Image = My.Resources.MultiMediaImage
9671 ImageSelectedPicture.Tag = UploadFileType.MultiMedia
9673 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9674 ImageSelectedPicture.Tag = UploadFileType.Invalid
9675 ImagefilePathText.Text = ""
9678 Catch ex As FileNotFoundException
9679 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9680 ImageSelectedPicture.Tag = UploadFileType.Invalid
9681 ImagefilePathText.Text = ""
9682 MessageBox.Show("File not found.")
9683 Catch ex As Exception
9684 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9685 ImageSelectedPicture.Tag = UploadFileType.Invalid
9686 ImagefilePathText.Text = ""
9687 MessageBox.Show("The type of this file is not image.")
9691 Private Sub ImageSelection_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _
9692 ImagefilePathText.KeyDown, _
9693 FilePickButton.KeyDown, _
9694 ImageServiceCombo.KeyDown
9695 If e.KeyCode = Keys.Escape Then
9696 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9697 ImageSelectedPicture.Tag = UploadFileType.Invalid
9698 TimelinePanel.Visible = True
9699 TimelinePanel.Enabled = True
9700 ImageSelectionPanel.Visible = False
9701 ImageSelectionPanel.Enabled = False
9702 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9703 ImagefilePathText.CausesValidation = True
9707 Private Sub ImageSelection_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
9708 ImagefilePathText.KeyPress, _
9709 FilePickButton.KeyPress, _
9710 ImageServiceCombo.KeyPress
9711 If Convert.ToInt32(e.KeyChar) = &H1B Then
9712 ImagefilePathText.CausesValidation = False
9717 Private Sub ImageSelection_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles _
9718 ImagefilePathText.PreviewKeyDown, _
9719 FilePickButton.PreviewKeyDown, _
9720 ImageServiceCombo.PreviewKeyDown
9721 If e.KeyCode = Keys.Escape Then
9722 ImagefilePathText.CausesValidation = False
9726 Private Sub SetImageServiceCombo()
9727 Dim svc As String = ""
9728 If ImageServiceCombo.SelectedIndex > -1 Then svc = ImageServiceCombo.SelectedItem.ToString
9729 ImageServiceCombo.Items.Clear()
9730 If SettingDialog.IsOAuth Then
9731 ImageServiceCombo.Items.Add("TwitPic")
9732 ImageServiceCombo.Items.Add("img.ly")
9733 ImageServiceCombo.Items.Add("yfrog")
9734 ImageServiceCombo.Items.Add("Plixi")
9736 ImageServiceCombo.Items.Add("")
9739 'ImageServiceCombo.Items.Add("TwitVideo")
9741 ImageServiceCombo.SelectedIndex = 0
9743 Dim idx As Integer = ImageServiceCombo.Items.IndexOf(svc)
9745 ImageServiceCombo.SelectedIndex = 0
9747 ImageServiceCombo.SelectedIndex = idx
9752 Private ReadOnly Property ImageService() As String
9754 Return CStr(ImageServiceCombo.SelectedItem)
9758 Private Sub ImageCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageCancelButton.Click
9759 ImagefilePathText.CausesValidation = False
9760 TimelinePanel.Visible = True
9761 TimelinePanel.Enabled = True
9762 ImageSelectionPanel.Visible = False
9763 ImageSelectionPanel.Enabled = False
9764 DirectCast(ListTab.SelectedTab.Tag, DetailsListView).Focus()
9765 ImagefilePathText.CausesValidation = True
9768 Private Sub ImageServiceCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageServiceCombo.SelectedIndexChanged
9769 If ImageSelectedPicture.Tag IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ImageService) Then
9771 Dim fi As New FileInfo(ImagefilePathText.Text.Trim)
9772 If Not Me.pictureService(Me.ImageService).CheckValidFilesize(fi.Extension, fi.Length) Then
9773 ImagefilePathText.Text = ""
9774 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
9775 ImageSelectedPicture.Tag = UploadFileType.Invalid
9777 Catch ex As Exception
9780 _modifySettingCommon = True
9781 SaveConfigsAll(False)
9786 Private Sub ListManageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListManageToolStripMenuItem.Click
9787 Using form As New ListManage(tw)
9792 Public WriteOnly Property ModifySettingCommon() As Boolean
9793 Set(ByVal value As Boolean)
9794 _modifySettingCommon = value
9798 Public WriteOnly Property ModifySettingLocal() As Boolean
9799 Set(ByVal value As Boolean)
9800 _modifySettingLocal = value
9804 Public WriteOnly Property ModifySettingAtId() As Boolean
9805 Set(ByVal value As Boolean)
9806 _modifySettingAtId = value
9810 Private Sub SourceLinkLabel_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles SourceLinkLabel.LinkClicked
9811 Dim link As String = CType(SourceLinkLabel.Tag, String)
9812 If Not String.IsNullOrEmpty(link) Then
9817 Private Sub SourceLinkLabel_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SourceLinkLabel.MouseEnter
9818 Dim link As String = CType(SourceLinkLabel.Tag, String)
9819 If Not String.IsNullOrEmpty(link) Then
9820 StatusLabelUrl.Text = link
9824 Private Sub SourceLinkLabel_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SourceLinkLabel.MouseLeave
9828 Private Sub MenuItemCommand_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemCommand.DropDownOpening
9829 If Me.ExistCurrentPost AndAlso Not _curPost.IsDm Then
9830 RtCountMenuItem.Enabled = True
9832 RtCountMenuItem.Enabled = False
9836 Private Sub CopyUserIdStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyUserIdStripMenuItem.Click
9840 Private Sub CopyUserId()
9841 If _curPost Is Nothing Then Exit Sub
9842 Dim clstr As String = _curPost.ScreenName
9844 Clipboard.SetDataObject(clstr, False, 5, 100)
9845 Catch ex As Exception
9846 MessageBox.Show(ex.Message)
9850 Private Sub ShowRelatedStatusesMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowRelatedStatusesMenuItem.Click, ShowRelatedStatusesMenuItem2.Click
9851 Dim backToTab As TabClass = If(_curTab Is Nothing, _statuses.Tabs(ListTab.SelectedTab.Text), _statuses.Tabs(_curTab.Text))
9852 If Me.ExistCurrentPost AndAlso Not _curPost.IsDm Then
9853 'PublicSearchも除外した方がよい?
9854 If _statuses.GetTabByType(TabUsageType.Related) Is Nothing Then
9855 Const TabName As String = "Related Tweets"
9856 Dim tName As String = TabName
9857 If Not Me.AddNewTab(tName, False, TabUsageType.Related) Then
9858 For i As Integer = 2 To 100
9859 tName = TabName + i.ToString()
9860 If Me.AddNewTab(tName, False, TabUsageType.Related) Then
9861 _statuses.AddTab(tName, TabUsageType.Related, Nothing)
9866 _statuses.AddTab(tName, TabUsageType.Related, Nothing)
9868 _statuses.GetTabByName(tName).UnreadManage = False
9869 _statuses.GetTabByName(tName).Notify = False
9872 Dim tb As TabClass = _statuses.GetTabByType(TabUsageType.Related)
9873 tb.RelationTargetPost = _curPost
9874 Me.ClearTab(tb.TabName, False)
9875 For i As Integer = 0 To ListTab.TabPages.Count - 1
9876 If tb.TabName = ListTab.TabPages(i).Text Then
9877 ListTab.SelectedIndex = i
9878 ListTabSelect(ListTab.TabPages(i))
9883 GetTimeline(WORKERTYPE.Related, 1, 1, tb.TabName)
9887 Private Sub CacheInfoMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CacheInfoMenuItem.Click
9888 Dim buf As New StringBuilder
9889 buf.AppendFormat("キャッシュメモリ容量 : {0}bytes({1}MB)" + vbCrLf, DirectCast(TIconDic, ImageDictionary).CacheMemoryLimit, DirectCast(TIconDic, ImageDictionary).CacheMemoryLimit / 1048576)
9890 buf.AppendFormat("物理メモリ使用割合 : {0}%" + vbCrLf, DirectCast(TIconDic, ImageDictionary).PhysicalMemoryLimit)
9891 buf.AppendFormat("キャッシュエントリ保持数 : {0}" + vbCrLf, DirectCast(TIconDic, ImageDictionary).CacheCount)
9892 buf.AppendFormat("キャッシュエントリ破棄数 : {0}" + vbCrLf, DirectCast(TIconDic, ImageDictionary).CacheRemoveCount)
9893 MessageBox.Show(buf.ToString, "アイコンキャッシュ使用状況")
9896 #Region "Userstream"
9897 Private _isActiveUserstream As Boolean = False
9899 Private Sub tw_PostDeleted(ByVal id As Long)
9901 If InvokeRequired AndAlso Not IsDisposed Then
9903 _statuses.RemovePostReserve(id)
9904 If _curTab IsNot Nothing AndAlso _statuses.Tabs(_curTab.Text).Contains(id) Then
9905 _itemCache = Nothing
9906 _itemCacheIndex = -1
9907 _postCache = Nothing
9908 DirectCast(_curTab.Tag, DetailsListView).Update()
9909 If _curPost.StatusId = id Then DispSelectedPost(True)
9914 Catch ex As ObjectDisposedException
9919 Private Sub tw_NewPostFromStream()
9920 If SettingDialog.ReadOldPosts Then
9921 _statuses.SetRead() '新着時未読クリア
9924 Dim rsltAddCount As Integer = _statuses.DistributePosts()
9925 SyncLock _syncObject
9926 Dim tm As Date = Now
9927 If _tlTimestamps.ContainsKey(tm) Then
9928 _tlTimestamps(tm) += rsltAddCount
9930 _tlTimestamps.Add(Now, rsltAddCount)
9932 Dim oneHour As Date = Now.Subtract(New TimeSpan(1, 0, 0))
9933 Dim keys As New List(Of Date)
9935 For Each key As Date In _tlTimestamps.Keys
9936 If key.CompareTo(oneHour) < 0 Then
9939 _tlCount += _tlTimestamps(key)
9942 For Each key As Date In keys
9943 _tlTimestamps.Remove(key)
9947 'Static before As DateTime = Now
9948 'If before.Subtract(Now).Seconds > -5 Then Exit Sub
9952 If SettingDialog.UserstreamPeriodInt > 0 Then Exit Sub
9955 If InvokeRequired AndAlso Not IsDisposed Then
9956 Invoke(New Action(Of Boolean)(AddressOf RefreshTimeline), True)
9959 Catch ex As ObjectDisposedException
9964 Private Sub tw_UserStreamStarted()
9965 Me._isActiveUserstream = True
9966 If InvokeRequired AndAlso Not IsDisposed Then
9967 Invoke(New MethodInvoker(AddressOf tw_UserStreamStarted))
9971 MenuItemUserStream.Text = "&UserStream ▶"
9972 MenuItemUserStream.Enabled = True
9973 StopToolStripMenuItem.Text = "&Stop"
9974 StopToolStripMenuItem.Enabled = True
9976 StatusLabel.Text = "UserStream Started."
9979 Private Sub tw_UserStreamStopped()
9980 Me._isActiveUserstream = False
9981 If InvokeRequired AndAlso Not IsDisposed Then
9982 Invoke(New MethodInvoker(AddressOf tw_UserStreamStopped))
9986 MenuItemUserStream.Text = "&UserStream ■"
9987 MenuItemUserStream.Enabled = True
9988 StopToolStripMenuItem.Text = "&Start"
9989 StopToolStripMenuItem.Enabled = True
9991 StatusLabel.Text = "UserStream Stopped."
9994 Private Sub tw_UserStreamEventArrived(ByVal ev As Twitter.FormattedEvent)
9995 If InvokeRequired AndAlso Not IsDisposed Then
9996 Invoke(New Action(Of Twitter.FormattedEvent)(AddressOf tw_UserStreamEventArrived), ev)
9999 StatusLabel.Text = "Event: " + ev.Event
10000 'If ev.Event = "favorite" Then
10001 ' NotifyFavorite(ev)
10004 If ev.Event = "favorite" OrElse ev.Event = "unfavorite" Then
10005 If _curTab IsNot Nothing AndAlso _statuses.Tabs(_curTab.Text).Contains(ev.Id) Then
10006 _itemCache = Nothing
10007 _itemCacheIndex = -1
10008 _postCache = Nothing
10009 DirectCast(_curTab.Tag, DetailsListView).Update()
10011 If ev.Event = "unfavorite" AndAlso ev.Username.ToLower.Equals(tw.Username.ToLower) Then
10012 RemovePostFromFavTab(New Int64() {ev.Id})
10017 Private Sub NotifyEvent(ByVal ev As Twitter.FormattedEvent)
10019 If BalloonRequired(ev) Then
10020 NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
10021 If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = ""
10022 NotifyIcon1.BalloonTipTitle += "Tween [" + ev.Event.ToUpper() + "] by " + DirectCast(IIf(Not String.IsNullOrEmpty(ev.Username), ev.Username, ""), String)
10023 If Not String.IsNullOrEmpty(ev.Target) Then
10024 NotifyIcon1.BalloonTipText = ev.Target
10026 NotifyIcon1.BalloonTipText = " "
10028 NotifyIcon1.ShowBalloonTip(500)
10032 Dim snd As String = SettingDialog.EventSoundFile
10033 If Not _initial AndAlso SettingDialog.PlaySound AndAlso snd <> "" Then
10034 If CBool(ev.Eventtype And SettingDialog.EventNotifyFlag) AndAlso IsMyEventNotityAsEventType(ev) Then
10036 Dim dir As String = My.Application.Info.DirectoryPath
10037 If Directory.Exists(Path.Combine(dir, "Sounds")) Then
10038 dir = Path.Combine(dir, "Sounds")
10040 My.Computer.Audio.Play(Path.Combine(dir, snd), AudioPlayMode.Background)
10041 Catch ex As Exception
10048 Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
10049 MenuItemUserStream.Enabled = False
10050 If Me._isActiveUserstream Then
10051 tw.StopUserStream()
10053 tw.StartUserStream()
10057 Private Sub TrackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackToolStripMenuItem.Click
10058 Static inputTrack As String = ""
10059 If TrackToolStripMenuItem.Checked Then
10060 Using inputForm As New InputTabName
10061 inputForm.TabName = inputTrack
10062 inputForm.FormTitle = "Input track word"
10063 inputForm.FormDescription = "Track word"
10064 If inputForm.ShowDialog() <> Windows.Forms.DialogResult.OK Then
10065 TrackToolStripMenuItem.Checked = False
10068 inputTrack = inputForm.TabName.Trim()
10070 If Not inputTrack.Equals(tw.TrackWord) Then
10071 tw.TrackWord = inputTrack
10072 Me._modifySettingCommon = True
10073 TrackToolStripMenuItem.Checked = Not String.IsNullOrEmpty(inputTrack)
10074 tw.ReconnectUserStream()
10078 tw.ReconnectUserStream()
10080 Me._modifySettingCommon = True
10083 Private Sub AllrepliesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllrepliesToolStripMenuItem.Click
10084 tw.AllAtReply = AllrepliesToolStripMenuItem.Checked
10085 Me._modifySettingCommon = True
10086 tw.ReconnectUserStream()
10089 Private Sub EventViewerMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EventViewerMenuItem.Click
10090 If evtDialog Is Nothing OrElse evtDialog.IsDisposed Then
10091 evtDialog = Nothing
10092 evtDialog = New EventViewerDialog
10093 evtDialog.Owner = Me
10095 Dim pos As Point = evtDialog.Location
10096 pos.X = Convert.ToInt32(Me.Location.X + Me.Size.Width / 2 - evtDialog.Size.Width / 2)
10097 pos.Y = Convert.ToInt32(Me.Location.Y + Me.Size.Height / 2 - evtDialog.Size.Height / 2)
10098 evtDialog.Location = pos
10100 evtDialog.EventSource = tw.StoredEvent
10101 If Not evtDialog.Visible Then
10104 evtDialog.Activate()
10106 Me.TopMost = Me.SettingDialog.AlwaysTop
10110 Private Sub TweenRestartMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TweenRestartMenuItem.Click
10114 Application.Restart()
10115 Catch ex As Exception
10116 MessageBox.Show("Failed to restart. Please run Tween manually.")
10120 Private Sub OpenOwnFavedMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenOwnFavedMenuItem.Click
10121 If Not tw.Username = "" Then OpenUriAsync(My.Resources.FavstarUrl + "users/" + tw.Username + "/recent")
10124 Private Sub OpenOwnHomeMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenOwnHomeMenuItem.Click
10125 OpenUriAsync("http://twitter.com/" + tw.Username)
10128 Private Sub doTranslation(ByVal str As String)
10129 Dim g As New Google
10130 Dim buf As String = ""
10131 If String.IsNullOrEmpty(str) Then Exit Sub
10132 Dim srclng As String = g.LanguageDetect(str)
10133 Dim dstlng As String = SettingDialog.TranslateLanguage
10134 Dim msg As String = ""
10135 If srclng <> dstlng AndAlso g.Translate(srclng, dstlng, str, buf, msg) Then
10136 PostBrowser.DocumentText = createDetailHtml(buf)
10138 If msg.StartsWith("Err:") Then
10139 StatusLabel.Text = msg
10144 Private Sub TranslationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TranslationToolStripMenuItem.Click
10145 If Not Me.ExistCurrentPost Then Exit Sub
10146 doTranslation(_curPost.TextFromApi)
10149 Private Sub SelectionTranslationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionTranslationToolStripMenuItem.Click
10150 doTranslation(WebBrowser_GetSelectionText(PostBrowser))
10153 Private ReadOnly Property ExistCurrentPost As Boolean
10155 If _curPost Is Nothing Then Return False
10156 If _curPost.IsDeleted Then Return False
10161 Protected Overrides Sub Finalize()
10165 Private Sub ShowUserTimelineToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShowUserTimelineToolStripMenuItem.Click, ShowUserTimelineContextMenuItem.Click
10169 Private Shared _instance As TweenMain
10171 Public Shared Function GetInstance() As TweenMain
10175 Public ReadOnly Property FavEventChangeUnread As Boolean
10177 Return SettingDialog.FavEventUnread
10181 Private Function GetUserIdFromCurPostOrInput(ByVal caption As String) As String
10182 Dim id As String = ""
10183 If _curPost IsNot Nothing Then
10184 id = _curPost.ScreenName
10186 Using inputName As New InputTabName()
10187 inputName.FormTitle = caption
10188 inputName.FormDescription = My.Resources.FRMessage1
10189 inputName.TabName = id
10190 If inputName.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso _
10191 Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
10192 id = inputName.TabName.Trim
10200 Private Sub UserTimelineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserTimelineToolStripMenuItem.Click
10201 Dim id As String = GetUserIdFromCurPostOrInput("Show UserTimeline")
10202 If Not String.IsNullOrEmpty(id) Then
10203 AddNewTabForUserTimeline(id)
10207 Private Sub UserFavorareToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserFavorareToolStripMenuItem.Click
10208 Dim id As String = GetUserIdFromCurPostOrInput("Show Favstar")
10209 If Not String.IsNullOrEmpty(id) Then
10210 OpenUriAsync(My.Resources.FavstarUrl + "users/" + id + "/recent")
10214 Private Sub SystemEvents_PowerModeChanged(ByVal sender As Object, ByVal e As Microsoft.Win32.PowerModeChangedEventArgs)
10215 If e.Mode = Microsoft.Win32.PowerModes.Resume Then osResumed = True