diff --git a/LogWriter.cs b/LogWriter.cs index 2cea8e4..e516f91 100644 --- a/LogWriter.cs +++ b/LogWriter.cs @@ -7,25 +7,14 @@ namespace EnderIce2.SDRSharpPlugin { public static void WriteToFile(string Message) { - if (!SDRSharp.Radio.Utils.GetBooleanSetting("LogRPC", false)) + if (SDRSharp.Radio.Utils.GetBooleanSetting("LogRPC", false)) { - return; - } - - string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - string filepath = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\DiscordRPCLog_" + DateTime.Now.Date.ToShortDateString().Replace('/', '_') + ".log"; - if (!File.Exists(filepath)) - { - using StreamWriter sw = File.CreateText(filepath); - sw.WriteLine($"[{DateTime.Now}] {Message}"); - } - else - { - using StreamWriter sw = File.AppendText(filepath); + string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\"; + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + using StreamWriter sw = File.AppendText(AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\DiscordRPCLog_" + DateTime.Now.Date.ToShortDateString().Replace('/', '_') + ".log"); sw.WriteLine($"[{DateTime.Now}] {Message}"); } } diff --git a/MainPlugin.cs b/MainPlugin.cs index ea3538e..617c3c6 100644 --- a/MainPlugin.cs +++ b/MainPlugin.cs @@ -19,7 +19,11 @@ namespace EnderIce2.SDRSharpPlugin private ISharpControl _control; private bool playedBefore; - private TopWindowMessages windowMessages; + private DiscordRpcClient client; + private bool isRunning = true; + public bool HasGui => true; + public string DisplayName => "Discord RPC"; + public UserControl Gui => _controlPanel; private readonly RichPresence presence = new RichPresence() { @@ -30,27 +34,14 @@ namespace EnderIce2.SDRSharpPlugin LargeImageKey = "image_large", LargeImageText = "SDRSharp", SmallImageKey = "image_small", - SmallImageText = $"SDR-RPC plugin v{Assembly.LoadFrom("SDR-RPC.dll").GetName().Version} by EnderIce2" // should show the correct version + SmallImageText = $"SDR-RPC Plugin v{Assembly.LoadFrom("SDR-RPC.dll").GetName().Version}" } }; - private DiscordRpcClient client; - private bool isRunning = true; - public bool HasGui => true; - public string DisplayName => "Discord RPC"; - public UserControl Gui => _controlPanel; - public void Initialize(ISharpControl control) { - if (Utils.GetBooleanSetting("ShowWelcomePage", true)) - { - new WelcomeForm().ShowDialog(); - } - _controlPanel = new SettingsPanel(); - windowMessages = new TopWindowMessages(); // TODO: do something when "EnableRPCInvite" is set to false _control = control; - if (Utils.GetBooleanSetting("EnableRPC", true)) { if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18) @@ -70,40 +61,12 @@ namespace EnderIce2.SDRSharpPlugin client.OnError += OnError; client.OnConnectionEstablished += OnConnectionEstablished; client.OnConnectionFailed += OnConnectionFailed; - client.OnSubscribe += OnSubscribe; - client.OnUnsubscribe += OnUnsubscribe; - client.OnJoin += OnJoin; - client.OnJoinRequested += OnJoinRequested; presence.Timestamps = new Timestamps() { Start = DateTime.UtcNow }; - client.SetPresence(presence); client.Initialize(); - try - { - //if (Utils.GetBooleanSetting("EnableRPCInvite", false)) - //{ - // _control.RegisterFrontControl(windowMessages, PluginPosition.Top); - // presence.Secrets = new Secrets() - // { - // JoinSecret = "invalid_secret" - // }; - // presence.Party = new Party() - // { - // ID = Secrets.CreateFriendlySecret(new Random()), - // Size = 1, - // Max = 100 - // }; - // windowMessages.Show(); - // client.SetSubscription(EventType.Join | EventType.JoinRequest); - //} - } - catch (Exception ex) - { - MessageBox.Show(ex.ToString()); - } _ = MainLoop(); } else @@ -115,6 +78,7 @@ namespace EnderIce2.SDRSharpPlugin private async Task MainLoop() { + loop_start: try { await Task.Delay(2000).ConfigureAwait(false); @@ -122,23 +86,8 @@ namespace EnderIce2.SDRSharpPlugin LogWriter.WriteToFile($"MainLoop called {isRunning} {client.IsInitialized}"); while (client != null && isRunning) { - //if (Utils.GetBooleanSetting("EnableRPCInvite", false)) - //{ - // LogWriter.WriteToFile("Setting secret..."); - // try - // { - // // TODO: Get spy server host + port address - // //string sdr_url = "sdr://" + host + ":" + port + "/"; - // //LogWriter.WriteToFile(sdr_url); - // //presence.Secrets.JoinSecret = sdr_url; - // } - // catch (Exception ex) - // { - // LogWriter.WriteToFile(ex.ToString()); - // } - //} - LogWriter.WriteToFile("Waiting 500ms in loop..."); - await Task.Delay(500).ConfigureAwait(false); + LogWriter.WriteToFile("Waiting 5000ms in loop..."); + await Task.Delay(5000).ConfigureAwait(false); // 5 second delay if (_control.RdsRadioText != null) { if (_control.IsPlaying) @@ -160,36 +109,21 @@ namespace EnderIce2.SDRSharpPlugin { try { - string space_for_listen_list = " | "; - if (!Utils.GetBooleanSetting("EnableRPCInvite", false)) - { - space_for_listen_list = ""; - } - LogWriter.WriteToFile($"Frequency: {_control.Frequency}"); LogWriter.WriteToFile($"RdsRadioText: {_control.RdsRadioText}"); LogWriter.WriteToFile($"RdsProgramService: {_control.RdsProgramService}"); LogWriter.WriteToFile("Setting presence..."); - presence.Details = $"Frequency: {string.Format("{0:#,0,,0 Hz}", _control.Frequency)}"; - if (string.IsNullOrWhiteSpace(_control.RdsRadioText + _control.RdsProgramService)) - { - presence.State = $"RDS: unknown{space_for_listen_list}"; - } - else if (_control.FmStereo) - { - presence.State = $"RDS: ((( {_control.RdsProgramService} ))) - {_control.RdsRadioText}{space_for_listen_list}"; - } - else - { - presence.State = $"RDS: {_control.RdsProgramService} - {_control.RdsRadioText}{space_for_listen_list}"; - } + presence.Details = $"Frequency: {$"{_control.Frequency:#,0,,0 Hz}"}"; + presence.State = string.IsNullOrWhiteSpace(_control.RdsRadioText + _control.RdsProgramService) + ? "RDS: unknown" + : _control.FmStereo + ? $"RDS: ((( {_control.RdsProgramService} ))) - {_control.RdsRadioText}" + : $"RDS: {_control.RdsProgramService} - {_control.RdsRadioText}"; } catch (Exception ex) { LogWriter.WriteToFile(ex.ToString()); } - /* presence.Secrets.JoinSecret = */ - /* _control.RegisterFrontControl(Gui, PluginPosition.Top); */ } try { @@ -221,8 +155,7 @@ namespace EnderIce2.SDRSharpPlugin { if (ex.Message.Contains("The process cannot access the file")) { - _ = MainLoop(); - return; + goto loop_start; } _controlPanel.ChangeStatus = $"RPC Update Error\n{ex.Message}"; LogWriter.WriteToFile(ex.ToString()); @@ -244,57 +177,14 @@ namespace EnderIce2.SDRSharpPlugin private void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args) => _controlPanel.ChangeStatus = "RPC Connection Established!"; - private void OnSubscribe(object sender, SubscribeMessage args) => _controlPanel.ChangeStatus = $"Subscribed: {args.Event}"; - - private void OnUnsubscribe(object sender, UnsubscribeMessage args) => _controlPanel.ChangeStatus = $"Unsubscribed: {args.Event}"; - - private void OnError(object sender, ErrorMessage args) - { - _controlPanel.ChangeStatus = $"RPC Error:\n{args.Message}"; - windowMessages.ChangeLabel = "SDR# RPC | Internal error"; - } + private void OnError(object sender, ErrorMessage args) => _controlPanel.ChangeStatus = $"RPC Error:\n{args.Message}"; private void OnClose(object sender, CloseMessage args) { _controlPanel.ChangeStatus = "RPC Closed"; - windowMessages.ChangeLabel = "SDR# RPC | Closed"; Close(); } - private void OnReady(object sender, ReadyMessage args) - { - _controlPanel.ChangeStatus = "RPC Ready"; - windowMessages.ChangeLabel = "SDR# RPC | Ready"; - } - - private void OnJoin(object sender, JoinMessage args) - { - presence.Party.Size++; - presence.Secrets.JoinSecret = args.Secret; - MessageBox.Show("OnJoin: " + args.Secret); - _control.StopRadio(); - _control.RefreshSource(true); - Utils.SaveSetting("spyserver.uri", args.Secret); - _control.StartRadio(); - } - - private async void OnJoinRequested(object sender, JoinRequestMessage args) - { - try - { - if (await windowMessages.RequestAnswer(client, args)) - { - MessageBox.Show("Accepted RequestAnswer"); - } - else - { - MessageBox.Show("Declined RequestAnswer"); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.ToString()); - } - } + private void OnReady(object sender, ReadyMessage args) => _controlPanel.ChangeStatus = "RPC Ready"; } } \ No newline at end of file diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..adfd7a9 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DiscordRPC.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DiscordRPC.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap gear { + get { + object obj = ResourceManager.GetObject("gear", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/TopWindowMessages.resx b/Properties/Resources.resx similarity index 93% rename from TopWindowMessages.resx rename to Properties/Resources.resx index 1af7de1..4a91add 100644 --- a/TopWindowMessages.resx +++ b/Properties/Resources.resx @@ -117,4 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/gear.png b/Resources/gear.png new file mode 100644 index 0000000..8cc9976 Binary files /dev/null and b/Resources/gear.png differ diff --git a/SDRSharpPlugin.DiscordRPC.csproj b/SDRSharpPlugin.DiscordRPC.csproj index f898f68..6fd8b1b 100644 --- a/SDRSharpPlugin.DiscordRPC.csproj +++ b/SDRSharpPlugin.DiscordRPC.csproj @@ -129,34 +129,34 @@ + + True + True + Resources.resx + UserControl SettingsPanel.cs - - UserControl - - - TopWindowMessages.cs - - + Form - - WelcomeForm.cs + + SettingsForm.cs + + ResXFileCodeGenerator + Resources.Designer.cs + SettingsPanel.cs - - TopWindowMessages.cs - - - WelcomeForm.cs + + SettingsForm.cs @@ -164,6 +164,7 @@ Always + diff --git a/WelcomeForm.Designer.cs b/SettingsForm.Designer.cs similarity index 97% rename from WelcomeForm.Designer.cs rename to SettingsForm.Designer.cs index 88449d6..7509b8a 100644 --- a/WelcomeForm.Designer.cs +++ b/SettingsForm.Designer.cs @@ -1,6 +1,6 @@ namespace EnderIce2.SDRSharpPlugin { - partial class WelcomeForm + partial class SettingsForm { /// /// Required designer variable. @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WelcomeForm)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsForm)); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.button1 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); @@ -104,7 +104,7 @@ this.button2.UseVisualStyleBackColor = false; this.button2.Click += new System.EventHandler(this.Button2_Click); // - // WelcomeForm + // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; @@ -123,11 +123,11 @@ this.MaximumSize = new System.Drawing.Size(816, 489); this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(816, 489); - this.Name = "WelcomeForm"; + this.Name = "SettingsForm"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Thank you for installing DiscordRPC by EnderIce2"; + this.Text = "SDRSharp Discord RPC Settings"; this.TopMost = true; this.ResumeLayout(false); this.PerformLayout(); diff --git a/SettingsForm.cs b/SettingsForm.cs new file mode 100644 index 0000000..fcfc3bf --- /dev/null +++ b/SettingsForm.cs @@ -0,0 +1,33 @@ +using SDRSharp.Radio; +using System; +using System.Windows.Forms; + +namespace EnderIce2.SDRSharpPlugin +{ + public partial class SettingsForm : Form + { + public SettingsForm() => InitializeComponent(); + + private void Button2_Click(object sender, EventArgs e) => System.Diagnostics.Process.Start("https://ko-fi.com/enderice2"); + + private void Button1_Click(object sender, EventArgs e) => Close(); + + private void CheckBox1_CheckedChanged(object sender, EventArgs e) => Utils.SaveSetting("ShowWelcomePage", !checkBox1.Checked); + } +} + + //try + //{ + // System.Diagnostics.Process.Start("https://github.com/EnderIce2/SDR-RPC"); // open the url (on some systems can show "The system cannot find the file specified.") + //} + //catch (System.ComponentModel.Win32Exception) // The system cannot find the file specified. + //{ + // try + // { + // System.Diagnostics.Process.Start("iexplore", "https://github.com/EnderIce2/SDR-RPC"); // open the url with internet explorer + // } + // catch (System.ComponentModel.Win32Exception) // The system cannot find the file specified. + // { + // System.Diagnostics.Process.Start("notepad", "https://github.com/EnderIce2/SDR-RPC"); // if internet explorer is not installed (idk how we can get to that point but whatever), open the link in notepad + // } + //} \ No newline at end of file diff --git a/WelcomeForm.resx b/SettingsForm.resx similarity index 100% rename from WelcomeForm.resx rename to SettingsForm.resx diff --git a/SettingsPanel.Designer.cs b/SettingsPanel.Designer.cs index 58b3d39..32ccb94 100644 --- a/SettingsPanel.Designer.cs +++ b/SettingsPanel.Designer.cs @@ -34,7 +34,6 @@ this.label2 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.checkBox2 = new System.Windows.Forms.CheckBox(); - this.checkBox3 = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // checkBox1 @@ -61,7 +60,7 @@ this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.label1.Font = new System.Drawing.Font("Verdana", 7F); this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244))))); - this.label1.Location = new System.Drawing.Point(0, 67); + this.label1.Location = new System.Drawing.Point(1, 46); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(200, 57); this.label1.TabIndex = 1; @@ -97,14 +96,16 @@ // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackgroundImage = global::DiscordRPC.Properties.Resources.gear; + this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.button1.FlatAppearance.BorderSize = 0; this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button1.Font = new System.Drawing.Font("Verdana", 7F); this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244))))); - this.button1.Location = new System.Drawing.Point(151, 3); + this.button1.Location = new System.Drawing.Point(175, 0); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(46, 23); + this.button1.Size = new System.Drawing.Size(25, 25); this.button1.TabIndex = 4; - this.button1.Text = "Help"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.Button1_Click); // @@ -122,31 +123,11 @@ this.checkBox2.UseVisualStyleBackColor = true; this.checkBox2.CheckedChanged += new System.EventHandler(this.CheckBox2_CheckedChanged); // - // checkBox3 - // - this.checkBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.checkBox3.Font = new System.Drawing.Font("Verdana", 6.5F); - this.checkBox3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244))))); - this.checkBox3.Location = new System.Drawing.Point(3, 43); - this.checkBox3.Name = "checkBox3"; - this.checkBox3.Size = new System.Drawing.Size(197, 21); - this.checkBox3.TabIndex = 6; - this.checkBox3.Text = "Enable Invite Feature (not tested)"; - this.checkBox3.UseVisualStyleBackColor = true; -#if DEBUG - this.checkBox3.Visible = true; -#else - this.checkBox3.Visible = false; -#endif - this.checkBox3.CheckedChanged += new System.EventHandler(this.CheckBox3_CheckedChanged); - // // SettingsPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15))))); - this.Controls.Add(this.checkBox3); this.Controls.Add(this.button1); this.Controls.Add(this.checkBox2); this.Controls.Add(this.label2); @@ -172,6 +153,5 @@ private System.Windows.Forms.Label label2; private System.Windows.Forms.Button button1; private System.Windows.Forms.CheckBox checkBox2; - private System.Windows.Forms.CheckBox checkBox3; } } diff --git a/SettingsPanel.cs b/SettingsPanel.cs index e6f4a3c..6e28198 100644 --- a/SettingsPanel.cs +++ b/SettingsPanel.cs @@ -24,28 +24,10 @@ namespace EnderIce2.SDRSharpPlugin textBox1.Text = Utils.GetStringSetting("ClientID"); checkBox1.Checked = Utils.GetBooleanSetting("EnableRPC", true); checkBox2.Checked = Utils.GetBooleanSetting("LogRPC", false); - checkBox3.Checked = Utils.GetBooleanSetting("EnableRPCInvite", false); LogWriter.WriteToFile("SettingsPanel loaded"); } - private void Button1_Click(object sender, EventArgs e) - { - try - { - System.Diagnostics.Process.Start("https://github.com/EnderIce2/SDR-RPC"); // open the url (on some systems can show "The system cannot find the file specified.") - } - catch (System.ComponentModel.Win32Exception) // The system cannot find the file specified. - { - try - { - System.Diagnostics.Process.Start("iexplore", "https://github.com/EnderIce2/SDR-RPC"); // open the url with internet explorer - } - catch (System.ComponentModel.Win32Exception) // The system cannot find the file specified. - { - System.Diagnostics.Process.Start("notepad", "https://github.com/EnderIce2/SDR-RPC"); // if internet explorer is not installed, open the link in notepad - } - } - } + private void Button1_Click(object sender, EventArgs e) => new SettingsForm().Show(); private void CheckBox1_CheckedChanged(object sender, EventArgs e) { @@ -57,13 +39,6 @@ namespace EnderIce2.SDRSharpPlugin private void CheckBox2_CheckedChanged(object sender, EventArgs e) => Utils.SaveSetting("LogRPC", checkBox2.Checked); - private void CheckBox3_CheckedChanged(object sender, EventArgs e) - { - Utils.SaveSetting("EnableRPCInvite", checkBox3.Checked); - label1.Text = "Restart required"; - LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox3.Checked}"); - } - private async void TextBox1_KeyDown(object sender, KeyEventArgs e) { textBox1.Text.Replace(" ", ""); @@ -82,7 +57,7 @@ namespace EnderIce2.SDRSharpPlugin e.Handled = true; e.SuppressKeyPress = true; await Task.Delay(100).ConfigureAwait(false); - textBox1.Text = Utils.GetStringSetting("ClientID"); + textBox1.Text = Utils.GetStringSetting("ClientID"); // write what we stored, should not trigger keydown event label1.Text = $"Configuration Updated.\nNew ID: {Utils.GetStringSetting("ClientID")}"; } diff --git a/TopWindowMessages.Designer.cs b/TopWindowMessages.Designer.cs deleted file mode 100644 index 3227c16..0000000 --- a/TopWindowMessages.Designer.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace EnderIce2.SDRSharpPlugin -{ - partial class TopWindowMessages - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); - this.button1.FlatAppearance.BorderSize = 0; - this.button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Maroon; - this.button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F); - this.button1.Location = new System.Drawing.Point(629, 4); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 0; - this.button1.Text = "Decline"; - this.button1.UseVisualStyleBackColor = false; - this.button1.Visible = false; - // - // button2 - // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); - this.button2.FlatAppearance.BorderSize = 0; - this.button2.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Green; - this.button2.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0))))); - this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F); - this.button2.Location = new System.Drawing.Point(548, 4); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 1; - this.button2.Text = "Accept"; - this.button2.UseVisualStyleBackColor = false; - this.button2.Visible = false; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label1.AutoEllipsis = true; - this.label1.Location = new System.Drawing.Point(3, 4); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(304, 23); - this.label1.TabIndex = 2; - this.label1.Text = "Loading"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // TopWindowMessages - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60))))); - this.Controls.Add(this.label1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F); - this.MaximumSize = new System.Drawing.Size(9999999, 30); - this.MinimumSize = new System.Drawing.Size(0, 30); - this.Name = "TopWindowMessages"; - this.Size = new System.Drawing.Size(707, 30); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - private System.Windows.Forms.Label label1; - } -} diff --git a/TopWindowMessages.cs b/TopWindowMessages.cs deleted file mode 100644 index 48d432e..0000000 --- a/TopWindowMessages.cs +++ /dev/null @@ -1,61 +0,0 @@ -using DiscordRPC; -using DiscordRPC.Message; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace EnderIce2.SDRSharpPlugin -{ - public partial class TopWindowMessages : UserControl - { - public TopWindowMessages() => InitializeComponent(); - private string _ChangeLabel; - public string ChangeLabel - { - get => _ChangeLabel; - set - { - _ChangeLabel = value; - label1.Text = value; - LogWriter.WriteToFile(value); - } - } - private bool AnswerA; - private bool AnswerD; - public async Task RequestAnswer(DiscordRpcClient client, JoinRequestMessage args) - { - LogWriter.WriteToFile("Incoming RPC request from " + args.User.Username); - button1.Visible = true; - button2.Visible = true; - ChangeLabel = $"SDR# RPC | {args.User.Username} has requested to get Spy Server Network address."; - while (!AnswerA || !AnswerD) // TODO: Rework - { - LogWriter.WriteToFile("waiting..."); - Application.DoEvents(); - await Task.Delay(200).ConfigureAwait(false); - } - bool tmpansw = AnswerA; - LogWriter.WriteToFile($"Client sent an answer. {tmpansw}"); - client.Respond(args, tmpansw); - AnswerA = false; - AnswerD = false; - button1.Visible = false; - button2.Visible = false; - SetDefaultTextInLabel(tmpansw); - return tmpansw; - } - private async void SetDefaultTextInLabel(bool accepted) - { - if (accepted) - { - ChangeLabel = $"SDR# RPC | Request accepted"; - } - else - { - ChangeLabel = $"SDR# RPC | Request declined"; - } - - await Task.Delay(5000).ConfigureAwait(false); - ChangeLabel = $"SDR# RPC | Ready"; - } - } -} \ No newline at end of file diff --git a/WelcomeForm.cs b/WelcomeForm.cs deleted file mode 100644 index 0f1fb98..0000000 --- a/WelcomeForm.cs +++ /dev/null @@ -1,17 +0,0 @@ -using SDRSharp.Radio; -using System; -using System.Windows.Forms; - -namespace EnderIce2.SDRSharpPlugin -{ - public partial class WelcomeForm : Form - { - public WelcomeForm() => InitializeComponent(); - - private void Button2_Click(object sender, EventArgs e) => System.Diagnostics.Process.Start("https://ko-fi.com/enderice2"); - - private void Button1_Click(object sender, EventArgs e) => Close(); - - private void CheckBox1_CheckedChanged(object sender, EventArgs e) => Utils.SaveSetting("ShowWelcomePage", !checkBox1.Checked); - } -} \ No newline at end of file