mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
InputText: Fixed several issues
- Fixed lots of handle leak caused by Threading. Now uses ThreadPool instead of Thread. This change may fix IME issue that cannot input character like Japanese for instance. - Commented out some non-used part. - Removed ref keyword from ScanAndReplace().
This commit is contained in:
parent
533d53e446
commit
71601d7564
@ -2,6 +2,6 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
[assembly: AssemblyCopyright("© 2010 - Peter Souza IV")]
|
[assembly: AssemblyCopyright("© 2010 - Peter Souza IV")]
|
||||||
[assembly: AssemblyVersion("1.4.0.0")]
|
[assembly: AssemblyVersion("1.6.0.0")]
|
||||||
[assembly: AssemblyInformationalVersion(Rainmeter.Version.Informational)]
|
[assembly: AssemblyInformationalVersion(Rainmeter.Version.Informational)]
|
||||||
[assembly: AssemblyProduct("Rainmeter")]
|
[assembly: AssemblyProduct("Rainmeter")]
|
||||||
|
@ -18,7 +18,7 @@ namespace InputText
|
|||||||
"Peter Souza IV",
|
"Peter Souza IV",
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
1.05,
|
1.06,
|
||||||
|
|
||||||
// E-mail
|
// E-mail
|
||||||
"psouza4@gmail.com",
|
"psouza4@gmail.com",
|
||||||
@ -125,13 +125,13 @@ namespace InputText
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The unique instance ID of this request.</param>
|
/// <param name="id">The unique instance ID of this request.</param>
|
||||||
/// <returns>Current value for this meter.</returns>
|
/// <returns>Current value for this meter.</returns>
|
||||||
[DllExport]
|
//[DllExport]
|
||||||
public static double Update2(UInt32 id)
|
//public static double Update2(UInt32 id)
|
||||||
{
|
//{
|
||||||
// Do not modify this member (although you can comment it out). Instead, update
|
// // Do not modify this member (although you can comment it out). Instead, update
|
||||||
// your code in 'PluginCode.cs'.
|
// // your code in 'PluginCode.cs'.
|
||||||
return new YourPlugin().Update2(Plugin, id);
|
// return new YourPlugin().Update2(Plugin, id);
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rainmeter's request for text data from the plugin.
|
/// Rainmeter's request for text data from the plugin.
|
||||||
|
@ -19,10 +19,10 @@ namespace InputText
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Update2(Rainmeter.Settings.InstanceSettings Instance)
|
//public double Update2(Rainmeter.Settings.InstanceSettings Instance)
|
||||||
{
|
//{
|
||||||
return 0.0;
|
// return 0.0;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public string GetString(Rainmeter.Settings.InstanceSettings Instance)
|
public string GetString(Rainmeter.Settings.InstanceSettings Instance)
|
||||||
{
|
{
|
||||||
@ -176,20 +176,20 @@ namespace InputText
|
|||||||
// used. For example:
|
// used. For example:
|
||||||
//
|
//
|
||||||
// DefaultValue="hello there, how are you"
|
// DefaultValue="hello there, how are you"
|
||||||
sLine = ScanAndReplace(sLine, "DefaultValue", ref Overrides);
|
sLine = ScanAndReplace(sLine, "DefaultValue", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "X", ref Overrides);
|
sLine = ScanAndReplace(sLine, "X", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "Y", ref Overrides);
|
sLine = ScanAndReplace(sLine, "Y", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "W", ref Overrides);
|
sLine = ScanAndReplace(sLine, "W", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "H", ref Overrides);
|
sLine = ScanAndReplace(sLine, "H", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "StringStyle", ref Overrides);
|
sLine = ScanAndReplace(sLine, "StringStyle", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "StringAlign", ref Overrides);
|
sLine = ScanAndReplace(sLine, "StringAlign", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "FocusDismiss", ref Overrides);
|
sLine = ScanAndReplace(sLine, "FocusDismiss", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "FontColor", ref Overrides);
|
sLine = ScanAndReplace(sLine, "FontColor", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "FontFace", ref Overrides);
|
sLine = ScanAndReplace(sLine, "FontFace", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "SolidColor", ref Overrides);
|
sLine = ScanAndReplace(sLine, "SolidColor", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "Password", ref Overrides);
|
sLine = ScanAndReplace(sLine, "Password", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "FontSize", ref Overrides);
|
sLine = ScanAndReplace(sLine, "FontSize", Overrides);
|
||||||
sLine = ScanAndReplace(sLine, "TopMost", ref Overrides);
|
sLine = ScanAndReplace(sLine, "TopMost", Overrides);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// Get user input
|
// Get user input
|
||||||
@ -352,7 +352,6 @@ namespace InputText
|
|||||||
{
|
{
|
||||||
input.ShowDialog(new WindowWrapper(Rainmeter.GetConfigWindow(Instance)));
|
input.ShowDialog(new WindowWrapper(Rainmeter.GetConfigWindow(Instance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (input.drBackup != System.Windows.Forms.DialogResult.None)
|
if (input.drBackup != System.Windows.Forms.DialogResult.None)
|
||||||
{
|
{
|
||||||
@ -454,7 +453,7 @@ namespace InputText
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ScanAndReplace() -- searches for a tag and its value, adding it to overrides if found, and then removing it from the input line
|
#region ScanAndReplace() -- searches for a tag and its value, adding it to overrides if found, and then removing it from the input line
|
||||||
private string ScanAndReplace(string sLine, string sTagName, ref Dictionary<string, string> Overrides)
|
private string ScanAndReplace(string sLine, string sTagName, Dictionary<string, string> Overrides)
|
||||||
{
|
{
|
||||||
if (FindTag(sLine, sTagName))
|
if (FindTag(sLine, sTagName))
|
||||||
{
|
{
|
||||||
|
@ -583,104 +583,94 @@ namespace InputText
|
|||||||
|
|
||||||
public UInt32 Update(Rainmeter.Settings Plugin, UInt32 id)
|
public UInt32 Update(Rainmeter.Settings Plugin, UInt32 id)
|
||||||
{
|
{
|
||||||
bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_U_AlreadyRunning", false);
|
//bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_U_AlreadyRunning", false);
|
||||||
if (!bAlreadyRunning)
|
//if (!bAlreadyRunning)
|
||||||
{
|
//{
|
||||||
UpdateThread thread_details = new UpdateThread(Plugin.Instances[id]);
|
// Plugin.Instances[id].SetTempValue("__RMT_U_AlreadyRunning", true);
|
||||||
Thread thread = new Thread(new ThreadStart(thread_details.Go));
|
|
||||||
thread.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
// ThreadPool.QueueUserWorkItem(_instance =>
|
||||||
{
|
// {
|
||||||
return (UInt32)Plugin.Instances[id].GetTempValue("__RMT_U_LastValue", 0);
|
// Rainmeter.Settings.InstanceSettings Instance = (Rainmeter.Settings.InstanceSettings)_instance;
|
||||||
}
|
|
||||||
catch
|
// try
|
||||||
|
// {
|
||||||
|
// Instance.SetTempValue("__RMT_U_LastValue", new PluginCode().Update(Instance));
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in Update(), " + ex.GetType().ToString() + ": " + ex.Message);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Instance.SetTempValue("__RMT_U_AlreadyRunning", false);
|
||||||
|
// }, Plugin.Instances[id]);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// return (UInt32)Plugin.Instances[id].GetTempValue("__RMT_U_LastValue", 0);
|
||||||
|
//}
|
||||||
|
//catch
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UpdateThread
|
//public double Update2(Rainmeter.Settings Plugin, UInt32 id)
|
||||||
{
|
//{
|
||||||
private Rainmeter.Settings.InstanceSettings Instance = null;
|
// bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_U2_AlreadyRunning", false);
|
||||||
|
// if (!bAlreadyRunning)
|
||||||
|
// {
|
||||||
|
// Plugin.Instances[id].SetTempValue("__RMT_U2_AlreadyRunning", true);
|
||||||
|
|
||||||
public UpdateThread(Rainmeter.Settings.InstanceSettings _Instance)
|
// ThreadPool.QueueUserWorkItem(_instance =>
|
||||||
{
|
// {
|
||||||
this.Instance = _Instance;
|
// Rainmeter.Settings.InstanceSettings Instance = (Rainmeter.Settings.InstanceSettings)_instance;
|
||||||
}
|
|
||||||
|
|
||||||
public void Go()
|
// try
|
||||||
{
|
// {
|
||||||
this.Instance.SetTempValue("__RMT_U_AlreadyRunning", true);
|
// Instance.SetTempValue("__RMT_U2_LastValue", new PluginCode().Update2(Instance));
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in Update2(), " + ex.GetType().ToString() + ": " + ex.Message);
|
||||||
|
// }
|
||||||
|
|
||||||
try
|
// Instance.SetTempValue("__RMT_U2_AlreadyRunning", false);
|
||||||
{
|
// }, Plugin.Instances[id]);
|
||||||
this.Instance.SetTempValue("__RMT_U_LastValue", new PluginCode().Update(this.Instance));
|
// }
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in GetString(), " + ex.GetType().ToString() + ": " + ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Instance.SetTempValue("__RMT_U_AlreadyRunning", false);
|
// try
|
||||||
}
|
// {
|
||||||
}
|
// return (double)Plugin.Instances[id].GetTempValue("__RMT_U2_LastValue", 0.0);
|
||||||
|
// }
|
||||||
public double Update2(Rainmeter.Settings Plugin, UInt32 id)
|
// catch
|
||||||
{
|
// {
|
||||||
bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_U2_AlreadyRunning", false);
|
// return 0.0;
|
||||||
if (!bAlreadyRunning)
|
// }
|
||||||
{
|
//}
|
||||||
Update2Thread thread_details = new Update2Thread(Plugin.Instances[id]);
|
|
||||||
Thread thread = new Thread(new ThreadStart(thread_details.Go));
|
|
||||||
thread.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return (double)Plugin.Instances[id].GetTempValue("__RMT_U2_LastValue", 0.0);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Update2Thread
|
|
||||||
{
|
|
||||||
private Rainmeter.Settings.InstanceSettings Instance = null;
|
|
||||||
|
|
||||||
public Update2Thread(Rainmeter.Settings.InstanceSettings _Instance)
|
|
||||||
{
|
|
||||||
this.Instance = _Instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Go()
|
|
||||||
{
|
|
||||||
this.Instance.SetTempValue("__RMT_U2_AlreadyRunning", true);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.Instance.SetTempValue("__RMT_U2_LastValue", new PluginCode().Update2(this.Instance));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in GetString(), " + ex.GetType().ToString() + ": " + ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Instance.SetTempValue("__RMT_U2_AlreadyRunning", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetString(Rainmeter.Settings Plugin, UInt32 id)
|
public string GetString(Rainmeter.Settings Plugin, UInt32 id)
|
||||||
{
|
{
|
||||||
bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_GS_AlreadyRunning", false);
|
bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_GS_AlreadyRunning", false);
|
||||||
if (!bAlreadyRunning)
|
if (!bAlreadyRunning)
|
||||||
{
|
{
|
||||||
GetStringThread thread_details = new GetStringThread(Plugin.Instances[id]);
|
Plugin.Instances[id].SetTempValue("__RMT_GS_AlreadyRunning", true);
|
||||||
Thread thread = new Thread(new ThreadStart(thread_details.Go));
|
|
||||||
thread.Start();
|
ThreadPool.QueueUserWorkItem(_instance =>
|
||||||
|
{
|
||||||
|
Rainmeter.Settings.InstanceSettings Instance = (Rainmeter.Settings.InstanceSettings)_instance;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Instance.SetTempValue("__RMT_GS_LastValue", new PluginCode().GetString(Instance));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in GetString(), " + ex.GetType().ToString() + ": " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance.SetTempValue("__RMT_GS_AlreadyRunning", false);
|
||||||
|
}, Plugin.Instances[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -693,70 +683,43 @@ namespace InputText
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GetStringThread
|
|
||||||
{
|
|
||||||
private Rainmeter.Settings.InstanceSettings Instance = null;
|
|
||||||
|
|
||||||
public GetStringThread(Rainmeter.Settings.InstanceSettings _Instance)
|
|
||||||
{
|
|
||||||
this.Instance = _Instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Go()
|
|
||||||
{
|
|
||||||
this.Instance.SetTempValue("__RMT_GS_AlreadyRunning", true);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.Instance.SetTempValue("__RMT_GS_LastValue", new PluginCode().GetString(this.Instance));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in GetString(), " + ex.GetType().ToString() + ": " + ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Instance.SetTempValue("__RMT_GS_AlreadyRunning", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ExecuteBang(Rainmeter.Settings Plugin, UInt32 id, string sArguments)
|
public void ExecuteBang(Rainmeter.Settings Plugin, UInt32 id, string sArguments)
|
||||||
{
|
{
|
||||||
bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_EB_AlreadyRunning", false);
|
bool bAlreadyRunning = (bool)Plugin.Instances[id].GetTempValue("__RMT_EB_AlreadyRunning", false);
|
||||||
if (!bAlreadyRunning)
|
if (!bAlreadyRunning)
|
||||||
{
|
{
|
||||||
ExecuteBangThread thread_details = new ExecuteBangThread(Plugin.Instances[id], sArguments);
|
Plugin.Instances[id].SetTempValue("__RMT_EB_AlreadyRunning", true);
|
||||||
Thread thread = new Thread(new ThreadStart(thread_details.Go));
|
|
||||||
thread.Start();
|
ThreadPool.QueueUserWorkItem(_param =>
|
||||||
|
{
|
||||||
|
Rainmeter.Settings.InstanceSettings Instance = (Rainmeter.Settings.InstanceSettings)((ExecuteBangParam)_param).Instance;
|
||||||
|
string Command = (string)((ExecuteBangParam)_param).Command;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new PluginCode().ExecuteBang(Instance, Command);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in ExecuteBang(), " + ex.GetType().ToString() + ": " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance.SetTempValue("__RMT_EB_AlreadyRunning", false);
|
||||||
|
}, new ExecuteBangParam(Plugin.Instances[id], sArguments));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteBangThread
|
private class ExecuteBangParam
|
||||||
{
|
{
|
||||||
private Rainmeter.Settings.InstanceSettings Instance = null;
|
public Rainmeter.Settings.InstanceSettings Instance = null;
|
||||||
private string Command = string.Empty;
|
public string Command = string.Empty;
|
||||||
|
|
||||||
public ExecuteBangThread(Rainmeter.Settings.InstanceSettings _Instance, string _Command)
|
public ExecuteBangParam(Rainmeter.Settings.InstanceSettings _Instance, string _Command)
|
||||||
{
|
{
|
||||||
this.Instance = _Instance;
|
this.Instance = _Instance;
|
||||||
this.Command = _Command;
|
this.Command = _Command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Go()
|
|
||||||
{
|
|
||||||
this.Instance.SetTempValue("__RMT_EB_AlreadyRunning", true);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new PluginCode().ExecuteBang(this.Instance, this.Command);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Rainmeter.Log(Rainmeter.LogLevel.Error, "C# plugin in GetString(), " + ex.GetType().ToString() + ": " + ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Instance.SetTempValue("__RMT_EB_AlreadyRunning", false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user