This commit is contained in:
EnderIce2 2021-04-30 02:27:41 +03:00
parent 4913bb45c4
commit 4753a7849b
3 changed files with 12 additions and 18 deletions

View File

@ -37,18 +37,9 @@ namespace EnderIce2.SDRSharpPlugin
}; };
private DiscordRpcClient client; private DiscordRpcClient client;
private bool isRunning = true; private bool isRunning = true;
public string DisplayName public string DisplayName => _displayName;
{ public bool HasGui => true;
get { return _displayName; } public UserControl Gui => _controlPanel;
}
public bool HasGui
{
get { return true; }
}
public UserControl Gui
{
get { return _controlPanel; }
}
public void Initialize(ISharpControl control) public void Initialize(ISharpControl control)
{ {
IConfigurationPanelProvider configurationPanelProvider; IConfigurationPanelProvider configurationPanelProvider;
@ -72,6 +63,7 @@ namespace EnderIce2.SDRSharpPlugin
{ {
MessageBox.Show(ex.ToString()); MessageBox.Show(ex.ToString());
} }
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{ {
presence.Secrets = new Secrets() presence.Secrets = new Secrets()
@ -85,6 +77,7 @@ namespace EnderIce2.SDRSharpPlugin
Max = 100 Max = 100
}; };
} }
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{ {
windowMessages.Show(); windowMessages.Show();
@ -128,8 +121,12 @@ namespace EnderIce2.SDRSharpPlugin
{ {
Start = DateTime.UtcNow Start = DateTime.UtcNow
}; };
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
client.SetSubscription(EventType.Join | EventType.JoinRequest); client.SetSubscription(EventType.Join | EventType.JoinRequest);
}
client.SetPresence(presence); client.SetPresence(presence);
client.Initialize(); client.Initialize();
try try
@ -148,7 +145,6 @@ namespace EnderIce2.SDRSharpPlugin
{ {
_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 void Client_OnPresenceUpdate(object sender, PresenceMessage args)
@ -243,7 +239,7 @@ namespace EnderIce2.SDRSharpPlugin
} }
} }
LogWriter.WriteToFile("Waiting 500ms in loop..."); LogWriter.WriteToFile("Waiting 500ms in loop...");
await Task.Delay(500); await Task.Delay(500).ConfigureAwait(false);
if (_control.RdsRadioText != null) if (_control.RdsRadioText != null)
{ {
if (_control.IsPlaying) if (_control.IsPlaying)
@ -287,7 +283,7 @@ namespace EnderIce2.SDRSharpPlugin
LogWriter.WriteToFile(ex.ToString()); LogWriter.WriteToFile(ex.ToString());
} }
/* presence.Secrets.JoinSecret = */ /* presence.Secrets.JoinSecret = */
// TODO: _control.RegisterFrontControl(Gui, PluginPosition.Top); /* _control.RegisterFrontControl(Gui, PluginPosition.Top); */
} }
try try
{ {

View File

@ -59,7 +59,7 @@ namespace EnderIce2.SDRSharpPlugin
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}");
// TODO: implement Utils.GetBooleanSetting("EnableRPC"); /* Utils.GetBooleanSetting("EnableRPC"); */
} }
private void Button1_Click(object sender, EventArgs e) private void Button1_Click(object sender, EventArgs e)

View File

@ -46,9 +46,7 @@ namespace EnderIce2.SDRSharpPlugin
AnswerD = false; AnswerD = false;
button1.Visible = false; button1.Visible = false;
button2.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); 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; return tmpansw;
} }
private async Task SetDefaultTextInLabel(bool accepted) private async Task SetDefaultTextInLabel(bool accepted)