50 Commits

Author SHA1 Message Date
EnderIce2
d303158d1c Changes in interface and how plugin works 2021-06-27 00:00:05 +03:00
EnderIce2
94385a30ec Removed old code 2021-06-26 23:18:51 +03:00
EnderIce2
6969375c2e Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-06-25 00:58:48 +03:00
EnderIce2
2566a97b73 Change Version to 1.0.0.2 2021-06-25 00:58:40 +03:00
Alex
f1bd9120d8 Update README.md 2021-06-25 00:39:44 +03:00
EnderIce2
06e389b035 Small patch 2021-06-25 00:38:07 +03:00
EnderIce2
d7997418c0 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-06-25 00:09:41 +03:00
EnderIce2
235e13e948 Removed useless code 2021-06-25 00:09:20 +03:00
Alex
805f8c408b Update README.md 2021-06-08 17:33:45 +03:00
EnderIce2
f4845c49e0 Small code improvement 2021-05-21 20:17:35 +03:00
EnderIce2
da9b48cf7c Quality 2021-05-13 23:09:25 +03:00
EnderIce2
0c4311a936 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-05-13 22:55:22 +03:00
EnderIce2
29b9b5a6cf Rollback Newtonsoft.Json 2021-05-13 22:55:07 +03:00
Alex
c478046c18 Delete .github/workflows directory 2021-05-13 22:51:18 +03:00
EnderIce2
c9dadfb41c Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-05-13 22:48:21 +03:00
EnderIce2
9cbd7dd67e Update Newtonsoft.Json 2021-05-13 22:47:54 +03:00
EnderIce2
a441168176 Cleaning Code 2021-05-13 22:45:50 +03:00
Alex
3b8ede239b Create codeql-analysis.yml 2021-05-13 22:34:11 +03:00
Alex
ede61b75ed Update README.md 2021-05-13 22:31:34 +03:00
EnderIce2
0cc81d35e2 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-05-13 22:08:10 +03:00
EnderIce2
e120cb0795 2021-05-13 22:07:50 +03:00
Alex
9864925bcd Update README.md 2021-05-13 21:30:13 +03:00
EnderIce2
ad3a91d314 UI Update 2021-05-10 14:24:34 +03:00
EnderIce2
bf44bd1076 Updated for SDRSharp 1811 2021-05-10 13:22:46 +03:00
EnderIce2
0b51536839 2021-05-05 08:44:07 +03:00
EnderIce2
4753a7849b 2021-04-30 02:27:41 +03:00
EnderIce2
4913bb45c4 2021-04-30 01:59:24 +03:00
EnderIce2
a1a66c3dd1 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-04-29 23:53:59 +03:00
EnderIce2
7d2a7d3dc0 2021-04-29 23:48:16 +03:00
Alex
f9fdaa969e Update LICENSE 2021-04-29 23:17:53 +03:00
Alex
e008886fd7 Update README.md 2021-04-28 17:09:12 +03:00
Alex
071c1071df Update README.md 2021-04-28 16:52:34 +03:00
Alex
e0b304b2a2 Merge pull request #1 from codacy-badger/codacy-badge
Add a Codacy badge to README.md
2021-04-28 16:51:06 +03:00
The Codacy Badger
e67214c4b9 Add Codacy badge 2021-04-28 13:48:25 +00:00
EnderIce2
59fda87954 Code Quality 2021-04-23 21:34:39 +03:00
Alex
54c8969d2b Update README.md 2021-04-23 02:37:56 +03:00
Alex
0cd9bb75fc typo 2021-03-09 08:43:13 +02:00
Alex
d8711ff1bc Update README.md 2020-11-11 01:51:50 +02:00
EnderIce2
ab06d0167b Minor tweak 2020-11-05 19:57:53 +02:00
EnderIce2
ad8cd96c55 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2020-10-26 16:11:43 +02:00
EnderIce2
76d8a1e640 Typo 2020-10-26 16:11:20 +02:00
Alex
85d99f1d0c Adding "Plugin Log" 2020-10-26 09:25:20 +02:00
EnderIce2
131fc8dc10 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2020-10-26 08:42:38 +02:00
EnderIce2
f69b5e623b Fixed showing wrong version 2020-10-26 08:42:26 +02:00
Alex
902086f99a Added emojis 2020-10-26 03:18:22 +02:00
Alex
fb8c9e6c93 Update README.md 2020-10-26 03:13:25 +02:00
Alex
03aad884dd Fixing images 2020-10-26 03:12:27 +02:00
Alex
411f606bfc Add files via upload 2020-10-26 03:08:24 +02:00
Alex
0c844e8ee6 Create README.md 2020-10-26 03:08:03 +02:00
Alex
c7cdd07ba0 Update README.md 2020-10-26 03:01:16 +02:00
28 changed files with 563 additions and 728 deletions

View File

@@ -28,5 +28,8 @@ If applicable, add screenshots to help explain your problem.
- Plugin Version [e.g. 1.2] - Plugin Version [e.g. 1.2]
- SDR# Version [e.g. revision 1770 4698f0a] - SDR# Version [e.g. revision 1770 4698f0a]
**Plugin Log**
A copy of \RPCLogs\DiscordRPCLog_XX.XX.XXXX.log on https://pastebin.com or other copy-paste website.
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

1
.github/MEDIA/README.md vendored Normal file
View File

@@ -0,0 +1 @@
# Files for README.md

View File

@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
SDR-RPC | Plugin for SDRSharp Software adding Discord Rich Presence SDR-RPC | Plugin for SDRSharp Software adding Discord Rich Presence
Copyright (C) 2020 Albu Alexandru Gabriel Copyright (C) 2021 Albu Alexandru Gabriel
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode: notice like this when it starts in an interactive mode:
SDR-RPC Copyright (C) 2020 Albu Alexandru Gabriel SDR-RPC Copyright (C) 2021 Albu Alexandru Gabriel
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.

View File

@@ -7,22 +7,14 @@ namespace EnderIce2.SDRSharpPlugin
{ {
public static void WriteToFile(string Message) 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\\"; string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\";
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
string filepath = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\DiscordRPCLog_" + DateTime.Now.Date.ToShortDateString().Replace('/', '_') + ".log"; using StreamWriter sw = File.AppendText(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);
sw.WriteLine($"[{DateTime.Now}] {Message}"); sw.WriteLine($"[{DateTime.Now}] {Message}");
} }
} }

View File

@@ -12,21 +12,20 @@ namespace EnderIce2.SDRSharpPlugin
{ {
public class MainPlugin : ISharpPlugin public class MainPlugin : ISharpPlugin
{ {
private const string _displayName = "Discord RPC";
private SettingsPanel _controlPanel; private SettingsPanel _controlPanel;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")] private const LogLevel logLevel = LogLevel.Trace;
private static LogLevel logLevel = LogLevel.Trace; private const int discordPipe = -1;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
private static int discordPipe = -1;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
bool RPCalreadyLoaded = false;
private ISharpControl _control; private ISharpControl _control;
bool playedBefore = false; private bool playedBefore;
private IConfigurationPanelProvider configurationPanelProvider;
private SDRSharp.FrontEnds.SpyServer.ControllerPanel controllerPanel; private DiscordRpcClient client;
public TopWindowMessages windowMessages; private bool isRunning = true;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")] public bool HasGui => true;
private RichPresence presence = new RichPresence() public string DisplayName => "Discord RPC";
public UserControl Gui => _controlPanel;
private readonly RichPresence presence = new RichPresence()
{ {
Details = "Loading...", Details = "Loading...",
State = "Loading...", State = "Loading...",
@@ -35,71 +34,25 @@ namespace EnderIce2.SDRSharpPlugin
LargeImageKey = "image_large", LargeImageKey = "image_large",
LargeImageText = "SDRSharp", LargeImageText = "SDRSharp",
SmallImageKey = "image_small", SmallImageKey = "image_small",
SmallImageText = $"SDR-RPC plugin v{Assembly.GetEntryAssembly().GetName().Version} by EnderIce2" SmallImageText = $"SDR-RPC Plugin v{Assembly.LoadFrom("SDR-RPC.dll").GetName().Version}"
} }
}; };
private static DiscordRpcClient client;
private static bool isRunning = true;
public string DisplayName
{
get { return _displayName; }
}
public bool HasGui
{
get { return true; }
}
public UserControl Gui
{
get { return _controlPanel; }
}
public void Initialize(ISharpControl control) public void Initialize(ISharpControl control)
{ {
if (Utils.GetBooleanSetting("ShowWelcomePage", true))
new WelcomeForm().ShowDialog();
_controlPanel = new SettingsPanel(); _controlPanel = new SettingsPanel();
windowMessages = new TopWindowMessages(); // TODO: do something when "EnableRPCInvite" is set to false
_control = control; _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 (Utils.GetBooleanSetting("EnableRPC", true))
{ {
if (RPCalreadyLoaded)
{
_controlPanel.ChangeStatus = "Restart required";
return;
}
if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18) 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) client = new DiscordRpcClient(Utils.GetStringSetting("ClientID"), pipe: discordPipe)
{ {
Logger = new ConsoleLogger(logLevel, true) Logger = new ConsoleLogger(logLevel, true)
}; };
client.RegisterUriScheme(); client.RegisterUriScheme();
client.OnRpcMessage += Client_OnRpcMessage; client.OnRpcMessage += Client_OnRpcMessage;
client.OnPresenceUpdate += Client_OnPresenceUpdate; client.OnPresenceUpdate += Client_OnPresenceUpdate;
@@ -108,128 +61,33 @@ namespace EnderIce2.SDRSharpPlugin
client.OnError += OnError; client.OnError += OnError;
client.OnConnectionEstablished += OnConnectionEstablished; client.OnConnectionEstablished += OnConnectionEstablished;
client.OnConnectionFailed += OnConnectionFailed; client.OnConnectionFailed += OnConnectionFailed;
client.OnSubscribe += OnSubscribe;
client.OnUnsubscribe += OnUnsubscribe;
client.OnJoin += OnJoin;
client.OnJoinRequested += OnJoinRequested;
//client.OnSpectate += OnSpectate;
presence.Timestamps = new Timestamps() presence.Timestamps = new Timestamps()
{ {
Start = DateTime.UtcNow Start = DateTime.UtcNow
}; };
if (Utils.GetBooleanSetting("EnableRPCInvite", false))
client.SetSubscription(EventType.Join | EventType.JoinRequest);
client.SetPresence(presence); client.SetPresence(presence);
client.Initialize(); client.Initialize();
try
{
configurationPanelProvider = (IConfigurationPanelProvider)_control.Source;
controllerPanel = (SDRSharp.FrontEnds.SpyServer.ControllerPanel)configurationPanelProvider.Gui;
}
catch (Exception ex)
{
LogWriter.WriteToFile("----> " + ex.ToString());
MessageBox.Show($"Cannot get Spy Server Network address\n\nError:\n{ex}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
_ = MainLoop(); _ = MainLoop();
} }
else else
{
_controlPanel.ChangeStatus = "RPC is disabled"; _controlPanel.ChangeStatus = "RPC is disabled";
}
LogWriter.WriteToFile("EOM Initialize"); LogWriter.WriteToFile("EOM Initialize");
} }
private void Client_OnPresenceUpdate(object sender, PresenceMessage args)
{ private async Task MainLoop()
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)
{ {
loop_start:
try try
{ {
if (await windowMessages.RequestAnswer(client, args)) await Task.Delay(2000).ConfigureAwait(false);
{
MessageBox.Show("Accepted RequestAnswer");
}
else
{
MessageBox.Show("Declined RequestAnswer");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
async Task MainLoop()
{
try
{
await Task.Delay(2000);
isRunning = true; isRunning = true;
LogWriter.WriteToFile($"MainLoop called {isRunning} {client.IsInitialized}"); LogWriter.WriteToFile($"MainLoop called {isRunning} {client.IsInitialized}");
while (client != null && isRunning) while (client != null && isRunning)
{ {
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) LogWriter.WriteToFile("Waiting 5000ms in loop...");
{ await Task.Delay(5000).ConfigureAwait(false); // 5 second delay
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);
if (_control.RdsRadioText != null) if (_control.RdsRadioText != null)
{ {
if (_control.IsPlaying) if (_control.IsPlaying)
@@ -238,7 +96,10 @@ namespace EnderIce2.SDRSharpPlugin
playedBefore = true; playedBefore = true;
} }
else if (!_control.IsPlaying && playedBefore) else if (!_control.IsPlaying && playedBefore)
{
presence.Assets.SmallImageKey = "pause"; presence.Assets.SmallImageKey = "pause";
}
if (!playedBefore) if (!playedBefore)
{ {
presence.Details = "Frequency: Not playing"; presence.Details = "Frequency: Not playing";
@@ -248,25 +109,27 @@ namespace EnderIce2.SDRSharpPlugin
{ {
try try
{ {
string space_for_listen_list = " | ";
if (!Utils.GetBooleanSetting("EnableRPCInvite", false))
space_for_listen_list = "";
LogWriter.WriteToFile($"Frequency: {_control.Frequency}"); LogWriter.WriteToFile($"Frequency: {_control.Frequency}");
LogWriter.WriteToFile($"RdsRadioText: {_control.RdsRadioText}"); LogWriter.WriteToFile($"RdsRadioText: {_control.RdsRadioText}");
LogWriter.WriteToFile($"RdsProgramService: {_control.RdsProgramService}"); LogWriter.WriteToFile($"RdsProgramService: {_control.RdsProgramService}");
LogWriter.WriteToFile("Setting presence..."); LogWriter.WriteToFile("Setting presence...");
presence.Details = $"Frequency: {string.Format("{0:#,0,,0 Hz}", _control.Frequency)}"; presence.Details = $"Frequency: {$"{_control.Frequency:#,0,,0 Hz}"}";
if (string.IsNullOrWhiteSpace(_control.RdsRadioText + _control.RdsProgramService)) 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 else
presence.State = $"RDS: {_control.RdsProgramService} - {_control.RdsRadioText}{space_for_listen_list}"; {
presence.State = $"RDS: unknown";
}
} }
catch (Exception ex) catch (Exception ex)
{ {
LogWriter.WriteToFile(ex.ToString()); LogWriter.WriteToFile(ex.ToString());
} }
/*presence.Secrets.JoinSecret = */
//_control.RegisterFrontControl(Gui, PluginPosition.Top);
} }
try try
{ {
@@ -282,30 +145,52 @@ namespace EnderIce2.SDRSharpPlugin
else else
{ {
LogWriter.WriteToFile("Frequency or Radio Text are null!"); LogWriter.WriteToFile("Frequency or Radio Text are null!");
await Task.Delay(1000); await Task.Delay(1000).ConfigureAwait(false);
} }
} }
if (client == null) if (client == null)
{
_controlPanel.ChangeStatus = "Client was null"; _controlPanel.ChangeStatus = "Client was null";
}
else else
{
_controlPanel.ChangeStatus = "Presence stopped"; _controlPanel.ChangeStatus = "Presence stopped";
} }
}
catch (Exception ex) catch (Exception ex)
{ {
if (ex.Message.Contains("The process cannot access the file")) if (ex.Message.Contains("The process cannot access the file"))
{ {
_ = MainLoop(); goto loop_start;
return;
} }
_controlPanel.ChangeStatus = $"RPC Update Error\n{ex.Message}"; _controlPanel.ChangeStatus = $"RPC Update Error\n{ex.Message}";
LogWriter.WriteToFile(ex.ToString()); LogWriter.WriteToFile(ex.ToString());
} }
} }
public void Close() public void Close()
{ {
LogWriter.WriteToFile("Close called"); LogWriter.WriteToFile("Close called");
isRunning = false; isRunning = false;
client.Dispose(); 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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")] [assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("0.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"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="richTextBox1.Text" xml:space="preserve"> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<value>----------------------------------------------------------------------------------- <data name="gear" type="System.Resources.ResXFileRef, System.Windows.Forms">
URL for discord-rpc-csharp: https://github.com/Lachee/discord-rpc-csharp <value>..\Resources\gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
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>
</data> </data>
</root> </root>

View File

@@ -1 +1,84 @@
![GitHub](https://img.shields.io/github/license/EnderIce2/SDR-RPC)
![GitHub All Releases](https://img.shields.io/github/downloads/EnderIce2/SDR-RPC/total)
![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)](https://twitter.com/intent/follow?screen_name=enderice22)
# SDR-RPC # SDR-RPC
SDR-RPC is an [SDRSharp](https://airspy.com/download/) plugin that adds Discord RPC feature in it
---
### ✨Features
- 🎛Enable / Disable
- ✏Showing frequency, play state and RDS almost in realtime
- 🔌Most of the code is made asynchronous
- 📖Logging for troubleshooting problems
- 🔨Easy to install
- 🎧Invite feature (give Spy Server Address or listen using voice chat system) [coming soon]
---
### 🎁How to install
📽Video:
[![](http://img.youtube.com/vi/Otn-xSn_ioI/0.jpg)](http://www.youtube.com/watch?v=Otn-xSn_ioI "")
---
### 🎫Example
📽Video:
[![](http://img.youtube.com/vi/7k02dPqAjBA/0.jpg)](http://www.youtube.com/watch?v=7k02dPqAjBA "")
---
### 💻Building by yourself
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 Plugin SDK](https://airspy.com/?ddownload=5944)
- SDRSharp.Common.dll
- SDRSharp.PanView.dll
- SDRSharp.Radio.dll
2. Click "Code" and select "Open with Visual Studio" or "Download ZIP"
![Captură de ecran 2020-10-26 025111.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20025111.png)
3. If you downloaded as ZIP, unzip the archive and double click on "SDRSharpPlugin.DiscordRPC.sln"
4. Build it and move files to SDR# location (if the compile fails try copying Reference files into /bin/Debug or /bin/Release folder)
---
### 👀Setting your custom images on RPC
1. Go to https://discord.com/developers/applications and create your own application
2. Name it "SDRSharp" or something similar
![Captură de ecran 2020-10-26 023639.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20023639.png)
3. Go to Rich Presence > Rich Presence Assets and add your own images with these names:
![Captură de ecran 2020-10-26 023706.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20023706.png)
4. Go back to General Information and copy Client ID
![Captură de ecran 2020-10-26 023915.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20023915.png)
5. Paste the Client ID you copied earlier in plugin textbox from SDRSharp and press the ENTER key
![Captură de ecran 2020-10-26 024024.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20024024.png)
6. Restart the SDRSharp and it should be changed with your custom images
---
### 📕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 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> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <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> <HintPath>packages\Newtonsoft.Json.12.0.2\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>
</Reference> </Reference>
<Reference Include="SDRSharp.Common, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86"> <Reference Include="SDRSharp.Common, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@@ -65,6 +60,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Runtime" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
@@ -133,44 +129,46 @@
<Compile Include="LogWriter.cs" /> <Compile Include="LogWriter.cs" />
<Compile Include="MainPlugin.cs" /> <Compile Include="MainPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.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"> <Compile Include="SettingsPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="SettingsPanel.Designer.cs"> <Compile Include="SettingsPanel.Designer.cs">
<DependentUpon>SettingsPanel.cs</DependentUpon> <DependentUpon>SettingsPanel.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="TopWindowMessages.cs"> <Compile Include="SettingsForm.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="TopWindowMessages.Designer.cs">
<DependentUpon>TopWindowMessages.cs</DependentUpon>
</Compile>
<Compile Include="WelcomeForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="WelcomeForm.Designer.cs"> <Compile Include="SettingsForm.Designer.cs">
<DependentUpon>WelcomeForm.cs</DependentUpon> <DependentUpon>SettingsForm.cs</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="SettingsPanel.resx"> <EmbeddedResource Include="SettingsPanel.resx">
<DependentUpon>SettingsPanel.cs</DependentUpon> <DependentUpon>SettingsPanel.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="TopWindowMessages.resx"> <EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>TopWindowMessages.cs</DependentUpon> <DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="WelcomeForm.resx">
<DependentUpon>WelcomeForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="DiscordAPI\LICENSE.txt" /> <Content Include="DiscordAPI\LICENSE.txt" />
<Content Include="Resgister.txt"> <Content Include="Register.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<None Include="Resources\gear.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include=".editorconfig" /> <None Include=".editorconfig" />
<None Include="app.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <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.checkBox1 = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label(); 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.button1 = new System.Windows.Forms.Button();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// checkBox1 // checkBox1
@@ -43,9 +39,11 @@
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.checkBox1.Checked = true; this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked; 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.Location = new System.Drawing.Point(3, 3);
this.checkBox1.Name = "checkBox1"; 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.TabIndex = 0;
this.checkBox1.Text = "Enable Discord RPC"; this.checkBox1.Text = "Enable Discord RPC";
this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.UseVisualStyleBackColor = true;
@@ -56,100 +54,54 @@
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoEllipsis = true;
this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 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.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.TabIndex = 1;
this.label1.Text = "Loading status..."; this.label1.Text = "Loading status...";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 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 // button1
// //
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 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.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.TabIndex = 4;
this.button1.Text = "Help";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1_Click); 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 // SettingsPanel
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.checkBox3); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.Controls.Add(this.button1); 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.label1);
this.Controls.Add(this.checkBox1); 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.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.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label label1; 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.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; private string _ChangeStatus;
public string ChangeStatus public string ChangeStatus
{ {
get get => _ChangeStatus;
{
return _ChangeStatus;
}
set set
{ {
_ChangeStatus = value; _ChangeStatus = value;
@@ -24,66 +21,27 @@ namespace EnderIce2.SDRSharpPlugin
public SettingsPanel() public SettingsPanel()
{ {
InitializeComponent(); InitializeComponent();
textBox1.Text = Utils.GetStringSetting("ClientID"); checkBox1.Checked = Utils.GetBooleanSetting("EnableRPC", true);
if (Utils.GetBooleanSetting("EnableRPC", true)) LogWriter.WriteToFile("User Control Loaded");
checkBox1.Checked = true;
else
checkBox1.Checked = false;
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) private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{ {
Utils.SaveSetting("EnableRPC", checkBox1.Checked); Utils.SaveSetting("EnableRPC", checkBox1.Checked);
label1.Text = "Restart required"; label1.Text = "Restart required";
LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox1.Checked}"); 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"); // can't use bcz System.Drawing.Color is from dotnet core 5
} //MainPlugin._control.ThemeForeColor;
//BackColor = MainPlugin._control.ThemePanelColor;
private void CheckBox2_CheckedChanged(object sender, EventArgs e) //MainPlugin._control.ThemeBackColor;
{ BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
Utils.SaveSetting("LogRPC", checkBox2.Checked); ForeColor = System.Drawing.Color.FromArgb(244, 244, 244);
}
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);
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}");
} }
} }
} }

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,64 +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 = false;
private bool AnswerD = false;
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);
}
bool tmpansw = AnswerA;
LogWriter.WriteToFile($"Client sent an answer. {tmpansw}");
client.Respond(args, tmpansw);
AnswerA = false;
AnswerD = false;
button1.Visible = false;
button2.Visible = false;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
SetDefaultTextInLabel(tmpansw);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
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);
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"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net46" /> <package id="Newtonsoft.Json" version="12.0.2" targetFramework="net46" />
</packages> </packages>