25 Commits

Author SHA1 Message Date
d303158d1c Changes in interface and how plugin works 2021-06-27 00:00:05 +03:00
94385a30ec Removed old code 2021-06-26 23:18:51 +03:00
6969375c2e Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-06-25 00:58:48 +03:00
2566a97b73 Change Version to 1.0.0.2 2021-06-25 00:58:40 +03:00
f1bd9120d8 Update README.md 2021-06-25 00:39:44 +03:00
06e389b035 Small patch 2021-06-25 00:38:07 +03:00
d7997418c0 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-06-25 00:09:41 +03:00
235e13e948 Removed useless code 2021-06-25 00:09:20 +03:00
805f8c408b Update README.md 2021-06-08 17:33:45 +03:00
f4845c49e0 Small code improvement 2021-05-21 20:17:35 +03:00
da9b48cf7c Quality 2021-05-13 23:09:25 +03:00
0c4311a936 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-05-13 22:55:22 +03:00
29b9b5a6cf Rollback Newtonsoft.Json 2021-05-13 22:55:07 +03:00
c478046c18 Delete .github/workflows directory 2021-05-13 22:51:18 +03:00
c9dadfb41c Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-05-13 22:48:21 +03:00
9cbd7dd67e Update Newtonsoft.Json 2021-05-13 22:47:54 +03:00
a441168176 Cleaning Code 2021-05-13 22:45:50 +03:00
3b8ede239b Create codeql-analysis.yml 2021-05-13 22:34:11 +03:00
ede61b75ed Update README.md 2021-05-13 22:31:34 +03:00
0cc81d35e2 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-05-13 22:08:10 +03:00
e120cb0795 2021-05-13 22:07:50 +03:00
9864925bcd Update README.md 2021-05-13 21:30:13 +03:00
ad3a91d314 UI Update 2021-05-10 14:24:34 +03:00
bf44bd1076 Updated for SDRSharp 1811 2021-05-10 13:22:46 +03:00
0b51536839 2021-05-05 08:44:07 +03:00
19 changed files with 455 additions and 755 deletions

View File

@ -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);
using StreamWriter sw = File.AppendText(AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\DiscordRPCLog_" + DateTime.Now.Date.ToShortDateString().Replace('/', '_') + ".log");
sw.WriteLine($"[{DateTime.Now}] {Message}");
}
}

View File

@ -12,18 +12,20 @@ namespace EnderIce2.SDRSharpPlugin
{
public class MainPlugin : ISharpPlugin
{
private const string _displayName = "Discord RPC";
private SettingsPanel _controlPanel;
private const LogLevel logLevel = LogLevel.Trace;
private const int discordPipe = -1;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
bool RPCalreadyLoaded = false;
private ISharpControl _control;
bool playedBefore = false;
private SDRSharp.FrontEnds.SpyServer.ControllerPanel controllerPanel;
private TopWindowMessages windowMessages;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
private RichPresence presence = new RichPresence()
private bool playedBefore;
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()
{
Details = "Loading...",
State = "Loading...",
@ -32,78 +34,24 @@ 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 string DisplayName => _displayName;
public bool HasGui => true;
public UserControl Gui => _controlPanel;
public void Initialize(ISharpControl control)
{
IConfigurationPanelProvider configurationPanelProvider;
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;
try
{
if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
_control.RegisterFrontControl(windowMessages, PluginPosition.Top);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
presence.Secrets = new Secrets()
{
JoinSecret = "invalid_secret"
};
presence.Party = new Party()
{
ID = Secrets.CreateFriendlySecret(new Random()),
Size = 1,
Max = 100
};
}
if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
windowMessages.Show();
}
if (Utils.GetBooleanSetting("EnableRPC", true))
{
if (RPCalreadyLoaded)
{
_controlPanel.ChangeStatus = "Restart required";
return;
}
if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18)
{
client = new DiscordRpcClient("765213507321856078", pipe: discordPipe)
{
Logger = new ConsoleLogger(logLevel, true)
};
Utils.SaveSetting("ClientID", "765213507321856078");
}
else
{
client = new DiscordRpcClient(Utils.GetStringSetting("ClientID"), pipe: discordPipe)
{
Logger = new ConsoleLogger(logLevel, true)
};
}
client.RegisterUriScheme();
client.OnRpcMessage += Client_OnRpcMessage;
@ -113,32 +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
};
if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
client.SetSubscription(EventType.Join | EventType.JoinRequest);
}
client.SetPresence(presence);
client.Initialize();
try
{
configurationPanelProvider = (IConfigurationPanelProvider)_control.Source;
controllerPanel = (SDRSharp.FrontEnds.SpyServer.ControllerPanel)configurationPanelProvider.Gui;
}
catch (Exception ex)
{
LogWriter.WriteToFile("----> " + ex);
MessageBox.Show($"Cannot get Spy Server Network address\n\nError:\n{ex}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
_ = MainLoop();
}
else
@ -147,76 +75,10 @@ namespace EnderIce2.SDRSharpPlugin
}
LogWriter.WriteToFile("EOM Initialize");
}
private void Client_OnPresenceUpdate(object sender, PresenceMessage args)
{
LogWriter.WriteToFile($"[RpcMessage] | Presence state: {args.Presence.State}");
}
private void Client_OnRpcMessage(object sender, IMessage msg)
{
LogWriter.WriteToFile($"[RpcMessage] | {msg.Type} | {msg}");
}
private void OnConnectionFailed(object sender, ConnectionFailedMessage args)
{
_controlPanel.ChangeStatus = $"RPC Connection Failed!\n{args.Type} | {args.FailedPipe}";
}
private void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args)
{
_controlPanel.ChangeStatus = "RPC Connection Established!";
}
private void OnError(object sender, ErrorMessage args)
{
_controlPanel.ChangeStatus = $"RPC Error:\n{args.Message}";
windowMessages.ChangeLabel = "SDR# RPC | Internal error";
}
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 OnSubscribe(object sender, SubscribeMessage args)
{
_controlPanel.ChangeStatus = $"Subscribed: {args.Event}";
}
private void OnUnsubscribe(object sender, UnsubscribeMessage args)
{
_controlPanel.ChangeStatus = $"Unsubscribed: {args.Event}";
}
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());
}
}
async Task MainLoop()
private async Task MainLoop()
{
loop_start:
try
{
await Task.Delay(2000).ConfigureAwait(false);
@ -224,22 +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
{
string sdr_url = "sdr://" + controllerPanel.Host + ":" + controllerPanel.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)
@ -261,29 +109,27 @@ 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.Details = $"Frequency: {$"{_control.Frequency:#,0,,0 Hz}"}";
if (!string.IsNullOrWhiteSpace(_control.RdsRadioText + _control.RdsProgramService))
{
presence.State = $"RDS: unknown{space_for_listen_list}";
string radio_text = string.IsNullOrWhiteSpace(_control.RdsRadioText) ? "" : $" - {_control.RdsRadioText}";
presence.State = _control.FmStereo
? $"RDS: ((( {_control.RdsProgramService} ))){radio_text}"
: $"RDS: {_control.RdsProgramService}{radio_text}";
}
else
{
presence.State = $"RDS: {_control.RdsProgramService} - {_control.RdsRadioText}{space_for_listen_list}";
presence.State = $"RDS: unknown";
}
}
catch (Exception ex)
{
LogWriter.WriteToFile(ex.ToString());
}
/* presence.Secrets.JoinSecret = */
/* _control.RegisterFrontControl(Gui, PluginPosition.Top); */
}
try
{
@ -315,18 +161,36 @@ 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());
}
}
public void Close()
{
LogWriter.WriteToFile("Close called");
isRunning = false;
client.Dispose();
}
private void Client_OnPresenceUpdate(object sender, PresenceMessage args) => LogWriter.WriteToFile($"[RpcMessage] | Presence state: {args.Presence.State}");
private void Client_OnRpcMessage(object sender, IMessage msg) => LogWriter.WriteToFile($"[RpcMessage] | {msg.Type} | {msg}");
private void OnConnectionFailed(object sender, ConnectionFailedMessage args) => _controlPanel.ChangeStatus = $"RPC Connection Failed!\n{args.Type} | {args.FailedPipe}";
private void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args) => _controlPanel.ChangeStatus = "RPC Connection Established!";
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";
Close();
}
private void OnReady(object sender, ReadyMessage args) => _controlPanel.ChangeStatus = "RPC Ready";
}
}

View File

@ -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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

73
Properties/Resources.Designer.cs generated Normal file
View 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));
}
}
}
}

View File

@ -117,44 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="richTextBox1.Text" xml:space="preserve">
<value>-----------------------------------------------------------------------------------
URL for discord-rpc-csharp: https://github.com/Lachee/discord-rpc-csharp
License for discord-rpc-csharp:
MIT License
Copyright (c) 2018 Lachee
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----------------------------------------------------------------------------------
URL for Newtonsoft.Json: https://github.com/JamesNK/Newtonsoft.Json
License for Newtonsoft.Json:
The MIT License (MIT)
Copyright (c) 2007 James Newton-King
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DE</value>
<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>

View File

@ -3,7 +3,7 @@
![GitHub release (latest by date)](https://img.shields.io/github/v/release/EnderIce2/SDR-RPC)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/800cd7ade7ab4aa386f79b5c999a2959)](https://app.codacy.com/gh/EnderIce2/SDR-RPC?utm_source=github.com&utm_medium=referral&utm_content=EnderIce2/SDR-RPC&utm_campaign=Badge_Grade_Settings)
[![CodeFactor](https://www.codefactor.io/repository/github/enderice2/sdr-rpc/badge?s=6ea1f91b515716a019633ad07f7d3138bc136f22)](https://www.codefactor.io/repository/github/enderice2/sdr-rpc)
![Twitter Follow](https://img.shields.io/twitter/follow/enderice22?style=social)
[![Twitter Follow](https://img.shields.io/twitter/follow/enderice22?style=social)](https://twitter.com/intent/follow?screen_name=enderice22)
# SDR-RPC
SDR-RPC is an [SDRSharp](https://airspy.com/download/) plugin that adds Discord RPC feature in it
@ -41,8 +41,7 @@ SDR-RPC is an [SDRSharp](https://airspy.com/download/) plugin that adds Discord
1. You need to download this stuff before compiling:
- [Visual Studio 2019](https://visualstudio.microsoft.com/vs/)
- [.NET 4.6](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net46-developer-pack-offline-installer)
- SDRSharp files (for References)
- SDRSharp.exe
- [SDRSharp Plugin SDK](https://airspy.com/?ddownload=5944)
- SDRSharp.Common.dll
- SDRSharp.PanView.dll
- SDRSharp.Radio.dll
@ -82,5 +81,4 @@ SDR-RPC is an [SDRSharp](https://airspy.com/download/) plugin that adds Discord
### 📕TODO List
- Invite people to get Spy Server Address or connecting via voice chat system to listen and having the ability to change the frequency
- Change Settings Panel to WPF User Control
- Add better RDS decoder (if it is even possible)
- Change Settings Panel to match SDR# theme

BIN
Resources/gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -43,12 +43,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="SDRSharp, Version=1.0.0.1765, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Downloads\sdrsharp-x86\SDRSharp.exe</HintPath>
<HintPath>packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SDRSharp.Common, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
@ -65,6 +60,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -133,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>
@ -168,9 +164,11 @@
<Content Include="Register.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Resources\gear.png" />
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

188
SettingsForm.Designer.cs generated Normal file
View File

@ -0,0 +1,188 @@
namespace EnderIce2.SDRSharpPlugin
{
partial class SettingsForm
{
/// <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 Windows Form 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.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(200, 126);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "&OK";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.Button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F);
this.label1.Location = new System.Drawing.Point(6, 6);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(241, 24);
this.label1.TabIndex = 3;
this.label1.Text = "DiscordRPC Plugin Settings";
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Location = new System.Drawing.Point(12, 126);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(93, 23);
this.button2.TabIndex = 5;
this.button2.Text = "Support Me";
this.button2.UseVisualStyleBackColor = false;
this.button2.Click += new System.EventHandler(this.Button2_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(12, 105);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(205, 17);
this.checkBox1.TabIndex = 6;
this.checkBox1.Text = "Enable Logging (for debugging)";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged_1);
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.textBox1.Location = new System.Drawing.Point(12, 49);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(263, 21);
this.textBox1.TabIndex = 7;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 33);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(63, 13);
this.label2.TabIndex = 8;
this.label2.Text = "Client ID:";
//
// button3
//
this.button3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button3.Location = new System.Drawing.Point(141, 76);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(64, 23);
this.button3.TabIndex = 9;
this.button3.Text = "Reset";
this.button3.UseVisualStyleBackColor = false;
this.button3.Click += new System.EventHandler(this.Button3_Click);
//
// button4
//
this.button4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button4.Location = new System.Drawing.Point(211, 76);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(64, 23);
this.button4.TabIndex = 10;
this.button4.Text = "Apply";
this.button4.UseVisualStyleBackColor = false;
this.button4.Click += new System.EventHandler(this.Button4_Click);
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button5.Location = new System.Drawing.Point(111, 126);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(83, 23);
this.button5.TabIndex = 11;
this.button5.Text = "Licenses";
this.button5.UseVisualStyleBackColor = false;
this.button5.Click += new System.EventHandler(this.Button5_Click);
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.ClientSize = new System.Drawing.Size(287, 161);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SettingsForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SDRSharp Discord RPC Settings";
this.TopMost = true;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
}
}

63
SettingsForm.cs Normal file
View File

@ -0,0 +1,63 @@
using SDRSharp.Radio;
using System;
using System.Windows.Forms;
namespace EnderIce2.SDRSharpPlugin
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
textBox1.Text = Utils.GetStringSetting("ClientID");
checkBox1.Checked = Utils.GetBooleanSetting("LogRPC", false);
}
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);
private void Button5_Click(object sender, EventArgs e)
{
MessageBox.Show("MIT License\n\nCopyright (c) 2018 Lachee\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.", "discord-rpc-csharp");
MessageBox.Show("The MIT License (MIT)\n\nCopyright(c) 2007 James Newton-King\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "Newtonsoft.Json");
}
private void CheckBox1_CheckedChanged_1(object sender, EventArgs e) => Utils.SaveSetting("LogRPC", checkBox1.Checked);
private void Button4_Click(object sender, EventArgs e)
{
textBox1.Text.Replace(" ", "").Replace("\n", "").Replace("\r", "");
if (!int.TryParse(textBox1.Text, out _) || textBox1.Text.Length != 18)
{
MessageBox.Show("Invalid Client ID!");
}
Utils.SaveSetting("ClientID", textBox1.Text);
label1.Text = $"Configuration Updated.\nNew ID: {Utils.GetStringSetting("ClientID")}";
}
private void Button3_Click(object sender, EventArgs e)
{
Utils.SaveSetting("ClientID", "765213507321856078");
textBox1.Text = "765213507321856078";
}
}
}
//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
// }
//}

View File

@ -30,11 +30,7 @@
{
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
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
@ -43,9 +39,11 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Font = new System.Drawing.Font("Verdana", 7F);
this.checkBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.checkBox1.Location = new System.Drawing.Point(3, 3);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(146, 21);
this.checkBox1.Size = new System.Drawing.Size(153, 21);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "Enable Discord RPC";
this.checkBox1.UseVisualStyleBackColor = true;
@ -56,89 +54,47 @@
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.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label1.Location = new System.Drawing.Point(0, 67);
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, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(196, 70);
this.label1.Size = new System.Drawing.Size(200, 132);
this.label1.TabIndex = 1;
this.label1.Text = "Loading status...";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Location = new System.Drawing.Point(56, 143);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(134, 13);
this.textBox1.TabIndex = 2;
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox1_KeyDown);
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBox1_KeyPress);
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(0, 143);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Client ID:";
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(147, 3);
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(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);
//
// checkBox2
//
this.checkBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.checkBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F);
this.checkBox2.Location = new System.Drawing.Point(3, 25);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(158, 21);
this.checkBox2.TabIndex = 5;
this.checkBox2.Text = "Log RPC (for debugging)";
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("Microsoft Sans Serif", 7.25F);
this.checkBox3.Location = new System.Drawing.Point(3, 43);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(193, 21);
this.checkBox3.TabIndex = 6;
this.checkBox3.Text = "Enable Invite Feature (not tested)";
this.checkBox3.UseVisualStyleBackColor = true;
this.checkBox3.CheckedChanged += new System.EventHandler(this.CheckBox3_CheckedChanged);
//
// SettingsPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.checkBox3);
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.button1);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.checkBox1);
this.Font = new System.Drawing.Font("Verdana", 7F);
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.MinimumSize = new System.Drawing.Size(200, 160);
this.Name = "SettingsPanel";
this.Size = new System.Drawing.Size(196, 163);
this.Size = new System.Drawing.Size(200, 160);
this.Load += new System.EventHandler(this.SettingsPanel_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -146,10 +102,6 @@
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox3;
}
}

View File

@ -10,10 +10,7 @@ namespace EnderIce2.SDRSharpPlugin
private string _ChangeStatus;
public string ChangeStatus
{
get
{
return _ChangeStatus;
}
get => _ChangeStatus;
set
{
_ChangeStatus = value;
@ -24,85 +21,27 @@ namespace EnderIce2.SDRSharpPlugin
public SettingsPanel()
{
InitializeComponent();
textBox1.Text = Utils.GetStringSetting("ClientID");
if (Utils.GetBooleanSetting("EnableRPC", true))
{
checkBox1.Checked = true;
}
else
{
checkBox1.Checked = false;
checkBox1.Checked = Utils.GetBooleanSetting("EnableRPC", true);
LogWriter.WriteToFile("User Control Loaded");
}
if (Utils.GetBooleanSetting("LogRPC", false))
{
checkBox2.Checked = true;
}
else
{
checkBox2.Checked = false;
}
if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
checkBox3.Checked = true;
}
else
{
checkBox3.Checked = false;
}
LogWriter.WriteToFile("SettingsPanel loaded");
}
private void Button1_Click(object sender, EventArgs e) => new SettingsForm().Show();
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
Utils.SaveSetting("EnableRPC", checkBox1.Checked);
label1.Text = "Restart required";
LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox1.Checked}");
/* Utils.GetBooleanSetting("EnableRPC"); */
}
private void Button1_Click(object sender, EventArgs e)
private void SettingsPanel_Load(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/EnderIce2/SDR-RPC");
}
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
Utils.SaveSetting("LogRPC", checkBox2.Checked);
}
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)
{
if (e.KeyCode == Keys.Enter && textBox1.Text.Replace(" ", "").Length == 18)
{
Utils.SaveSetting("ClientID", textBox1.Text);
e.Handled = true;
e.SuppressKeyPress = true;
await Task.Delay(200).ConfigureAwait(false);
textBox1.Text = Utils.GetStringSetting("ClientID");
label1.Text = "Saved.";
}
}
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}");
// can't use bcz System.Drawing.Color is from dotnet core 5
//MainPlugin._control.ThemeForeColor;
//BackColor = MainPlugin._control.ThemePanelColor;
//MainPlugin._control.ThemeBackColor;
BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
ForeColor = System.Drawing.Color.FromArgb(244, 244, 244);
}
}
}

View File

@ -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;
}
}

View File

@ -1,67 +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
{
return _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 Task 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";
}
}
}

135
WelcomeForm.Designer.cs generated
View File

@ -1,135 +0,0 @@
namespace EnderIce2.SDRSharpPlugin
{
partial class WelcomeForm
{
/// <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 Windows Form 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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WelcomeForm));
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.richTextBox1.Cursor = System.Windows.Forms.Cursors.Default;
this.richTextBox1.Location = new System.Drawing.Point(12, 58);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(776, 327);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = resources.GetString("richTextBox1.Text");
//
// button1
//
this.button1.Location = new System.Drawing.Point(713, 415);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "&OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(93, 419);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(160, 17);
this.checkBox1.TabIndex = 2;
this.checkBox1.Text = "Don\'t show me this next time";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F);
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(170, 24);
this.label1.TabIndex = 3;
this.label1.Text = "DiscordRPC Plugin";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 42);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Licenses:";
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 415);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 5;
this.button2.Text = "Support Me";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.Button2_Click);
//
// WelcomeForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button2);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.richTextBox1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(816, 489);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(816, 489);
this.Name = "WelcomeForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Thank you for installing DiscordRPC by EnderIce2";
this.TopMost = true;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2;
}
}

View File

@ -1,29 +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);
}
}
}

11
app.config Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net46" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net46" />
</packages>