Private Servicer As New BackgroundWorkerServicer
- Public Sub New(ByVal Message As String, _
+ Public Sub New(ByVal owner As System.Windows.Forms.Form, _
+ ByVal Message As String, _
ByVal DoWork As DoWorkEventHandler)
- doInitialize(Message, DoWork, Nothing, Nothing)
+ doInitialize(owner, Message, DoWork, Nothing, Nothing)
End Sub
- Public Sub New(ByVal Message As String, _
+ Public Sub New(ByVal owner As System.Windows.Forms.Form, _
+ ByVal Message As String, _
ByVal DoWork As DoWorkEventHandler, _
ByVal RunWorkerCompleted As RunWorkerCompletedEventHandler)
- doInitialize(Message, DoWork, RunWorkerCompleted, Nothing)
+ doInitialize(owner, Message, DoWork, RunWorkerCompleted, Nothing)
End Sub
- Public Sub New(ByVal Message As String, _
+ Public Sub New(ByVal owner As System.Windows.Forms.Form, _
+ ByVal Message As String, _
ByVal DoWork As DoWorkEventHandler, _
ByVal RunWorkerCompleted As RunWorkerCompletedEventHandler, _
ByVal Argument As Object)
- doInitialize(Message, DoWork, RunWorkerCompleted, Argument)
+ doInitialize(owner, Message, DoWork, RunWorkerCompleted, Argument)
End Sub
- Private Sub doInitialize(ByVal Message As String, _
- ByVal DoWork As DoWorkEventHandler, _
- ByVal RunWorkerCompleted As RunWorkerCompletedEventHandler, _
- ByVal Argument As Object)
+ Private Sub doInitialize(ByVal owner As System.Windows.Forms.Form, _
+ ByVal Message As String, _
+ ByVal DoWork As DoWorkEventHandler, _
+ ByVal RunWorkerCompleted As RunWorkerCompletedEventHandler, _
+ ByVal Argument As Object)
' この呼び出しはデザイナーで必要です。
InitializeComponent()
' InitializeComponent() 呼び出しの後で初期化を追加します。
+ Me.Owner = owner
Me.InfoMessage = Message
AddHandler Me.Servicer.DoWork, DoWork
Thread.Sleep(100)
My.Application.DoEvents()
End While
+ Me.TopMost = False ' MessageBoxが裏に隠れる問題に対応
Me.Close()
End Sub
+ ' フォームを閉じたあとに親フォームが最前面にならない問題に対応
+
+ Private Sub FormInfo_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
+ Owner.TopMost = Not Owner.TopMost
+ Owner.TopMost = Not Owner.TopMost
+ End Sub
End Class
End Sub
Private Sub RefreshLists()
- Using dlg As New FormInfo("Getting Lists...", AddressOf RefreshLists_DoWork)
+ Using dlg As New FormInfo(Me, "Getting Lists...", AddressOf RefreshLists_DoWork)
dlg.ShowDialog()
If Not String.IsNullOrEmpty(DirectCast(dlg.Result, String)) Then
MessageBox.Show("Failed to get lists. (" + DirectCast(dlg.Result, String) + ")")
End Sub
Private Sub RefreshLists()
- Using dlg As New FormInfo(My.Resources.ListsGetting, AddressOf RefreshLists_Dowork)
+ Using dlg As New FormInfo(Me, My.Resources.ListsGetting, AddressOf RefreshLists_Dowork)
dlg.ShowDialog()
If Not String.IsNullOrEmpty(DirectCast(dlg.Result, String)) Then
MessageBox.Show(String.Format(My.Resources.ListsDeleteFailed, DirectCast(dlg.Result, String)))
'
'ShowUserInfo
'
+ Me.AllowDrop = True
resources.ApplyResources(Me, "$this")
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.CancelButton = Me.ButtonClose
<metadata name="ContextMenuUserPicture.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>697, 15</value>
</metadata>
- <data name="ChangeIconToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
- <value>139, 22</value>
- </data>
- <data name="ChangeIconToolStripMenuItem.Text" xml:space="preserve">
- <value>アイコンの変更</value>
- </data>
<data name="ContextMenuUserPicture.Size" type="System.Drawing.Size, System.Drawing">
<value>140, 26</value>
</data>
<data name=">>UserPicture.ZOrder" xml:space="preserve">
<value>15</value>
</data>
+ <data name="ChangeIconToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
+ <value>139, 22</value>
+ </data>
+ <data name="ChangeIconToolStripMenuItem.Text" xml:space="preserve">
+ <value>アイコンの変更</value>
+ </data>
<metadata name="BackgroundWorkerImageLoader.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ContextMenuRecentPostBrowser.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>326, 17</value>
</metadata>
+ <data name="ContextMenuRecentPostBrowser.Size" type="System.Drawing.Size, System.Drawing">
+ <value>167, 48</value>
+ </data>
+ <data name=">>ContextMenuRecentPostBrowser.Name" xml:space="preserve">
+ <value>ContextMenuRecentPostBrowser</value>
+ </data>
+ <data name=">>ContextMenuRecentPostBrowser.Type" xml:space="preserve">
+ <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
<data name="SelectionCopyToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>166, 22</value>
</data>
<data name="SelectAllToolStripMenuItem.Text" xml:space="preserve">
<value>すべて選択</value>
</data>
- <data name="ContextMenuRecentPostBrowser.Size" type="System.Drawing.Size, System.Drawing">
- <value>167, 48</value>
- </data>
- <data name=">>ContextMenuRecentPostBrowser.Name" xml:space="preserve">
- <value>ContextMenuRecentPostBrowser</value>
- </data>
- <data name=">>ContextMenuRecentPostBrowser.Type" xml:space="preserve">
- <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </data>
<data name="LabelRecentPost.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
Imports System.Web
Imports System.Text.RegularExpressions
Imports System.ComponentModel
+Imports System.IO
Public Class ShowUserInfo
arg.location = TextBoxLocation.Text
arg.description = TextBoxDescription.Text
- Using dlg As New FormInfo(My.Resources.UserInfoButtonEdit_ClickText2, _
+ Using dlg As New FormInfo(Me, My.Resources.UserInfoButtonEdit_ClickText2, _
AddressOf UpdateProfile_Dowork, _
Nothing, _
arg)
e.Result = arg.tw.PostUpdateProfileImage(arg.FileName)
End Sub
-#Region "変更後アイコン取得(Twitterの仕様により正常動作しない)"
Private Sub UpdateProfileImage_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
Dim res As String = ""
Dim xdocbuf As String = ""
End Try
End Sub
-#End Region
-
- Private Sub ChangeIconToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeIconToolStripMenuItem.Click
- OpenFileDialogIcon.Filter = My.Resources.ChangeIconToolStripMenuItem_ClickText1
- OpenFileDialogIcon.Title = My.Resources.ChangeIconToolStripMenuItem_ClickText2
- OpenFileDialogIcon.FileName = ""
-
- Dim rslt As Windows.Forms.DialogResult = OpenFileDialogIcon.ShowDialog
-
- If rslt <> Windows.Forms.DialogResult.OK Then
- Exit Sub
- End If
+ Private Sub doChangeIcon(ByVal filename As String)
Dim res As String = ""
- Dim arg As New UpdateProfileImageArgs With {.tw = MyOwner.TwitterInstance, .FileName = OpenFileDialogIcon.FileName}
+ Dim arg As New UpdateProfileImageArgs With {.tw = MyOwner.TwitterInstance, .FileName = filename}
- Using dlg As New FormInfo(My.Resources.ChangeIconToolStripMenuItem_ClickText3, _
+ Using dlg As New FormInfo(Me, My.Resources.ChangeIconToolStripMenuItem_ClickText3, _
AddressOf UpdateProfileImage_Dowork, _
AddressOf UpdateProfileImage_RunWorkerCompleted,
arg)
MessageBox.Show(My.Resources.ChangeIconToolStripMenuItem_ClickText5)
End If
End Using
+ End Sub
+
+
+ Private Sub ChangeIconToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeIconToolStripMenuItem.Click
+ OpenFileDialogIcon.Filter = My.Resources.ChangeIconToolStripMenuItem_ClickText1
+ OpenFileDialogIcon.Title = My.Resources.ChangeIconToolStripMenuItem_ClickText2
+ OpenFileDialogIcon.FileName = ""
+
+ Dim rslt As Windows.Forms.DialogResult = OpenFileDialogIcon.ShowDialog
+ If rslt <> Windows.Forms.DialogResult.OK Then
+ Exit Sub
+ End If
+
+ If isValidIconFile(New FileInfo(OpenFileDialogIcon.FileName)) Then
+ doChangeIcon(OpenFileDialogIcon.FileName)
+ Else
+ MessageBox.Show("ユーザーアイコンとして使用できないファイルです")
+ End If
End Sub
Private Sub ButtonBlock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBlock.Click
End If
End If
End Sub
+
+ Private Function isValidExtension(ByVal ext As String) As Boolean
+ Return ext.Equals(".jpg") OrElse ext.Equals(".jpeg") OrElse ext.Equals(".png") OrElse ext.Equals(".gif")
+ End Function
+
+ Private Function isValidIconFile(ByVal info As FileInfo) As Boolean
+ Dim ext As String = info.Extension.ToLower
+ Return isValidExtension(ext) AndAlso info.Length < 700 * 1024
+ End Function
+
+ Private Sub ShowUserInfo_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragOver
+ If e.Data.GetDataPresent(DataFormats.FileDrop) Then
+ Dim filename As String = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
+ Dim fl As New FileInfo(filename)
+
+ e.Effect = DragDropEffects.None
+ If isValidIconFile(fl) Then
+ e.Effect = DragDropEffects.Copy
+ End If
+ Else
+ e.Effect = DragDropEffects.None
+ End If
+ End Sub
+
+ Private Sub ShowUserInfo_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
+ If e.Data.GetDataPresent(DataFormats.FileDrop) Then
+ Dim filename As String = CType(e.Data.GetData(DataFormats.FileDrop, False), String())(0)
+ doChangeIcon(filename)
+ End If
+ End Sub
End Class
\ No newline at end of file
Dim tmp As String
Dim args As New GetApiInfoArgs With {.tw = tw, .info = info}
- Using dlg As New FormInfo(My.Resources.ApiInfo6, AddressOf GetApiInfo_Dowork, Nothing, args)
+ Using dlg As New FormInfo(Me, My.Resources.ApiInfo6, AddressOf GetApiInfo_Dowork, Nothing, args)
dlg.ShowDialog()
If CBool(dlg.Result) Then
tmp = My.Resources.ApiInfo1 + args.info.MaxCount.ToString() + Environment.NewLine + _
Dim arg As New FollowRemoveCommandArgs
arg.tw = tw
arg.id = inputName.TabName.Trim()
- Using _info As New FormInfo(My.Resources.FollowCommandText1, _
+ Using _info As New FormInfo(Me, My.Resources.FollowCommandText1, _
AddressOf FollowCommand_DoWork, _
Nothing, _
arg)
End Using
End If
- Using _info As New FormInfo(My.Resources.RemoveCommandText1, _
+ Using _info As New FormInfo(Me, My.Resources.RemoveCommandText1, _
AddressOf RemoveCommand_DoWork, _
Nothing, _
arg)
Not String.IsNullOrEmpty(inputName.TabName.Trim()) Then
Dim ret As String = ""
args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(inputName.TabName.Trim))
- Using _info As New FormInfo(My.Resources.ShowFriendshipText1, _
+ Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
AddressOf ShowFriendship_DoWork, _
Nothing, _
args)
Dim args As New ShowFriendshipArgs
args.tw = tw
args.ids.Add(New ShowFriendshipArgs.FriendshipInfo(id.Trim))
- Using _info As New FormInfo(My.Resources.ShowFriendshipText1, _
+ Using _info As New FormInfo(Me, My.Resources.ShowFriendshipText1, _
AddressOf ShowFriendship_DoWork, _
Nothing, _
args)
args.tw = tw
args.id = id
args.xmlbuf = xmlbuf
- Using _info As New FormInfo(My.Resources.doShowUserStatusText1, _
+ Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
AddressOf GetUserInfo_DoWork, _
Nothing, _
args)
args.tw = tw
args.id = id
args.xmlbuf = xmlbuf
- Using _info As New FormInfo(My.Resources.doShowUserStatusText1, _
+ Using _info As New FormInfo(Me, My.Resources.doShowUserStatusText1, _
AddressOf GetUserInfo_DoWork, _
Nothing, _
args)
Private Sub RtCountMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtCountMenuItem.Click
If _curPost IsNot Nothing Then
- Using _info As New FormInfo(My.Resources.RtCountMenuItem_ClickText1, _
+ Using _info As New FormInfo(Me, My.Resources.RtCountMenuItem_ClickText1, _
AddressOf GetRetweet_DoWork)
Dim retweet_count As Integer = 0