mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 17:36:25 +00:00
Refactoring project structure to better separate UI concerns
This commit is contained in:
parent
e88c1c20d6
commit
491b13aec3
37 changed files with 248 additions and 266 deletions
121
DataNode.cs
121
DataNode.cs
|
@ -1,121 +0,0 @@
|
|||
using Substrate.Core;
|
||||
using Substrate.Nbt;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public class DataNodeOld
|
||||
{
|
||||
public DataNodeOld ()
|
||||
{
|
||||
}
|
||||
|
||||
public DataNodeOld (DataNodeOld parent)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public DataNodeOld Parent { get; set; }
|
||||
|
||||
private bool _modified;
|
||||
public bool Modified
|
||||
{
|
||||
get { return _modified; }
|
||||
set
|
||||
{
|
||||
if (value && Parent != null) {
|
||||
Parent.Modified = value;
|
||||
}
|
||||
_modified = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Expanded { get; set; }
|
||||
}
|
||||
|
||||
public class NbtDataNode : DataNodeOld
|
||||
{
|
||||
public NbtDataNode ()
|
||||
{
|
||||
}
|
||||
|
||||
public NbtDataNode (DataNodeOld parent)
|
||||
: base(parent)
|
||||
{
|
||||
}
|
||||
|
||||
public NbtTree Tree { get; set; }
|
||||
}
|
||||
|
||||
public class RegionChunkData : NbtDataNode
|
||||
{
|
||||
public RegionChunkData (RegionFile file, int x, int z)
|
||||
: this(null, file, x, z)
|
||||
{
|
||||
}
|
||||
|
||||
public RegionChunkData (DataNodeOld parent, RegionFile file, int x, int z)
|
||||
: base(parent)
|
||||
{
|
||||
Region = file;
|
||||
X = x;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public RegionFile Region { get; private set; }
|
||||
public int X { get; private set; }
|
||||
public int Z { get; private set; }
|
||||
}
|
||||
|
||||
public class RegionData : DataNodeOld
|
||||
{
|
||||
public RegionData (string path)
|
||||
: this(null, path)
|
||||
{
|
||||
}
|
||||
|
||||
public RegionData (DataNodeOld parent, string path)
|
||||
: base(parent)
|
||||
{
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public string Path { get; private set; }
|
||||
}
|
||||
|
||||
public class NbtFileData : NbtDataNode
|
||||
{
|
||||
public NbtFileData (string path, CompressionType cztype)
|
||||
: this(null, path, cztype)
|
||||
{
|
||||
}
|
||||
|
||||
public NbtFileData (DataNodeOld parent, string path, CompressionType cztype)
|
||||
: base(parent)
|
||||
{
|
||||
Path = path;
|
||||
CompressionType = cztype;
|
||||
}
|
||||
|
||||
public string Path { get; private set; }
|
||||
public CompressionType CompressionType { get; private set; }
|
||||
}
|
||||
|
||||
public class DirectoryData : DataNodeOld
|
||||
{
|
||||
public DirectoryData (string path)
|
||||
: this(null, path)
|
||||
{
|
||||
}
|
||||
|
||||
public DirectoryData (DataNodeOld parent, string path)
|
||||
: base(parent)
|
||||
{
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public string Path { get; private set; }
|
||||
}
|
||||
}
|
61
FormRegistry.cs
Normal file
61
FormRegistry.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public static class FormRegistry
|
||||
{
|
||||
public delegate bool EditStringAction (StringFormData data);
|
||||
public delegate bool EditRestrictedStringAction (RestrictedStringFormData data);
|
||||
public delegate bool EditTagScalarAction (TagScalarFormData data);
|
||||
public delegate bool EditByteArrayAction (ByteArrayFormData data);
|
||||
|
||||
public static EditStringAction EditString { get; set; }
|
||||
public static EditRestrictedStringAction RenameTag { get; set; }
|
||||
public static EditTagScalarAction EditTagScalar { get; set; }
|
||||
public static EditByteArrayAction EditByteArray { get; set; }
|
||||
}
|
||||
|
||||
public class TagScalarFormData
|
||||
{
|
||||
public TagScalarFormData (TagNode tag)
|
||||
{
|
||||
Tag = tag;
|
||||
}
|
||||
|
||||
public TagNode Tag { get; private set; }
|
||||
}
|
||||
|
||||
public class StringFormData
|
||||
{
|
||||
public StringFormData (String value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public String Value { get; set; }
|
||||
}
|
||||
|
||||
public class RestrictedStringFormData : StringFormData
|
||||
{
|
||||
private List<String> _restricted = new List<string>();
|
||||
|
||||
public RestrictedStringFormData (String value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
public List<String> RestrictedValues
|
||||
{
|
||||
get { return _restricted; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ByteArrayFormData
|
||||
{
|
||||
public string NodeName { get; set; }
|
||||
public int BytesPerElement { get; set; }
|
||||
public byte[] Data { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Windows;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
//susing System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
|
@ -221,11 +221,12 @@ namespace NBTExplorer.Model
|
|||
|
||||
public override bool RenameNode ()
|
||||
{
|
||||
if (CanRenameNode && TagParent.IsNamedContainer) {
|
||||
EditName form = new EditName(TagParent.NamedTagContainer.GetTagName(Tag));
|
||||
form.InvalidNames.AddRange(TagParent.NamedTagContainer.TagNamesInUse);
|
||||
if (form.ShowDialog() == DialogResult.OK && form.IsModified) {
|
||||
if (TagParent.NamedTagContainer.RenameTag(Tag, form.TagName)) {
|
||||
if (CanRenameNode && TagParent.IsNamedContainer && FormRegistry.EditString != null) {
|
||||
RestrictedStringFormData data = new RestrictedStringFormData(TagParent.NamedTagContainer.GetTagName(Tag));
|
||||
data.RestrictedValues.AddRange(TagParent.NamedTagContainer.TagNamesInUse);
|
||||
|
||||
if (FormRegistry.RenameTag(data)) {
|
||||
if (TagParent.NamedTagContainer.RenameTag(Tag, data.Value)) {
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -284,61 +285,77 @@ namespace NBTExplorer.Model
|
|||
|
||||
protected bool EditScalarValue (TagNode tag)
|
||||
{
|
||||
EditValue form = new EditValue(tag);
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
IsModified = true;
|
||||
return true;
|
||||
if (FormRegistry.EditTagScalar != null) {
|
||||
if (FormRegistry.EditTagScalar(new TagScalarFormData(tag))) {
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool EditStringValue (TagNode tag)
|
||||
{
|
||||
EditString form = new EditString(tag.ToTagString().Data);
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
tag.ToTagString().Data = form.StringValue;
|
||||
|
||||
IsModified = true;
|
||||
return true;
|
||||
if (FormRegistry.EditString != null) {
|
||||
StringFormData data = new StringFormData(tag.ToTagString().Data);
|
||||
if (FormRegistry.EditString(data)) {
|
||||
tag.ToTagString().Data = data.Value;
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool EditByteHexValue (TagNode tag)
|
||||
{
|
||||
HexEditor form = new HexEditor(NodeName, tag.ToTagByteArray().Data, 1);
|
||||
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
|
||||
Array.Copy(form.Data, tag.ToTagByteArray().Data, tag.ToTagByteArray().Length);
|
||||
if (FormRegistry.EditByteArray != null) {
|
||||
byte[] byteData = new byte[tag.ToTagByteArray().Length];
|
||||
Array.Copy(tag.ToTagByteArray().Data, byteData, byteData.Length);
|
||||
|
||||
IsModified = true;
|
||||
return true;
|
||||
ByteArrayFormData data = new ByteArrayFormData() {
|
||||
NodeName = NodeName,
|
||||
BytesPerElement = 1,
|
||||
Data = byteData,
|
||||
};
|
||||
|
||||
if (FormRegistry.EditByteArray(data)) {
|
||||
Array.Copy(data.Data, tag.ToTagByteArray().Data, tag.ToTagByteArray().Length);
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool EditIntHexValue (TagNode tag)
|
||||
{
|
||||
TagNodeIntArray iatag = tag.ToTagIntArray();
|
||||
byte[] data = new byte[iatag.Length * 4];
|
||||
for (int i = 0; i < iatag.Length; i++) {
|
||||
byte[] buf = BitConverter.GetBytes(iatag.Data[i]);
|
||||
Array.Copy(buf, 0, data, 4 * i, 4);
|
||||
}
|
||||
|
||||
HexEditor form = new HexEditor(NodeName, data, 4);
|
||||
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
|
||||
if (FormRegistry.EditByteArray != null) {
|
||||
TagNodeIntArray iatag = tag.ToTagIntArray();
|
||||
byte[] byteData = new byte[iatag.Length * 4];
|
||||
for (int i = 0; i < iatag.Length; i++) {
|
||||
iatag.Data[i] = BitConverter.ToInt32(form.Data, i * 4);
|
||||
byte[] buf = BitConverter.GetBytes(iatag.Data[i]);
|
||||
Array.Copy(buf, 0, byteData, 4 * i, 4);
|
||||
}
|
||||
|
||||
IsModified = true;
|
||||
return true;
|
||||
ByteArrayFormData data = new ByteArrayFormData() {
|
||||
NodeName = NodeName,
|
||||
BytesPerElement = 4,
|
||||
Data = byteData,
|
||||
};
|
||||
|
||||
if (FormRegistry.EditByteArray(data)) {
|
||||
for (int i = 0; i < iatag.Length; i++) {
|
||||
iatag.Data[i] = BitConverter.ToInt32(data.Data, i * 4);
|
||||
}
|
||||
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagKey : IComparable<TagKey>
|
||||
{
|
|
@ -80,60 +80,60 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Forms\CancelSearchForm.cs">
|
||||
<Compile Include="FormRegistry.cs" />
|
||||
<Compile Include="Windows\CancelSearchForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CancelSearchForm.Designer.cs">
|
||||
<Compile Include="Windows\CancelSearchForm.Designer.cs">
|
||||
<DependentUpon>CancelSearchForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IconRegistry.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<Compile Include="Windows\IconRegistry.cs" />
|
||||
<Compile Include="Windows\MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<Compile Include="Windows\MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DataNode.cs" />
|
||||
<Compile Include="Forms\About.cs">
|
||||
<Compile Include="Windows\About.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\About.Designer.cs">
|
||||
<Compile Include="Windows\About.Designer.cs">
|
||||
<DependentUpon>About.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditName.cs">
|
||||
<Compile Include="Windows\EditName.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditName.Designer.cs">
|
||||
<Compile Include="Windows\EditName.Designer.cs">
|
||||
<DependentUpon>EditName.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditString.cs">
|
||||
<Compile Include="Windows\EditString.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditString.Designer.cs">
|
||||
<Compile Include="Windows\EditString.Designer.cs">
|
||||
<DependentUpon>EditString.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CreateNode.cs">
|
||||
<Compile Include="Windows\CreateNode.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CreateNode.Designer.cs">
|
||||
<Compile Include="Windows\CreateNode.Designer.cs">
|
||||
<DependentUpon>CreateNode.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditValue.cs">
|
||||
<Compile Include="Windows\EditValue.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditValue.Designer.cs">
|
||||
<Compile Include="Windows\EditValue.Designer.cs">
|
||||
<DependentUpon>EditValue.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Find.cs">
|
||||
<Compile Include="Windows\Find.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Find.Designer.cs">
|
||||
<Compile Include="Windows\Find.Designer.cs">
|
||||
<DependentUpon>Find.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditHex.cs">
|
||||
<Compile Include="Windows\EditHex.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EditHex.Designer.cs">
|
||||
<Compile Include="Windows\EditHex.Designer.cs">
|
||||
<DependentUpon>EditHex.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\CompoundTagContainer.cs" />
|
||||
|
@ -170,7 +170,7 @@
|
|||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SearchWorker.cs" />
|
||||
<Compile Include="TagKey.cs" />
|
||||
<Compile Include="Model\TagKey.cs" />
|
||||
<Compile Include="Vendor\Be.Windows.Forms.HexBox\BuiltInContextMenu.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
@ -191,32 +191,33 @@
|
|||
<Compile Include="Vendor\Be.Windows.Forms.HexBox\MemoryDataBlock.cs" />
|
||||
<Compile Include="Vendor\Be.Windows.Forms.HexBox\NativeMethods.cs" />
|
||||
<Compile Include="Vendor\Be.Windows.Forms.HexBox\Util.cs" />
|
||||
<EmbeddedResource Include="Forms\CancelSearchForm.resx">
|
||||
<Compile Include="Windows\FormHandlers.cs" />
|
||||
<EmbeddedResource Include="Windows\CancelSearchForm.resx">
|
||||
<DependentUpon>CancelSearchForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<EmbeddedResource Include="Windows\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\About.resx">
|
||||
<EmbeddedResource Include="Windows\About.resx">
|
||||
<DependentUpon>About.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EditName.resx">
|
||||
<EmbeddedResource Include="Windows\EditName.resx">
|
||||
<DependentUpon>EditName.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EditString.resx">
|
||||
<EmbeddedResource Include="Windows\EditString.resx">
|
||||
<DependentUpon>EditString.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\CreateNode.resx">
|
||||
<EmbeddedResource Include="Windows\CreateNode.resx">
|
||||
<DependentUpon>CreateNode.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EditValue.resx">
|
||||
<EmbeddedResource Include="Windows\EditValue.resx">
|
||||
<DependentUpon>EditValue.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\Find.resx">
|
||||
<EmbeddedResource Include="Windows\Find.resx">
|
||||
<DependentUpon>Find.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EditHex.resx">
|
||||
<EmbeddedResource Include="Windows\EditHex.resx">
|
||||
<DependentUpon>EditHex.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
|
@ -246,6 +247,7 @@
|
|||
<None Include="Resources\arrow-270.png" />
|
||||
<Content Include="Vendor\Be.Windows.Forms.HexBox\HexBox.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Windows;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class About
|
||||
{
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class About : Form
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer.Forms
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class CancelSearchForm
|
||||
{
|
12
Windows/CancelSearchForm.cs
Normal file
12
Windows/CancelSearchForm.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class CancelSearchForm : Form
|
||||
{
|
||||
public CancelSearchForm ()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class CreateNodeForm
|
||||
{
|
|
@ -1,13 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class CreateNodeForm : Form
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class HexEditor
|
||||
{
|
|
@ -1,13 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Be.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class HexEditor : Form
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class EditName
|
||||
{
|
|
@ -1,12 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class EditName : Form
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class EditString
|
||||
{
|
|
@ -1,13 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class EditString : Form
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class EditValue
|
||||
{
|
|
@ -1,12 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class EditValue : Form
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class Find
|
||||
{
|
|
@ -1,11 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class Find : Form
|
||||
{
|
60
Windows/FormHandlers.cs
Normal file
60
Windows/FormHandlers.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public class IconRegistry
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
|
@ -1,16 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Forms;
|
||||
using NBTExplorer.Model;
|
||||
using Substrate.Nbt;
|
||||
using NBTExplorer.Properties;
|
||||
using System.Collections.Specialized;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
namespace NBTExplorer.Windows
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
|
@ -45,6 +44,7 @@ namespace NBTExplorer
|
|||
{
|
||||
InitializeComponent();
|
||||
InitializeIconRegistry();
|
||||
FormHandlers.Register();
|
||||
|
||||
FormClosing += MainForm_Closing;
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer.Forms
|
||||
{
|
||||
public partial class CancelSearchForm : Form
|
||||
{
|
||||
public CancelSearchForm ()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue