From 7d2a7d3dc0a08e4ec6800363fa598a061aca8c9f Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Thu, 29 Apr 2021 23:48:16 +0300 Subject: [PATCH] --- LogWriter.cs | 3 +++ MainPlugin.cs | 14 ++++++++++---- Properties/AssemblyInfo.cs | 4 ++-- SettingsPanel.cs | 9 +++++++-- TopWindowMessages.cs | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/LogWriter.cs b/LogWriter.cs index 6a5f8cf..5e51f8c 100644 --- a/LogWriter.cs +++ b/LogWriter.cs @@ -8,7 +8,10 @@ namespace EnderIce2.SDRSharpPlugin public static void WriteToFile(string Message) { if (!SDRSharp.Radio.Utils.GetBooleanSetting("LogRPC", false)) + { return; + } + string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\"; if (!Directory.Exists(path)) { diff --git a/MainPlugin.cs b/MainPlugin.cs index aa4c979..6e9d7f9 100644 --- a/MainPlugin.cs +++ b/MainPlugin.cs @@ -20,9 +20,8 @@ namespace EnderIce2.SDRSharpPlugin bool RPCalreadyLoaded = false; private ISharpControl _control; bool playedBefore = false; - private IConfigurationPanelProvider configurationPanelProvider; private SDRSharp.FrontEnds.SpyServer.ControllerPanel controllerPanel; - public TopWindowMessages windowMessages; + private TopWindowMessages windowMessages; [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "")] private RichPresence presence = new RichPresence() { @@ -37,7 +36,7 @@ namespace EnderIce2.SDRSharpPlugin } }; private static DiscordRpcClient client; - private static bool isRunning = true; + private bool isRunning = true; public string DisplayName { get { return _displayName; } @@ -52,6 +51,8 @@ namespace EnderIce2.SDRSharpPlugin } public void Initialize(ISharpControl control) { + IConfigurationPanelProvider configurationPanelProvider; + if (Utils.GetBooleanSetting("ShowWelcomePage", true)) { new WelcomeForm().ShowDialog(); @@ -63,7 +64,9 @@ namespace EnderIce2.SDRSharpPlugin try { if (Utils.GetBooleanSetting("EnableRPCInvite", false)) + { _control.RegisterFrontControl(windowMessages, PluginPosition.Top); + } } catch (Exception ex) { @@ -139,7 +142,10 @@ namespace EnderIce2.SDRSharpPlugin _ = MainLoop(); } else + { _controlPanel.ChangeStatus = "RPC is disabled"; + } + LogWriter.WriteToFile("EOM Initialize"); } private void Client_OnPresenceUpdate(object sender, PresenceMessage args) @@ -214,7 +220,7 @@ namespace EnderIce2.SDRSharpPlugin { try { - await Task.Delay(2000); + await Task.Delay(2000).ConfigureAwait(false); isRunning = true; LogWriter.WriteToFile($"MainLoop called {isRunning} {client.IsInitialized}"); while (client != null && isRunning) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index e517e45..a23a50f 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SettingsPanel.cs b/SettingsPanel.cs index bbe881d..50761dd 100644 --- a/SettingsPanel.cs +++ b/SettingsPanel.cs @@ -59,7 +59,7 @@ namespace EnderIce2.SDRSharpPlugin Utils.SaveSetting("EnableRPC", checkBox1.Checked); label1.Text = "Restart required"; LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox1.Checked}"); - //Utils.GetBooleanSetting("EnableRPC"); + // TODO: implement Utils.GetBooleanSetting("EnableRPC"); } private void Button1_Click(object sender, EventArgs e) @@ -75,9 +75,14 @@ namespace EnderIce2.SDRSharpPlugin private void TextBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.')) + { e.Handled = true; + } + if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1)) + { e.Handled = true; + } } private async void TextBox1_KeyDown(object sender, KeyEventArgs e) @@ -87,7 +92,7 @@ namespace EnderIce2.SDRSharpPlugin Utils.SaveSetting("ClientID", textBox1.Text); e.Handled = true; e.SuppressKeyPress = true; - await Task.Delay(200); + await Task.Delay(200).ConfigureAwait(false); textBox1.Text = Utils.GetStringSetting("ClientID"); label1.Text = "Saved."; } diff --git a/TopWindowMessages.cs b/TopWindowMessages.cs index b210824..a023232 100644 --- a/TopWindowMessages.cs +++ b/TopWindowMessages.cs @@ -37,7 +37,7 @@ namespace EnderIce2.SDRSharpPlugin { LogWriter.WriteToFile("waiting..."); Application.DoEvents(); - await Task.Delay(200); + await Task.Delay(200).ConfigureAwait(false); } bool tmpansw = AnswerA; LogWriter.WriteToFile($"Client sent an answer. {tmpansw}");