forked from mirrors/NBTExplorer
Convenience improvements
This commit is contained in:
parent
43f579de7c
commit
92ce098218
8 changed files with 134 additions and 37 deletions
1
About.cs
1
About.cs
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
@ -97,7 +96,7 @@ namespace NBTExplorer
|
|||
private bool ValidateNameInput ()
|
||||
{
|
||||
string text = textBox1.Text.Trim();
|
||||
if (String.IsNullOrWhiteSpace(text)) {
|
||||
if (String.IsNullOrEmpty(text)) {
|
||||
MessageBox.Show("You must provide a nonempty name.");
|
||||
return false;
|
||||
}
|
||||
|
|
1
Find.cs
1
Find.cs
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
|
31
Form1.Designer.cs
generated
31
Form1.Designer.cs
generated
|
@ -49,6 +49,7 @@
|
|||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||
this._buttonOpen = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonOpenFolder = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonSave = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._buttonRename = new System.Windows.Forms.ToolStripButton();
|
||||
|
@ -70,6 +71,7 @@
|
|||
this._nodeContainerContext = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.openSubTreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openMinecraftSaveFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.toolStripContainer1.ContentPanel.SuspendLayout();
|
||||
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
|
||||
|
@ -96,6 +98,7 @@
|
|||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem,
|
||||
this.openFolderToolStripMenuItem,
|
||||
this.openMinecraftSaveFolderToolStripMenuItem,
|
||||
this.toolStripSeparator3,
|
||||
this.saveToolStripMenuItem,
|
||||
this.toolStripSeparator4,
|
||||
|
@ -165,7 +168,7 @@
|
|||
this.findToolStripMenuItem.Image = global::NBTExplorer.Properties.Resources.binocular;
|
||||
this.findToolStripMenuItem.Name = "findToolStripMenuItem";
|
||||
this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
|
||||
this.findToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.findToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||
this.findToolStripMenuItem.Text = "Find...";
|
||||
this.findToolStripMenuItem.Click += new System.EventHandler(this.findToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -174,7 +177,7 @@
|
|||
this.findNextToolStripMenuItem.Image = global::NBTExplorer.Properties.Resources.binocular__arrow;
|
||||
this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem";
|
||||
this.findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3;
|
||||
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||
this.findNextToolStripMenuItem.Text = "Find Next";
|
||||
this.findNextToolStripMenuItem.Click += new System.EventHandler(this.findNextToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -235,6 +238,7 @@
|
|||
//
|
||||
// _nodeTree
|
||||
//
|
||||
this._nodeTree.AllowDrop = true;
|
||||
this._nodeTree.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this._nodeTree.ImageIndex = 0;
|
||||
this._nodeTree.ImageList = this.imageList1;
|
||||
|
@ -243,6 +247,8 @@
|
|||
this._nodeTree.SelectedImageIndex = 0;
|
||||
this._nodeTree.Size = new System.Drawing.Size(562, 351);
|
||||
this._nodeTree.TabIndex = 0;
|
||||
this._nodeTree.DragDrop += new System.Windows.Forms.DragEventHandler(this._nodeTree_DragDrop);
|
||||
this._nodeTree.DragEnter += new System.Windows.Forms.DragEventHandler(this._nodeTree_DragEnter);
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
|
@ -268,6 +274,7 @@
|
|||
this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
|
||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._buttonOpen,
|
||||
this._buttonOpenFolder,
|
||||
this._buttonSave,
|
||||
this.toolStripSeparator1,
|
||||
this._buttonRename,
|
||||
|
@ -302,6 +309,16 @@
|
|||
this._buttonOpen.Text = "Open NBT Data Source";
|
||||
this._buttonOpen.Click += new System.EventHandler(this.toolStripButton1_Click);
|
||||
//
|
||||
// _buttonOpenFolder
|
||||
//
|
||||
this._buttonOpenFolder.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonOpenFolder.Image = global::NBTExplorer.Properties.Resources.folder_open;
|
||||
this._buttonOpenFolder.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonOpenFolder.Name = "_buttonOpenFolder";
|
||||
this._buttonOpenFolder.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonOpenFolder.Text = "Open Folder";
|
||||
this._buttonOpenFolder.Click += new System.EventHandler(this._buttonOpenFolder_Click);
|
||||
//
|
||||
// _buttonSave
|
||||
//
|
||||
this._buttonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
|
@ -489,8 +506,16 @@
|
|||
this.saveItemToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
|
||||
this.saveItemToolStripMenuItem.Text = "Save Node";
|
||||
//
|
||||
// openMinecraftSaveFolderToolStripMenuItem
|
||||
//
|
||||
this.openMinecraftSaveFolderToolStripMenuItem.Name = "openMinecraftSaveFolderToolStripMenuItem";
|
||||
this.openMinecraftSaveFolderToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
|
||||
this.openMinecraftSaveFolderToolStripMenuItem.Text = "Open &Minecraft Save Folder";
|
||||
this.openMinecraftSaveFolderToolStripMenuItem.Click += new System.EventHandler(this.openMinecraftSaveFolderToolStripMenuItem_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(562, 400);
|
||||
|
@ -561,6 +586,8 @@
|
|||
private System.Windows.Forms.ToolStripButton _buttonFindNext;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
|
||||
private System.Windows.Forms.ToolStripButton _buttonOpenFolder;
|
||||
private System.Windows.Forms.ToolStripMenuItem openMinecraftSaveFolderToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
118
Form1.cs
118
Form1.cs
|
@ -26,16 +26,13 @@ namespace NBTExplorer
|
|||
_nodeTree.NodeMouseClick += NodeClicked;
|
||||
_nodeTree.NodeMouseDoubleClick += NodeDoubleClicked;
|
||||
|
||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
path = Path.Combine(path, ".minecraft");
|
||||
path = Path.Combine(path, "saves");
|
||||
|
||||
if (!Directory.Exists(path)) {
|
||||
path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1) {
|
||||
OpenFile(args[1]);
|
||||
}
|
||||
else {
|
||||
OpenMinecraftDir();
|
||||
}
|
||||
|
||||
LoadDirectory(path);
|
||||
_nodeTree.Nodes[0].Expand();
|
||||
}
|
||||
|
||||
public void LoadNbtStream (TreeNodeCollection parent, Stream stream)
|
||||
|
@ -481,6 +478,48 @@ namespace NBTExplorer
|
|||
_buttonAddTagCompound.Enabled = state;
|
||||
}
|
||||
|
||||
public void OpenDirectory (string path)
|
||||
{
|
||||
_nodeTree.Nodes.Clear();
|
||||
|
||||
LoadDirectory(path);
|
||||
|
||||
if (_nodeTree.Nodes.Count > 0) {
|
||||
_nodeTree.Nodes[0].Expand();
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenPaths (string[] paths)
|
||||
{
|
||||
_nodeTree.Nodes.Clear();
|
||||
|
||||
foreach (string path in paths) {
|
||||
if (Directory.Exists(path)) {
|
||||
LoadDirectory(path);
|
||||
}
|
||||
else if (File.Exists(path)) {
|
||||
TryLoadFile(_nodeTree.Nodes, path);
|
||||
}
|
||||
}
|
||||
|
||||
if (_nodeTree.Nodes.Count > 0) {
|
||||
_nodeTree.Nodes[0].Expand();
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenMinecraftDir ()
|
||||
{
|
||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
path = Path.Combine(path, ".minecraft");
|
||||
path = Path.Combine(path, "saves");
|
||||
|
||||
if (!Directory.Exists(path)) {
|
||||
path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
|
||||
}
|
||||
|
||||
OpenDirectory(path);
|
||||
}
|
||||
|
||||
public void LoadDirectory (string path)
|
||||
{
|
||||
LoadDirectory(path, _nodeTree.Nodes);
|
||||
|
@ -559,18 +598,36 @@ namespace NBTExplorer
|
|||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.RestoreDirectory = true;
|
||||
ofd.Multiselect = false;
|
||||
ofd.Multiselect = true;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||
_nodeTree.Nodes.Clear();
|
||||
TryLoadFile(_nodeTree.Nodes, ofd.FileName);
|
||||
OpenPaths(ofd.FileNames);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenFile (string file)
|
||||
{
|
||||
_nodeTree.Nodes.Clear();
|
||||
TryLoadFile(_nodeTree.Nodes, file);
|
||||
}
|
||||
|
||||
private string _openFolderPath = null;
|
||||
private void OpenFolder ()
|
||||
{
|
||||
FolderBrowserDialog ofd = new FolderBrowserDialog();
|
||||
if (_openFolderPath != null)
|
||||
ofd.SelectedPath = _openFolderPath;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||
_openFolderPath = ofd.SelectedPath;
|
||||
OpenDirectory(ofd.SelectedPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveAll ()
|
||||
{
|
||||
if (_nodeTree.Nodes.Count > 0) {
|
||||
SaveNode(_nodeTree.Nodes[0]);
|
||||
foreach (TreeNode node in _nodeTree.Nodes) {
|
||||
SaveNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,11 +684,7 @@ namespace NBTExplorer
|
|||
|
||||
private void openFolderToolStripMenuItem_Click (object sender, EventArgs e)
|
||||
{
|
||||
FolderBrowserDialog ofd = new FolderBrowserDialog();
|
||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||
_nodeTree.Nodes.Clear();
|
||||
LoadDirectory(ofd.SelectedPath);
|
||||
}
|
||||
OpenFolder();
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click (object sender, EventArgs e)
|
||||
|
@ -1138,6 +1191,33 @@ namespace NBTExplorer
|
|||
else
|
||||
FindNext();
|
||||
}
|
||||
|
||||
private void _buttonOpenFolder_Click (object sender, EventArgs e)
|
||||
{
|
||||
OpenFolder();
|
||||
}
|
||||
|
||||
private void DropFile (DragEventArgs e)
|
||||
{
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
OpenPaths(files);
|
||||
}
|
||||
|
||||
private void _nodeTree_DragDrop (object sender, DragEventArgs e)
|
||||
{
|
||||
DropFile(e);
|
||||
}
|
||||
|
||||
private void _nodeTree_DragEnter (object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
private void openMinecraftSaveFolderToolStripMenuItem_Click (object sender, EventArgs e)
|
||||
{
|
||||
OpenMinecraftDir();
|
||||
}
|
||||
}
|
||||
|
||||
public class TagKey : IComparable<TagKey>
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADW
|
||||
LgAAAk1TRnQBSQFMAgEBDgEAAYgBAAGIAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
LgAAAk1TRnQBSQFMAgEBDgEAAaABAAGgAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
AwABQAMAAQEBAAEYBgABMBIAA/wD+SH4A/kD/AMAA/0D+SH4A/kD/WMAAZYBqQG8AVwBhAGuAVwBhAGu
|
||||
AVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGuAVwBhAGu
|
||||
AVwBhAGuAZYBqQG8AwACzwHLArkBsAK5AbACuQGwArkBsAK5AbACuQGwArkBsAK5AbACuQGwArkBsAK5
|
||||
|
@ -517,11 +517,11 @@
|
|||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFySURBVDhPY2CgBthfz8CyP4kl40AiczcM19sxnEHGyHIg
|
||||
tSA9cLv3xrErn6rWXPp+T+f/d7s7wHh2hikKhomD1IDUgvTADdiVwOx+c4r3EWQDlpc4/ofhJYV2cINB
|
||||
akBqQXrgBuyIZ8m9vyz7wbPNDf9heEuj338YXlftARcHyYPUgvTADdgawzz17anlf//fXfUfhu+uKgcy
|
||||
akBqQXrgBuyIZ8m9vyz7wbPNDf9heEuj338YXlftARcHyYPUgvTADdgawzz11fHlf//fXfUfhu+uKgcy
|
||||
IfjMzDS4OEgepBakB27A5ijmGT8vzf//+cRUON7dEfofhjc3+KLIgdSC9MAN2BDFPPvbudn/PxyZCMcg
|
||||
zavKXcCGLCt2QJEDqQXpgRuwOoJ5/qeT0/6/2d8DxyDNID6MRpYDqQXpgRuwPIx58btD/f9f7monCoPU
|
||||
gvTADVgSwrjsFTDun25tIgqD1IL0wA2YH8C4+smWxv8PN9QShUFqQXrgBkzxZNzxYF31//trq4jCILUg
|
||||
PTAD5FKNGee1uTAeJQWD9AANkAMZwg/E4kAsRSIG6QHppQwAAARN3Xh69LLBAAAAAElFTkSuQmCC
|
||||
PTAD5FKNGee1uTAeJQWD9AANkAMZwg/E4kAsRSIG6QHppQwAAOQ03Wz0/VCVAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="_nodeContainerContext.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
|
|
|
@ -37,17 +37,10 @@
|
|||
<ApplicationIcon>dead_bush.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Ionic.Zlib">
|
||||
<HintPath>..\Substrate\SubstrateCS\bin\Release\Ionic.Zlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Substrate">
|
||||
<HintPath>..\Substrate\SubstrateCS\bin\Release\Substrate.dll</HintPath>
|
||||
<HintPath>..\Substrate\SubstrateCS\bin\Release\NET4\Substrate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
@ -103,6 +96,7 @@
|
|||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer
|
||||
|
|
Loading…
Reference in a new issue