mirror of
https://github.com/Macro-Deck-App/Macro-Deck.git
synced 2026-06-06 13:54:55 +08:00
* cleanup usings (to global) * refactor template rendering and add custom cottle functions
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System.Windows.Forms;
|
|
using Newtonsoft.Json;
|
|
using SuchByte.MacroDeck.GUI.CustomControls;
|
|
using SuchByte.MacroDeck.Logging;
|
|
|
|
namespace SuchByte.MacroDeck.GUI.Dialogs;
|
|
|
|
public partial class JsonButtonEditor : DialogForm
|
|
{
|
|
|
|
static JsonSerializerSettings jsonSerializerSettings = new()
|
|
{
|
|
TypeNameHandling = TypeNameHandling.Auto,
|
|
NullValueHandling = NullValueHandling.Ignore,
|
|
Formatting = Formatting.Indented,
|
|
Error = (sender, args) => {
|
|
MacroDeckLogger.Warning(typeof(JsonButtonEditor), args.ErrorContext.Error.Message);
|
|
args.ErrorContext.Handled = true;
|
|
}
|
|
};
|
|
|
|
|
|
public ActionButton.ActionButton ActionButton { get; set; }
|
|
|
|
|
|
public JsonButtonEditor(ActionButton.ActionButton actionButton)
|
|
{
|
|
InitializeComponent();
|
|
|
|
ActionButton = actionButton;
|
|
if (ActionButton.LabelOff != null)
|
|
{
|
|
ActionButton.LabelOff.LabelBase64 = string.Empty;
|
|
}
|
|
if (ActionButton.LabelOn != null)
|
|
{
|
|
ActionButton.LabelOn.LabelBase64 = string.Empty;
|
|
}
|
|
jsonTextBox.Text = JsonConvert.SerializeObject(ActionButton, jsonSerializerSettings);
|
|
}
|
|
|
|
private void BtnApply_Click(object sender, EventArgs e)
|
|
{
|
|
ActionButton = JsonConvert.DeserializeObject<ActionButton.ActionButton>(jsonTextBox.Text, jsonSerializerSettings);
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
} |