Experimental monomac-based version of project
121
NBTExplorerMac/DataNode.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
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; }
|
||||
}
|
||||
}
|
30
NBTExplorerMac/IconRegistry.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public class IconRegistry
|
||||
{
|
||||
private Dictionary<Type, int> _iconRegistry;
|
||||
|
||||
public IconRegistry ()
|
||||
{
|
||||
_iconRegistry = new Dictionary<Type, int>();
|
||||
}
|
||||
|
||||
public int DefaultIcon { get; set; }
|
||||
|
||||
public int Lookup (Type type)
|
||||
{
|
||||
if (_iconRegistry.ContainsKey(type))
|
||||
return _iconRegistry[type];
|
||||
else
|
||||
return DefaultIcon;
|
||||
}
|
||||
|
||||
public void Register (Type type, int iconIndex)
|
||||
{
|
||||
_iconRegistry[type] = iconIndex;
|
||||
}
|
||||
}
|
||||
}
|
18
NBTExplorerMac/Info.plist
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.NBTExplorerMac</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>NBTExplorerMac</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.6</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
19
NBTExplorerMac/LICENSE.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (C) 2011 by Justin Aquadro
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
24
NBTExplorerMac/Mac/AppDelegate.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoMac.Foundation;
|
||||
using MonoMac.AppKit;
|
||||
using MonoMac.ObjCRuntime;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
public partial class AppDelegate : NSApplicationDelegate
|
||||
{
|
||||
MainWindowController mainWindowController;
|
||||
|
||||
public AppDelegate ()
|
||||
{
|
||||
}
|
||||
|
||||
public override void FinishedLaunching (NSObject notification)
|
||||
{
|
||||
mainWindowController = new MainWindowController ();
|
||||
mainWindowController.Window.MakeKeyAndOrderFront (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
NBTExplorerMac/Mac/AppDelegate.designer.cs
generated
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
namespace Test
|
||||
{
|
||||
// Should subclass MonoMac.AppKit.NSResponder
|
||||
[MonoMac.Foundation.Register("AppDelegate")]
|
||||
public partial class AppDelegate
|
||||
{
|
||||
}
|
||||
}
|
||||
|
4074
NBTExplorerMac/Mac/MainMenu.xib
Normal file
35
NBTExplorerMac/Mac/MainWindow.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MonoMac.Foundation;
|
||||
using MonoMac.AppKit;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public partial class MainWindow : MonoMac.AppKit.NSWindow
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
// Called when created from unmanaged code
|
||||
public MainWindow (IntPtr handle) : base (handle)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// Called when created directly from a XIB file
|
||||
[Export ("initWithCoder:")]
|
||||
public MainWindow (NSCoder coder) : base (coder)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// Shared initialization code
|
||||
void Initialize ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
17
NBTExplorerMac/Mac/MainWindow.designer.cs
generated
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
|
||||
// Should subclass MonoMac.AppKit.NSWindow
|
||||
[MonoMac.Foundation.Register("MainWindow")]
|
||||
public partial class MainWindow
|
||||
{
|
||||
}
|
||||
|
||||
// Should subclass MonoMac.AppKit.NSWindowController
|
||||
[MonoMac.Foundation.Register("MainWindowController")]
|
||||
public partial class MainWindowController
|
||||
{
|
||||
}
|
||||
}
|
||||
|
189
NBTExplorerMac/Mac/MainWindow.xib
Normal file
|
@ -0,0 +1,189 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1060</int>
|
||||
<string key="IBDocument.SystemVersion">10D573</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">762</string>
|
||||
<string key="IBDocument.AppKitVersion">1038.29</string>
|
||||
<string key="IBDocument.HIToolboxVersion">460.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="NS.object.0">762</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="2" />
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys" id="0">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSCustomObject" id="1001">
|
||||
<string key="NSClassName">MainWindowController</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1003">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1004">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="748157544">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{131, 74}, {606, 354}}</string>
|
||||
<int key="NSWTFlags">611844096</int>
|
||||
<string key="NSWindowTitle">Window</string>
|
||||
<string key="NSWindowClass">MainWindow</string>
|
||||
<nil key="NSViewClass" />
|
||||
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
|
||||
<object class="NSView" key="NSWindowView" id="312036702">
|
||||
<reference key="NSNextResponder" />
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrameSize">{606, 354}</string>
|
||||
<reference key="NSSuperview" />
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
|
||||
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">window</string>
|
||||
<reference key="source" ref="1001" />
|
||||
<reference key="destination" ref="748157544" />
|
||||
</object>
|
||||
<int key="connectionID">6</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<reference key="object" ref="0" />
|
||||
<reference key="children" ref="1000" />
|
||||
<nil key="parent" />
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="1001" />
|
||||
<reference key="parent" ref="0" />
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="1003" />
|
||||
<reference key="parent" ref="0" />
|
||||
<string key="objectName">First Responder</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-3</int>
|
||||
<reference key="object" ref="1004" />
|
||||
<reference key="parent" ref="0" />
|
||||
<string key="objectName">Application</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">2</int>
|
||||
<reference key="object" ref="748157544" />
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="312036702" />
|
||||
</object>
|
||||
<reference key="parent" ref="0" />
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">3</int>
|
||||
<reference key="object" ref="312036702" />
|
||||
<reference key="parent" ref="748157544" />
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>-1.IBPluginDependency</string>
|
||||
<string>-2.IBPluginDependency</string>
|
||||
<string>-3.IBPluginDependency</string>
|
||||
<string>2.IBEditorWindowLastContentRect</string>
|
||||
<string>2.IBPluginDependency</string>
|
||||
<string>2.IBWindowTemplateEditedContentRect</string>
|
||||
<string>2.NSWindowTemplate.visibleAtLaunch</string>
|
||||
<string>3.IBPluginDependency</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{319, 371}, {606, 354}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{319, 371}, {606, 354}}</string>
|
||||
<boolean value="YES" />
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0" />
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="activeLocalization" />
|
||||
<object class="NSMutableDictionary" key="localizations">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0" />
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID" />
|
||||
<int key="maxID">6</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MainWindow</string>
|
||||
<string key="superclassName">NSWindow</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey" />
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MainWindowController</string>
|
||||
<string key="superclassName">NSWindowController</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey" />
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
|
||||
<integer value="3000" key="NS.object.0" />
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<nil key="IBDocument.LastKnownRelativeProjectPath" />
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
</data>
|
||||
</archive>
|
48
NBTExplorerMac/Mac/MainWindowController.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MonoMac.Foundation;
|
||||
using MonoMac.AppKit;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public partial class MainWindowController : MonoMac.AppKit.NSWindowController
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
// Called when created from unmanaged code
|
||||
public MainWindowController (IntPtr handle) : base (handle)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// Called when created directly from a XIB file
|
||||
[Export ("initWithCoder:")]
|
||||
public MainWindowController (NSCoder coder) : base (coder)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// Call to load from the XIB/NIB file
|
||||
public MainWindowController () : base ("MainWindow")
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// Shared initialization code
|
||||
void Initialize ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//strongly typed window accessor
|
||||
public new MainWindow Window {
|
||||
get {
|
||||
return (MainWindow)base.Window;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
NBTExplorerMac/Mac/TreeDataNode.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public class TreeDataNode
|
||||
{
|
||||
public TreeDataNode ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
NBTExplorerMac/Mac/TreeDataSource.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace NBTExplorer.Mac
|
||||
{
|
||||
public class TreeDataSource
|
||||
{
|
||||
public TreeDataSource ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
718
NBTExplorerMac/MainForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,718 @@
|
|||
namespace NBTExplorer
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent ()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemOpen = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemOpenFolder = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemOpenMinecraftSaveFolder = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._menuItemSave = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._menuItemExit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemCut = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemCopy = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemPaste = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._menuItemRename = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemEditValue = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemDelete = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemFind = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemFindNext = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemAbout = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._nodeTree = new System.Windows.Forms.TreeView();
|
||||
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._buttonCut = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonCopy = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonPaste = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._buttonRename = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonEdit = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonDelete = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._buttonAddTagByte = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagShort = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagInt = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagLong = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagFloat = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagDouble = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagByteArray = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagIntArray = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagString = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagList = new System.Windows.Forms.ToolStripButton();
|
||||
this._buttonAddTagCompound = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this._buttonFindNext = new System.Windows.Forms.ToolStripButton();
|
||||
this.BottomToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.TopToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.RightToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.LeftToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.ContentPanel = new System.Windows.Forms.ToolStripContentPanel();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemRecentFiles = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._menuItemRecentFolders = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.editToolStripMenuItem,
|
||||
this.searchToolStripMenuItem,
|
||||
this.helpToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(619, 24);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._menuItemOpen,
|
||||
this._menuItemOpenFolder,
|
||||
this._menuItemOpenMinecraftSaveFolder,
|
||||
this.toolStripSeparator3,
|
||||
this._menuItemSave,
|
||||
this.toolStripSeparator4,
|
||||
this._menuItemRecentFiles,
|
||||
this._menuItemRecentFolders,
|
||||
this.toolStripSeparator8,
|
||||
this._menuItemExit});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "&File";
|
||||
//
|
||||
// _menuItemOpen
|
||||
//
|
||||
this._menuItemOpen.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemOpen.Image")));
|
||||
this._menuItemOpen.Name = "_menuItemOpen";
|
||||
this._menuItemOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||
this._menuItemOpen.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemOpen.Text = "&Open...";
|
||||
//
|
||||
// _menuItemOpenFolder
|
||||
//
|
||||
this._menuItemOpenFolder.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemOpenFolder.Image")));
|
||||
this._menuItemOpenFolder.Name = "_menuItemOpenFolder";
|
||||
this._menuItemOpenFolder.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||
| System.Windows.Forms.Keys.O)));
|
||||
this._menuItemOpenFolder.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemOpenFolder.Text = "Open &Folder...";
|
||||
//
|
||||
// _menuItemOpenMinecraftSaveFolder
|
||||
//
|
||||
this._menuItemOpenMinecraftSaveFolder.Name = "_menuItemOpenMinecraftSaveFolder";
|
||||
this._menuItemOpenMinecraftSaveFolder.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemOpenMinecraftSaveFolder.Text = "Open &Minecraft Save Folder";
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(220, 6);
|
||||
//
|
||||
// _menuItemSave
|
||||
//
|
||||
this._menuItemSave.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemSave.Image")));
|
||||
this._menuItemSave.Name = "_menuItemSave";
|
||||
this._menuItemSave.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this._menuItemSave.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemSave.Text = "&Save";
|
||||
//
|
||||
// toolStripSeparator4
|
||||
//
|
||||
this.toolStripSeparator4.Name = "toolStripSeparator4";
|
||||
this.toolStripSeparator4.Size = new System.Drawing.Size(220, 6);
|
||||
//
|
||||
// _menuItemExit
|
||||
//
|
||||
this._menuItemExit.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemExit.Image")));
|
||||
this._menuItemExit.Name = "_menuItemExit";
|
||||
this._menuItemExit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
|
||||
this._menuItemExit.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemExit.Text = "E&xit";
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._menuItemCut,
|
||||
this._menuItemCopy,
|
||||
this._menuItemPaste,
|
||||
this.toolStripSeparator7,
|
||||
this._menuItemRename,
|
||||
this._menuItemEditValue,
|
||||
this._menuItemDelete});
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
|
||||
this.editToolStripMenuItem.Text = "&Edit";
|
||||
//
|
||||
// _menuItemCut
|
||||
//
|
||||
this._menuItemCut.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemCut.Image")));
|
||||
this._menuItemCut.Name = "_menuItemCut";
|
||||
this._menuItemCut.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X)));
|
||||
this._menuItemCut.Size = new System.Drawing.Size(166, 22);
|
||||
this._menuItemCut.Text = "Cu&t";
|
||||
//
|
||||
// _menuItemCopy
|
||||
//
|
||||
this._menuItemCopy.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemCopy.Image")));
|
||||
this._menuItemCopy.Name = "_menuItemCopy";
|
||||
this._menuItemCopy.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this._menuItemCopy.Size = new System.Drawing.Size(166, 22);
|
||||
this._menuItemCopy.Text = "&Copy";
|
||||
//
|
||||
// _menuItemPaste
|
||||
//
|
||||
this._menuItemPaste.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemPaste.Image")));
|
||||
this._menuItemPaste.Name = "_menuItemPaste";
|
||||
this._menuItemPaste.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V)));
|
||||
this._menuItemPaste.Size = new System.Drawing.Size(166, 22);
|
||||
this._menuItemPaste.Text = "&Paste";
|
||||
//
|
||||
// toolStripSeparator7
|
||||
//
|
||||
this.toolStripSeparator7.Name = "toolStripSeparator7";
|
||||
this.toolStripSeparator7.Size = new System.Drawing.Size(163, 6);
|
||||
//
|
||||
// _menuItemRename
|
||||
//
|
||||
this._menuItemRename.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemRename.Image")));
|
||||
this._menuItemRename.Name = "_menuItemRename";
|
||||
this._menuItemRename.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R)));
|
||||
this._menuItemRename.Size = new System.Drawing.Size(166, 22);
|
||||
this._menuItemRename.Text = "&Rename";
|
||||
//
|
||||
// _menuItemEditValue
|
||||
//
|
||||
this._menuItemEditValue.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemEditValue.Image")));
|
||||
this._menuItemEditValue.Name = "_menuItemEditValue";
|
||||
this._menuItemEditValue.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
|
||||
this._menuItemEditValue.Size = new System.Drawing.Size(166, 22);
|
||||
this._menuItemEditValue.Text = "&Edit Value";
|
||||
//
|
||||
// _menuItemDelete
|
||||
//
|
||||
this._menuItemDelete.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemDelete.Image")));
|
||||
this._menuItemDelete.Name = "_menuItemDelete";
|
||||
this._menuItemDelete.ShortcutKeys = System.Windows.Forms.Keys.Delete;
|
||||
this._menuItemDelete.Size = new System.Drawing.Size(166, 22);
|
||||
this._menuItemDelete.Text = "&Delete";
|
||||
//
|
||||
// searchToolStripMenuItem
|
||||
//
|
||||
this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._menuItemFind,
|
||||
this._menuItemFindNext});
|
||||
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
|
||||
this.searchToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
|
||||
this.searchToolStripMenuItem.Text = "&Search";
|
||||
//
|
||||
// _menuItemFind
|
||||
//
|
||||
this._menuItemFind.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemFind.Image")));
|
||||
this._menuItemFind.Name = "_menuItemFind";
|
||||
this._menuItemFind.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
|
||||
this._menuItemFind.Size = new System.Drawing.Size(146, 22);
|
||||
this._menuItemFind.Text = "Find...";
|
||||
//
|
||||
// _menuItemFindNext
|
||||
//
|
||||
this._menuItemFindNext.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemFindNext.Image")));
|
||||
this._menuItemFindNext.Name = "_menuItemFindNext";
|
||||
this._menuItemFindNext.ShortcutKeys = System.Windows.Forms.Keys.F3;
|
||||
this._menuItemFindNext.Size = new System.Drawing.Size(146, 22);
|
||||
this._menuItemFindNext.Text = "Find Next";
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._menuItemAbout});
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.helpToolStripMenuItem.Text = "&Help";
|
||||
//
|
||||
// _menuItemAbout
|
||||
//
|
||||
this._menuItemAbout.Image = ((System.Drawing.Image)(resources.GetObject("_menuItemAbout.Image")));
|
||||
this._menuItemAbout.Name = "_menuItemAbout";
|
||||
this._menuItemAbout.ShortcutKeys = System.Windows.Forms.Keys.F1;
|
||||
this._menuItemAbout.Size = new System.Drawing.Size(126, 22);
|
||||
this._menuItemAbout.Text = "&About";
|
||||
//
|
||||
// _nodeTree
|
||||
//
|
||||
this._nodeTree.AllowDrop = true;
|
||||
this._nodeTree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._nodeTree.ImageIndex = 0;
|
||||
this._nodeTree.ImageList = this.imageList1;
|
||||
this._nodeTree.ItemHeight = 18;
|
||||
this._nodeTree.Location = new System.Drawing.Point(0, 49);
|
||||
this._nodeTree.Margin = new System.Windows.Forms.Padding(0);
|
||||
this._nodeTree.Name = "_nodeTree";
|
||||
this._nodeTree.SelectedImageIndex = 0;
|
||||
this._nodeTree.Size = new System.Drawing.Size(619, 374);
|
||||
this._nodeTree.TabIndex = 0;
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList1.Images.SetKeyName(0, "document-attribute-b.png");
|
||||
this.imageList1.Images.SetKeyName(1, "document-attribute-s.png");
|
||||
this.imageList1.Images.SetKeyName(2, "document-attribute-i.png");
|
||||
this.imageList1.Images.SetKeyName(3, "document-attribute-l.png");
|
||||
this.imageList1.Images.SetKeyName(4, "document-attribute-f.png");
|
||||
this.imageList1.Images.SetKeyName(5, "document-attribute-d.png");
|
||||
this.imageList1.Images.SetKeyName(6, "edit-code.png");
|
||||
this.imageList1.Images.SetKeyName(7, "edit-small-caps.png");
|
||||
this.imageList1.Images.SetKeyName(8, "edit-list.png");
|
||||
this.imageList1.Images.SetKeyName(9, "box.png");
|
||||
this.imageList1.Images.SetKeyName(10, "folder.png");
|
||||
this.imageList1.Images.SetKeyName(11, "block.png");
|
||||
this.imageList1.Images.SetKeyName(12, "wooden-box.png");
|
||||
this.imageList1.Images.SetKeyName(13, "map.png");
|
||||
this.imageList1.Images.SetKeyName(14, "edit-code-i.png");
|
||||
this.imageList1.Images.SetKeyName(15, "question-white.png");
|
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._buttonOpen,
|
||||
this._buttonOpenFolder,
|
||||
this._buttonSave,
|
||||
this.toolStripSeparator1,
|
||||
this._buttonCut,
|
||||
this._buttonCopy,
|
||||
this._buttonPaste,
|
||||
this.toolStripSeparator6,
|
||||
this._buttonRename,
|
||||
this._buttonEdit,
|
||||
this._buttonDelete,
|
||||
this.toolStripSeparator2,
|
||||
this._buttonAddTagByte,
|
||||
this._buttonAddTagShort,
|
||||
this._buttonAddTagInt,
|
||||
this._buttonAddTagLong,
|
||||
this._buttonAddTagFloat,
|
||||
this._buttonAddTagDouble,
|
||||
this._buttonAddTagByteArray,
|
||||
this._buttonAddTagIntArray,
|
||||
this._buttonAddTagString,
|
||||
this._buttonAddTagList,
|
||||
this._buttonAddTagCompound,
|
||||
this.toolStripSeparator5,
|
||||
this._buttonFindNext});
|
||||
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
|
||||
this.toolStrip1.Name = "toolStrip1";
|
||||
this.toolStrip1.Size = new System.Drawing.Size(619, 25);
|
||||
this.toolStrip1.Stretch = true;
|
||||
this.toolStrip1.TabIndex = 0;
|
||||
//
|
||||
// _buttonOpen
|
||||
//
|
||||
this._buttonOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonOpen.Image = ((System.Drawing.Image)(resources.GetObject("_buttonOpen.Image")));
|
||||
this._buttonOpen.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonOpen.Name = "_buttonOpen";
|
||||
this._buttonOpen.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonOpen.Text = "Open NBT Data Source";
|
||||
//
|
||||
// _buttonOpenFolder
|
||||
//
|
||||
this._buttonOpenFolder.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonOpenFolder.Image = ((System.Drawing.Image)(resources.GetObject("_buttonOpenFolder.Image")));
|
||||
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";
|
||||
//
|
||||
// _buttonSave
|
||||
//
|
||||
this._buttonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonSave.Image = ((System.Drawing.Image)(resources.GetObject("_buttonSave.Image")));
|
||||
this._buttonSave.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonSave.Name = "_buttonSave";
|
||||
this._buttonSave.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonSave.Text = "Save All Modified Tags";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// _buttonCut
|
||||
//
|
||||
this._buttonCut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonCut.Image = ((System.Drawing.Image)(resources.GetObject("_buttonCut.Image")));
|
||||
this._buttonCut.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonCut.Name = "_buttonCut";
|
||||
this._buttonCut.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonCut.Text = "Cut";
|
||||
//
|
||||
// _buttonCopy
|
||||
//
|
||||
this._buttonCopy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonCopy.Image = ((System.Drawing.Image)(resources.GetObject("_buttonCopy.Image")));
|
||||
this._buttonCopy.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonCopy.Name = "_buttonCopy";
|
||||
this._buttonCopy.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonCopy.Text = "Copy";
|
||||
//
|
||||
// _buttonPaste
|
||||
//
|
||||
this._buttonPaste.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonPaste.Image = ((System.Drawing.Image)(resources.GetObject("_buttonPaste.Image")));
|
||||
this._buttonPaste.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonPaste.Name = "_buttonPaste";
|
||||
this._buttonPaste.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonPaste.Text = "Paste";
|
||||
//
|
||||
// toolStripSeparator6
|
||||
//
|
||||
this.toolStripSeparator6.Name = "toolStripSeparator6";
|
||||
this.toolStripSeparator6.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// _buttonRename
|
||||
//
|
||||
this._buttonRename.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonRename.Image = ((System.Drawing.Image)(resources.GetObject("_buttonRename.Image")));
|
||||
this._buttonRename.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonRename.Name = "_buttonRename";
|
||||
this._buttonRename.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonRename.Text = "Rename Tag";
|
||||
//
|
||||
// _buttonEdit
|
||||
//
|
||||
this._buttonEdit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonEdit.Image = ((System.Drawing.Image)(resources.GetObject("_buttonEdit.Image")));
|
||||
this._buttonEdit.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonEdit.Name = "_buttonEdit";
|
||||
this._buttonEdit.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonEdit.Text = "Edit Tag Value";
|
||||
//
|
||||
// _buttonDelete
|
||||
//
|
||||
this._buttonDelete.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonDelete.Image = ((System.Drawing.Image)(resources.GetObject("_buttonDelete.Image")));
|
||||
this._buttonDelete.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonDelete.Name = "_buttonDelete";
|
||||
this._buttonDelete.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonDelete.Text = "Delete Tag";
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// _buttonAddTagByte
|
||||
//
|
||||
this._buttonAddTagByte.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagByte.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagByte.Image")));
|
||||
this._buttonAddTagByte.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagByte.Name = "_buttonAddTagByte";
|
||||
this._buttonAddTagByte.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagByte.Text = "Add Byte Tag";
|
||||
//
|
||||
// _buttonAddTagShort
|
||||
//
|
||||
this._buttonAddTagShort.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagShort.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagShort.Image")));
|
||||
this._buttonAddTagShort.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagShort.Name = "_buttonAddTagShort";
|
||||
this._buttonAddTagShort.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagShort.Text = "Add Short Tag";
|
||||
//
|
||||
// _buttonAddTagInt
|
||||
//
|
||||
this._buttonAddTagInt.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagInt.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagInt.Image")));
|
||||
this._buttonAddTagInt.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagInt.Name = "_buttonAddTagInt";
|
||||
this._buttonAddTagInt.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagInt.Text = "Add Int Tag";
|
||||
//
|
||||
// _buttonAddTagLong
|
||||
//
|
||||
this._buttonAddTagLong.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagLong.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagLong.Image")));
|
||||
this._buttonAddTagLong.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagLong.Name = "_buttonAddTagLong";
|
||||
this._buttonAddTagLong.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagLong.Text = "Add Long Tag";
|
||||
//
|
||||
// _buttonAddTagFloat
|
||||
//
|
||||
this._buttonAddTagFloat.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagFloat.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagFloat.Image")));
|
||||
this._buttonAddTagFloat.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagFloat.Name = "_buttonAddTagFloat";
|
||||
this._buttonAddTagFloat.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagFloat.Text = "Add Float Tag";
|
||||
//
|
||||
// _buttonAddTagDouble
|
||||
//
|
||||
this._buttonAddTagDouble.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagDouble.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagDouble.Image")));
|
||||
this._buttonAddTagDouble.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagDouble.Name = "_buttonAddTagDouble";
|
||||
this._buttonAddTagDouble.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagDouble.Text = "Add Double Tag";
|
||||
//
|
||||
// _buttonAddTagByteArray
|
||||
//
|
||||
this._buttonAddTagByteArray.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagByteArray.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagByteArray.Image")));
|
||||
this._buttonAddTagByteArray.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagByteArray.Name = "_buttonAddTagByteArray";
|
||||
this._buttonAddTagByteArray.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagByteArray.Text = "Add Byte Array Tag";
|
||||
//
|
||||
// _buttonAddTagIntArray
|
||||
//
|
||||
this._buttonAddTagIntArray.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagIntArray.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagIntArray.Image")));
|
||||
this._buttonAddTagIntArray.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this._buttonAddTagIntArray.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagIntArray.Name = "_buttonAddTagIntArray";
|
||||
this._buttonAddTagIntArray.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagIntArray.Text = "Add Int Array Tag";
|
||||
//
|
||||
// _buttonAddTagString
|
||||
//
|
||||
this._buttonAddTagString.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagString.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagString.Image")));
|
||||
this._buttonAddTagString.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagString.Name = "_buttonAddTagString";
|
||||
this._buttonAddTagString.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagString.Text = "Add String Tag";
|
||||
//
|
||||
// _buttonAddTagList
|
||||
//
|
||||
this._buttonAddTagList.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagList.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagList.Image")));
|
||||
this._buttonAddTagList.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagList.Name = "_buttonAddTagList";
|
||||
this._buttonAddTagList.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagList.Text = "Add List Tag";
|
||||
//
|
||||
// _buttonAddTagCompound
|
||||
//
|
||||
this._buttonAddTagCompound.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonAddTagCompound.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagCompound.Image")));
|
||||
this._buttonAddTagCompound.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonAddTagCompound.Name = "_buttonAddTagCompound";
|
||||
this._buttonAddTagCompound.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonAddTagCompound.Text = "Add Compound Tag";
|
||||
//
|
||||
// toolStripSeparator5
|
||||
//
|
||||
this.toolStripSeparator5.Name = "toolStripSeparator5";
|
||||
this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// _buttonFindNext
|
||||
//
|
||||
this._buttonFindNext.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this._buttonFindNext.Image = ((System.Drawing.Image)(resources.GetObject("_buttonFindNext.Image")));
|
||||
this._buttonFindNext.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this._buttonFindNext.Name = "_buttonFindNext";
|
||||
this._buttonFindNext.Size = new System.Drawing.Size(23, 22);
|
||||
this._buttonFindNext.Text = "Find / Find Next";
|
||||
//
|
||||
// BottomToolStripPanel
|
||||
//
|
||||
this.BottomToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.BottomToolStripPanel.Name = "BottomToolStripPanel";
|
||||
this.BottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.BottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.BottomToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// TopToolStripPanel
|
||||
//
|
||||
this.TopToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.TopToolStripPanel.Name = "TopToolStripPanel";
|
||||
this.TopToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.TopToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.TopToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// RightToolStripPanel
|
||||
//
|
||||
this.RightToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.RightToolStripPanel.Name = "RightToolStripPanel";
|
||||
this.RightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.RightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.RightToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// LeftToolStripPanel
|
||||
//
|
||||
this.LeftToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.LeftToolStripPanel.Name = "LeftToolStripPanel";
|
||||
this.LeftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.LeftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.LeftToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// ContentPanel
|
||||
//
|
||||
this.ContentPanel.Size = new System.Drawing.Size(562, 376);
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.testToolStripMenuItem});
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(97, 26);
|
||||
//
|
||||
// testToolStripMenuItem
|
||||
//
|
||||
this.testToolStripMenuItem.Name = "testToolStripMenuItem";
|
||||
this.testToolStripMenuItem.Size = new System.Drawing.Size(96, 22);
|
||||
this.testToolStripMenuItem.Text = "Test";
|
||||
//
|
||||
// _menuItemRecentFiles
|
||||
//
|
||||
this._menuItemRecentFiles.Name = "_menuItemRecentFiles";
|
||||
this._menuItemRecentFiles.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemRecentFiles.Text = "Recent Files";
|
||||
//
|
||||
// _menuItemRecentFolders
|
||||
//
|
||||
this._menuItemRecentFolders.Name = "_menuItemRecentFolders";
|
||||
this._menuItemRecentFolders.Size = new System.Drawing.Size(223, 22);
|
||||
this._menuItemRecentFolders.Text = "Recent Folders";
|
||||
//
|
||||
// toolStripSeparator8
|
||||
//
|
||||
this.toolStripSeparator8.Name = "toolStripSeparator8";
|
||||
this.toolStripSeparator8.Size = new System.Drawing.Size(220, 6);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(619, 423);
|
||||
this.Controls.Add(this.toolStrip1);
|
||||
this.Controls.Add(this._nodeTree);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "MainForm";
|
||||
this.Text = "NBTExplorer";
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.toolStrip1.ResumeLayout(false);
|
||||
this.toolStrip1.PerformLayout();
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
|
||||
private System.Windows.Forms.TreeView _nodeTree;
|
||||
private System.Windows.Forms.ToolStrip toolStrip1;
|
||||
private System.Windows.Forms.ToolStripButton _buttonOpen;
|
||||
private System.Windows.Forms.ToolStripButton _buttonSave;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripButton _buttonRename;
|
||||
private System.Windows.Forms.ToolStripButton _buttonEdit;
|
||||
private System.Windows.Forms.ToolStripButton _buttonDelete;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagByte;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagShort;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagInt;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagLong;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagFloat;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagDouble;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagByteArray;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagList;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagCompound;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagString;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemAbout;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemOpen;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemOpenFolder;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemSave;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemExit;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemFind;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemFindNext;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
|
||||
private System.Windows.Forms.ToolStripButton _buttonFindNext;
|
||||
private System.Windows.Forms.ToolStripButton _buttonOpenFolder;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemOpenMinecraftSaveFolder;
|
||||
private System.Windows.Forms.ToolStripPanel BottomToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripPanel TopToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripPanel RightToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripPanel LeftToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripContentPanel ContentPanel;
|
||||
private System.Windows.Forms.ToolStripButton _buttonAddTagIntArray;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemCut;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemCopy;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemPaste;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemRename;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemEditValue;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemDelete;
|
||||
private System.Windows.Forms.ToolStripButton _buttonCut;
|
||||
private System.Windows.Forms.ToolStripButton _buttonCopy;
|
||||
private System.Windows.Forms.ToolStripButton _buttonPaste;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemRecentFiles;
|
||||
private System.Windows.Forms.ToolStripMenuItem _menuItemRecentFolders;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
|
||||
}
|
||||
}
|
||||
|
983
NBTExplorerMac/MainForm.cs
Normal file
|
@ -0,0 +1,983 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private static Dictionary<TagType, int> _tagIconIndex;
|
||||
|
||||
private IconRegistry _iconRegistry;
|
||||
|
||||
private string _openFolderPath = null;
|
||||
|
||||
static MainForm ()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public MainForm ()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeIconRegistry();
|
||||
|
||||
FormClosing += MainForm_Closing;
|
||||
|
||||
_nodeTree.BeforeExpand += _nodeTree_BeforeExpand;
|
||||
_nodeTree.AfterCollapse += _nodeTree_AfterCollapse;
|
||||
_nodeTree.AfterSelect += _nodeTree_AfterSelect;
|
||||
_nodeTree.NodeMouseDoubleClick += _nodeTree_NodeMouseDoubleClick;
|
||||
_nodeTree.NodeMouseClick += _nodeTree_NodeMouseClick;
|
||||
_nodeTree.DragEnter += _nodeTree_DragEnter;
|
||||
_nodeTree.DragDrop += _nodeTree_DragDrop;
|
||||
|
||||
_buttonOpen.Click += _buttonOpen_Click;
|
||||
_buttonOpenFolder.Click += _buttonOpenFolder_Click;
|
||||
_buttonSave.Click += _buttonSave_Click;
|
||||
_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;
|
||||
_buttonFindNext.Click += _buttonFindNext_Click;
|
||||
|
||||
_menuItemOpen.Click += _menuItemOpen_Click;
|
||||
_menuItemOpenFolder.Click += _menuItemOpenFolder_Click;
|
||||
_menuItemOpenMinecraftSaveFolder.Click += _menuItemOpenMinecraftSaveFolder_Click;
|
||||
_menuItemSave.Click += _menuItemSave_Click;
|
||||
_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;
|
||||
_menuItemFind.Click += _menuItemFind_Click;
|
||||
_menuItemFindNext.Click += _menuItemFindNext_Click;
|
||||
_menuItemAbout.Click += _menuItemAbout_Click;
|
||||
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1) {
|
||||
string[] paths = new string[args.Length - 1];
|
||||
Array.Copy(args, 1, paths, 0, paths.Length);
|
||||
OpenPaths(paths);
|
||||
}
|
||||
else {
|
||||
OpenMinecraftDirectory();
|
||||
}
|
||||
|
||||
UpdateOpenMenu();
|
||||
}
|
||||
|
||||
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);
|
||||
_iconRegistry.Register(typeof(CubicRegionDataNode), 11);
|
||||
_iconRegistry.Register(typeof(NbtFileDataNode), 12);
|
||||
_iconRegistry.Register(typeof(TagIntArrayDataNode), 14);
|
||||
}
|
||||
|
||||
private void OpenFile ()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.RestoreDirectory = true;
|
||||
ofd.Multiselect = true;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||
OpenPaths(ofd.FileNames);
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void OpenFolder ()
|
||||
{
|
||||
FolderBrowserDialog ofd = new FolderBrowserDialog();
|
||||
if (_openFolderPath != null)
|
||||
ofd.SelectedPath = _openFolderPath;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||
_openFolderPath = ofd.SelectedPath;
|
||||
OpenPaths(new string[] { ofd.SelectedPath });
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void OpenPaths (string[] paths)
|
||||
{
|
||||
_nodeTree.Nodes.Clear();
|
||||
|
||||
foreach (string path in paths) {
|
||||
if (Directory.Exists(path)) {
|
||||
DirectoryDataNode node = new DirectoryDataNode(path);
|
||||
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
||||
|
||||
AddPathToHistory(Settings.Default.RecentDirectories, path);
|
||||
}
|
||||
else if (File.Exists(path)) {
|
||||
DataNode node = null;
|
||||
foreach (var item in FileTypeRegistry.RegisteredTypes) {
|
||||
if (item.Value.NamePatternTest(path))
|
||||
node = item.Value.NodeCreate(path);
|
||||
}
|
||||
|
||||
if (node != null) {
|
||||
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
||||
AddPathToHistory(Settings.Default.RecentFiles, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_nodeTree.Nodes.Count > 0) {
|
||||
_nodeTree.Nodes[0].Expand();
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
UpdateOpenMenu();
|
||||
}
|
||||
|
||||
private void OpenMinecraftDirectory ()
|
||||
{
|
||||
try {
|
||||
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);
|
||||
}
|
||||
|
||||
OpenPaths(new string[] { path });
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessageBox.Show("Could not open default Minecraft save directory");
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
try {
|
||||
OpenPaths(new string[] { Directory.GetCurrentDirectory() });
|
||||
}
|
||||
catch (Exception) {
|
||||
MessageBox.Show("Could not open current directory, this tool is probably not compatible with your platform.");
|
||||
Console.WriteLine(e.Message);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private TreeNode CreateUnexpandedNode (DataNode node)
|
||||
{
|
||||
TreeNode frontNode = new TreeNode(node.NodeDisplay);
|
||||
frontNode.ImageIndex = _iconRegistry.Lookup(node.GetType());
|
||||
frontNode.SelectedImageIndex = frontNode.ImageIndex;
|
||||
frontNode.Tag = node;
|
||||
frontNode.ContextMenuStrip = BuildNodeContextMenu(node);
|
||||
|
||||
if (node.HasUnexpandedChildren || node.Nodes.Count > 0)
|
||||
frontNode.Nodes.Add(new TreeNode());
|
||||
|
||||
return frontNode;
|
||||
}
|
||||
|
||||
private ContextMenuStrip BuildNodeContextMenu (DataNode node)
|
||||
{
|
||||
if (node == null)
|
||||
return null;
|
||||
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
|
||||
if (node.CanReoderNode) {
|
||||
ToolStripMenuItem itemUp = new ToolStripMenuItem("Move &Up", Properties.Resources.ArrowUp, _contextMoveUp_Click);
|
||||
ToolStripMenuItem itemDn = new ToolStripMenuItem("Move &Down", Properties.Resources.ArrowDown, _contextMoveDown_Click);
|
||||
|
||||
itemUp.Enabled = node.CanMoveNodeUp;
|
||||
itemDn.Enabled = node.CanMoveNodeDown;
|
||||
|
||||
menu.Items.Add(itemUp);
|
||||
menu.Items.Add(itemDn);
|
||||
}
|
||||
|
||||
return (menu.Items.Count > 0) ? menu : null;
|
||||
}
|
||||
|
||||
private void _contextMoveUp_Click (object sender, EventArgs e)
|
||||
{
|
||||
TreeNode frontNode = _nodeTree.SelectedNode;
|
||||
if (frontNode == null)
|
||||
return;
|
||||
|
||||
DataNode node = frontNode.Tag as DataNode;
|
||||
if (node == null || !node.CanMoveNodeUp)
|
||||
return;
|
||||
|
||||
node.ChangeRelativePosition(-1);
|
||||
RefreshChildNodes(frontNode.Parent, node.Parent);
|
||||
}
|
||||
|
||||
private void _contextMoveDown_Click (object sender, EventArgs e)
|
||||
{
|
||||
TreeNode frontNode = _nodeTree.SelectedNode;
|
||||
if (frontNode == null)
|
||||
return;
|
||||
|
||||
DataNode node = frontNode.Tag as DataNode;
|
||||
if (node == null || !node.CanMoveNodeDown)
|
||||
return;
|
||||
|
||||
node.ChangeRelativePosition(1);
|
||||
RefreshChildNodes(frontNode.Parent, node.Parent);
|
||||
}
|
||||
|
||||
private void ExpandNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
if (node.IsExpanded)
|
||||
return;
|
||||
|
||||
node.Nodes.Clear();
|
||||
|
||||
DataNode backNode = node.Tag as DataNode;
|
||||
if (!backNode.IsExpanded)
|
||||
backNode.Expand();
|
||||
|
||||
foreach (DataNode child in backNode.Nodes)
|
||||
node.Nodes.Add(CreateUnexpandedNode(child));
|
||||
}
|
||||
|
||||
private void CollapseNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode backNode = node.Tag as DataNode;
|
||||
if (backNode.IsModified)
|
||||
return;
|
||||
|
||||
backNode.Collapse();
|
||||
|
||||
node.Nodes.Clear();
|
||||
if (backNode.HasUnexpandedChildren)
|
||||
node.Nodes.Add(new TreeNode());
|
||||
}
|
||||
|
||||
private void CreateNode (TreeNode node, TagType type)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanCreateTag(type))
|
||||
return;
|
||||
|
||||
if (dataNode.CreateNode(type)) {
|
||||
node.Text = dataNode.NodeDisplay;
|
||||
RefreshChildNodes(node, dataNode);
|
||||
UpdateUI(dataNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshChildNodes (TreeNode node, DataNode dataNode)
|
||||
{
|
||||
Dictionary<DataNode, TreeNode> currentNodes = new Dictionary<DataNode, TreeNode>();
|
||||
foreach (TreeNode child in node.Nodes) {
|
||||
if (child.Tag is DataNode)
|
||||
currentNodes.Add(child.Tag as DataNode, child);
|
||||
}
|
||||
|
||||
node.Nodes.Clear();
|
||||
foreach (DataNode child in dataNode.Nodes) {
|
||||
if (!currentNodes.ContainsKey(child))
|
||||
node.Nodes.Add(CreateUnexpandedNode(child));
|
||||
else
|
||||
node.Nodes.Add(currentNodes[child]);
|
||||
}
|
||||
|
||||
foreach (TreeNode child in node.Nodes)
|
||||
child.ContextMenuStrip = BuildNodeContextMenu(child.Tag as DataNode);
|
||||
|
||||
if (node.Nodes.Count == 0 && dataNode.HasUnexpandedChildren) {
|
||||
ExpandNode(node);
|
||||
node.Expand();
|
||||
}
|
||||
}
|
||||
|
||||
private void EditNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanEditNode)
|
||||
return;
|
||||
|
||||
if (dataNode.EditNode()) {
|
||||
node.Text = dataNode.NodeDisplay;
|
||||
UpdateUI(dataNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenameNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanRenameNode)
|
||||
return;
|
||||
|
||||
if (dataNode.RenameNode()) {
|
||||
node.Text = dataNode.NodeDisplay;
|
||||
UpdateUI(dataNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanDeleteNode)
|
||||
return;
|
||||
|
||||
if (dataNode.DeleteNode()) {
|
||||
UpdateUI(node.Parent.Tag as DataNode);
|
||||
UpdateNodeText(node.Parent);
|
||||
node.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanCopyNode)
|
||||
return;
|
||||
|
||||
dataNode.CopyNode();
|
||||
}
|
||||
|
||||
private void CutNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanCutNode)
|
||||
return;
|
||||
|
||||
if (dataNode.CutNode()) {
|
||||
UpdateUI(node.Parent.Tag as DataNode);
|
||||
UpdateNodeText(node.Parent);
|
||||
node.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void PasteNode (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (!dataNode.CanPasteIntoNode)
|
||||
return;
|
||||
|
||||
if (dataNode.PasteNode()) {
|
||||
node.Text = dataNode.NodeDisplay;
|
||||
RefreshChildNodes(node, dataNode);
|
||||
UpdateUI(dataNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void Save ()
|
||||
{
|
||||
foreach (TreeNode node in _nodeTree.Nodes) {
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (dataNode != null)
|
||||
dataNode.Save();
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private bool ConfirmExit ()
|
||||
{
|
||||
if (CheckModifications()) {
|
||||
if (MessageBox.Show("You currently have unsaved changes. Close anyway?", "Unsaved Changes", MessageBoxButtons.OKCancel) != DialogResult.OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private CancelSearchForm _searchForm;
|
||||
private SearchState _searchState;
|
||||
|
||||
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;
|
||||
|
||||
_searchState = new SearchState() {
|
||||
RootNode = dataNode,
|
||||
SearchName = form.NameToken,
|
||||
SearchValue = form.ValueToken,
|
||||
DiscoverCallback = SearchDiscoveryCallback,
|
||||
CollapseCallback = SearchCollapseCallback,
|
||||
EndCallback = SearchEndCallback,
|
||||
};
|
||||
|
||||
SearchNextNode();
|
||||
}
|
||||
|
||||
private void SearchNextNode ()
|
||||
{
|
||||
if (_searchState == null)
|
||||
return;
|
||||
|
||||
SearchWorker worker = new SearchWorker(_searchState, this);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
t.Join();
|
||||
}
|
||||
|
||||
private void SearchDiscoveryCallback (DataNode node)
|
||||
{
|
||||
_nodeTree.SelectedNode = FindFrontNode(node);
|
||||
|
||||
if (_searchForm != null) {
|
||||
_searchForm.DialogResult = DialogResult.OK;
|
||||
_searchForm = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchCollapseCallback (DataNode node)
|
||||
{
|
||||
CollapseBelow(node);
|
||||
}
|
||||
|
||||
private void SearchEndCallback (DataNode node)
|
||||
{
|
||||
_searchForm.DialogResult = DialogResult.OK;
|
||||
_searchForm = null;
|
||||
|
||||
MessageBox.Show("End of results");
|
||||
}
|
||||
|
||||
private TreeNode GetRootFromDataNodePath (DataNode node, out Stack<DataNode> hierarchy)
|
||||
{
|
||||
hierarchy = new Stack<DataNode>();
|
||||
while (node != null) {
|
||||
hierarchy.Push(node);
|
||||
node = node.Parent;
|
||||
}
|
||||
|
||||
DataNode rootDataNode = hierarchy.Pop();
|
||||
TreeNode frontNode = null;
|
||||
foreach (TreeNode child in _nodeTree.Nodes) {
|
||||
if (child.Tag == rootDataNode)
|
||||
frontNode = child;
|
||||
}
|
||||
|
||||
return frontNode;
|
||||
}
|
||||
|
||||
private TreeNode FindFrontNode (DataNode node)
|
||||
{
|
||||
Stack<DataNode> hierarchy;
|
||||
TreeNode frontNode = GetRootFromDataNodePath(node, out hierarchy);
|
||||
|
||||
if (frontNode == null)
|
||||
return null;
|
||||
|
||||
while (hierarchy.Count > 0) {
|
||||
if (!frontNode.IsExpanded) {
|
||||
frontNode.Nodes.Add(new TreeNode());
|
||||
frontNode.Expand();
|
||||
}
|
||||
|
||||
DataNode childData = hierarchy.Pop();
|
||||
foreach (TreeNode childFront in frontNode.Nodes) {
|
||||
if (childFront.Tag == childData) {
|
||||
frontNode = childFront;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return frontNode;
|
||||
}
|
||||
|
||||
private void CollapseBelow (DataNode node)
|
||||
{
|
||||
Stack<DataNode> hierarchy;
|
||||
TreeNode frontNode = GetRootFromDataNodePath(node, out hierarchy);
|
||||
|
||||
if (frontNode == null)
|
||||
return;
|
||||
|
||||
while (hierarchy.Count > 0) {
|
||||
if (!frontNode.IsExpanded)
|
||||
return;
|
||||
|
||||
DataNode childData = hierarchy.Pop();
|
||||
foreach (TreeNode childFront in frontNode.Nodes) {
|
||||
if (childFront.Tag == childData) {
|
||||
frontNode = childFront;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (frontNode.IsExpanded)
|
||||
frontNode.Collapse();
|
||||
}
|
||||
|
||||
private void UpdateNodeText (TreeNode node)
|
||||
{
|
||||
if (node == null || !(node.Tag is DataNode))
|
||||
return;
|
||||
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
node.Text = dataNode.NodeDisplay;
|
||||
}
|
||||
|
||||
private bool CheckModifications ()
|
||||
{
|
||||
foreach (TreeNode node in _nodeTree.Nodes) {
|
||||
DataNode dataNode = node.Tag as DataNode;
|
||||
if (dataNode != null && dataNode.IsModified)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UpdateUI ()
|
||||
{
|
||||
TreeNode selected = _nodeTree.SelectedNode;
|
||||
if (selected != null && selected.Tag is DataNode) {
|
||||
UpdateUI(selected.Tag as DataNode);
|
||||
}
|
||||
else {
|
||||
_buttonSave.Enabled = CheckModifications();
|
||||
_buttonFindNext.Enabled = false;
|
||||
|
||||
_menuItemSave.Enabled = _buttonSave.Enabled;
|
||||
_menuItemFind.Enabled = false;
|
||||
_menuItemFindNext.Enabled = _searchState != null;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
_buttonSave.Enabled = CheckModifications();
|
||||
_buttonCopy.Enabled = node.CanCopyNode;
|
||||
_buttonCut.Enabled = node.CanCutNode;
|
||||
_buttonDelete.Enabled = node.CanDeleteNode;
|
||||
_buttonEdit.Enabled = node.CanEditNode;
|
||||
_buttonFindNext.Enabled = node.CanSearchNode || _searchState != null;
|
||||
_buttonPaste.Enabled = node.CanPasteIntoNode;
|
||||
_buttonRename.Enabled = node.CanRenameNode;
|
||||
|
||||
_menuItemSave.Enabled = _buttonSave.Enabled;
|
||||
_menuItemCopy.Enabled = node.CanCopyNode;
|
||||
_menuItemCut.Enabled = node.CanCutNode;
|
||||
_menuItemDelete.Enabled = node.CanDeleteNode;
|
||||
_menuItemEditValue.Enabled = node.CanEditNode;
|
||||
_menuItemFind.Enabled = node.CanSearchNode;
|
||||
_menuItemPaste.Enabled = node.CanPasteIntoNode;
|
||||
_menuItemRename.Enabled = node.CanRenameNode;
|
||||
_menuItemFind.Enabled = node.CanSearchNode;
|
||||
_menuItemFindNext.Enabled = _searchState != null;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void MainForm_Closing (object sender, CancelEventArgs e)
|
||||
{
|
||||
Settings.Default.RecentFiles = Settings.Default.RecentFiles;
|
||||
Settings.Default.Save();
|
||||
if (!ConfirmExit())
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
#region TreeView Event Handlers
|
||||
|
||||
private void _nodeTree_BeforeExpand (object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
ExpandNode(e.Node);
|
||||
}
|
||||
|
||||
private void _nodeTree_AfterCollapse (object sender, TreeViewEventArgs e)
|
||||
{
|
||||
CollapseNode(e.Node);
|
||||
}
|
||||
|
||||
private void _nodeTree_AfterSelect (object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node != null)
|
||||
UpdateUI(e.Node.Tag as DataNode);
|
||||
}
|
||||
|
||||
private void _nodeTree_NodeMouseDoubleClick (object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
EditNode(e.Node);
|
||||
}
|
||||
|
||||
private void _nodeTree_NodeMouseClick (object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
_nodeTree.SelectedNode = e.Node;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Toolstrip Event Handlers
|
||||
|
||||
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)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
private void _buttonEdit_Click (object sender, EventArgs e)
|
||||
{
|
||||
EditNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _buttonRename_Click (object sender, EventArgs e)
|
||||
{
|
||||
RenameNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _buttonDelete_Click (object sender, EventArgs e)
|
||||
{
|
||||
DeleteNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _buttonCopy_Click (object sernder, EventArgs e)
|
||||
{
|
||||
CopyNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _buttonCut_Click (object sernder, EventArgs e)
|
||||
{
|
||||
CutNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _buttonPaste_Click (object sernder, EventArgs e)
|
||||
{
|
||||
PasteNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _buttonAddTagByteArray_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_BYTE_ARRAY);
|
||||
}
|
||||
|
||||
private void _buttonAddTagByte_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_BYTE);
|
||||
}
|
||||
|
||||
private void _buttonAddTagCompound_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_COMPOUND);
|
||||
}
|
||||
|
||||
private void _buttonAddTagDouble_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_DOUBLE);
|
||||
}
|
||||
|
||||
private void _buttonAddTagFloat_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_FLOAT);
|
||||
}
|
||||
|
||||
private void _buttonAddTagInt_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_INT);
|
||||
}
|
||||
|
||||
private void _buttonAddTagIntArray_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_INT_ARRAY);
|
||||
}
|
||||
|
||||
private void _buttonAddTagList_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_LIST);
|
||||
}
|
||||
|
||||
private void _buttonAddTagLong_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_LONG);
|
||||
}
|
||||
|
||||
private void _buttonAddTagShort_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_SHORT);
|
||||
}
|
||||
|
||||
private void _buttonAddTagString_Click (object sender, EventArgs e)
|
||||
{
|
||||
CreateNode(_nodeTree.SelectedNode, TagType.TAG_STRING);
|
||||
}
|
||||
|
||||
private void _buttonFindNext_Click (object sender, EventArgs e)
|
||||
{
|
||||
if (_searchState != null)
|
||||
SearchNextNode();
|
||||
else
|
||||
SearchNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Menu Event Handlers
|
||||
|
||||
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)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
private void _menuItemExit_Click (object sender, EventArgs e)
|
||||
{
|
||||
Settings.Default.Save();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void _menuItemEditValue_Click (object sender, EventArgs e)
|
||||
{
|
||||
EditNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemRename_Click (object sender, EventArgs e)
|
||||
{
|
||||
RenameNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemDelete_Click (object sender, EventArgs e)
|
||||
{
|
||||
DeleteNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemCopy_Click (object sender, EventArgs e)
|
||||
{
|
||||
CopyNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemCut_Click (object sender, EventArgs e)
|
||||
{
|
||||
CutNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemPaste_Click (object sender, EventArgs e)
|
||||
{
|
||||
PasteNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemFind_Click (object sender, EventArgs e)
|
||||
{
|
||||
SearchNode(_nodeTree.SelectedNode);
|
||||
}
|
||||
|
||||
private void _menuItemFindNext_Click (object sender, EventArgs e)
|
||||
{
|
||||
SearchNextNode();
|
||||
}
|
||||
|
||||
private void _menuItemAbout_Click (object sender, EventArgs e)
|
||||
{
|
||||
new About().ShowDialog();
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
BIN
NBTExplorerMac/MainForm.resources
Normal file
1146
NBTExplorerMac/MainForm.resx
Normal file
65
NBTExplorerMac/Model/CompoundTagContainer.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class CompoundTagContainer : INamedTagContainer
|
||||
{
|
||||
private TagNodeCompound _tag;
|
||||
|
||||
public CompoundTagContainer (TagNodeCompound tag)
|
||||
{
|
||||
_tag = tag;
|
||||
}
|
||||
|
||||
public int TagCount
|
||||
{
|
||||
get { return _tag.Count; }
|
||||
}
|
||||
|
||||
public IEnumerable<string> TagNamesInUse
|
||||
{
|
||||
get { return _tag.Keys; }
|
||||
}
|
||||
|
||||
public string GetTagName (TagNode tag)
|
||||
{
|
||||
foreach (String name in _tag.Keys)
|
||||
if (_tag[name] == tag)
|
||||
return name;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool AddTag (TagNode tag, string name)
|
||||
{
|
||||
if (_tag.ContainsKey(name))
|
||||
return false;
|
||||
|
||||
_tag.Add(name, tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RenameTag (TagNode tag, string name)
|
||||
{
|
||||
if (_tag.ContainsKey(name))
|
||||
return false;
|
||||
|
||||
string oldName = GetTagName(tag);
|
||||
_tag.Remove(oldName);
|
||||
_tag.Add(name, tag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeleteTag (TagNode tag)
|
||||
{
|
||||
foreach (String name in _tag.Keys)
|
||||
if (_tag[name] == tag)
|
||||
return _tag.Remove(name);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
75
NBTExplorerMac/Model/CubicRegionDataNode.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class CubicRegionDataNode : DataNode
|
||||
{
|
||||
private string _path;
|
||||
private CubicRegionFile _region;
|
||||
|
||||
private static Regex _namePattern = new Regex(@"^r2(\.-?\d+){3}\.(mcr|mca)$");
|
||||
|
||||
private CubicRegionDataNode (string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
|
||||
public static CubicRegionDataNode TryCreateFrom (string path)
|
||||
{
|
||||
return new CubicRegionDataNode(path);
|
||||
}
|
||||
|
||||
public static bool SupportedNamePattern (string path)
|
||||
{
|
||||
path = Path.GetFileName(path);
|
||||
return _namePattern.IsMatch(path);
|
||||
}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.Search;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded; }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
try {
|
||||
if (_region == null)
|
||||
_region = new CubicRegionFile(_path);
|
||||
|
||||
for (int x = 0; x < 32; x++) {
|
||||
for (int z = 0; z < 32; z++) {
|
||||
if (_region.HasChunk(x, z)) {
|
||||
Nodes.Add(new RegionChunkDataNode(_region, x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
MessageBox.Show("Not a valid cubic region file.", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReleaseCore ()
|
||||
{
|
||||
if (_region != null)
|
||||
_region.Close();
|
||||
_region = null;
|
||||
Nodes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
24
NBTExplorerMac/Model/CubicRegionFile.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using Substrate.Core;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class CubicRegionFile : RegionFile
|
||||
{
|
||||
private const int _sectorBytes = 256;
|
||||
private static byte[] _emptySector = new byte[_sectorBytes];
|
||||
|
||||
public CubicRegionFile (string path)
|
||||
: base(path)
|
||||
{ }
|
||||
|
||||
protected override int SectorBytes
|
||||
{
|
||||
get { return _sectorBytes; }
|
||||
}
|
||||
|
||||
protected override byte[] EmptySector
|
||||
{
|
||||
get { return _emptySector; }
|
||||
}
|
||||
}
|
||||
}
|
215
NBTExplorerMac/Model/DataNode.cs
Normal file
|
@ -0,0 +1,215 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class DataNode
|
||||
{
|
||||
private DataNode _parent;
|
||||
private DataNodeCollection _children;
|
||||
|
||||
private bool _expanded;
|
||||
private bool _modified;
|
||||
|
||||
public DataNode ()
|
||||
{
|
||||
_children = new DataNodeCollection(this);
|
||||
}
|
||||
|
||||
public DataNode Parent
|
||||
{
|
||||
get { return _parent; }
|
||||
internal set { _parent = value; }
|
||||
}
|
||||
|
||||
public DataNodeCollection Nodes
|
||||
{
|
||||
get { return _children; }
|
||||
}
|
||||
|
||||
public bool IsModified
|
||||
{
|
||||
get { return _modified; }
|
||||
set
|
||||
{
|
||||
if (value && Parent != null)
|
||||
Parent.IsModified = value;
|
||||
_modified = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get { return _expanded; }
|
||||
private set { _expanded = value; }
|
||||
}
|
||||
|
||||
public void Expand ()
|
||||
{
|
||||
if (!IsExpanded) {
|
||||
ExpandCore();
|
||||
IsExpanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ExpandCore () { }
|
||||
|
||||
public void Collapse ()
|
||||
{
|
||||
if (IsExpanded && !IsModified) {
|
||||
Release();
|
||||
IsExpanded = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Release ()
|
||||
{
|
||||
foreach (DataNode node in Nodes)
|
||||
node.Release();
|
||||
|
||||
ReleaseCore();
|
||||
IsExpanded = false;
|
||||
}
|
||||
|
||||
protected virtual void ReleaseCore ()
|
||||
{
|
||||
Nodes.Clear();
|
||||
}
|
||||
|
||||
public void Save ()
|
||||
{
|
||||
foreach (DataNode node in Nodes)
|
||||
if (node.IsModified)
|
||||
node.Save();
|
||||
|
||||
SaveCore();
|
||||
IsModified = false;
|
||||
}
|
||||
|
||||
protected virtual void SaveCore ()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual string NodeName
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
public virtual string NodeDisplay
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
public virtual bool HasUnexpandedChildren
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#region Capabilities
|
||||
|
||||
protected virtual NodeCapabilities Capabilities
|
||||
{
|
||||
get { return NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanRenameNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Rename) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanEditNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Edit) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanDeleteNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Delete) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanCopyNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Copy) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanCutNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Cut) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanPasteIntoNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.PasteInto) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanSearchNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Search) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanReoderNode
|
||||
{
|
||||
get { return (Capabilities & NodeCapabilities.Reorder) != NodeCapabilities.None; }
|
||||
}
|
||||
|
||||
public virtual bool CanMoveNodeUp
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual bool CanMoveNodeDown
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual bool CanCreateTag (TagType type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operations
|
||||
|
||||
public virtual bool CreateNode (TagType type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool RenameNode ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool EditNode ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool DeleteNode ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CopyNode ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CutNode ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool PasteNode ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool ChangeRelativePosition (int offset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
121
NBTExplorerMac/Model/DataNodeCollection.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class DataNodeCollection : IList<DataNode>
|
||||
{
|
||||
private List<DataNode> _nodes;
|
||||
private DataNode _parent;
|
||||
|
||||
internal DataNodeCollection (DataNode parent)
|
||||
{
|
||||
_parent = parent;
|
||||
_nodes = new List<DataNode>();
|
||||
}
|
||||
|
||||
public int IndexOf (DataNode item)
|
||||
{
|
||||
return _nodes.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert (int index, DataNode item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("item");
|
||||
if (item.Parent != null)
|
||||
throw new ArgumentException("The item is already assigned to another DataNode.");
|
||||
|
||||
item.Parent = _parent;
|
||||
|
||||
_nodes.Insert(index, item);
|
||||
}
|
||||
|
||||
public void RemoveAt (int index)
|
||||
{
|
||||
if (index < 0 || index >= _nodes.Count)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
|
||||
DataNode node = _nodes[index];
|
||||
node.Parent = null;
|
||||
|
||||
_nodes.RemoveAt(index);
|
||||
}
|
||||
|
||||
DataNode IList<DataNode>.this[int index]
|
||||
{
|
||||
get { return _nodes[index]; }
|
||||
set
|
||||
{
|
||||
if (index < 0 || index > _nodes.Count)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("item");
|
||||
if (value.Parent != null)
|
||||
throw new ArgumentException("The item is already assigned to another DataNode.");
|
||||
|
||||
_nodes[index].Parent = null;
|
||||
_nodes[index] = value;
|
||||
_nodes[index].Parent = _parent;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add (DataNode item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("item");
|
||||
if (item.Parent != null)
|
||||
throw new ArgumentException("The item is already assigned to another DataNode.");
|
||||
|
||||
item.Parent = _parent;
|
||||
|
||||
_nodes.Add(item);
|
||||
}
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
foreach (DataNode node in _nodes)
|
||||
node.Parent = null;
|
||||
|
||||
_nodes.Clear();
|
||||
}
|
||||
|
||||
public bool Contains (DataNode item)
|
||||
{
|
||||
return _nodes.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo (DataNode[] array, int arrayIndex)
|
||||
{
|
||||
_nodes.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _nodes.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<DataNode>.IsReadOnly
|
||||
{
|
||||
get { return (_nodes as IList<DataNode>).IsReadOnly; }
|
||||
}
|
||||
|
||||
public bool Remove (DataNode item)
|
||||
{
|
||||
if (_nodes.Contains(item))
|
||||
item.Parent = null;
|
||||
|
||||
return _nodes.Remove(item);
|
||||
}
|
||||
|
||||
public IEnumerator<DataNode> GetEnumerator ()
|
||||
{
|
||||
return _nodes.GetEnumerator();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
|
||||
{
|
||||
return _nodes.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
55
NBTExplorerMac/Model/DirectoryDataNode.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.IO;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class DirectoryDataNode : DataNode
|
||||
{
|
||||
private string _path;
|
||||
|
||||
public DirectoryDataNode (string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.Search;
|
||||
}
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded; }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
foreach (string dirpath in Directory.GetDirectories(_path)) {
|
||||
Nodes.Add(new DirectoryDataNode(dirpath));
|
||||
}
|
||||
|
||||
foreach (string filepath in Directory.GetFiles(_path)) {
|
||||
DataNode node = null;
|
||||
foreach (var item in FileTypeRegistry.RegisteredTypes) {
|
||||
if (item.Value.NamePatternTest(filepath))
|
||||
node = item.Value.NodeCreate(filepath);
|
||||
}
|
||||
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReleaseCore ()
|
||||
{
|
||||
Nodes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
69
NBTExplorerMac/Model/FileTypeRegistry.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public delegate bool NamePatternTestFunc (string path);
|
||||
public delegate DataNode NodeCreateFunc (string path);
|
||||
|
||||
public class FileTypeRecord
|
||||
{
|
||||
public NamePatternTestFunc NamePatternTest { get; set; }
|
||||
public NodeCreateFunc NodeCreate { get; set; }
|
||||
}
|
||||
|
||||
public class FileTypeRegistry
|
||||
{
|
||||
private static Dictionary<Type, FileTypeRecord> _registry = new Dictionary<Type, FileTypeRecord>();
|
||||
|
||||
public static FileTypeRecord Lookup (Type type)
|
||||
{
|
||||
if (_registry.ContainsKey(type))
|
||||
return _registry[type];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Register (Type type, FileTypeRecord record)
|
||||
{
|
||||
_registry[type] = record;
|
||||
}
|
||||
|
||||
public static void Register<T> (FileTypeRecord record)
|
||||
{
|
||||
Register(typeof(T), record);
|
||||
}
|
||||
|
||||
public static IEnumerable<KeyValuePair<Type, FileTypeRecord>> RegisteredTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var item in _registry)
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
|
||||
static FileTypeRegistry ()
|
||||
{
|
||||
try {
|
||||
Register<NbtFileDataNode>(new FileTypeRecord() {
|
||||
NamePatternTest = NbtFileDataNode.SupportedNamePattern,
|
||||
NodeCreate = NbtFileDataNode.TryCreateFrom,
|
||||
});
|
||||
|
||||
Register<RegionFileDataNode>(new FileTypeRecord() {
|
||||
NamePatternTest = RegionFileDataNode.SupportedNamePattern,
|
||||
NodeCreate = RegionFileDataNode.TryCreateFrom,
|
||||
});
|
||||
|
||||
Register<CubicRegionDataNode>(new FileTypeRecord() {
|
||||
NamePatternTest = CubicRegionDataNode.SupportedNamePattern,
|
||||
NodeCreate = CubicRegionDataNode.TryCreateFrom,
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
Program.StaticInitFailure(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
NBTExplorerMac/Model/ListTagContainer.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class ListTagContainer : IOrderedTagContainer
|
||||
{
|
||||
private TagNodeList _tag;
|
||||
|
||||
public ListTagContainer (TagNodeList tag)
|
||||
{
|
||||
_tag = tag;
|
||||
}
|
||||
|
||||
public int TagCount
|
||||
{
|
||||
get { return _tag.Count; }
|
||||
}
|
||||
|
||||
public bool DeleteTag (TagNode tag)
|
||||
{
|
||||
return _tag.Remove(tag);
|
||||
}
|
||||
|
||||
public int GetTagIndex (TagNode tag)
|
||||
{
|
||||
return _tag.IndexOf(tag);
|
||||
}
|
||||
|
||||
public bool InsertTag (TagNode tag, int index)
|
||||
{
|
||||
if (index < 0 || index > _tag.Count)
|
||||
return false;
|
||||
|
||||
_tag.Insert(index, tag);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
141
NBTExplorerMac/Model/NbtFileDataNode.cs
Normal file
|
@ -0,0 +1,141 @@
|
|||
using System.IO;
|
||||
using Substrate.Core;
|
||||
using Substrate.Nbt;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class NbtFileDataNode : DataNode, IMetaTagContainer
|
||||
{
|
||||
private NbtTree _tree;
|
||||
private string _path;
|
||||
private CompressionType _compressionType;
|
||||
|
||||
private CompoundTagContainer _container;
|
||||
|
||||
private static Regex _namePattern = new Regex(@"\.(dat|nbt|schematic)$");
|
||||
|
||||
private NbtFileDataNode (string path, CompressionType compressionType)
|
||||
{
|
||||
_path = path;
|
||||
_compressionType = compressionType;
|
||||
_container = new CompoundTagContainer(new TagNodeCompound());
|
||||
}
|
||||
|
||||
public static NbtFileDataNode TryCreateFrom (string path)
|
||||
{
|
||||
return TryCreateFrom(path, CompressionType.GZip)
|
||||
?? TryCreateFrom(path, CompressionType.None);
|
||||
}
|
||||
|
||||
private static NbtFileDataNode TryCreateFrom (string path, CompressionType compressionType)
|
||||
{
|
||||
try {
|
||||
NBTFile file = new NBTFile(path);
|
||||
NbtTree tree = new NbtTree();
|
||||
tree.ReadFrom(file.GetDataInputStream(compressionType));
|
||||
|
||||
if (tree.Root == null)
|
||||
return null;
|
||||
|
||||
return new NbtFileDataNode(path, compressionType);
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SupportedNamePattern (string path)
|
||||
{
|
||||
path = Path.GetFileName(path);
|
||||
return _namePattern.IsMatch(path);
|
||||
}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.CreateTag
|
||||
| NodeCapabilities.PasteInto
|
||||
| NodeCapabilities.Search;
|
||||
}
|
||||
}
|
||||
|
||||
public override string NodeName
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeName; }
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded; }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
if (_tree == null) {
|
||||
NBTFile file = new NBTFile(_path);
|
||||
_tree = new NbtTree();
|
||||
_tree.ReadFrom(file.GetDataInputStream(_compressionType));
|
||||
|
||||
if (_tree.Root != null)
|
||||
_container = new CompoundTagContainer(_tree.Root);
|
||||
}
|
||||
|
||||
foreach (TagNode tag in _tree.Root.Values) {
|
||||
TagDataNode node = TagDataNode.CreateFromTag(tag);
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReleaseCore ()
|
||||
{
|
||||
_tree = null;
|
||||
Nodes.Clear();
|
||||
}
|
||||
|
||||
protected override void SaveCore ()
|
||||
{
|
||||
NBTFile file = new NBTFile(_path);
|
||||
using (Stream str = file.GetDataOutputStream(_compressionType)) {
|
||||
_tree.WriteTo(str);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNamedContainer
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool IsOrderedContainer
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public INamedTagContainer NamedTagContainer
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
public IOrderedTagContainer OrderedTagContainer
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public int TagCount
|
||||
{
|
||||
get { return _container.TagCount; }
|
||||
}
|
||||
|
||||
public bool DeleteTag (TagNode tag)
|
||||
{
|
||||
return _container.DeleteTag(tag);
|
||||
}
|
||||
}
|
||||
}
|
19
NBTExplorerMac/Model/NodeCapabilities.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
[Flags]
|
||||
public enum NodeCapabilities
|
||||
{
|
||||
None = 0,
|
||||
Cut = 0x1,
|
||||
Copy = 0x2,
|
||||
PasteInto = 0x4,
|
||||
Rename = 0x8,
|
||||
Edit = 0x10,
|
||||
Delete = 0x20,
|
||||
CreateTag = 0x40,
|
||||
Search = 0x80,
|
||||
Reorder = 0x100,
|
||||
}
|
||||
}
|
104
NBTExplorerMac/Model/RegionChunkDataNode.cs
Normal file
|
@ -0,0 +1,104 @@
|
|||
using Substrate.Core;
|
||||
using Substrate.Nbt;
|
||||
using System.IO;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class RegionChunkDataNode : DataNode, IMetaTagContainer
|
||||
{
|
||||
private RegionFile _regionFile;
|
||||
private NbtTree _tree;
|
||||
private int _x;
|
||||
private int _z;
|
||||
|
||||
private CompoundTagContainer _container;
|
||||
|
||||
public RegionChunkDataNode (RegionFile regionFile, int x, int z)
|
||||
{
|
||||
_regionFile = regionFile;
|
||||
_x = x;
|
||||
_z = z;
|
||||
_container = new CompoundTagContainer(new TagNodeCompound());
|
||||
}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.CreateTag
|
||||
| NodeCapabilities.PasteInto
|
||||
| NodeCapabilities.Search;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded; }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return "Chunk [" + _x + ", " + _z + "]"; }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
if (_tree == null) {
|
||||
_tree = new NbtTree();
|
||||
_tree.ReadFrom(_regionFile.GetChunkDataInputStream(_x, _z));
|
||||
|
||||
if (_tree.Root != null)
|
||||
_container = new CompoundTagContainer(_tree.Root);
|
||||
}
|
||||
|
||||
foreach (TagNode tag in _tree.Root.Values) {
|
||||
TagDataNode node = TagDataNode.CreateFromTag(tag);
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReleaseCore ()
|
||||
{
|
||||
_tree = null;
|
||||
Nodes.Clear();
|
||||
}
|
||||
|
||||
protected override void SaveCore ()
|
||||
{
|
||||
using (Stream str = _regionFile.GetChunkDataOutputStream(_x, _z)) {
|
||||
_tree.WriteTo(str);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNamedContainer
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool IsOrderedContainer
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public INamedTagContainer NamedTagContainer
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
public IOrderedTagContainer OrderedTagContainer
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public int TagCount
|
||||
{
|
||||
get { return _container.TagCount; }
|
||||
}
|
||||
|
||||
public bool DeleteTag (TagNode tag)
|
||||
{
|
||||
return _container.DeleteTag(tag);
|
||||
}
|
||||
}
|
||||
}
|
76
NBTExplorerMac/Model/RegionFileDataNode.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Core;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class RegionFileDataNode : DataNode
|
||||
{
|
||||
private string _path;
|
||||
private RegionFile _region;
|
||||
|
||||
private static Regex _namePattern = new Regex(@"^r(\.-?\d+){2}\.(mcr|mca)$");
|
||||
|
||||
private RegionFileDataNode (string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
|
||||
public static RegionFileDataNode TryCreateFrom (string path)
|
||||
{
|
||||
return new RegionFileDataNode(path);
|
||||
}
|
||||
|
||||
public static bool SupportedNamePattern (string path)
|
||||
{
|
||||
path = Path.GetFileName(path);
|
||||
return _namePattern.IsMatch(path);
|
||||
}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.Search;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded; }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
try {
|
||||
if (_region == null)
|
||||
_region = new RegionFile(_path);
|
||||
|
||||
for (int x = 0; x < 32; x++) {
|
||||
for (int z = 0; z < 32; z++) {
|
||||
if (_region.HasChunk(x, z)) {
|
||||
Nodes.Add(new RegionChunkDataNode(_region, x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
MessageBox.Show("Not a valid region file.", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReleaseCore ()
|
||||
{
|
||||
if (_region != null)
|
||||
_region.Close();
|
||||
_region = null;
|
||||
Nodes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
37
NBTExplorerMac/Model/TagByteArrayDataNode.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagByteArrayDataNode : TagDataNode
|
||||
{
|
||||
public TagByteArrayDataNode (TagNodeByteArray tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
protected new TagNodeByteArray Tag
|
||||
{
|
||||
get { return base.Tag as TagNodeByteArray; }
|
||||
}
|
||||
|
||||
public override bool CanEditNode
|
||||
{
|
||||
get { return !IsMono(); }
|
||||
}
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditByteHexValue(Tag);
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeDisplayPrefix + Tag.Data.Length + " bytes"; }
|
||||
}
|
||||
|
||||
private bool IsMono ()
|
||||
{
|
||||
return Type.GetType("Mono.Runtime") != null;
|
||||
}
|
||||
}
|
||||
}
|
26
NBTExplorerMac/Model/TagByteDataNode.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagByteDataNode : TagDataNode
|
||||
{
|
||||
public TagByteDataNode (TagNodeByte tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
protected new TagNodeByte Tag
|
||||
{
|
||||
get { return base.Tag as TagNodeByte; }
|
||||
}
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditScalarValue(Tag);
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeDisplayPrefix + unchecked((sbyte)Tag.Data).ToString(); }
|
||||
}
|
||||
}
|
||||
}
|
130
NBTExplorerMac/Model/TagCompoundDataNode.cs
Normal file
|
@ -0,0 +1,130 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagCompoundDataNode : TagDataNode.Container
|
||||
{
|
||||
private CompoundTagContainer _container;
|
||||
|
||||
public TagCompoundDataNode (TagNodeCompound tag)
|
||||
: base(tag)
|
||||
{
|
||||
_container = new CompoundTagContainer(tag);
|
||||
}
|
||||
|
||||
protected new TagNodeCompound Tag
|
||||
{
|
||||
get { return base.Tag as TagNodeCompound; }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
var list = new SortedList<TagKey, TagNode>();
|
||||
foreach (var item in Tag) {
|
||||
list.Add(new TagKey(item.Key, item.Value.GetTagType()), item.Value);
|
||||
}
|
||||
|
||||
foreach (var item in list) {
|
||||
TagDataNode node = TagDataNode.CreateFromTag(item.Value);
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanCreateTag (TagType type)
|
||||
{
|
||||
return Enum.IsDefined(typeof(TagType), type) && type != TagType.TAG_END;
|
||||
}
|
||||
|
||||
public override bool CanPasteIntoNode
|
||||
{
|
||||
get { return NbtClipboardData.ContainsData; }
|
||||
}
|
||||
|
||||
public override bool CreateNode (TagType type)
|
||||
{
|
||||
if (!CanCreateTag(type))
|
||||
return false;
|
||||
|
||||
CreateNodeForm form = new CreateNodeForm(type, true);
|
||||
form.InvalidNames.AddRange(_container.TagNamesInUse);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
AddTag(form.TagNode, form.TagName);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool PasteNode ()
|
||||
{
|
||||
if (!CanPasteIntoNode)
|
||||
return false;
|
||||
|
||||
NbtClipboardData clipboard = NbtClipboardData.CopyFromClipboard();
|
||||
if (clipboard.Node == null)
|
||||
return false;
|
||||
|
||||
string name = clipboard.Name;
|
||||
if (String.IsNullOrEmpty(name))
|
||||
name = "UNNAMED";
|
||||
|
||||
AddTag(clipboard.Node, MakeUniqueName(name));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsNamedContainer
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override INamedTagContainer NamedTagContainer
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
public override int TagCount
|
||||
{
|
||||
get { return _container.TagCount; }
|
||||
}
|
||||
|
||||
public override bool DeleteTag (TagNode tag)
|
||||
{
|
||||
return _container.DeleteTag(tag);
|
||||
}
|
||||
|
||||
private void AddTag (TagNode tag, string name)
|
||||
{
|
||||
_container.AddTag(tag, name);
|
||||
IsModified = true;
|
||||
|
||||
if (IsExpanded) {
|
||||
TagDataNode node = TagDataNode.CreateFromTag(tag);
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
private string MakeUniqueName (string name)
|
||||
{
|
||||
List<string> names = new List<string>(_container.TagNamesInUse);
|
||||
if (!names.Contains(name))
|
||||
return name;
|
||||
|
||||
int index = 1;
|
||||
while (names.Contains(MakeCandidateName(name, index)))
|
||||
index++;
|
||||
|
||||
return MakeCandidateName(name, index);
|
||||
}
|
||||
|
||||
private string MakeCandidateName (string name, int index)
|
||||
{
|
||||
return name + " (Copy " + index + ")";
|
||||
}
|
||||
}
|
||||
}
|
36
NBTExplorerMac/Model/TagContainerInterface.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Collections.Generic;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public interface ITagContainer
|
||||
{
|
||||
int TagCount { get; }
|
||||
|
||||
bool DeleteTag (TagNode tag);
|
||||
}
|
||||
|
||||
public interface IMetaTagContainer : ITagContainer
|
||||
{
|
||||
bool IsNamedContainer { get; }
|
||||
bool IsOrderedContainer { get; }
|
||||
|
||||
INamedTagContainer NamedTagContainer { get; }
|
||||
IOrderedTagContainer OrderedTagContainer { get; }
|
||||
}
|
||||
|
||||
public interface INamedTagContainer : ITagContainer
|
||||
{
|
||||
IEnumerable<string> TagNamesInUse { get; }
|
||||
|
||||
string GetTagName (TagNode tag);
|
||||
bool AddTag (TagNode tag, string name);
|
||||
bool RenameTag (TagNode tag, string name);
|
||||
}
|
||||
|
||||
public interface IOrderedTagContainer : ITagContainer
|
||||
{
|
||||
int GetTagIndex (TagNode tag);
|
||||
bool InsertTag (TagNode tag, int index);
|
||||
}
|
||||
}
|
344
NBTExplorerMac/Model/TagDataNode.cs
Normal file
|
@ -0,0 +1,344 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public abstract class TagDataNode : DataNode
|
||||
{
|
||||
public abstract class Container : TagDataNode, IMetaTagContainer
|
||||
{
|
||||
protected Container (TagNode tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
#region ITagContainer
|
||||
|
||||
public virtual int TagCount
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public virtual bool IsNamedContainer
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual bool IsOrderedContainer
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public virtual INamedTagContainer NamedTagContainer
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public virtual IOrderedTagContainer OrderedTagContainer
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public virtual bool DeleteTag (TagNode tag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.Copy
|
||||
| NodeCapabilities.CreateTag
|
||||
| NodeCapabilities.Cut
|
||||
| NodeCapabilities.Delete
|
||||
| NodeCapabilities.PasteInto
|
||||
| (TagParent.IsNamedContainer ? NodeCapabilities.Rename : NodeCapabilities.None)
|
||||
| (TagParent.IsOrderedContainer ? NodeCapabilities.Reorder : NodeCapabilities.None)
|
||||
| NodeCapabilities.Search;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded && TagCount > 0; }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeDisplayPrefix + TagCount + ((TagCount == 1) ? " entry" : " entries"); }
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<TagType, Type> _tagRegistry;
|
||||
|
||||
static TagDataNode ()
|
||||
{
|
||||
_tagRegistry = new Dictionary<TagType, Type>();
|
||||
_tagRegistry[TagType.TAG_BYTE] = typeof(TagByteDataNode);
|
||||
_tagRegistry[TagType.TAG_BYTE_ARRAY] = typeof(TagByteArrayDataNode);
|
||||
_tagRegistry[TagType.TAG_COMPOUND] = typeof(TagCompoundDataNode);
|
||||
_tagRegistry[TagType.TAG_DOUBLE] = typeof(TagDoubleDataNode);
|
||||
_tagRegistry[TagType.TAG_FLOAT] = typeof(TagFloatDataNode);
|
||||
_tagRegistry[TagType.TAG_INT] = typeof(TagIntDataNode);
|
||||
_tagRegistry[TagType.TAG_INT_ARRAY] = typeof(TagIntArrayDataNode);
|
||||
_tagRegistry[TagType.TAG_LIST] = typeof(TagListDataNode);
|
||||
_tagRegistry[TagType.TAG_LONG] = typeof(TagLongDataNode);
|
||||
_tagRegistry[TagType.TAG_SHORT] = typeof(TagShortDataNode);
|
||||
_tagRegistry[TagType.TAG_STRING] = typeof(TagStringDataNode);
|
||||
}
|
||||
|
||||
static public TagDataNode CreateFromTag (TagNode tag)
|
||||
{
|
||||
if (tag == null || !_tagRegistry.ContainsKey(tag.GetTagType()))
|
||||
return null;
|
||||
|
||||
return Activator.CreateInstance(_tagRegistry[tag.GetTagType()], tag) as TagDataNode;
|
||||
}
|
||||
|
||||
static public TagNode DefaultTag (TagType type)
|
||||
{
|
||||
switch (type) {
|
||||
case TagType.TAG_BYTE:
|
||||
return new TagNodeByte(0);
|
||||
case TagType.TAG_BYTE_ARRAY:
|
||||
return new TagNodeByteArray(new byte[0]);
|
||||
case TagType.TAG_COMPOUND:
|
||||
return new TagNodeCompound();
|
||||
case TagType.TAG_DOUBLE:
|
||||
return new TagNodeDouble(0);
|
||||
case TagType.TAG_FLOAT:
|
||||
return new TagNodeFloat(0);
|
||||
case TagType.TAG_INT:
|
||||
return new TagNodeInt(0);
|
||||
case TagType.TAG_INT_ARRAY:
|
||||
return new TagNodeIntArray(new int[0]);
|
||||
case TagType.TAG_LIST:
|
||||
return new TagNodeList(TagType.TAG_BYTE);
|
||||
case TagType.TAG_LONG:
|
||||
return new TagNodeLong(0);
|
||||
case TagType.TAG_SHORT:
|
||||
return new TagNodeShort(0);
|
||||
case TagType.TAG_STRING:
|
||||
return new TagNodeString("");
|
||||
default:
|
||||
return new TagNodeByte(0);
|
||||
}
|
||||
}
|
||||
|
||||
private TagNode _tag;
|
||||
|
||||
protected TagDataNode (TagNode tag)
|
||||
{
|
||||
_tag = tag;
|
||||
}
|
||||
|
||||
protected IMetaTagContainer TagParent
|
||||
{
|
||||
get { return base.Parent as IMetaTagContainer; }
|
||||
}
|
||||
|
||||
protected TagNode Tag
|
||||
{
|
||||
get { return _tag; }
|
||||
set
|
||||
{
|
||||
if (_tag.GetTagType() == value.GetTagType())
|
||||
_tag = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return NodeCapabilities.Copy
|
||||
| NodeCapabilities.Cut
|
||||
| NodeCapabilities.Delete
|
||||
| NodeCapabilities.Edit
|
||||
| (TagParent.IsNamedContainer ? NodeCapabilities.Rename : NodeCapabilities.None)
|
||||
| (TagParent.IsOrderedContainer ? NodeCapabilities.Reorder : NodeCapabilities.None);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanMoveNodeUp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TagParent.IsOrderedContainer)
|
||||
return TagParent.OrderedTagContainer.GetTagIndex(Tag) > 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanMoveNodeDown
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TagParent.IsOrderedContainer)
|
||||
return TagParent.OrderedTagContainer.GetTagIndex(Tag) < (TagParent.TagCount - 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override string NodeName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TagParent == null || !TagParent.IsNamedContainer)
|
||||
return null;
|
||||
|
||||
return TagParent.NamedTagContainer.GetTagName(Tag);
|
||||
}
|
||||
}
|
||||
|
||||
protected string NodeDisplayPrefix
|
||||
{
|
||||
get
|
||||
{
|
||||
string name = NodeName;
|
||||
return String.IsNullOrEmpty(name) ? "" : name + ": ";
|
||||
}
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeDisplayPrefix + Tag.ToString(); }
|
||||
}
|
||||
|
||||
public override bool DeleteNode ()
|
||||
{
|
||||
if (CanDeleteNode) {
|
||||
TagParent.DeleteTag(Tag);
|
||||
return Parent.Nodes.Remove(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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)) {
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CopyNode ()
|
||||
{
|
||||
if (CanCopyNode) {
|
||||
NbtClipboardData clip = new NbtClipboardData(NodeName, Tag);
|
||||
clip.CopyToClipboard();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CutNode ()
|
||||
{
|
||||
if (CanCutNode) {
|
||||
NbtClipboardData clip = new NbtClipboardData(NodeName, Tag);
|
||||
clip.CopyToClipboard();
|
||||
|
||||
TagParent.DeleteTag(Tag);
|
||||
Parent.Nodes.Remove(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool ChangeRelativePosition (int offset)
|
||||
{
|
||||
if (CanReoderNode) {
|
||||
int curIndex = TagParent.OrderedTagContainer.GetTagIndex(Tag);
|
||||
int newIndex = curIndex + offset;
|
||||
|
||||
if (newIndex < 0 || newIndex >= TagParent.OrderedTagContainer.TagCount)
|
||||
return false;
|
||||
|
||||
TagParent.OrderedTagContainer.DeleteTag(Tag);
|
||||
TagParent.OrderedTagContainer.InsertTag(Tag, newIndex);
|
||||
|
||||
DataNode parent = Parent;
|
||||
parent.Nodes.Remove(this);
|
||||
parent.Nodes.Insert(newIndex, this);
|
||||
parent.IsModified = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool EditScalarValue (TagNode tag)
|
||||
{
|
||||
EditValue form = new EditValue(tag);
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
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;
|
||||
}
|
||||
else
|
||||
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);
|
||||
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
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) {
|
||||
for (int i = 0; i < iatag.Length; i++) {
|
||||
iatag.Data[i] = BitConverter.ToInt32(form.Data, i * 4);
|
||||
}
|
||||
|
||||
IsModified = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
16
NBTExplorerMac/Model/TagDoubleDataNode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagDoubleDataNode : TagDataNode
|
||||
{
|
||||
public TagDoubleDataNode (TagNodeDouble tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditScalarValue(Tag);
|
||||
}
|
||||
}
|
||||
}
|
16
NBTExplorerMac/Model/TagFloatDataNode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagFloatDataNode : TagDataNode
|
||||
{
|
||||
public TagFloatDataNode (TagNodeFloat tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditScalarValue(Tag);
|
||||
}
|
||||
}
|
||||
}
|
37
NBTExplorerMac/Model/TagIntArrayDataNode.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagIntArrayDataNode : TagDataNode
|
||||
{
|
||||
public TagIntArrayDataNode (TagNodeIntArray tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
protected new TagNodeIntArray Tag
|
||||
{
|
||||
get { return base.Tag as TagNodeIntArray; }
|
||||
}
|
||||
|
||||
public override bool CanEditNode
|
||||
{
|
||||
get { return !IsMono(); }
|
||||
}
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditIntHexValue(Tag);
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeDisplayPrefix + Tag.Data.Length + " integers"; }
|
||||
}
|
||||
|
||||
private bool IsMono ()
|
||||
{
|
||||
return Type.GetType("Mono.Runtime") != null;
|
||||
}
|
||||
}
|
||||
}
|
16
NBTExplorerMac/Model/TagIntDataNode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagIntDataNode : TagDataNode
|
||||
{
|
||||
public TagIntDataNode (TagNodeInt tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditScalarValue(Tag);
|
||||
}
|
||||
}
|
||||
}
|
111
NBTExplorerMac/Model/TagListDataNode.cs
Normal file
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagListDataNode : TagDataNode.Container
|
||||
{
|
||||
private ListTagContainer _container;
|
||||
|
||||
public TagListDataNode (TagNodeList tag)
|
||||
: base(tag)
|
||||
{
|
||||
_container = new ListTagContainer(tag);
|
||||
}
|
||||
|
||||
protected new TagNodeList Tag
|
||||
{
|
||||
get { return base.Tag as TagNodeList; }
|
||||
set { base.Tag = value; }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
foreach (TagNode tag in Tag) {
|
||||
TagDataNode node = TagDataNode.CreateFromTag(tag);
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanCreateTag (TagType type)
|
||||
{
|
||||
if (Tag.Count > 0)
|
||||
return Tag.ValueType == type;
|
||||
else
|
||||
return Enum.IsDefined(typeof(TagType), type) && type != TagType.TAG_END;
|
||||
}
|
||||
|
||||
public override bool CanPasteIntoNode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NbtClipboardData.ContainsData) {
|
||||
TagNode node = NbtClipboardData.CopyFromClipboard().Node;
|
||||
if (node != null && node.GetTagType() == Tag.ValueType)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CreateNode (TagType type)
|
||||
{
|
||||
if (!CanCreateTag(type))
|
||||
return false;
|
||||
|
||||
if (Tag.Count == 0) {
|
||||
Tag.ChangeValueType(type);
|
||||
}
|
||||
|
||||
AppendTag(TagDataNode.DefaultTag(type));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool PasteNode ()
|
||||
{
|
||||
if (!CanPasteIntoNode)
|
||||
return false;
|
||||
|
||||
NbtClipboardData clipboard = NbtClipboardData.CopyFromClipboard();
|
||||
if (clipboard.Node == null)
|
||||
return false;
|
||||
|
||||
AppendTag(clipboard.Node);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsOrderedContainer
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override IOrderedTagContainer OrderedTagContainer
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
public override int TagCount
|
||||
{
|
||||
get { return _container.TagCount; }
|
||||
}
|
||||
|
||||
public override bool DeleteTag (TagNode tag)
|
||||
{
|
||||
return _container.DeleteTag(tag);
|
||||
}
|
||||
|
||||
private void AppendTag (TagNode tag)
|
||||
{
|
||||
_container.InsertTag(tag, _container.TagCount);
|
||||
IsModified = true;
|
||||
|
||||
if (IsExpanded) {
|
||||
TagDataNode node = TagDataNode.CreateFromTag(tag);
|
||||
if (node != null)
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
NBTExplorerMac/Model/TagLongDataNode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagLongDataNode : TagDataNode
|
||||
{
|
||||
public TagLongDataNode (TagNodeLong tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditScalarValue(Tag);
|
||||
}
|
||||
}
|
||||
}
|
16
NBTExplorerMac/Model/TagShortDataNode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagShortDataNode : TagDataNode
|
||||
{
|
||||
public TagShortDataNode (TagNodeShort tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditScalarValue(Tag);
|
||||
}
|
||||
}
|
||||
}
|
21
NBTExplorerMac/Model/TagStringDataNode.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class TagStringDataNode : TagDataNode
|
||||
{
|
||||
public TagStringDataNode (TagNodeString tag)
|
||||
: base(tag)
|
||||
{ }
|
||||
|
||||
public override bool EditNode ()
|
||||
{
|
||||
return EditStringValue(Tag);
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return NodeDisplayPrefix + Tag.ToString().Replace('\n', (char)0x00B6); }
|
||||
}
|
||||
}
|
||||
}
|
72
NBTExplorerMac/NBTExplorerMac.csproj
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{01F9A296-C477-4CBF-A0D0-41E697048257}</ProjectGuid>
|
||||
<ProjectTypeGuids>{948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>NBTExplorerMac</RootNamespace>
|
||||
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
|
||||
<AssemblyName>NBTExplorerMac</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<EnablePackageSigning>False</EnablePackageSigning>
|
||||
<IncludeMonoRuntime>False</IncludeMonoRuntime>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<EnableCodeSigning>False</EnableCodeSigning>
|
||||
<CreatePackage>False</CreatePackage>
|
||||
<CodeSigningKey>Mac Developer</CodeSigningKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<EnablePackageSigning>False</EnablePackageSigning>
|
||||
<IncludeMonoRuntime>False</IncludeMonoRuntime>
|
||||
<LinkMode>Full</LinkMode>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<EnableCodeSigning>False</EnableCodeSigning>
|
||||
<CreatePackage>False</CreatePackage>
|
||||
<CodeSigningKey>Mac Developer</CodeSigningKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
|
||||
<IncludeMonoRuntime>True</IncludeMonoRuntime>
|
||||
<LinkMode>Full</LinkMode>
|
||||
<EnablePackageSigning>True</EnablePackageSigning>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<EnableCodeSigning>True</EnableCodeSigning>
|
||||
<CreatePackage>True</CreatePackage>
|
||||
<CodeSigningKey>3rd Party Mac Developer Application</CodeSigningKey>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="MonoMac" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Mono\MonoMac\v0.0\Mono.MonoMac.targets" />
|
||||
</Project>
|
62
NBTExplorerMac/NbtClipboardData.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
[Serializable]
|
||||
public class NbtClipboardData
|
||||
{
|
||||
public string Name;
|
||||
|
||||
private byte[] _data;
|
||||
|
||||
[NonSerialized]
|
||||
public TagNode Node;
|
||||
|
||||
public NbtClipboardData (String name, TagNode node)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
TagNodeCompound root = new TagNodeCompound();
|
||||
root.Add("root", node);
|
||||
NbtTree tree = new NbtTree(root);
|
||||
|
||||
using (MemoryStream ms = new MemoryStream()) {
|
||||
tree.WriteTo(ms);
|
||||
_data = new byte[ms.Length];
|
||||
Array.Copy(ms.GetBuffer(), _data, ms.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ContainsData
|
||||
{
|
||||
get { return Clipboard.ContainsData(typeof(NbtClipboardData).FullName); }
|
||||
}
|
||||
|
||||
public void CopyToClipboard ()
|
||||
{
|
||||
Clipboard.SetData(typeof(NbtClipboardData).FullName, this);
|
||||
}
|
||||
|
||||
public static NbtClipboardData CopyFromClipboard ()
|
||||
{
|
||||
NbtClipboardData clip = Clipboard.GetData(typeof(NbtClipboardData).FullName) as NbtClipboardData;
|
||||
if (clip == null)
|
||||
return null;
|
||||
|
||||
NbtTree tree = new NbtTree();
|
||||
using (MemoryStream ms = new MemoryStream(clip._data)) {
|
||||
tree.ReadFrom(ms);
|
||||
}
|
||||
|
||||
TagNodeCompound root = tree.Root;
|
||||
if (root == null || !root.ContainsKey("root"))
|
||||
return null;
|
||||
|
||||
clip.Node = root["root"];
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
}
|
35
NBTExplorerMac/Program.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main ()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
|
||||
public static void StaticInitFailure (Exception e)
|
||||
{
|
||||
Console.WriteLine("Static Initialization Failure:");
|
||||
|
||||
Exception original = e;
|
||||
while (e != null) {
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine(e.StackTrace);
|
||||
e = e.InnerException;
|
||||
}
|
||||
|
||||
MessageBox.Show("Application failed during static initialization: " + original.Message);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
36
NBTExplorerMac/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NBTExplorer")]
|
||||
[assembly: AssemblyDescription("Graphical editor for most NBT data sources. NBT is used by Minecraft.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NBTExplorer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Justin Aquadro 2011-2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("11f3587a-6155-499e-b7b5-ebd48fdca479")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.0.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.2.0")]
|
77
NBTExplorerMac/Properties/Resources.Designer.cs
generated
Normal file
|
@ -0,0 +1,77 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.269
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NBTExplorer.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NBTExplorer.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ArrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ArrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
NBTExplorerMac/Properties/Resources.resources
Normal file
127
NBTExplorerMac/Properties/Resources.resx
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrow-270.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrow-090.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
48
NBTExplorerMac/Properties/Settings.Designer.cs
generated
Normal file
|
@ -0,0 +1,48 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.269
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NBTExplorer.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public global::System.Collections.Specialized.StringCollection RecentFiles {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["RecentFiles"]));
|
||||
}
|
||||
set {
|
||||
this["RecentFiles"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public global::System.Collections.Specialized.StringCollection RecentDirectories {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["RecentDirectories"]));
|
||||
}
|
||||
set {
|
||||
this["RecentDirectories"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
NBTExplorerMac/Properties/Settings.settings
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="NBTExplorer.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="RecentDirectories" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
BIN
NBTExplorerMac/Resources/24/box-24.png
Normal file
After Width: | Height: | Size: 654 B |
BIN
NBTExplorerMac/Resources/24/cross.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
NBTExplorerMac/Resources/24/document-b.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
NBTExplorerMac/Resources/24/document-d.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
NBTExplorerMac/Resources/24/document-f.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
NBTExplorerMac/Resources/24/document-i.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
NBTExplorerMac/Resources/24/document-l.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
NBTExplorerMac/Resources/24/document-s.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
NBTExplorerMac/Resources/24/document.png
Normal file
After Width: | Height: | Size: 624 B |
BIN
NBTExplorerMac/Resources/24/edit-code-i.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
NBTExplorerMac/Resources/24/edit-code.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
NBTExplorerMac/Resources/24/edit-list.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
NBTExplorerMac/Resources/24/edit-smallcaps.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
NBTExplorerMac/Resources/24/pencil.png
Normal file
After Width: | Height: | Size: 603 B |
BIN
NBTExplorerMac/Resources/24/scissors.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
NBTExplorerMac/Resources/24/selection-input.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
NBTExplorerMac/Resources/Dead_Bush.png
Normal file
After Width: | Height: | Size: 693 B |
BIN
NBTExplorerMac/Resources/arrow-090.png
Normal file
After Width: | Height: | Size: 618 B |
BIN
NBTExplorerMac/Resources/arrow-270.png
Normal file
After Width: | Height: | Size: 622 B |
BIN
NBTExplorerMac/Resources/binocular--arrow.png
Normal file
After Width: | Height: | Size: 733 B |
BIN
NBTExplorerMac/Resources/binocular.png
Normal file
After Width: | Height: | Size: 621 B |
BIN
NBTExplorerMac/Resources/clipboard-paste.png
Normal file
After Width: | Height: | Size: 685 B |
BIN
NBTExplorerMac/Resources/cross.png
Normal file
After Width: | Height: | Size: 544 B |
BIN
NBTExplorerMac/Resources/disk--pencil.png
Normal file
After Width: | Height: | Size: 677 B |
BIN
NBTExplorerMac/Resources/disk-24.png
Normal file
After Width: | Height: | Size: 691 B |
BIN
NBTExplorerMac/Resources/disk.png
Normal file
After Width: | Height: | Size: 507 B |
BIN
NBTExplorerMac/Resources/document-attribute-b.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
NBTExplorerMac/Resources/document-attribute-i.png
Normal file
After Width: | Height: | Size: 587 B |
BIN
NBTExplorerMac/Resources/document-copy.png
Normal file
After Width: | Height: | Size: 606 B |
BIN
NBTExplorerMac/Resources/door.png
Normal file
After Width: | Height: | Size: 503 B |
BIN
NBTExplorerMac/Resources/edit-code-b.png
Normal file
After Width: | Height: | Size: 388 B |
BIN
NBTExplorerMac/Resources/edit-code-i.png
Normal file
After Width: | Height: | Size: 380 B |
BIN
NBTExplorerMac/Resources/edit-code.png
Normal file
After Width: | Height: | Size: 308 B |
BIN
NBTExplorerMac/Resources/folder-open-24.png
Normal file
After Width: | Height: | Size: 886 B |
BIN
NBTExplorerMac/Resources/folder-open-document.png
Normal file
After Width: | Height: | Size: 677 B |
BIN
NBTExplorerMac/Resources/folder-open.png
Normal file
After Width: | Height: | Size: 647 B |
BIN
NBTExplorerMac/Resources/information-frame.png
Normal file
After Width: | Height: | Size: 898 B |
BIN
NBTExplorerMac/Resources/pencil.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
NBTExplorerMac/Resources/question-frame.png
Normal file
After Width: | Height: | Size: 925 B |
BIN
NBTExplorerMac/Resources/question-white.png
Normal file
After Width: | Height: | Size: 761 B |
BIN
NBTExplorerMac/Resources/scissors.png
Normal file
After Width: | Height: | Size: 690 B |
BIN
NBTExplorerMac/Resources/selection-input.png
Normal file
After Width: | Height: | Size: 265 B |
121
NBTExplorerMac/SearchWorker.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Model;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
internal class SearchState
|
||||
{
|
||||
public DataNode RootNode { get; set; }
|
||||
public string SearchName { get; set; }
|
||||
public string SearchValue { get; set; }
|
||||
|
||||
public IEnumerator<DataNode> State { get; set; }
|
||||
|
||||
public Action<DataNode> DiscoverCallback { get; set; }
|
||||
public Action<DataNode> ProgressCallback { get; set; }
|
||||
public Action<DataNode> CollapseCallback { get; set; }
|
||||
public Action<DataNode> EndCallback { get; set; }
|
||||
}
|
||||
|
||||
internal class SearchWorker
|
||||
{
|
||||
private ContainerControl _sender;
|
||||
private SearchState _state;
|
||||
private bool _cancel;
|
||||
private object _lock;
|
||||
|
||||
public SearchWorker (SearchState state, ContainerControl sender)
|
||||
{
|
||||
_state = state;
|
||||
_sender = sender;
|
||||
_lock = new object();
|
||||
}
|
||||
|
||||
public void Cancel ()
|
||||
{
|
||||
lock (_lock) {
|
||||
_cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Run ()
|
||||
{
|
||||
if (_state.State == null)
|
||||
_state.State = FindNode(_state.RootNode).GetEnumerator();
|
||||
|
||||
if (!_state.State.MoveNext())
|
||||
InvokeEndCallback();
|
||||
}
|
||||
|
||||
private IEnumerable<DataNode> FindNode (DataNode node)
|
||||
{
|
||||
lock (_lock) {
|
||||
if (_cancel)
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (node == null)
|
||||
yield break;
|
||||
|
||||
bool searchExpanded = false;
|
||||
if (!node.IsExpanded) {
|
||||
node.Expand();
|
||||
searchExpanded = true;
|
||||
}
|
||||
|
||||
TagDataNode tagNode = node as TagDataNode;
|
||||
if (tagNode != null) {
|
||||
bool mName = _state.SearchName == null;
|
||||
bool mValue = _state.SearchValue == null;
|
||||
|
||||
if (_state.SearchName != null) {
|
||||
string tagName = node.NodeName;
|
||||
if (tagName != null)
|
||||
mName = tagName.Contains(_state.SearchName);
|
||||
}
|
||||
if (_state.SearchValue != null) {
|
||||
string tagValue = node.NodeDisplay;
|
||||
if (tagValue != null)
|
||||
mValue = tagValue.Contains(_state.SearchValue);
|
||||
}
|
||||
|
||||
if (mName && mValue) {
|
||||
InvokeDiscoverCallback(node);
|
||||
yield return node;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DataNode sub in node.Nodes) {
|
||||
foreach (DataNode s in FindNode(sub))
|
||||
yield return s;
|
||||
}
|
||||
|
||||
if (searchExpanded) {
|
||||
if (!node.IsModified) {
|
||||
node.Collapse();
|
||||
InvokeCollapseCallback(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InvokeDiscoverCallback (DataNode node)
|
||||
{
|
||||
if (_sender != null && _state.DiscoverCallback != null)
|
||||
_sender.BeginInvoke(_state.DiscoverCallback, new object[] { node });
|
||||
}
|
||||
|
||||
private void InvokeCollapseCallback (DataNode node)
|
||||
{
|
||||
if (_sender != null && _state.CollapseCallback != null)
|
||||
_sender.BeginInvoke(_state.CollapseCallback, new object[] { node });
|
||||
}
|
||||
|
||||
private void InvokeEndCallback ()
|
||||
{
|
||||
if (_sender != null && _state.EndCallback != null)
|
||||
_sender.BeginInvoke(_state.EndCallback, new object[] { null });
|
||||
}
|
||||
}
|
||||
}
|
39
NBTExplorerMac/TagKey.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer
|
||||
{
|
||||
public class TagKey : IComparable<TagKey>
|
||||
{
|
||||
public TagKey (string name, TagType type)
|
||||
{
|
||||
Name = name;
|
||||
TagType = type;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public TagType TagType { get; set; }
|
||||
|
||||
#region IComparer<TagKey> Members
|
||||
|
||||
public int Compare (TagKey x, TagKey y)
|
||||
{
|
||||
int typeDiff = (int)x.TagType - (int)y.TagType;
|
||||
if (typeDiff != 0)
|
||||
return typeDiff;
|
||||
|
||||
return String.Compare(x.Name, y.Name, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IComparable<TagKey> Members
|
||||
|
||||
public int CompareTo (TagKey other)
|
||||
{
|
||||
return Compare(this, other);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
70
NBTExplorerMac/Vendor/Be.Windows.Forms.HexBox/AssemblyInfo.cs
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Permissions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("Be.Windows.Forms.HexBox")]
|
||||
[assembly: AssemblyDescription("hex edit control (C# DOTNET)")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Be")]
|
||||
[assembly: AssemblyProduct("Be.Windows.Forms.HexBox")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.4.7.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
|
||||
//[assembly: AssemblyKeyFile("../../HexBox.snk")]
|
||||
//[assembly: AssemblyKeyName("")]
|
||||
|
||||
//[assembly:IsolatedStorageFilePermission(SecurityAction.RequestRefuse, UserQuota=1048576)]
|
||||
//[assembly:SecurityPermission(SecurityAction.RequestRefuse, UnmanagedCode=true)]
|
||||
//[assembly:FileIOPermission(SecurityAction.RequestOptional, Unrestricted=true)]
|
||||
|
||||
[assembly:CLSCompliant(true)]
|
||||
|
||||
[assembly:ComVisible(false)]
|
220
NBTExplorerMac/Vendor/Be.Windows.Forms.HexBox/BuiltInContextMenu.cs
vendored
Normal file
|
@ -0,0 +1,220 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a build-in ContextMenuStrip manager for HexBox control to show Copy, Cut, Paste menu in contextmenu of the control.
|
||||
/// </summary>
|
||||
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
|
||||
public sealed class BuiltInContextMenu : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the HexBox control.
|
||||
/// </summary>
|
||||
HexBox _hexBox;
|
||||
/// <summary>
|
||||
/// Contains the ContextMenuStrip control.
|
||||
/// </summary>
|
||||
ContextMenuStrip _contextMenuStrip;
|
||||
/// <summary>
|
||||
/// Contains the "Cut"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _cutToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Contains the "Copy"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _copyToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Contains the "Paste"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _pasteToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Contains the "Select All"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _selectAllToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of BuildInContextMenu class.
|
||||
/// </summary>
|
||||
/// <param name="hexBox">the HexBox control</param>
|
||||
internal BuiltInContextMenu(HexBox hexBox)
|
||||
{
|
||||
_hexBox = hexBox;
|
||||
_hexBox.ByteProviderChanged += new EventHandler(HexBox_ByteProviderChanged);
|
||||
}
|
||||
/// <summary>
|
||||
/// If ByteProvider
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void HexBox_ByteProviderChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckBuiltInContextMenu();
|
||||
}
|
||||
/// <summary>
|
||||
/// Assigns the ContextMenuStrip control to the HexBox control.
|
||||
/// </summary>
|
||||
void CheckBuiltInContextMenu()
|
||||
{
|
||||
if (Util.DesignMode)
|
||||
return;
|
||||
|
||||
if (this._contextMenuStrip == null)
|
||||
{
|
||||
ContextMenuStrip cms = new ContextMenuStrip();
|
||||
_cutToolStripMenuItem = new ToolStripMenuItem(CutMenuItemTextInternal, CutMenuItemImage, new EventHandler(CutMenuItem_Click));
|
||||
cms.Items.Add(_cutToolStripMenuItem);
|
||||
_copyToolStripMenuItem = new ToolStripMenuItem(CopyMenuItemTextInternal, CopyMenuItemImage, new EventHandler(CopyMenuItem_Click));
|
||||
cms.Items.Add(_copyToolStripMenuItem);
|
||||
_pasteToolStripMenuItem = new ToolStripMenuItem(PasteMenuItemTextInternal, PasteMenuItemImage, new EventHandler(PasteMenuItem_Click));
|
||||
cms.Items.Add(_pasteToolStripMenuItem);
|
||||
|
||||
cms.Items.Add(new ToolStripSeparator());
|
||||
|
||||
_selectAllToolStripMenuItem = new ToolStripMenuItem(SelectAllMenuItemTextInternal, SelectAllMenuItemImage, new EventHandler(SelectAllMenuItem_Click));
|
||||
cms.Items.Add(_selectAllToolStripMenuItem);
|
||||
cms.Opening += new CancelEventHandler(BuildInContextMenuStrip_Opening);
|
||||
|
||||
_contextMenuStrip = cms;
|
||||
}
|
||||
|
||||
if (this._hexBox.ByteProvider == null && this._hexBox.ContextMenuStrip != null)
|
||||
this._hexBox.ContextMenuStrip = null;
|
||||
else if (this._hexBox.ByteProvider != null && this._hexBox.ContextMenuStrip == null)
|
||||
this._hexBox.ContextMenuStrip = _contextMenuStrip;
|
||||
}
|
||||
/// <summary>
|
||||
/// Before opening the ContextMenuStrip, we manage the availability of the items.
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void BuildInContextMenuStrip_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
_cutToolStripMenuItem.Enabled = this._hexBox.CanCut();
|
||||
_copyToolStripMenuItem.Enabled = this._hexBox.CanCopy();
|
||||
_pasteToolStripMenuItem.Enabled = this._hexBox.CanPaste();
|
||||
_selectAllToolStripMenuItem.Enabled = this._hexBox.CanSelectAll();
|
||||
}
|
||||
/// <summary>
|
||||
/// The handler for the "Cut"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void CutMenuItem_Click(object sender, EventArgs e) { this._hexBox.Cut(); }
|
||||
/// <summary>
|
||||
/// The handler for the "Copy"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void CopyMenuItem_Click(object sender, EventArgs e) { this._hexBox.Copy(); }
|
||||
/// <summary>
|
||||
/// The handler for the "Paste"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void PasteMenuItem_Click(object sender, EventArgs e) { this._hexBox.Paste(); }
|
||||
/// <summary>
|
||||
/// The handler for the "Select All"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void SelectAllMenuItem_Click(object sender, EventArgs e) { this._hexBox.SelectAll(); }
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Copy" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string CopyMenuItemText
|
||||
{
|
||||
get { return _copyMenuItemText; }
|
||||
set { _copyMenuItemText = value; }
|
||||
} string _copyMenuItemText;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Cut" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string CutMenuItemText
|
||||
{
|
||||
get { return _cutMenuItemText; }
|
||||
set { _cutMenuItemText = value; }
|
||||
} string _cutMenuItemText;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Paste" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string PasteMenuItemText
|
||||
{
|
||||
get { return _pasteMenuItemText; }
|
||||
set { _pasteMenuItemText = value; }
|
||||
} string _pasteMenuItemText;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Select All" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string SelectAllMenuItemText
|
||||
{
|
||||
get { return _selectAllMenuItemText; }
|
||||
set { _selectAllMenuItemText = value; }
|
||||
} string _selectAllMenuItemText = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text of the "Cut" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string CutMenuItemTextInternal { get { return !string.IsNullOrEmpty(CutMenuItemText) ? CutMenuItemText : "Cut"; } }
|
||||
/// <summary>
|
||||
/// Gets the text of the "Copy" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string CopyMenuItemTextInternal { get { return !string.IsNullOrEmpty(CopyMenuItemText) ? CopyMenuItemText : "Copy"; } }
|
||||
/// <summary>
|
||||
/// Gets the text of the "Paste" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string PasteMenuItemTextInternal { get { return !string.IsNullOrEmpty(PasteMenuItemText) ? PasteMenuItemText : "Paste"; } }
|
||||
/// <summary>
|
||||
/// Gets the text of the "Select All" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string SelectAllMenuItemTextInternal { get { return !string.IsNullOrEmpty(SelectAllMenuItemText) ? SelectAllMenuItemText : "SelectAll"; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Cut" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image CutMenuItemImage
|
||||
{
|
||||
get { return _cutMenuItemImage; }
|
||||
set { _cutMenuItemImage = value; }
|
||||
} Image _cutMenuItemImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Copy" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image CopyMenuItemImage
|
||||
{
|
||||
get { return _copyMenuItemImage; }
|
||||
set { _copyMenuItemImage = value; }
|
||||
} Image _copyMenuItemImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Paste" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image PasteMenuItemImage
|
||||
{
|
||||
get { return _pasteMenuItemImage; }
|
||||
set { _pasteMenuItemImage = value; }
|
||||
} Image _pasteMenuItemImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Select All" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image SelectAllMenuItemImage
|
||||
{
|
||||
get { return _selectAllMenuItemImage; }
|
||||
set { _selectAllMenuItemImage = value; }
|
||||
} Image _selectAllMenuItemImage = null;
|
||||
}
|
||||
}
|
104
NBTExplorerMac/Vendor/Be.Windows.Forms.HexBox/ByteCharConverters.cs
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// The interface for objects that can translate between characters and bytes.
|
||||
/// </summary>
|
||||
public interface IByteCharConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the character to display for the byte passed across.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
char ToChar(byte b);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the byte to use when the character passed across is entered during editing.
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
byte ToByte(char c);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default <see cref="IByteCharConverter"/> implementation.
|
||||
/// </summary>
|
||||
public class DefaultByteCharConverter : IByteCharConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the character to display for the byte passed across.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public virtual char ToChar(byte b)
|
||||
{
|
||||
return b > 0x1F && !(b > 0x7E && b < 0xA0) ? (char)b : '.';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the byte to use for the character passed across.
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
public virtual byte ToByte(char c)
|
||||
{
|
||||
return (byte)c;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a description of the byte char provider.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "Default";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A byte char provider that can translate bytes encoded in codepage 500 EBCDIC
|
||||
/// </summary>
|
||||
public class EbcdicByteCharProvider : IByteCharConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// The IBM EBCDIC code page 500 encoding. Note that this is not always supported by .NET,
|
||||
/// the underlying platform has to provide support for it.
|
||||
/// </summary>
|
||||
private Encoding _ebcdicEncoding = Encoding.GetEncoding(500);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the EBCDIC character corresponding to the byte passed across.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public virtual char ToChar(byte b)
|
||||
{
|
||||
string encoded = _ebcdicEncoding.GetString(new byte[] { b });
|
||||
return encoded.Length > 0 ? encoded[0] : '.';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the byte corresponding to the EBCDIC character passed across.
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
public virtual byte ToByte(char c)
|
||||
{
|
||||
byte[] decoded = _ebcdicEncoding.GetBytes(new char[] { c });
|
||||
return decoded.Length > 0 ? decoded[0] : (byte)0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a description of the byte char provider.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "EBCDIC (Code Page 500)";
|
||||
}
|
||||
}
|
||||
}
|
127
NBTExplorerMac/Vendor/Be.Windows.Forms.HexBox/ByteCollection.cs
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
using System;
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of bytes.
|
||||
/// </summary>
|
||||
public class ByteCollection : CollectionBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ByteCollection class.
|
||||
/// </summary>
|
||||
public ByteCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ByteCollection class.
|
||||
/// </summary>
|
||||
/// <param name="bs">an array of bytes to add to collection</param>
|
||||
public ByteCollection(byte[] bs)
|
||||
{ AddRange(bs); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of a byte
|
||||
/// </summary>
|
||||
public byte this[int index]
|
||||
{
|
||||
get { return (byte)List[index]; }
|
||||
set { List[index] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a byte into the collection.
|
||||
/// </summary>
|
||||
/// <param name="b">the byte to add</param>
|
||||
public void Add(byte b)
|
||||
{ List.Add(b); }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a range of bytes to the collection.
|
||||
/// </summary>
|
||||
/// <param name="bs">the bytes to add</param>
|
||||
public void AddRange(byte[] bs)
|
||||
{ InnerList.AddRange(bs); }
|
||||
|
||||
/// <summary>
|
||||
/// Removes a byte from the collection.
|
||||
/// </summary>
|
||||
/// <param name="b">the byte to remove</param>
|
||||
public void Remove(byte b)
|
||||
{ List.Remove(b); }
|
||||
|
||||
/// <summary>
|
||||
/// Removes a range of bytes from the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the start byte</param>
|
||||
/// <param name="count">the count of the bytes to remove</param>
|
||||
public void RemoveRange(int index, int count)
|
||||
{ InnerList.RemoveRange(index, count); }
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a range of bytes to the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of start byte</param>
|
||||
/// <param name="bs">an array of bytes to insert</param>
|
||||
public void InsertRange(int index, byte[] bs)
|
||||
{ InnerList.InsertRange(index, bs); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all bytes in the array
|
||||
/// </summary>
|
||||
/// <returns>an array of bytes.</returns>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] bytes = new byte[Count];
|
||||
InnerList.CopyTo(0, bytes, 0, bytes.Length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a byte to the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index</param>
|
||||
/// <param name="b">a byte to insert</param>
|
||||
public void Insert(int index, byte b)
|
||||
{
|
||||
InnerList.Insert(index, b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the given byte.
|
||||
/// </summary>
|
||||
public int IndexOf(byte b)
|
||||
{
|
||||
return InnerList.IndexOf(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the byte exists in the collection.
|
||||
/// </summary>
|
||||
public bool Contains(byte b)
|
||||
{
|
||||
return InnerList.Contains(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the content of the collection into the given array.
|
||||
/// </summary>
|
||||
public void CopyTo(byte[] bs, int index)
|
||||
{
|
||||
InnerList.CopyTo(bs, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the content of the collection into an array.
|
||||
/// </summary>
|
||||
/// <returns>the array containing all bytes.</returns>
|
||||
public byte[] ToArray()
|
||||
{
|
||||
byte[] data = new byte[this.Count];
|
||||
this.CopyTo(data, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
28
NBTExplorerMac/Vendor/Be.Windows.Forms.HexBox/BytePositionInfo.cs
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a position in the HexBox control
|
||||
/// </summary>
|
||||
struct BytePositionInfo
|
||||
{
|
||||
public BytePositionInfo(long index, int characterPosition)
|
||||
{
|
||||
_index = index;
|
||||
_characterPosition = characterPosition;
|
||||
}
|
||||
|
||||
public int CharacterPosition
|
||||
{
|
||||
get { return _characterPosition; }
|
||||
} int _characterPosition;
|
||||
|
||||
public long Index
|
||||
{
|
||||
get { return _index; }
|
||||
} long _index;
|
||||
}
|
||||
}
|