diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index b9bc44b..1bee627 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -84,11 +84,11 @@ this.RightToolStripPanel = new System.Windows.Forms.ToolStripPanel(); this.LeftToolStripPanel = new System.Windows.Forms.ToolStripPanel(); this.ContentPanel = new System.Windows.Forms.ToolStripContentPanel(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); - this.statusStrip1.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -118,26 +118,26 @@ this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Text = "&File"; // - // openToolStripMenuItem + // _menuItemOpen // - this._menuItemOpen.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image"))); - this._menuItemOpen.Name = "openToolStripMenuItem"; + 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..."; // - // openFolderToolStripMenuItem + // _menuItemOpenFolder // - this._menuItemOpenFolder.Image = ((System.Drawing.Image)(resources.GetObject("openFolderToolStripMenuItem.Image"))); - this._menuItemOpenFolder.Name = "openFolderToolStripMenuItem"; + 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..."; // - // openMinecraftSaveFolderToolStripMenuItem + // _menuItemOpenMinecraftSaveFolder // - this._menuItemOpenMinecraftSaveFolder.Name = "openMinecraftSaveFolderToolStripMenuItem"; + this._menuItemOpenMinecraftSaveFolder.Name = "_menuItemOpenMinecraftSaveFolder"; this._menuItemOpenMinecraftSaveFolder.Size = new System.Drawing.Size(223, 22); this._menuItemOpenMinecraftSaveFolder.Text = "Open &Minecraft Save Folder"; // @@ -146,10 +146,10 @@ this.toolStripSeparator3.Name = "toolStripSeparator3"; this.toolStripSeparator3.Size = new System.Drawing.Size(220, 6); // - // saveToolStripMenuItem + // _menuItemSave // - this._menuItemSave.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image"))); - this._menuItemSave.Name = "saveToolStripMenuItem"; + 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"; @@ -159,10 +159,10 @@ this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Size = new System.Drawing.Size(220, 6); // - // exitToolStripMenuItem + // _menuItemExit // - this._menuItemExit.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem.Image"))); - this._menuItemExit.Name = "exitToolStripMenuItem"; + 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"; @@ -181,26 +181,26 @@ this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); this.editToolStripMenuItem.Text = "&Edit"; // - // cutToolStripMenuItem + // _menuItemCut // - this._menuItemCut.Image = ((System.Drawing.Image)(resources.GetObject("cutToolStripMenuItem.Image"))); - this._menuItemCut.Name = "cutToolStripMenuItem"; + 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"; // - // copyToolStripMenuItem + // _menuItemCopy // - this._menuItemCopy.Image = ((System.Drawing.Image)(resources.GetObject("copyToolStripMenuItem.Image"))); - this._menuItemCopy.Name = "copyToolStripMenuItem"; + 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"; // - // pasteToolStripMenuItem + // _menuItemPaste // - this._menuItemPaste.Image = ((System.Drawing.Image)(resources.GetObject("pasteToolStripMenuItem.Image"))); - this._menuItemPaste.Name = "pasteToolStripMenuItem"; + 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"; @@ -210,26 +210,26 @@ this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Size = new System.Drawing.Size(163, 6); // - // renameToolStripMenuItem + // _menuItemRename // - this._menuItemRename.Image = ((System.Drawing.Image)(resources.GetObject("renameToolStripMenuItem.Image"))); - this._menuItemRename.Name = "renameToolStripMenuItem"; + 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"; // - // editValueToolStripMenuItem + // _menuItemEditValue // - this._menuItemEditValue.Image = ((System.Drawing.Image)(resources.GetObject("editValueToolStripMenuItem.Image"))); - this._menuItemEditValue.Name = "editValueToolStripMenuItem"; + 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"; // - // deleteToolStripMenuItem + // _menuItemDelete // - this._menuItemDelete.Image = ((System.Drawing.Image)(resources.GetObject("deleteToolStripMenuItem.Image"))); - this._menuItemDelete.Name = "deleteToolStripMenuItem"; + 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"; @@ -243,18 +243,18 @@ this.searchToolStripMenuItem.Size = new System.Drawing.Size(54, 20); this.searchToolStripMenuItem.Text = "&Search"; // - // findToolStripMenuItem + // _menuItemFind // - this._menuItemFind.Image = ((System.Drawing.Image)(resources.GetObject("findToolStripMenuItem.Image"))); - this._menuItemFind.Name = "findToolStripMenuItem"; + 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..."; // - // findNextToolStripMenuItem + // _menuItemFindNext // - this._menuItemFindNext.Image = ((System.Drawing.Image)(resources.GetObject("findNextToolStripMenuItem.Image"))); - this._menuItemFindNext.Name = "findNextToolStripMenuItem"; + 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"; @@ -267,10 +267,10 @@ this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); this.helpToolStripMenuItem.Text = "&Help"; // - // aboutToolStripMenuItem + // _menuItemAbout // - this._menuItemAbout.Image = ((System.Drawing.Image)(resources.GetObject("aboutToolStripMenuItem.Image"))); - this._menuItemAbout.Name = "aboutToolStripMenuItem"; + 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"; @@ -288,7 +288,7 @@ 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, 350); + this._nodeTree.Size = new System.Drawing.Size(619, 374); this._nodeTree.TabIndex = 0; // // imageList1 @@ -592,22 +592,18 @@ // this.ContentPanel.Size = new System.Drawing.Size(562, 376); // - // statusStrip1 + // contextMenuStrip1 // - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 401); - this.statusStrip1.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(619, 22); - this.statusStrip1.TabIndex = 1; - this.statusStrip1.Text = "statusStrip1"; + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.testToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(97, 26); // - // toolStripStatusLabel1 + // testToolStripMenuItem // - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(604, 17); - this.toolStripStatusLabel1.Spring = true; + this.testToolStripMenuItem.Name = "testToolStripMenuItem"; + this.testToolStripMenuItem.Size = new System.Drawing.Size(96, 22); + this.testToolStripMenuItem.Text = "Test"; // // MainForm // @@ -615,7 +611,6 @@ 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.statusStrip1); this.Controls.Add(this.toolStrip1); this.Controls.Add(this._nodeTree); this.Controls.Add(this.menuStrip1); @@ -627,8 +622,7 @@ this.menuStrip1.PerformLayout(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); + this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -678,8 +672,6 @@ private System.Windows.Forms.ToolStripPanel RightToolStripPanel; private System.Windows.Forms.ToolStripPanel LeftToolStripPanel; private System.Windows.Forms.ToolStripContentPanel ContentPanel; - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripButton _buttonAddTagIntArray; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem _menuItemCut; @@ -693,6 +685,8 @@ 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; } } diff --git a/MainForm.cs b/MainForm.cs index d5df581..41ba40f 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -45,6 +45,7 @@ namespace NBTExplorer _nodeTree.AfterCollapse += _nodeTree_AfterCollapse; _nodeTree.AfterSelect += _nodeTree_AfterSelect; _nodeTree.NodeMouseDoubleClick += _nodeTree_NodeMouseDoubleClick; + _nodeTree.NodeMouseClick += _nodeTree_NodeMouseClick; _nodeTree.DragEnter += _nodeTree_DragEnter; _nodeTree.DragDrop += _nodeTree_DragDrop; @@ -192,6 +193,7 @@ namespace NBTExplorer frontNode.ImageIndex = _iconRegistry.Lookup(node.GetType()); frontNode.SelectedImageIndex = frontNode.ImageIndex; frontNode.Tag = node; + frontNode.ContextMenuStrip = BuildNodeContextMenu(node); if (node.HasUnexpandedChildren) frontNode.Nodes.Add(new TreeNode()); @@ -199,6 +201,46 @@ namespace NBTExplorer 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) + { + + } + private void ExpandNode (TreeNode node) { if (node == null || !(node.Tag is DataNode)) @@ -257,7 +299,18 @@ namespace NBTExplorer 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); + + /*foreach (DataNode child in dataNode.Nodes) { if (!currentNodes.ContainsKey(child)) node.Nodes.Add(CreateUnexpandedNode(child)); else @@ -266,7 +319,7 @@ namespace NBTExplorer foreach (TreeNode child in currentNodes.Values) { node.Nodes.Remove(child); - } + }*/ if (node.Nodes.Count == 0 && dataNode.HasUnexpandedChildren) { ExpandNode(node); @@ -629,6 +682,12 @@ namespace NBTExplorer 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)); diff --git a/MainForm.resx b/MainForm.resx index 5097d62..8f89107 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -112,16 +112,16 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - - + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAACkklEQVQ4T43SX0hTURzA8d9b @@ -139,7 +139,7 @@ gg== - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADrwAAA68AZW8ckkAAAI/SURBVDhPjdJPSJNxGAfw5xYd6+hZJIhCkm5d8hBeIq/9 @@ -155,7 +155,7 @@ 8h/ayQIkRwIF8QAAAABJRU5ErkJggg== - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABwklEQVQ4T6XOT0iTcRzH8e+e @@ -169,7 +169,7 @@ L1tJUV/SlAd3xCblH+s4aw2T/BzJAAAAAElFTkSuQmCC - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAB/UlEQVQ4T41SS0tVURjdEwc5 @@ -184,7 +184,7 @@ OFkM9KlfL99lseAvRjbC0XMbRtAAAAAASU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+Bg + cvnH0cZrrv8KuxaLBTbb8e1bYKd+I3LkYufVjY9A6i0QebOD4gZAXL+Ld4lEAhzHsStzs4cUgkwm+06k + 7vT84mDg5tbh8/dxKHkPI7N3Mfoc0AVv/Rx0N4UO9jM8ZPgqBhvSE7Y3EHqxwKtOzm8RFAcsT3u1kgE6 + iGGIYfh/2Hdq4Y7iRPNcr2bgN3SrJ86cZttBAAAAAElFTkSuQmCC - - 527, 17 + + 347, 17 diff --git a/Model/DataNode.cs b/Model/DataNode.cs index 3aac21a..bfe356e 100644 --- a/Model/DataNode.cs +++ b/Model/DataNode.cs @@ -146,6 +146,21 @@ namespace NBTExplorer.Model 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; @@ -190,6 +205,11 @@ namespace NBTExplorer.Model return false; } + public virtual bool ChangeRelativePosition (int offset) + { + return false; + } + #endregion } } diff --git a/Model/NodeCapabilities.cs b/Model/NodeCapabilities.cs index e5f08a3..9588730 100644 --- a/Model/NodeCapabilities.cs +++ b/Model/NodeCapabilities.cs @@ -14,5 +14,6 @@ namespace NBTExplorer.Model Delete = 0x20, CreateTag = 0x40, Search = 0x80, + Reorder = 0x100, } } diff --git a/Model/TagDataNode.cs b/Model/TagDataNode.cs index b85a0c2..b084621 100644 --- a/Model/TagDataNode.cs +++ b/Model/TagDataNode.cs @@ -57,6 +57,7 @@ namespace NBTExplorer.Model | NodeCapabilities.Delete | NodeCapabilities.PasteInto | (TagParent.IsNamedContainer ? NodeCapabilities.Rename : NodeCapabilities.None) + | (TagParent.IsOrderedContainer ? NodeCapabilities.Reorder : NodeCapabilities.None) | NodeCapabilities.Search; } } @@ -158,7 +159,28 @@ namespace NBTExplorer.Model | NodeCapabilities.Cut | NodeCapabilities.Delete | NodeCapabilities.Edit - | (TagParent.IsNamedContainer ? NodeCapabilities.Rename : NodeCapabilities.None); + | (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; } } @@ -238,6 +260,27 @@ namespace NBTExplorer.Model 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); + return true; + } + + return false; + } + protected bool EditScalarValue (TagNode tag) { EditValue form = new EditValue(tag); diff --git a/NBTExplorer.csproj b/NBTExplorer.csproj index 49c84e3..4a54f3e 100644 --- a/NBTExplorer.csproj +++ b/NBTExplorer.csproj @@ -119,13 +119,23 @@ + + + + + + + + + + Component @@ -196,6 +206,8 @@ + + diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index bdc9983..0d3bc07 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -59,5 +59,19 @@ namespace NBTExplorer.Properties { 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)); + } + } } } diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 7080a7d..39a9e38 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -112,9 +112,16 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\arrow-270.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrow-090.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/arrow-090.png b/Resources/arrow-090.png new file mode 100644 index 0000000..4e4f5b8 Binary files /dev/null and b/Resources/arrow-090.png differ diff --git a/Resources/arrow-270.png b/Resources/arrow-270.png new file mode 100644 index 0000000..8d5209b Binary files /dev/null and b/Resources/arrow-270.png differ