OSDN Git Service

ホットキーで、非アクティブ時はアクティブにするよう変更
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Mon, 13 Sep 2010 08:11:00 +0000 (08:11 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:15:25 +0000 (23:15 +0900)
設定画面のAPI最大値取得がうまく動かない場合があったので修正
STOTコピーの読み上げソフト対応(したつもり)

git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@855 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/ApiInformation.vb
Tween/Setting.vb
Tween/Tween.vb
Tween/Twitter.vb

index cbe092a..726e6dc 100644 (file)
@@ -80,7 +80,7 @@ Public Class ApiInformation
         _RemainCount = arg.ApiInfo.RemainCount
         _ResetTime = arg.ApiInfo.ResetTime
         _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds
-        _UsingCount = arg.ApiInfo.UsingCount
+        '_UsingCount = arg.ApiInfo.UsingCount
     End Sub
 
     Public Property MaxCount As Integer
index 6f68637..c610197 100644 (file)
@@ -1,4 +1,5 @@
 Imports System.ComponentModel
+Imports System.Threading
 
 ' Tween - Client of Twitter
 ' Copyright (c) 2007-2010 kiri_feather (@kiri_feather) <kiri_feather@gmail.com>
@@ -1800,7 +1801,7 @@ Public Class Setting
         CalcApiUsing()
     End Sub
 
-    Private Sub DisplayApiMaxCount(ByVal info As ApiInfo)
+    Private Sub DisplayApiMaxCount()
         If TwitterApiInfo.MaxCount > -1 Then
             LabelApiUsing.Text = String.Format(My.Resources.SettingAPIUse1, TwitterApiInfo.UsingCount, TwitterApiInfo.MaxCount)
         Else
@@ -1851,13 +1852,12 @@ Public Class Setting
         If tw IsNot Nothing Then
             If TwitterApiInfo.MaxCount = -1 Then
                 If Twitter.AccountState = ACCOUNT_STATE.Valid Then
-                    Dim info As New ApiInfo
-                    info.UsingCount = UsingApi
-                    Dim proc As New Action(Of ApiInfo)(Sub(infoCount)
-                                                           tw.GetInfoApi(infoCount) '取得エラー時はinfoCountは初期状態(値:-1)
-                                                           If Me.IsHandleCreated Then Me.Invoke(New Action(Of ApiInfo)(AddressOf DisplayApiMaxCount), infoCount)
-                                                       End Sub)
-                    proc.BeginInvoke(info, Nothing, Nothing)
+                    TwitterApiInfo.UsingCount = UsingApi
+                    Dim proc As New Thread(New Threading.ThreadStart(Sub()
+                                                                         tw.GetInfoApi(Nothing) '取得エラー時はinfoCountは初期状態(値:-1)
+                                                                         If Me.IsHandleCreated Then Invoke(New MethodInvoker(AddressOf DisplayApiMaxCount))
+                                                                     End Sub))
+                    proc.Start()
                 Else
                     LabelApiUsing.Text = String.Format(My.Resources.SettingAPIUse1, UsingApi, "???")
                 End If
@@ -1876,6 +1876,10 @@ Public Class Setting
     End Sub
 
     Private Sub Setting_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
+        Do
+            Thread.Sleep(10)
+            If Me.Disposing OrElse Me.IsDisposed Then Exit Sub
+        Loop Until Me.IsHandleCreated
         CalcApiUsing()
     End Sub
 
index c930654..ab95b2e 100644 (file)
@@ -4627,19 +4627,24 @@ RETRY:
                 sb.AppendFormat("{0}:{1} [http://twitter.com/{0}/status/{2}]{3}", post.Name, post.Data, post.Id, Environment.NewLine)
             End If
         Next
+        If IsProtected Then
+            MessageBox.Show(My.Resources.CopyStotText1)
+        End If
         If sb.Length > 0 Then
             clstr = sb.ToString()
             Try
-                Dim proc As New Action(Of String)(Sub(text)
-                                                      Me.Invoke(New Action(Of String)(AddressOf Clipboard.SetText), text)
-                                                  End Sub)
-                proc.BeginInvoke(clstr, Nothing, Nothing)
+                Clipboard.SetDataObject(clstr, False, 5, 100)
             Catch ex As Exception
                 MessageBox.Show(ex.Message)
             End Try
-        End If
-        If IsProtected Then
-            MessageBox.Show(My.Resources.CopyStotText1)
+            'Try
+            '    Dim proc As New Action(Of String)(Sub(text)
+            '                                          Me.Invoke(New Action(Of String)(AddressOf Clipboard.SetText), text)
+            '                                      End Sub)
+            '    proc.BeginInvoke(clstr, Nothing, Nothing)
+            'Catch ex As Exception
+            '    MessageBox.Show(ex.Message)
+            'End Try
         End If
     End Sub
 
@@ -8528,10 +8533,10 @@ RETRY:
     End Sub
 
     Private Sub _hookGlobalHotkey_HotkeyPressed(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles _hookGlobalHotkey.HotkeyPressed
-        If (Me.WindowState = FormWindowState.Normal OrElse Me.WindowState = FormWindowState.Maximized) AndAlso Me.Visible Then
+        If (Me.WindowState = FormWindowState.Normal OrElse Me.WindowState = FormWindowState.Maximized) AndAlso Me.Visible AndAlso Form.ActiveForm Is Me Then
             'アイコン化
             Me.Visible = False
-        Else
+        ElseIf Form.ActiveForm Is Nothing Then
             Me.Visible = True
             If Me.WindowState = FormWindowState.Minimized Then Me.WindowState = FormWindowState.Normal
             Me.Activate()
index 7f730b6..680c10a 100644 (file)
@@ -2446,12 +2446,14 @@ Public Class Twitter
             arg.ApiInfo.RemainCount = Integer.Parse(xdoc.SelectSingleNode("/hash/remaining-hits").InnerText)
             arg.ApiInfo.ResetTime = DateTime.Parse(xdoc.SelectSingleNode("/hash/reset-time").InnerText)
             arg.ApiInfo.ResetTimeInSeconds = Integer.Parse(xdoc.SelectSingleNode("/hash/reset-time-in-seconds").InnerText)
-            arg.ApiInfo.UsingCount = info.UsingCount
+            If info IsNot Nothing Then
+                arg.ApiInfo.UsingCount = info.UsingCount
 
-            info.MaxCount = arg.ApiInfo.MaxCount
-            info.RemainCount = arg.ApiInfo.RemainCount
-            info.ResetTime = arg.ApiInfo.ResetTime
-            info.ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds
+                info.MaxCount = arg.ApiInfo.MaxCount
+                info.RemainCount = arg.ApiInfo.RemainCount
+                info.ResetTime = arg.ApiInfo.ResetTime
+                info.ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds
+            End If
 
             RaiseEvent ApiInformationChanged(Me, arg)
             TwitterApiInfo.WriteBackEventArgs(arg)