From db1662dc9b4930ccab763f8a66332dfb93d70078 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sat, 10 Aug 2013 02:11:04 -0400 Subject: [PATCH] Ready for search and replace beta release (no replace-all yet) --- Controllers/RuleTreeController.cs | 140 ++++++++++++++++++++----- Model/CubicRegionDataNode.cs | 5 + Model/DataNode.cs | 16 +++ Model/DirectoryDataNode.cs | 12 +++ Model/NbtFileDataNode.cs | 5 + Model/RegionChunkDataNode.cs | 5 + Model/RegionFileDataNode.cs | 5 + Model/Search/SearchRule.cs | 146 +++++++++++++++++++++------ Model/TagDataNode.cs | 14 +++ Properties/AssemblyInfo.cs | 4 +- SearchWorker.cs | 23 ++++- Windows/CancelSearchForm.Designer.cs | 7 +- Windows/FindReplace.Designer.cs | 32 +++--- Windows/FindReplace.cs | 10 +- Windows/FindReplace.resx | 72 ++++++------- 15 files changed, 380 insertions(+), 116 deletions(-) diff --git a/Controllers/RuleTreeController.cs b/Controllers/RuleTreeController.cs index 5edb8e8..5fb8fc3 100644 --- a/Controllers/RuleTreeController.cs +++ b/Controllers/RuleTreeController.cs @@ -62,12 +62,6 @@ namespace NBTExplorer.Controllers public string VirtualRootDisplay { get { return _rootData.NodeDisplay; } - /*set - { - _rootData.SetDisplayName(value); - if (ShowVirtualRoot && _nodeTree.Nodes.Count > 0) - UpdateNodeText(_nodeTree.Nodes[0]); - }*/ } public void DeleteSelection () @@ -80,25 +74,20 @@ namespace NBTExplorer.Controllers if (node == null || !(node.Tag is SearchRule)) return; - SearchRule dataNode = node.Tag as SearchRule; - //if (!dataNode.CanDeleteNode) - // return; + TreeNode parent = node.Parent; + if (parent == null || !(parent.Tag is GroupRule)) + return; - /*if (dataNode.DeleteNode()) { - UpdateNodeText(node.Parent); - node.Remove(); + GroupRule parentData = parent.Tag as GroupRule; + SearchRule nodeData = node.Tag as SearchRule; - RemoveNodeFromSelection(node); - OnSelectionInvalidated(); - }*/ + parentData.Rules.Remove(nodeData); + parent.Nodes.Remove(node); } private TreeNode SelectedNode { - get - { - return _nodeTree.SelectedNode; - } + get { return _nodeTree.SelectedNode; } } private TreeNode CreateIntegralNode (string typeName) @@ -125,6 +114,26 @@ namespace NBTExplorer.Controllers return node; } + private void EditIntegralNode (TreeNode node, T rule, string typeName) + where K : TagNode + where T : IntegralTagRule + { + using (ValueRuleForm form = new ValueRuleForm(SearchRule.NumericOpStrings) { + Text = "Edit " + typeName + " Tag Rule", + TagName = rule.Name, + TagValue = rule.Value.ToString(), + Operator = rule.Operator, + }) { + if (form.ShowDialog() == DialogResult.OK) { + rule.Name = form.TagName; + rule.Value = form.TagValueAsLong; + rule.Operator = form.Operator; + } + } + + node.Text = rule.NodeDisplay; + } + private TreeNode CreateFloatNode (string typeName) where K : TagNode where T : FloatTagRule, new() @@ -149,6 +158,26 @@ namespace NBTExplorer.Controllers return node; } + private void EditFloatNode (TreeNode node, T rule, string typeName) + where K : TagNode + where T : FloatTagRule + { + using (ValueRuleForm form = new ValueRuleForm(SearchRule.NumericOpStrings) { + Text = "Edit " + typeName + " Tag Rule", + TagName = rule.Name, + TagValue = rule.Value.ToString(), + Operator = rule.Operator, + }) { + if (form.ShowDialog() == DialogResult.OK) { + rule.Name = form.TagName; + rule.Value = form.TagValueAsDouble; + rule.Operator = form.Operator; + } + } + + node.Text = rule.NodeDisplay; + } + private TreeNode CreateStringNode (string typeName) { StringTagRule rule = new StringTagRule(); @@ -171,6 +200,24 @@ namespace NBTExplorer.Controllers return node; } + private void EditStringNode (TreeNode node, StringTagRule rule, string typeName) + { + using (StringRuleForm form = new StringRuleForm(SearchRule.StringOpStrings) { + Text = "Edit " + typeName + " Tag Rule", + TagName = rule.Name, + TagValue = rule.Value, + Operator = rule.Operator, + }) { + if (form.ShowDialog() == DialogResult.OK) { + rule.Name = form.TagName; + rule.Value = form.TagValue; + rule.Operator = form.Operator; + } + } + + node.Text = rule.NodeDisplay; + } + private TreeNode CreateWildcardNode (string typeName) { WildcardRule rule = new WildcardRule(); @@ -193,6 +240,24 @@ namespace NBTExplorer.Controllers return node; } + private void EditWildcardNode (TreeNode node, WildcardRule rule, string typeName) + { + using (WildcardRuleForm form = new WildcardRuleForm(SearchRule.WildcardOpStrings) { + Text = "Edit " + typeName + " Rule", + TagName = rule.Name, + TagValue = rule.Value, + Operator = rule.Operator, + }) { + if (form.ShowDialog() == DialogResult.OK) { + rule.Name = form.TagName; + rule.Value = form.TagValue; + rule.Operator = form.Operator; + } + } + + node.Text = rule.NodeDisplay; + } + public void CreateNode (TreeNode node, TagType type) { if (node == null || !(node.Tag is GroupRule)) @@ -231,12 +296,39 @@ namespace NBTExplorer.Controllers node.Expand(); } + } - /*if (dataNode.CreateNode(type)) { - node.Text = dataNode.NodeDisplay; - RefreshChildNodes(node, dataNode); - OnSelectionInvalidated(); - }*/ + public void EditNode (TreeNode node) + { + if (node == null || !(node.Tag is SearchRule)) + return; + + SearchRule rule = node.Tag as SearchRule; + + if (rule is ByteTagRule) + EditIntegralNode(node, rule as ByteTagRule, "Byte"); + else if (rule is ShortTagRule) + EditIntegralNode(node, rule as ShortTagRule, "Short"); + else if (rule is IntTagRule) + EditIntegralNode(node, rule as IntTagRule, "Int"); + else if (rule is LongTagRule) + EditIntegralNode(node, rule as LongTagRule, "Long"); + else if (rule is FloatTagRule) + EditFloatNode(node, rule as FloatTagRule, "Float"); + else if (rule is DoubleTagRule) + EditFloatNode(node, rule as DoubleTagRule, "Double"); + else if (rule is StringTagRule) + EditStringNode(node, rule as StringTagRule, "String"); + else if (rule is WildcardRule) + EditWildcardNode(node, rule as WildcardRule, "Wildcard"); + } + + public void EditSelection () + { + if (_nodeTree.SelectedNode == null) + return; + + EditNode(_nodeTree.SelectedNode); } public void CreateWildcardNode (TreeNode node) diff --git a/Model/CubicRegionDataNode.cs b/Model/CubicRegionDataNode.cs index 6e6fca6..55c5785 100644 --- a/Model/CubicRegionDataNode.cs +++ b/Model/CubicRegionDataNode.cs @@ -41,6 +41,11 @@ namespace NBTExplorer.Model get { return !IsExpanded; } } + public override string NodePathName + { + get { return Path.GetFileName(_path); } + } + public override string NodeDisplay { get { return Path.GetFileName(_path); } diff --git a/Model/DataNode.cs b/Model/DataNode.cs index a11bd70..996c270 100644 --- a/Model/DataNode.cs +++ b/Model/DataNode.cs @@ -174,6 +174,22 @@ namespace NBTExplorer.Model get { return ""; } } + public string NodePath + { + get { + string name = NodePathName; + if (string.IsNullOrEmpty(name)) + name = "*"; + + return (Parent != null) ? Parent.NodePath + '/' + name : '/' + name; + } + } + + public virtual string NodePathName + { + get { return NodeName; } + } + public virtual string NodeDisplay { get { return ""; } diff --git a/Model/DirectoryDataNode.cs b/Model/DirectoryDataNode.cs index 83efe03..3b7b9c5 100644 --- a/Model/DirectoryDataNode.cs +++ b/Model/DirectoryDataNode.cs @@ -1,5 +1,6 @@ using System.IO; using System.Collections.Generic; +using System; namespace NBTExplorer.Model { @@ -21,6 +22,17 @@ namespace NBTExplorer.Model } } + public override string NodePathName + { + get + { + string name = Path.GetDirectoryName(_path); + int sepIndex = Math.Max(name.LastIndexOf('/'), name.LastIndexOf('\\')); + + return (sepIndex > 0) ? name.Substring(sepIndex + 1) : name; + } + } + public override string NodeDisplay { get { return Path.GetFileName(_path); } diff --git a/Model/NbtFileDataNode.cs b/Model/NbtFileDataNode.cs index edf10dc..c3bb464 100644 --- a/Model/NbtFileDataNode.cs +++ b/Model/NbtFileDataNode.cs @@ -70,6 +70,11 @@ namespace NBTExplorer.Model get { return Path.GetFileName(_path); } } + public override string NodePathName + { + get { return Path.GetFileName(_path); } + } + public override string NodeDisplay { get diff --git a/Model/RegionChunkDataNode.cs b/Model/RegionChunkDataNode.cs index 599ef66..19ce0b7 100644 --- a/Model/RegionChunkDataNode.cs +++ b/Model/RegionChunkDataNode.cs @@ -36,6 +36,11 @@ namespace NBTExplorer.Model get { return !IsExpanded; } } + public override string NodePathName + { + get { return _x + "." + _z; } + } + public override string NodeDisplay { get { return "Chunk [" + _x + ", " + _z + "]"; } diff --git a/Model/RegionFileDataNode.cs b/Model/RegionFileDataNode.cs index 8b2b2d7..d043b9e 100644 --- a/Model/RegionFileDataNode.cs +++ b/Model/RegionFileDataNode.cs @@ -42,6 +42,11 @@ namespace NBTExplorer.Model get { return !IsExpanded; } } + public override string NodePathName + { + get { return Path.GetFileName(_path); } + } + public override string NodeDisplay { get { return Path.GetFileName(_path); } diff --git a/Model/Search/SearchRule.cs b/Model/Search/SearchRule.cs index 8a1d65d..245eb23 100644 --- a/Model/Search/SearchRule.cs +++ b/Model/Search/SearchRule.cs @@ -170,13 +170,31 @@ namespace NBTExplorer.Model.Search TagDataNode childNode = GetChild(container, Name); T data = LookupTag(container, Name); - if (data != null && data.ToTagLong() == Value) { - if (!matchedNodes.Contains(childNode)) - matchedNodes.Add(childNode); - return true; + if (data != null) { + switch (Operator) { + case NumericOperator.Equals: + if (data.ToTagLong() != Value) + return false; + break; + case NumericOperator.NotEquals: + if (data.ToTagLong() == Value) + return false; + break; + case NumericOperator.GreaterThan: + if (data.ToTagLong() <= Value) + return false; + break; + case NumericOperator.LessThan: + if (data.ToTagLong() >= Value) + return false; + break; + } } - return false; + if (!matchedNodes.Contains(childNode)) + matchedNodes.Add(childNode); + + return true; } } @@ -209,13 +227,31 @@ namespace NBTExplorer.Model.Search TagDataNode childNode = GetChild(container, Name); T data = LookupTag(container, Name); - if (data != null && data.ToTagDouble() == Value) { - if (!matchedNodes.Contains(childNode)) - matchedNodes.Add(childNode); - return true; + if (data != null) { + switch (Operator) { + case NumericOperator.Equals: + if (data.ToTagDouble() != Value) + return false; + break; + case NumericOperator.NotEquals: + if (data.ToTagDouble() == Value) + return false; + break; + case NumericOperator.GreaterThan: + if (data.ToTagDouble() <= Value) + return false; + break; + case NumericOperator.LessThan: + if (data.ToTagDouble() >= Value) + return false; + break; + } } + + if (!matchedNodes.Contains(childNode)) + matchedNodes.Add(childNode); - return false; + return true; } } @@ -241,13 +277,39 @@ namespace NBTExplorer.Model.Search TagDataNode childNode = GetChild(container, Name); TagNodeString data = LookupTag(container, Name); - if (data != null && data.ToTagString() == Value) { - if (!matchedNodes.Contains(childNode)) - matchedNodes.Add(childNode); - return true; + if (data != null) { + switch (Operator) { + case StringOperator.Equals: + if (data.ToTagString().Data != Value) + return false; + break; + case StringOperator.NotEquals: + if (data.ToTagString().Data == Value) + return false; + break; + case StringOperator.Contains: + if (!data.ToTagString().Data.Contains(Value)) + return false; + break; + case StringOperator.NotContains: + if (data.ToTagString().Data.Contains(Value)) + return false; + break; + case StringOperator.StartsWith: + if (!data.ToTagString().Data.StartsWith(Value)) + return false; + break; + case StringOperator.EndsWith: + if (!data.ToTagString().Data.EndsWith(Value)) + return false; + break; + } } - return false; + if (!matchedNodes.Contains(childNode)) + matchedNodes.Add(childNode); + + return true; } } @@ -276,27 +338,51 @@ namespace NBTExplorer.Model.Search case TagType.TAG_INT: case TagType.TAG_LONG: case TagType.TAG_SHORT: - if (long.Parse(Value) == tag.ToTagLong()) { - if (!matchedNodes.Contains(childNode)) - matchedNodes.Add(childNode); - return true; + switch (Operator) { + case WildcardOperator.Equals: + if (long.Parse(Value) != tag.ToTagLong()) + return false; + break; + case WildcardOperator.NotEquals: + if (long.Parse(Value) == tag.ToTagLong()) + return false; + break; } - break; + + if (!matchedNodes.Contains(childNode)) + matchedNodes.Add(childNode); + return true; case TagType.TAG_FLOAT: case TagType.TAG_DOUBLE: - if (double.Parse(Value) == tag.ToTagDouble()) { - if (!matchedNodes.Contains(childNode)) - matchedNodes.Add(childNode); - return true; + switch (Operator) { + case WildcardOperator.Equals: + if (double.Parse(Value) != tag.ToTagDouble()) + return false; + break; + case WildcardOperator.NotEquals: + if (double.Parse(Value) == tag.ToTagDouble()) + return false; + break; } - break; + + if (!matchedNodes.Contains(childNode)) + matchedNodes.Add(childNode); + return true; case TagType.TAG_STRING: - if (Value == tag.ToTagString()) { - if (!matchedNodes.Contains(childNode)) - matchedNodes.Add(childNode); - return true; + switch (Operator) { + case WildcardOperator.Equals: + if (Value != tag.ToTagString().Data) + return false; + break; + case WildcardOperator.NotEquals: + if (Value == tag.ToTagString().Data) + return false; + break; } - break; + + if (!matchedNodes.Contains(childNode)) + matchedNodes.Add(childNode); + return true; } } catch { } diff --git a/Model/TagDataNode.cs b/Model/TagDataNode.cs index 8c52ff5..34d96e3 100644 --- a/Model/TagDataNode.cs +++ b/Model/TagDataNode.cs @@ -194,6 +194,20 @@ namespace NBTExplorer.Model } } + public override string NodePathName + { + get + { + if (Parent is TagDataNode.Container) { + TagDataNode.Container container = Parent as TagDataNode.Container; + if (container.IsOrderedContainer) + return container.OrderedTagContainer.GetTagIndex(Tag).ToString(); + } + + return base.NodePathName; + } + } + protected string NodeDisplayPrefix { get diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c2bbd9a..a2d6a97 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 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.4.0.0")] -[assembly: AssemblyFileVersion("2.4.0.0")] +[assembly: AssemblyVersion("2.5.0.0")] +[assembly: AssemblyFileVersion("2.5.0.0")] diff --git a/SearchWorker.cs b/SearchWorker.cs index 5c01337..7963f23 100644 --- a/SearchWorker.cs +++ b/SearchWorker.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using NBTExplorer.Model; +using System.Diagnostics; namespace NBTExplorer { @@ -11,6 +12,8 @@ namespace NBTExplorer IEnumerator State { get; set; } bool TerminateOnDiscover { get; set; } + float ProgressRate { get; set; } + void InvokeDiscoverCallback (DataNode node); void InvokeProgressCallback (DataNode node); void InvokeCollapseCallback (DataNode node); @@ -27,6 +30,7 @@ namespace NBTExplorer public DataNode RootNode { get; set; } public IEnumerator State { get; set; } public bool TerminateOnDiscover { get; set; } + public float ProgressRate { get; set; } public abstract void InvokeDiscoverCallback (DataNode node); public abstract void InvokeProgressCallback (DataNode node); @@ -36,6 +40,7 @@ namespace NBTExplorer protected NameValueSearchState () { TerminateOnDiscover = true; + ProgressRate = .5f; } public bool TestNode (DataNode node) @@ -68,6 +73,10 @@ namespace NBTExplorer private bool _cancel; private object _lock; + private Stopwatch _progressWatch; + private float _progressTime; + private float _lastSampleTime; + public SearchWorker (ISearchState state) { _state = state; @@ -83,11 +92,16 @@ namespace NBTExplorer public void Run () { + _progressWatch = new Stopwatch(); + _progressWatch.Start(); + if (_state.State == null) _state.State = FindNode(_state.RootNode).GetEnumerator(); if (!_state.State.MoveNext()) InvokeEndCallback(); + + _progressWatch.Stop(); } private IEnumerable FindNode (DataNode node) @@ -108,7 +122,14 @@ namespace NBTExplorer TagDataNode tagNode = node as TagDataNode; if (tagNode != null) { - InvokeProgressCallback(node); + float currentSampleTime = (float)_progressWatch.Elapsed.TotalSeconds; + _progressTime += (currentSampleTime - _lastSampleTime); + _lastSampleTime = currentSampleTime; + + if (_progressTime > _state.ProgressRate) { + InvokeProgressCallback(node); + _progressTime -= _state.ProgressRate; + } if (_state.TestNode(tagNode)) { InvokeDiscoverCallback(node); diff --git a/Windows/CancelSearchForm.Designer.cs b/Windows/CancelSearchForm.Designer.cs index 5e4216e..6187b5b 100644 --- a/Windows/CancelSearchForm.Designer.cs +++ b/Windows/CancelSearchForm.Designer.cs @@ -34,7 +34,7 @@ // _buttonCancel // this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this._buttonCancel.Location = new System.Drawing.Point(167, 57); + this._buttonCancel.Location = new System.Drawing.Point(232, 45); this._buttonCancel.Name = "_buttonCancel"; this._buttonCancel.Size = new System.Drawing.Size(75, 23); this._buttonCancel.TabIndex = 0; @@ -45,17 +45,16 @@ // this._searchPathLabel.Location = new System.Drawing.Point(12, 19); this._searchPathLabel.Name = "_searchPathLabel"; - this._searchPathLabel.Size = new System.Drawing.Size(385, 23); + this._searchPathLabel.Size = new System.Drawing.Size(514, 23); this._searchPathLabel.TabIndex = 1; this._searchPathLabel.Text = "..."; - this._searchPathLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // CancelSearchForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this._buttonCancel; - this.ClientSize = new System.Drawing.Size(409, 92); + this.ClientSize = new System.Drawing.Size(538, 84); this.Controls.Add(this._searchPathLabel); this.Controls.Add(this._buttonCancel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; diff --git a/Windows/FindReplace.Designer.cs b/Windows/FindReplace.Designer.cs index c8a7c56..0cdba2d 100644 --- a/Windows/FindReplace.Designer.cs +++ b/Windows/FindReplace.Designer.cs @@ -171,7 +171,7 @@ this._tbFindEdit.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbFindEdit.Name = "_tbFindEdit"; this._tbFindEdit.Size = new System.Drawing.Size(23, 22); - this._tbFindEdit.Text = "toolStripButton1"; + this._tbFindEdit.Text = "Edit Selected Rule"; this._tbFindEdit.Click += new System.EventHandler(this._tbFindEdit_Click); // // _tbFindDelete @@ -181,7 +181,7 @@ this._tbFindDelete.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbFindDelete.Name = "_tbFindDelete"; this._tbFindDelete.Size = new System.Drawing.Size(23, 22); - this._tbFindDelete.Text = "toolStripButton1"; + this._tbFindDelete.Text = "Delete Selected Rule"; this._tbFindDelete.Click += new System.EventHandler(this._tbFindDelete_Click); // // toolStripSeparator1 @@ -364,7 +364,7 @@ this._tbReplaceEdit.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceEdit.Name = "_tbReplaceEdit"; this._tbReplaceEdit.Size = new System.Drawing.Size(23, 22); - this._tbReplaceEdit.Text = "toolStripButton1"; + this._tbReplaceEdit.Text = "Edit Selected Tag"; this._tbReplaceEdit.Click += new System.EventHandler(this._tbReplaceEdit_Click); // // _tbReplaceDelete @@ -374,7 +374,7 @@ this._tbReplaceDelete.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceDelete.Name = "_tbReplaceDelete"; this._tbReplaceDelete.Size = new System.Drawing.Size(23, 22); - this._tbReplaceDelete.Text = "toolStripButton2"; + this._tbReplaceDelete.Text = "Delete Selected Tag"; this._tbReplaceDelete.Click += new System.EventHandler(this._tbReplaceDelete_Click); // // toolStripSeparator2 @@ -389,7 +389,7 @@ this._tbReplaceByte.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceByte.Name = "_tbReplaceByte"; this._tbReplaceByte.Size = new System.Drawing.Size(23, 22); - this._tbReplaceByte.Text = "toolStripButton11"; + this._tbReplaceByte.Text = "Add Byte Tag"; this._tbReplaceByte.Click += new System.EventHandler(this._tbReplaceByte_Click); // // _tbReplaceShort @@ -399,7 +399,7 @@ this._tbReplaceShort.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceShort.Name = "_tbReplaceShort"; this._tbReplaceShort.Size = new System.Drawing.Size(23, 22); - this._tbReplaceShort.Text = "toolStripButton12"; + this._tbReplaceShort.Text = "Add Short Tag"; this._tbReplaceShort.Click += new System.EventHandler(this._tbReplaceShort_Click); // // _tbReplaceInt @@ -409,7 +409,7 @@ this._tbReplaceInt.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceInt.Name = "_tbReplaceInt"; this._tbReplaceInt.Size = new System.Drawing.Size(23, 22); - this._tbReplaceInt.Text = "toolStripButton13"; + this._tbReplaceInt.Text = "Add Int Tag"; this._tbReplaceInt.Click += new System.EventHandler(this._tbReplaceInt_Click); // // _tbReplaceLong @@ -419,7 +419,7 @@ this._tbReplaceLong.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceLong.Name = "_tbReplaceLong"; this._tbReplaceLong.Size = new System.Drawing.Size(23, 22); - this._tbReplaceLong.Text = "toolStripButton14"; + this._tbReplaceLong.Text = "Add Long Tag"; this._tbReplaceLong.Click += new System.EventHandler(this._tbReplaceLong_Click); // // _tbReplaceFloat @@ -429,7 +429,7 @@ this._tbReplaceFloat.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceFloat.Name = "_tbReplaceFloat"; this._tbReplaceFloat.Size = new System.Drawing.Size(23, 22); - this._tbReplaceFloat.Text = "toolStripButton15"; + this._tbReplaceFloat.Text = "Add Float Tag"; this._tbReplaceFloat.Click += new System.EventHandler(this._tbReplaceFloat_Click); // // _tbReplaceDouble @@ -439,7 +439,7 @@ this._tbReplaceDouble.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceDouble.Name = "_tbReplaceDouble"; this._tbReplaceDouble.Size = new System.Drawing.Size(23, 22); - this._tbReplaceDouble.Text = "toolStripButton16"; + this._tbReplaceDouble.Text = "Add Double Tag"; this._tbReplaceDouble.Click += new System.EventHandler(this._tbReplaceDouble_Click); // // _tbReplaceByteArray @@ -449,7 +449,7 @@ this._tbReplaceByteArray.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceByteArray.Name = "_tbReplaceByteArray"; this._tbReplaceByteArray.Size = new System.Drawing.Size(23, 22); - this._tbReplaceByteArray.Text = "toolStripButton17"; + this._tbReplaceByteArray.Text = "Add Byte Array Tag"; this._tbReplaceByteArray.Click += new System.EventHandler(this._tbReplaceByteArray_Click); // // _tbReplaceIntArray @@ -459,7 +459,7 @@ this._tbReplaceIntArray.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceIntArray.Name = "_tbReplaceIntArray"; this._tbReplaceIntArray.Size = new System.Drawing.Size(23, 22); - this._tbReplaceIntArray.Text = "toolStripButton18"; + this._tbReplaceIntArray.Text = "Add Int Array Tag"; this._tbReplaceIntArray.Click += new System.EventHandler(this._tbReplaceIntArray_Click); // // _tbReplaceString @@ -469,7 +469,7 @@ this._tbReplaceString.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceString.Name = "_tbReplaceString"; this._tbReplaceString.Size = new System.Drawing.Size(23, 22); - this._tbReplaceString.Text = "toolStripButton19"; + this._tbReplaceString.Text = "Add String Tag"; this._tbReplaceString.Click += new System.EventHandler(this._tbReplaceString_Click); // // _tbReplaceList @@ -479,7 +479,7 @@ this._tbReplaceList.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceList.Name = "_tbReplaceList"; this._tbReplaceList.Size = new System.Drawing.Size(23, 22); - this._tbReplaceList.Text = "toolStripButton20"; + this._tbReplaceList.Text = "Add List Tag"; this._tbReplaceList.Click += new System.EventHandler(this._tbReplaceList_Click); // // _tbReplaceCompound @@ -489,7 +489,7 @@ this._tbReplaceCompound.ImageTransparentColor = System.Drawing.Color.Magenta; this._tbReplaceCompound.Name = "_tbReplaceCompound"; this._tbReplaceCompound.Size = new System.Drawing.Size(23, 22); - this._tbReplaceCompound.Text = "toolStripButton21"; + this._tbReplaceCompound.Text = "Add Compound Tag"; this._tbReplaceCompound.Click += new System.EventHandler(this._tbReplaceCompound_Click); // // _buttonFind @@ -549,7 +549,7 @@ this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "FindReplace"; - this.Text = "Replace"; + this.Text = "Find and Replace"; this.groupBox1.ResumeLayout(false); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); diff --git a/Windows/FindReplace.cs b/Windows/FindReplace.cs index 35de689..22264ee 100644 --- a/Windows/FindReplace.cs +++ b/Windows/FindReplace.cs @@ -239,8 +239,10 @@ namespace NBTExplorer.Windows private void SearchProgressCallback (DataNode node) { - if (node is TagCompoundDataNode && !string.IsNullOrEmpty(node.NodeName) && node.NodeName != _searchForm.SearchPathLabel) - _searchForm.SearchPathLabel = node.NodeName; + try { + _searchForm.SearchPathLabel = node.NodePath; + } + catch { } } private void SearchCollapseCallback (DataNode node) @@ -296,7 +298,7 @@ namespace NBTExplorer.Windows private void _tbFindEdit_Click (object sender, EventArgs e) { - //_findController.EditSelection(); + _findController.EditSelection(); } private void _tbReplaceEdit_Click (object sender, EventArgs e) @@ -312,6 +314,7 @@ namespace NBTExplorer.Windows public DataNode RootNode { get; set; } public IEnumerator State { get; set; } public bool TerminateOnDiscover { get; set; } + public float ProgressRate { get; set; } public abstract void InvokeDiscoverCallback (DataNode node); public abstract void InvokeProgressCallback (DataNode node); @@ -321,6 +324,7 @@ namespace NBTExplorer.Windows protected ContainerRuleSearchState () { TerminateOnDiscover = true; + ProgressRate = .5f; } public bool TestNode (DataNode node) diff --git a/Windows/FindReplace.resx b/Windows/FindReplace.resx index adfa65b..b475523 100644 --- a/Windows/FindReplace.resx +++ b/Windows/FindReplace.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABA - QgAAAk1TRnQBSQFMAgEBFAEAAYABAQGAAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA + QgAAAk1TRnQBSQFMAgEBFAEAAZABAQGQAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABYAMAAQEBAAEYBgABSP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AOEAA/8D/AP6GPgD+QP6A/wMAAP9 A/oS+AP5A/0D/2kAA/4D+QPxAboBogGKAbYBhgFWAbYBhgFWAbYBhgFWAbYBhgFWAbYBhgFWAbYBhgFW AbYBhgFWAbYBhgFWAbwBpAGNA/cMAAP8A/YD8wG8AcoBzQFVAZUBowFVAZUBowHQAdcB2QPzA/UD+wP/ @@ -443,48 +443,48 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJPSURBVDhPzZHdT1JxHMbPqqsuwpdq5kVrqzbW9CZj66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