mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-10 09:56:25 +00:00
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
|
using System;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace NBTExplorer.Windows
|
|||
|
{
|
|||
|
public static class FormHandlers
|
|||
|
{
|
|||
|
public static void Register ()
|
|||
|
{
|
|||
|
FormRegistry.EditByteArray = EditByteArrayHandler;
|
|||
|
FormRegistry.EditString = EditStringHandler;
|
|||
|
FormRegistry.EditTagScalar = EditTagScalarValueHandler;
|
|||
|
FormRegistry.RenameTag = RenameTagHandler;
|
|||
|
}
|
|||
|
|
|||
|
public static bool EditStringHandler (StringFormData data)
|
|||
|
{
|
|||
|
EditString form = new EditString(data.Value);
|
|||
|
if (form.ShowDialog() == DialogResult.OK) {
|
|||
|
data.Value = form.StringValue;
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public static bool RenameTagHandler (RestrictedStringFormData data)
|
|||
|
{
|
|||
|
EditName form = new EditName(data.Value);
|
|||
|
form.InvalidNames.AddRange(data.RestrictedValues);
|
|||
|
|
|||
|
if (form.ShowDialog() == DialogResult.OK && form.IsModified) {
|
|||
|
data.Value = form.TagName;
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public static bool EditTagScalarValueHandler (TagScalarFormData data)
|
|||
|
{
|
|||
|
EditValue form = new EditValue(data.Tag);
|
|||
|
if (form.ShowDialog() == DialogResult.OK)
|
|||
|
return true;
|
|||
|
else
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public static bool EditByteArrayHandler (ByteArrayFormData data)
|
|||
|
{
|
|||
|
HexEditor form = new HexEditor(data.NodeName, data.Data, data.BytesPerElement);
|
|||
|
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
|
|||
|
Array.Copy(form.Data, data.Data, data.Data.Length);
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|