2012-08-31 05:29:32 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2012-11-05 03:32:18 +00:00
|
|
|
|
using System.Collections.Specialized;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
using System.ComponentModel;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
using System.IO;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
using System.Threading;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using NBTExplorer.Model;
|
2012-09-02 23:15:37 +00:00
|
|
|
|
using NBTExplorer.Properties;
|
2012-11-05 03:32:18 +00:00
|
|
|
|
using Substrate.Nbt;
|
2012-11-20 06:02:35 +00:00
|
|
|
|
using NBTExplorer.Controllers;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-11-05 03:32:18 +00:00
|
|
|
|
namespace NBTExplorer.Windows
|
2012-08-31 05:29:32 +00:00
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
using Predicates = NodeTreeController.Predicates;
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
|
|
|
|
private static Dictionary<TagType, int> _tagIconIndex;
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
private NodeTreeController _controller;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
private IconRegistry _iconRegistry;
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private string _openFolderPath = null;
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
static MainForm ()
|
|
|
|
|
{
|
2012-10-05 02:26:57 +00:00
|
|
|
|
try {
|
|
|
|
|
_tagIconIndex = new Dictionary<TagType, int>();
|
|
|
|
|
_tagIconIndex[TagType.TAG_BYTE] = 0;
|
|
|
|
|
_tagIconIndex[TagType.TAG_SHORT] = 1;
|
|
|
|
|
_tagIconIndex[TagType.TAG_INT] = 2;
|
|
|
|
|
_tagIconIndex[TagType.TAG_LONG] = 3;
|
|
|
|
|
_tagIconIndex[TagType.TAG_FLOAT] = 4;
|
|
|
|
|
_tagIconIndex[TagType.TAG_DOUBLE] = 5;
|
|
|
|
|
_tagIconIndex[TagType.TAG_BYTE_ARRAY] = 6;
|
|
|
|
|
_tagIconIndex[TagType.TAG_STRING] = 7;
|
|
|
|
|
_tagIconIndex[TagType.TAG_LIST] = 8;
|
|
|
|
|
_tagIconIndex[TagType.TAG_COMPOUND] = 9;
|
|
|
|
|
_tagIconIndex[TagType.TAG_INT_ARRAY] = 14;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
Program.StaticInitFailure(e);
|
|
|
|
|
}
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MainForm ()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeIconRegistry();
|
2012-11-05 03:32:18 +00:00
|
|
|
|
FormHandlers.Register();
|
2012-11-09 05:14:23 +00:00
|
|
|
|
NbtClipboardController.Initialize(new NbtClipboardControllerWin());
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller = new NodeTreeController(_nodeTree);
|
|
|
|
|
_controller.ConfirmAction += _controller_ConfirmAction;
|
|
|
|
|
_controller.SelectionInvalidated += _controller_SelectionInvalidated;
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
FormClosing += MainForm_Closing;
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_nodeTree.BeforeExpand += _nodeTree_BeforeExpand;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_nodeTree.AfterCollapse += _nodeTree_AfterCollapse;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_nodeTree.AfterSelect += _nodeTree_AfterSelect;
|
|
|
|
|
_nodeTree.NodeMouseDoubleClick += _nodeTree_NodeMouseDoubleClick;
|
2012-09-02 03:59:53 +00:00
|
|
|
|
_nodeTree.NodeMouseClick += _nodeTree_NodeMouseClick;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_nodeTree.DragEnter += _nodeTree_DragEnter;
|
|
|
|
|
_nodeTree.DragDrop += _nodeTree_DragDrop;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_buttonOpen.Click += _buttonOpen_Click;
|
|
|
|
|
_buttonOpenFolder.Click += _buttonOpenFolder_Click;
|
|
|
|
|
_buttonSave.Click += _buttonSave_Click;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_buttonEdit.Click += _buttonEdit_Click;
|
|
|
|
|
_buttonRename.Click += _buttonRename_Click;
|
|
|
|
|
_buttonDelete.Click += _buttonDelete_Click;
|
|
|
|
|
_buttonCopy.Click += _buttonCopy_Click;
|
|
|
|
|
_buttonCut.Click += _buttonCut_Click;
|
|
|
|
|
_buttonPaste.Click += _buttonPaste_Click;
|
|
|
|
|
_buttonAddTagByte.Click += _buttonAddTagByte_Click;
|
|
|
|
|
_buttonAddTagByteArray.Click += _buttonAddTagByteArray_Click;
|
|
|
|
|
_buttonAddTagCompound.Click += _buttonAddTagCompound_Click;
|
|
|
|
|
_buttonAddTagDouble.Click += _buttonAddTagDouble_Click;
|
|
|
|
|
_buttonAddTagFloat.Click += _buttonAddTagFloat_Click;
|
|
|
|
|
_buttonAddTagInt.Click += _buttonAddTagInt_Click;
|
|
|
|
|
_buttonAddTagIntArray.Click += _buttonAddTagIntArray_Click;
|
|
|
|
|
_buttonAddTagList.Click += _buttonAddTagList_Click;
|
|
|
|
|
_buttonAddTagLong.Click += _buttonAddTagLong_Click;
|
|
|
|
|
_buttonAddTagShort.Click += _buttonAddTagShort_Click;
|
|
|
|
|
_buttonAddTagString.Click += _buttonAddTagString_Click;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_buttonFindNext.Click += _buttonFindNext_Click;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_menuItemOpen.Click += _menuItemOpen_Click;
|
|
|
|
|
_menuItemOpenFolder.Click += _menuItemOpenFolder_Click;
|
|
|
|
|
_menuItemOpenMinecraftSaveFolder.Click += _menuItemOpenMinecraftSaveFolder_Click;
|
|
|
|
|
_menuItemSave.Click += _menuItemSave_Click;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_menuItemExit.Click += _menuItemExit_Click;
|
|
|
|
|
_menuItemEditValue.Click += _menuItemEditValue_Click;
|
|
|
|
|
_menuItemRename.Click += _menuItemRename_Click;
|
|
|
|
|
_menuItemDelete.Click += _menuItemDelete_Click;
|
|
|
|
|
_menuItemCopy.Click += _menuItemCopy_Click;
|
|
|
|
|
_menuItemCut.Click += _menuItemCut_Click;
|
|
|
|
|
_menuItemPaste.Click += _menuItemPaste_Click;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_menuItemFind.Click += _menuItemFind_Click;
|
|
|
|
|
_menuItemFindNext.Click += _menuItemFindNext_Click;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_menuItemAbout.Click += _menuItemAbout_Click;
|
|
|
|
|
|
|
|
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
|
|
|
if (args.Length > 1) {
|
2012-09-01 23:27:50 +00:00
|
|
|
|
string[] paths = new string[args.Length - 1];
|
|
|
|
|
Array.Copy(args, 1, paths, 0, paths.Length);
|
|
|
|
|
OpenPaths(paths);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
OpenMinecraftDirectory();
|
|
|
|
|
}
|
2012-09-02 23:15:37 +00:00
|
|
|
|
|
|
|
|
|
UpdateOpenMenu();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeIconRegistry ()
|
|
|
|
|
{
|
|
|
|
|
_iconRegistry = new IconRegistry();
|
|
|
|
|
_iconRegistry.DefaultIcon = 15;
|
|
|
|
|
|
|
|
|
|
_iconRegistry.Register(typeof(TagByteDataNode), 0);
|
|
|
|
|
_iconRegistry.Register(typeof(TagShortDataNode), 1);
|
|
|
|
|
_iconRegistry.Register(typeof(TagIntDataNode), 2);
|
|
|
|
|
_iconRegistry.Register(typeof(TagLongDataNode), 3);
|
|
|
|
|
_iconRegistry.Register(typeof(TagFloatDataNode), 4);
|
|
|
|
|
_iconRegistry.Register(typeof(TagDoubleDataNode), 5);
|
|
|
|
|
_iconRegistry.Register(typeof(TagByteArrayDataNode), 6);
|
|
|
|
|
_iconRegistry.Register(typeof(TagStringDataNode), 7);
|
|
|
|
|
_iconRegistry.Register(typeof(TagListDataNode), 8);
|
|
|
|
|
_iconRegistry.Register(typeof(TagCompoundDataNode), 9);
|
|
|
|
|
_iconRegistry.Register(typeof(RegionChunkDataNode), 9);
|
|
|
|
|
_iconRegistry.Register(typeof(DirectoryDataNode), 10);
|
|
|
|
|
_iconRegistry.Register(typeof(RegionFileDataNode), 11);
|
2012-09-03 03:25:23 +00:00
|
|
|
|
_iconRegistry.Register(typeof(CubicRegionDataNode), 11);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_iconRegistry.Register(typeof(NbtFileDataNode), 12);
|
|
|
|
|
_iconRegistry.Register(typeof(TagIntArrayDataNode), 14);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 23:15:37 +00:00
|
|
|
|
private void OpenFile ()
|
2012-08-31 05:29:32 +00:00
|
|
|
|
{
|
2012-11-11 18:52:12 +00:00
|
|
|
|
if (!ConfirmAction("Open new file anyway?"))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-08-07 01:35:31 +00:00
|
|
|
|
using (OpenFileDialog ofd = new OpenFileDialog() {
|
|
|
|
|
RestoreDirectory = true,
|
|
|
|
|
Multiselect = true,
|
|
|
|
|
Filter = "All Files|*|NBT Files (*.dat, *.schematic)|*.dat;*.nbt;*.schematic|Region Files (*.mca, *.mcr)|*.mca;*.mcr",
|
|
|
|
|
FilterIndex = 0,
|
|
|
|
|
}) {
|
2013-05-25 07:30:52 +00:00
|
|
|
|
if (ofd.ShowDialog() == DialogResult.OK) {
|
|
|
|
|
OpenPaths(ofd.FileNames);
|
|
|
|
|
}
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
2012-09-02 04:43:54 +00:00
|
|
|
|
|
|
|
|
|
UpdateUI();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void OpenFolder ()
|
|
|
|
|
{
|
2012-11-11 18:52:12 +00:00
|
|
|
|
if (!ConfirmAction("Open new folder anyway?"))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-05-25 07:30:52 +00:00
|
|
|
|
using (FolderBrowserDialog ofd = new FolderBrowserDialog()) {
|
|
|
|
|
if (_openFolderPath != null)
|
|
|
|
|
ofd.SelectedPath = _openFolderPath;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
|
2013-05-25 07:30:52 +00:00
|
|
|
|
if (ofd.ShowDialog() == DialogResult.OK) {
|
|
|
|
|
_openFolderPath = ofd.SelectedPath;
|
|
|
|
|
OpenPaths(new string[] { ofd.SelectedPath });
|
|
|
|
|
}
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
2012-09-02 04:43:54 +00:00
|
|
|
|
|
|
|
|
|
UpdateUI();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 23:15:37 +00:00
|
|
|
|
private void OpenPaths (string[] paths)
|
2012-08-31 05:29:32 +00:00
|
|
|
|
{
|
2013-08-07 01:35:31 +00:00
|
|
|
|
int failCount = _controller.OpenPaths(paths);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
foreach (string path in paths) {
|
2012-11-20 06:02:35 +00:00
|
|
|
|
if (Directory.Exists(path))
|
2013-01-28 00:42:48 +00:00
|
|
|
|
AddPathToHistory(GetRecentDirectories(), path);
|
2012-11-20 06:02:35 +00:00
|
|
|
|
else if (File.Exists(path))
|
2013-08-07 01:35:31 +00:00
|
|
|
|
AddPathToHistory(GetRecentFiles(), path);
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
2012-09-02 04:43:54 +00:00
|
|
|
|
|
|
|
|
|
UpdateUI();
|
2012-09-02 23:15:37 +00:00
|
|
|
|
UpdateOpenMenu();
|
2013-05-25 03:30:58 +00:00
|
|
|
|
|
|
|
|
|
if (failCount > 0) {
|
|
|
|
|
MessageBox.Show("One or more selected files failed to open.");
|
|
|
|
|
}
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-07 01:35:31 +00:00
|
|
|
|
private StringCollection GetRecentFiles ()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return Settings.Default.RecentFiles;
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private StringCollection GetRecentDirectories ()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return Settings.Default.RecentDirectories;
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenMinecraftDirectory ()
|
|
|
|
|
{
|
2012-11-11 18:52:12 +00:00
|
|
|
|
if (!ConfirmAction("Open Minecraft save folder anyway?"))
|
|
|
|
|
return;
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
try {
|
2013-02-18 06:38:33 +00:00
|
|
|
|
string path = Environment.ExpandEnvironmentVariables("%APPDATA%");
|
|
|
|
|
if (!Directory.Exists(path)) {
|
|
|
|
|
path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
path = Path.Combine(path, ".minecraft");
|
|
|
|
|
path = Path.Combine(path, "saves");
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path)) {
|
|
|
|
|
path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
OpenPaths(new string[] { path });
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
2012-10-05 01:57:03 +00:00
|
|
|
|
catch (Exception e) {
|
2012-08-31 05:29:32 +00:00
|
|
|
|
MessageBox.Show("Could not open default Minecraft save directory");
|
2012-10-05 01:57:03 +00:00
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
try {
|
2012-09-01 23:27:50 +00:00
|
|
|
|
OpenPaths(new string[] { Directory.GetCurrentDirectory() });
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception) {
|
|
|
|
|
MessageBox.Show("Could not open current directory, this tool is probably not compatible with your platform.");
|
2012-10-05 01:57:03 +00:00
|
|
|
|
Console.WriteLine(e.Message);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
Application.Exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-02 04:43:54 +00:00
|
|
|
|
|
|
|
|
|
UpdateUI();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TreeNode CreateUnexpandedNode (DataNode node)
|
|
|
|
|
{
|
|
|
|
|
TreeNode frontNode = new TreeNode(node.NodeDisplay);
|
|
|
|
|
frontNode.ImageIndex = _iconRegistry.Lookup(node.GetType());
|
|
|
|
|
frontNode.SelectedImageIndex = frontNode.ImageIndex;
|
|
|
|
|
frontNode.Tag = node;
|
2013-08-07 01:35:31 +00:00
|
|
|
|
//frontNode.ContextMenuStrip = BuildNodeContextMenu(node);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-10-05 01:57:03 +00:00
|
|
|
|
if (node.HasUnexpandedChildren || node.Nodes.Count > 0)
|
2012-08-31 05:29:32 +00:00
|
|
|
|
frontNode.Nodes.Add(new TreeNode());
|
|
|
|
|
|
|
|
|
|
return frontNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExpandNode (TreeNode node)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.ExpandNode(node);
|
2013-08-07 01:35:31 +00:00
|
|
|
|
UpdateUI(node.Tag as DataNode);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void CollapseNode (TreeNode node)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CollapseNode(node);
|
2013-08-07 01:35:31 +00:00
|
|
|
|
UpdateUI(node.Tag as DataNode);
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ConfirmExit ()
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
if (_controller.CheckModifications()) {
|
2012-09-01 23:27:50 +00:00
|
|
|
|
if (MessageBox.Show("You currently have unsaved changes. Close anyway?", "Unsaved Changes", MessageBoxButtons.OKCancel) != DialogResult.OK)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-11 18:52:12 +00:00
|
|
|
|
private bool ConfirmAction (string actionMessage)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
if (_controller.CheckModifications()) {
|
2012-11-11 18:52:12 +00:00
|
|
|
|
if (MessageBox.Show("You currently have unsaved changes. " + actionMessage, "Unsaved Changes", MessageBoxButtons.OKCancel) != DialogResult.OK)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
private void _controller_ConfirmAction (object sender, MessageBoxEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_controller.CheckModifications()) {
|
|
|
|
|
if (MessageBox.Show("You currently have unsaved changes. " + e.Message, "Unsaved Changes", MessageBoxButtons.OKCancel) != DialogResult.OK)
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private CancelSearchForm _searchForm;
|
2012-11-10 19:00:11 +00:00
|
|
|
|
private SearchStateWin _searchState;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
|
|
|
|
|
private void SearchNode (TreeNode node)
|
|
|
|
|
{
|
|
|
|
|
if (node == null || !(node.Tag is DataNode))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DataNode dataNode = node.Tag as DataNode;
|
|
|
|
|
if (!dataNode.CanSearchNode)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Find form = new Find();
|
|
|
|
|
if (form.ShowDialog() != DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-11-10 19:00:11 +00:00
|
|
|
|
_searchState = new SearchStateWin(this) {
|
2012-09-01 23:27:50 +00:00
|
|
|
|
RootNode = dataNode,
|
|
|
|
|
SearchName = form.NameToken,
|
|
|
|
|
SearchValue = form.ValueToken,
|
|
|
|
|
DiscoverCallback = SearchDiscoveryCallback,
|
|
|
|
|
CollapseCallback = SearchCollapseCallback,
|
|
|
|
|
EndCallback = SearchEndCallback,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SearchNextNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SearchNextNode ()
|
|
|
|
|
{
|
|
|
|
|
if (_searchState == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-11-10 19:00:11 +00:00
|
|
|
|
SearchWorker worker = new SearchWorker(_searchState);
|
2012-09-01 23:27:50 +00:00
|
|
|
|
|
|
|
|
|
Thread t = new Thread(new ThreadStart(worker.Run));
|
|
|
|
|
t.IsBackground = true;
|
|
|
|
|
t.Start();
|
|
|
|
|
|
|
|
|
|
_searchForm = new CancelSearchForm();
|
|
|
|
|
if (_searchForm.ShowDialog(this) == DialogResult.Cancel) {
|
|
|
|
|
worker.Cancel();
|
|
|
|
|
_searchState = null;
|
2013-10-07 01:50:11 +00:00
|
|
|
|
|
|
|
|
|
UpdateUI();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t.Join();
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
public void SearchDiscoveryCallback (DataNode node)
|
2012-09-01 23:27:50 +00:00
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.SelectNode(node);
|
2012-09-01 23:27:50 +00:00
|
|
|
|
|
|
|
|
|
if (_searchForm != null) {
|
|
|
|
|
_searchForm.DialogResult = DialogResult.OK;
|
|
|
|
|
_searchForm = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
public void SearchCollapseCallback (DataNode node)
|
2012-09-01 23:27:50 +00:00
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CollapseBelow(node);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
public void SearchEndCallback (DataNode node)
|
2012-09-01 23:27:50 +00:00
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
if (_searchForm != null) {
|
|
|
|
|
_searchForm.DialogResult = DialogResult.OK;
|
|
|
|
|
_searchForm = null;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-07 01:50:11 +00:00
|
|
|
|
_searchState = null;
|
|
|
|
|
UpdateUI();
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
MessageBox.Show("End of results");
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateUI ()
|
|
|
|
|
{
|
|
|
|
|
TreeNode selected = _nodeTree.SelectedNode;
|
2012-11-15 05:27:35 +00:00
|
|
|
|
if (_nodeTree.SelectedNodes.Count > 1) {
|
|
|
|
|
UpdateUI(_nodeTree.SelectedNodes);
|
|
|
|
|
}
|
|
|
|
|
else if (selected != null && selected.Tag is DataNode) {
|
2012-09-01 23:27:50 +00:00
|
|
|
|
UpdateUI(selected.Tag as DataNode);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-11-15 05:27:35 +00:00
|
|
|
|
DisableButtons(_buttonAddTagByte, _buttonAddTagByteArray, _buttonAddTagCompound, _buttonAddTagDouble, _buttonAddTagFloat,
|
|
|
|
|
_buttonAddTagInt, _buttonAddTagIntArray, _buttonAddTagList, _buttonAddTagLong, _buttonAddTagShort,
|
|
|
|
|
_buttonAddTagString, _buttonCopy, _buttonCut, _buttonDelete, _buttonEdit, _buttonPaste, _buttonRefresh,
|
|
|
|
|
_buttonRename);
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_buttonSave.Enabled = _controller.CheckModifications();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_buttonFindNext.Enabled = false;
|
|
|
|
|
|
2012-11-15 05:27:35 +00:00
|
|
|
|
DisableMenuItems(_menuItemCopy, _menuItemCut, _menuItemDelete, _menuItemEditValue, _menuItemPaste, _menuItemRefresh,
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_menuItemRename, _menuItemMoveUp, _menuItemMoveDown);
|
2012-11-15 05:27:35 +00:00
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_menuItemSave.Enabled = _buttonSave.Enabled;
|
|
|
|
|
_menuItemFind.Enabled = false;
|
|
|
|
|
_menuItemFindNext.Enabled = _searchState != null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 05:27:35 +00:00
|
|
|
|
private void DisableButtons (params ToolStripButton[] buttons)
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripButton button in buttons)
|
|
|
|
|
button.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisableMenuItems (params ToolStripMenuItem[] buttons)
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripMenuItem button in buttons)
|
|
|
|
|
button.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
private void UpdateUI (DataNode node)
|
|
|
|
|
{
|
|
|
|
|
if (node == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_buttonAddTagByte.Enabled = node.CanCreateTag(TagType.TAG_BYTE);
|
|
|
|
|
_buttonAddTagByteArray.Enabled = node.CanCreateTag(TagType.TAG_BYTE_ARRAY);
|
|
|
|
|
_buttonAddTagCompound.Enabled = node.CanCreateTag(TagType.TAG_COMPOUND);
|
|
|
|
|
_buttonAddTagDouble.Enabled = node.CanCreateTag(TagType.TAG_DOUBLE);
|
|
|
|
|
_buttonAddTagFloat.Enabled = node.CanCreateTag(TagType.TAG_FLOAT);
|
|
|
|
|
_buttonAddTagInt.Enabled = node.CanCreateTag(TagType.TAG_INT);
|
|
|
|
|
_buttonAddTagIntArray.Enabled = node.CanCreateTag(TagType.TAG_INT_ARRAY);
|
|
|
|
|
_buttonAddTagList.Enabled = node.CanCreateTag(TagType.TAG_LIST);
|
|
|
|
|
_buttonAddTagLong.Enabled = node.CanCreateTag(TagType.TAG_LONG);
|
|
|
|
|
_buttonAddTagShort.Enabled = node.CanCreateTag(TagType.TAG_SHORT);
|
|
|
|
|
_buttonAddTagString.Enabled = node.CanCreateTag(TagType.TAG_STRING);
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_buttonSave.Enabled = _controller.CheckModifications();
|
2012-11-09 05:14:23 +00:00
|
|
|
|
_buttonCopy.Enabled = node.CanCopyNode && NbtClipboardController.IsInitialized;
|
|
|
|
|
_buttonCut.Enabled = node.CanCutNode && NbtClipboardController.IsInitialized;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_buttonDelete.Enabled = node.CanDeleteNode;
|
|
|
|
|
_buttonEdit.Enabled = node.CanEditNode;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_buttonFindNext.Enabled = node.CanSearchNode || _searchState != null;
|
2012-11-09 05:14:23 +00:00
|
|
|
|
_buttonPaste.Enabled = node.CanPasteIntoNode && NbtClipboardController.IsInitialized;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_buttonRename.Enabled = node.CanRenameNode;
|
2012-11-11 18:52:12 +00:00
|
|
|
|
_buttonRefresh.Enabled = node.CanRefreshNode;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_menuItemSave.Enabled = _buttonSave.Enabled;
|
2012-11-09 05:14:23 +00:00
|
|
|
|
_menuItemCopy.Enabled = node.CanCopyNode && NbtClipboardController.IsInitialized;
|
|
|
|
|
_menuItemCut.Enabled = node.CanCutNode && NbtClipboardController.IsInitialized;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_menuItemDelete.Enabled = node.CanDeleteNode;
|
|
|
|
|
_menuItemEditValue.Enabled = node.CanEditNode;
|
|
|
|
|
_menuItemFind.Enabled = node.CanSearchNode;
|
2012-11-09 05:14:23 +00:00
|
|
|
|
_menuItemPaste.Enabled = node.CanPasteIntoNode && NbtClipboardController.IsInitialized;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
_menuItemRename.Enabled = node.CanRenameNode;
|
2012-11-11 18:52:12 +00:00
|
|
|
|
_menuItemRefresh.Enabled = node.CanRefreshNode;
|
2012-09-01 23:27:50 +00:00
|
|
|
|
_menuItemFind.Enabled = node.CanSearchNode;
|
|
|
|
|
_menuItemFindNext.Enabled = _searchState != null;
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_menuItemMoveUp.Enabled = node.CanMoveNodeUp;
|
|
|
|
|
_menuItemMoveDown.Enabled = node.CanMoveNodeDown;
|
2012-11-15 05:27:35 +00:00
|
|
|
|
|
|
|
|
|
UpdateUI(_nodeTree.SelectedNodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateUI (IList<TreeNode> nodes)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
|
2012-11-15 05:27:35 +00:00
|
|
|
|
if (nodes == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_buttonAddTagByte.Enabled = _controller.CanOperateOnSelection(Predicates.CreateByteNodePred);
|
|
|
|
|
_buttonAddTagShort.Enabled = _controller.CanOperateOnSelection(Predicates.CreateShortNodePred);
|
|
|
|
|
_buttonAddTagInt.Enabled = _controller.CanOperateOnSelection(Predicates.CreateIntNodePred);
|
|
|
|
|
_buttonAddTagLong.Enabled = _controller.CanOperateOnSelection(Predicates.CreateLongNodePred);
|
|
|
|
|
_buttonAddTagFloat.Enabled = _controller.CanOperateOnSelection(Predicates.CreateFloatNodePred);
|
|
|
|
|
_buttonAddTagDouble.Enabled = _controller.CanOperateOnSelection(Predicates.CreateDoubleNodePred);
|
|
|
|
|
_buttonAddTagByteArray.Enabled = _controller.CanOperateOnSelection(Predicates.CreateByteArrayNodePred);
|
|
|
|
|
_buttonAddTagIntArray.Enabled = _controller.CanOperateOnSelection(Predicates.CreateIntArrayNodePred);
|
|
|
|
|
_buttonAddTagString.Enabled = _controller.CanOperateOnSelection(Predicates.CreateStringNodePred);
|
|
|
|
|
_buttonAddTagList.Enabled = _controller.CanOperateOnSelection(Predicates.CreateListNodePred);
|
|
|
|
|
_buttonAddTagCompound.Enabled = _controller.CanOperateOnSelection(Predicates.CreateCompoundNodePred);
|
|
|
|
|
|
|
|
|
|
_buttonSave.Enabled = _controller.CheckModifications();
|
|
|
|
|
_buttonRename.Enabled = _controller.CanOperateOnSelection(Predicates.RenameNodePred);
|
|
|
|
|
_buttonEdit.Enabled = _controller.CanOperateOnSelection(Predicates.EditNodePred);
|
|
|
|
|
_buttonDelete.Enabled = _controller.CanOperateOnSelection(Predicates.DeleteNodePred);
|
|
|
|
|
_buttonCut.Enabled = _controller.CanOperateOnSelection(Predicates.CutNodePred) && NbtClipboardController.IsInitialized; ;
|
|
|
|
|
_buttonCopy.Enabled = _controller.CanOperateOnSelection(Predicates.CopyNodePred) && NbtClipboardController.IsInitialized; ;
|
|
|
|
|
_buttonPaste.Enabled = _controller.CanOperateOnSelection(Predicates.PasteIntoNodePred) && NbtClipboardController.IsInitialized; ;
|
|
|
|
|
_buttonFindNext.Enabled = _controller.CanOperateOnSelection(Predicates.SearchNodePred) || _searchState != null;
|
|
|
|
|
_buttonRefresh.Enabled = _controller.CanOperateOnSelection(Predicates.RefreshNodePred);
|
2012-11-15 05:27:35 +00:00
|
|
|
|
|
|
|
|
|
_menuItemSave.Enabled = _buttonSave.Enabled;
|
|
|
|
|
_menuItemRename.Enabled = _buttonRename.Enabled;
|
|
|
|
|
_menuItemEditValue.Enabled = _buttonEdit.Enabled;
|
|
|
|
|
_menuItemDelete.Enabled = _buttonDelete.Enabled;
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_menuItemMoveUp.Enabled = _controller.CanOperateOnSelection(Predicates.MoveNodeUpPred);
|
|
|
|
|
_menuItemMoveDown.Enabled = _controller.CanOperateOnSelection(Predicates.MoveNodeDownPred);
|
2012-11-15 05:27:35 +00:00
|
|
|
|
_menuItemCut.Enabled = _buttonCut.Enabled;
|
|
|
|
|
_menuItemCopy.Enabled = _buttonCopy.Enabled;
|
|
|
|
|
_menuItemPaste.Enabled = _buttonPaste.Enabled;
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_menuItemFind.Enabled = _controller.CanOperateOnSelection(Predicates.SearchNodePred);
|
2012-11-15 05:27:35 +00:00
|
|
|
|
_menuItemRefresh.Enabled = _buttonRefresh.Enabled;
|
|
|
|
|
_menuItemFindNext.Enabled = _searchState != null;
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 23:15:37 +00:00
|
|
|
|
private void UpdateOpenMenu ()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
if (Settings.Default.RecentDirectories == null)
|
|
|
|
|
Settings.Default.RecentDirectories = new StringCollection();
|
|
|
|
|
if (Settings.Default.RecentFiles == null)
|
|
|
|
|
Settings.Default.RecentFiles = new StringCollection();
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_menuItemRecentFolders.DropDown = BuildRecentEntriesDropDown(Settings.Default.RecentDirectories);
|
|
|
|
|
_menuItemRecentFiles.DropDown = BuildRecentEntriesDropDown(Settings.Default.RecentFiles);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 06:02:35 +00:00
|
|
|
|
private void _controller_SelectionInvalidated (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 23:15:37 +00:00
|
|
|
|
private ToolStripDropDown BuildRecentEntriesDropDown (StringCollection list)
|
|
|
|
|
{
|
|
|
|
|
if (list == null || list.Count == 0)
|
|
|
|
|
return new ToolStripDropDown();
|
|
|
|
|
|
|
|
|
|
ToolStripDropDown menu = new ToolStripDropDown();
|
|
|
|
|
foreach (string entry in list) {
|
|
|
|
|
ToolStripMenuItem item = new ToolStripMenuItem("&" + (menu.Items.Count + 1) + " " + entry);
|
|
|
|
|
item.Tag = entry;
|
|
|
|
|
item.Click += _menuItemRecentPaths_Click;
|
|
|
|
|
|
|
|
|
|
menu.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddPathToHistory (StringCollection list, string entry)
|
|
|
|
|
{
|
2013-01-28 00:42:48 +00:00
|
|
|
|
if (list == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-09-02 23:15:37 +00:00
|
|
|
|
foreach (string item in list) {
|
|
|
|
|
if (item == entry) {
|
|
|
|
|
list.Remove(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (list.Count >= 5)
|
|
|
|
|
list.RemoveAt(list.Count - 1);
|
|
|
|
|
|
|
|
|
|
list.Insert(0, entry);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 05:27:35 +00:00
|
|
|
|
private GroupCapabilities CommonCapabilities (IEnumerable<GroupCapabilities> capabilities)
|
|
|
|
|
{
|
|
|
|
|
GroupCapabilities caps = GroupCapabilities.All;
|
|
|
|
|
foreach (GroupCapabilities cap in capabilities)
|
|
|
|
|
caps &= cap;
|
|
|
|
|
return caps;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
#region Event Handlers
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void MainForm_Closing (object sender, CancelEventArgs e)
|
|
|
|
|
{
|
2012-09-02 23:15:37 +00:00
|
|
|
|
Settings.Default.RecentFiles = Settings.Default.RecentFiles;
|
|
|
|
|
Settings.Default.Save();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
if (!ConfirmExit())
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
#region TreeView Event Handlers
|
|
|
|
|
|
|
|
|
|
private void _nodeTree_BeforeExpand (object sender, TreeViewCancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ExpandNode(e.Node);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void _nodeTree_AfterCollapse (object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CollapseNode(e.Node);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
private void _nodeTree_AfterSelect (object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
2012-09-01 23:27:50 +00:00
|
|
|
|
if (e.Node != null)
|
|
|
|
|
UpdateUI(e.Node.Tag as DataNode);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _nodeTree_NodeMouseDoubleClick (object sender, TreeNodeMouseClickEventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.EditNode(e.Node);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 03:59:53 +00:00
|
|
|
|
private void _nodeTree_NodeMouseClick (object sender, TreeNodeMouseClickEventArgs e)
|
|
|
|
|
{
|
2013-05-25 04:11:21 +00:00
|
|
|
|
if (e.Button == MouseButtons.Right) {
|
2013-08-07 01:35:31 +00:00
|
|
|
|
e.Node.ContextMenuStrip = _controller.BuildNodeContextMenu(e.Node, e.Node.Tag as DataNode);
|
2012-09-02 03:59:53 +00:00
|
|
|
|
_nodeTree.SelectedNode = e.Node;
|
2013-05-25 04:11:21 +00:00
|
|
|
|
}
|
2012-09-02 03:59:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void _nodeTree_DragDrop (object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenPaths((string[])e.Data.GetData(DataFormats.FileDrop));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _nodeTree_DragEnter (object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Toolstrip Event Handlers
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void _buttonOpen_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonOpenFolder_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFolder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonSave_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.Save();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
private void _buttonEdit_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.EditSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonRename_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.RenameSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonDelete_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.DeleteSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonCopy_Click (object sernder, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CopySelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonCut_Click (object sernder, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CutSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonPaste_Click (object sernder, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.PasteIntoSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagByteArray_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_BYTE_ARRAY);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagByte_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_BYTE);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagCompound_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_COMPOUND);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagDouble_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_DOUBLE);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagFloat_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_FLOAT);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagInt_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_INT);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagIntArray_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_INT_ARRAY);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagList_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_LIST);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagLong_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_LONG);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagShort_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_SHORT);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _buttonAddTagString_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CreateNode(TagType.TAG_STRING);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void _buttonFindNext_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_searchState != null)
|
|
|
|
|
SearchNextNode();
|
|
|
|
|
else
|
|
|
|
|
SearchNode(_nodeTree.SelectedNode);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-11 18:52:12 +00:00
|
|
|
|
private void _buttonRefresh_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.RefreshSelection();
|
2012-11-11 18:52:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Menu Event Handlers
|
|
|
|
|
|
2012-09-01 23:27:50 +00:00
|
|
|
|
private void _menuItemOpen_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemOpenFolder_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFolder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemOpenMinecraftSaveFolder_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenMinecraftDirectory();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemSave_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.Save();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
private void _menuItemExit_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-09-02 23:15:37 +00:00
|
|
|
|
Settings.Default.Save();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemEditValue_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.EditSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemRename_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.RenameSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemDelete_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.DeleteSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemCopy_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CopySelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemCut_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.CutSelection();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemPaste_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.PasteIntoSelection();
|
2012-09-01 23:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemFind_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SearchNode(_nodeTree.SelectedNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemFindNext_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SearchNextNode();
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemAbout_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
new About().ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 23:15:37 +00:00
|
|
|
|
private void _menuItemRecentPaths_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem item = sender as ToolStripMenuItem;
|
|
|
|
|
if (item == null || !(item.Tag is string))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
OpenPaths(new string[] { item.Tag as string });
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-11 18:52:12 +00:00
|
|
|
|
private void refreshToolStripMenuItem_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
_controller.RefreshSelection();
|
2012-11-11 18:52:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 01:14:45 +00:00
|
|
|
|
private void replaceToolStripMenuItem_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
2012-11-20 06:02:35 +00:00
|
|
|
|
Form form = new FindReplace(this, _controller, _nodeTree.SelectedNode.Tag as DataNode);
|
|
|
|
|
form.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemMoveUp_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_controller.MoveSelectionUp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _menuItemMoveDown_Click (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_controller.MoveSelectionDown();
|
2012-11-15 01:14:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 05:29:32 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|