mirror of
https://github.com/EnderIce2/SDR-RPC.git
synced 2025-05-26 03:14:26 +00:00
Removed old code
This commit is contained in:
parent
6969375c2e
commit
94385a30ec
25
LogWriter.cs
25
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}");
|
||||
}
|
||||
}
|
||||
|
146
MainPlugin.cs
146
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";
|
||||
}
|
||||
}
|
73
Properties/Resources.Designer.cs
generated
Normal file
73
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DiscordRPC.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap gear {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("gear", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -117,4 +117,8 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="gear" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
Resources/gear.png
Normal file
BIN
Resources/gear.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
@ -129,34 +129,34 @@
|
||||
<Compile Include="LogWriter.cs" />
|
||||
<Compile Include="MainPlugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SettingsPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SettingsPanel.Designer.cs">
|
||||
<DependentUpon>SettingsPanel.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TopWindowMessages.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TopWindowMessages.Designer.cs">
|
||||
<DependentUpon>TopWindowMessages.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WelcomeForm.cs">
|
||||
<Compile Include="SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WelcomeForm.Designer.cs">
|
||||
<DependentUpon>WelcomeForm.cs</DependentUpon>
|
||||
<Compile Include="SettingsForm.Designer.cs">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SettingsPanel.resx">
|
||||
<DependentUpon>SettingsPanel.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="TopWindowMessages.resx">
|
||||
<DependentUpon>TopWindowMessages.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="WelcomeForm.resx">
|
||||
<DependentUpon>WelcomeForm.cs</DependentUpon>
|
||||
<EmbeddedResource Include="SettingsForm.resx">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -164,6 +164,7 @@
|
||||
<Content Include="Register.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Resources\gear.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include=".editorconfig" />
|
||||
|
10
WelcomeForm.Designer.cs → SettingsForm.Designer.cs
generated
10
WelcomeForm.Designer.cs → SettingsForm.Designer.cs
generated
@ -1,6 +1,6 @@
|
||||
namespace EnderIce2.SDRSharpPlugin
|
||||
{
|
||||
partial class WelcomeForm
|
||||
partial class SettingsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,7 +28,7 @@
|
||||
/// </summary>
|
||||
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();
|
33
SettingsForm.cs
Normal file
33
SettingsForm.cs
Normal file
@ -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
|
||||
// }
|
||||
//}
|
32
SettingsPanel.Designer.cs
generated
32
SettingsPanel.Designer.cs
generated
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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")}";
|
||||
}
|
||||
|
||||
|
108
TopWindowMessages.Designer.cs
generated
108
TopWindowMessages.Designer.cs
generated
@ -1,108 +0,0 @@
|
||||
namespace EnderIce2.SDRSharpPlugin
|
||||
{
|
||||
partial class TopWindowMessages
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<bool> 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";
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user