-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cs
61 lines (49 loc) · 1.65 KB
/
Config.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using SuchByte.MacroDeck.GUI.CustomControls;
using SuchByte.MacroDeck.Plugins;
using System;
using SuchByte.MacroDeck.Logging;
using Newtonsoft.Json.Linq;
namespace hashashin.FxCommands
{
public partial class FxCommandsActionConfWnd : ActionConfigControl
{
PluginAction pluginAction;
public FxCommandsActionConfWnd(PluginAction pluginAction)
{
this.pluginAction = pluginAction;
InitializeComponent();
this.LoadConfig();
}
public override bool OnActionSave()
{
if (String.IsNullOrWhiteSpace(this.TextCommand.Text))
{
MacroDeckLogger.Error(Main.Instance, "command is empty: create action failed");
return false;
}
JObject configurationObject = JObject.FromObject(new
{
command = this.TextCommand.Text,
});
this.pluginAction.Configuration = configurationObject.ToString();
this.pluginAction.ConfigurationSummary = this.TextCommand.Text;
return true;
}
private void LoadConfig()
{
if (string.IsNullOrWhiteSpace(this.pluginAction.Configuration))
{
return;
}
try
{
JObject configurationObject = JObject.Parse(this.pluginAction.Configuration);
this.TextCommand.Text = configurationObject["command"].ToString();
}
catch (Exception ex)
{
MacroDeckLogger.Error(Main.Instance, $"hashashin.FxCommands LoadConfig {ex.Message}");
}
}
}
}