Replace-All seems to be working

This commit is contained in:
Justin Aquadro 2013-10-30 01:43:20 -04:00
parent a8cf67b8f4
commit 14444dd1b5
6 changed files with 124 additions and 52 deletions

View file

@ -5,13 +5,24 @@ namespace NBTExplorer.Model
{
public class DataNodeCollection : IList<DataNode>
{
private List<DataNode> _nodes;
private SnapshotList<DataNode> _nodes;
private DataNode _parent;
private int _changeCount;
internal DataNodeCollection (DataNode parent)
{
_parent = parent;
_nodes = new List<DataNode>();
_nodes = new SnapshotList<DataNode>();
}
public SnapshotState<DataNode> Snapshot ()
{
return _nodes.Snapshot();
}
public int ChangeCount
{
get { return _changeCount; }
}
public int IndexOf (DataNode item)
@ -29,6 +40,7 @@ namespace NBTExplorer.Model
item.Parent = _parent;
_nodes.Insert(index, item);
_changeCount++;
}
public void RemoveAt (int index)
@ -40,6 +52,7 @@ namespace NBTExplorer.Model
node.Parent = null;
_nodes.RemoveAt(index);
_changeCount++;
}
DataNode IList<DataNode>.this[int index]
@ -57,6 +70,7 @@ namespace NBTExplorer.Model
_nodes[index].Parent = null;
_nodes[index] = value;
_nodes[index].Parent = _parent;
_changeCount++;
}
}
@ -70,6 +84,7 @@ namespace NBTExplorer.Model
item.Parent = _parent;
_nodes.Add(item);
_changeCount++;
}
public void Clear ()
@ -78,6 +93,7 @@ namespace NBTExplorer.Model
node.Parent = null;
_nodes.Clear();
_changeCount++;
}
public bool Contains (DataNode item)
@ -105,6 +121,8 @@ namespace NBTExplorer.Model
if (_nodes.Contains(item))
item.Parent = null;
_changeCount++;
return _nodes.Remove(item);
}

View file

@ -87,6 +87,7 @@
<Compile Include="Controllers\RuleTreeController.cs" />
<Compile Include="Model\Search\SearchRule.cs" />
<Compile Include="NbtClipboardController.cs" />
<Compile Include="SnapshotList.cs" />
<Compile Include="Vendor\MultiSelectTreeView\MultiSelectTreeview.cs">
<SubType>Component</SubType>
</Compile>

View file

@ -11,6 +11,7 @@ namespace NBTExplorer
IEnumerator<DataNode> State { get; set; }
bool TerminateOnDiscover { get; set; }
bool IsTerminated { get; set; }
float ProgressRate { get; set; }
@ -30,6 +31,7 @@ namespace NBTExplorer
public DataNode RootNode { get; set; }
public IEnumerator<DataNode> State { get; set; }
public bool TerminateOnDiscover { get; set; }
public bool IsTerminated { get; set; }
public float ProgressRate { get; set; }
public abstract void InvokeDiscoverCallback (DataNode node);
@ -157,11 +159,26 @@ namespace NBTExplorer
}*/
}
foreach (DataNode sub in node.Nodes) {
foreach (DataNode s in FindNode(sub))
yield return s;
using (node.Nodes.Snapshot()) {
foreach (DataNode sub in node.Nodes) {
foreach (DataNode s in FindNode(sub))
yield return s;
}
}
/*IList<DataNode> nodeList = node.Nodes;
for (int i = 0; i < nodeList.Count; i++) {
int changeset = node.Nodes.ChangeCount;
foreach (DataNode s in FindNode(nodeList[i])) {
}
}
foreach (DataNode sub in node.Nodes) {
foreach (DataNode s in FindNode(sub))
yield return s;
}*/
if (searchExpanded) {
if (!node.IsModified) {
node.Collapse();
@ -187,6 +204,7 @@ namespace NBTExplorer
private void InvokeEndCallback ()
{
_state.IsTerminated = true;
_state.InvokeEndCallback(null);
}
}

View file

@ -519,7 +519,6 @@
// _buttonReplaceAll
//
this._buttonReplaceAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this._buttonReplaceAll.Enabled = false;
this._buttonReplaceAll.Location = new System.Drawing.Point(387, 417);
this._buttonReplaceAll.Name = "_buttonReplaceAll";
this._buttonReplaceAll.Size = new System.Drawing.Size(75, 23);

View file

@ -204,11 +204,12 @@ namespace NBTExplorer.Windows
RootNode = _mainSearchRoot,
DiscoverCallback = SearchDiscoveryReplaceAllCallback,
CollapseCallback = SearchCollapseCallback,
ProgressCallback = SearchProgressCallback,
EndCallback = SearchEndCallback,
TerminateOnDiscover = false,
};
SearchNextNode();
SearchNextNodeContinuous();
}
private void SearchNextNode ()
@ -231,6 +232,40 @@ namespace NBTExplorer.Windows
t.Join();
}
private void SearchNextNodeContinuous ()
{
if (_searchState == null)
return;
SearchWorker worker = new SearchWorker(_searchState);
Thread t = new Thread(new ThreadStart(RunContinuousReplace));
t.IsBackground = true;
t.Start();
_searchForm = new CancelSearchForm();
if (_searchForm.ShowDialog(this) == DialogResult.Cancel) {
worker.Cancel();
_searchState = null;
}
//t.Join();
}
private void RunContinuousReplace ()
{
SearchWorker worker = new SearchWorker(_searchState);
worker.Run();
Invoke((Action)(() => {
Reset();
}));
//while (worker.Continue()) ;
}
private delegate void Action ();
private void SearchDiscoveryCallback (DataNode node)
{
_mainController.SelectNode(node);
@ -331,6 +366,7 @@ namespace NBTExplorer.Windows
public DataNode RootNode { get; set; }
public IEnumerator<DataNode> State { get; set; }
public bool TerminateOnDiscover { get; set; }
public bool IsTerminated { get; set; }
public float ProgressRate { get; set; }
public abstract void InvokeDiscoverCallback (DataNode node);
@ -378,25 +414,25 @@ namespace NBTExplorer.Windows
public override void InvokeDiscoverCallback (DataNode node)
{
if (_sender != null && DiscoverCallback != null)
_sender.BeginInvoke(DiscoverCallback, new object[] { node });
_sender.Invoke(DiscoverCallback, new object[] { node });
}
public override void InvokeProgressCallback (DataNode node)
{
if (_sender != null && ProgressCallback != null)
_sender.BeginInvoke(ProgressCallback, new object[] { node });
_sender.Invoke(ProgressCallback, new object[] { node });
}
public override void InvokeCollapseCallback (DataNode node)
{
if (_sender != null && CollapseCallback != null)
_sender.BeginInvoke(CollapseCallback, new object[] { node });
_sender.Invoke(CollapseCallback, new object[] { node });
}
public override void InvokeEndCallback (DataNode node)
{
if (_sender != null && EndCallback != null)
_sender.BeginInvoke(EndCallback, new object[] { node });
_sender.Invoke(EndCallback, new object[] { node });
}
}
}

View file

@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABA
QgAAAk1TRnQBSQFMAgEBFAEAAaABAQGgAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
QgAAAk1TRnQBSQFMAgEBFAEAAagBAQGoAQEBEAEAARABAAT/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 @@
<data name="_tbFindGroupAnd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJOSURBVDhPzZHdT1JxHMbPqqsuwpdq5kVrqzbW9CZj86ab
WnrRlmu9jLbUrTVrsVW4wF4ssOYs0F4QpDFsalqCMAgo3MEwFhqSUVak6EHAA4igJhh100XnodPWf1C/
7bPz3fM8n40N4v95ZQ0Ozm4xWc58q8oukyfwrZRMHAJ/Z+yGw2q/HxNsrbw1XN0/QneEU98HU+kfvr6h
ZffpFjoNcCNDhw22cP7InANSZ60/kjZEFrPOUDJLjnxc9vAbqYzSuBABuJGhwwZbOLlfUnrRuvexa7aD
KR3UfMY+m8wOCeSfQhdkU4lex9cvADcydNhgCwcuwT1v5k9GM7bPLMGF7HDpYXv6Tk988r4x5W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KSwT9+W9PnuwiWKq7oKSwS6ui4n1d5m
DbQ09fsbWw2UjndydEUkj44D3MjQYYPtjnM6IdzcX1lYfoW7vbZXJO70yB85g2rDm9lOkWLqJa8mtAJw
I0OHDbZwcjLzVjOsX1NUsitv/6Xq/KPKuoLjmoaCY2ph0T7JWYAbGTpssIXDusQqhrVsUMywiWEDQx7D
OpZ8ho0M6LDBFg7cf/oI4hdUL5OmJP/aGQAAAABJRU5ErkJggg==
</value>
</data>
<data name="_tbFindGroupOr.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI9SURBVDhPzZHda1JxHMYPdddFFLRgXUaEsCC6ChYRvSBR
xEA3WuuN0S4CBxFLR8rYcmrl3OiixjB1ZmcnVEJSN5uzbS4tFouj5ZytTI94XuZxaLv0qvOYEf0F9YMP
5+H5Pp+rQ/w/77pRlPUYRMeNYTHXMcjW8O0xlF3g7050YNvQfr2Ld3OKLi3Da60l/qm//M375kfhvkuk
L+vzSYCMDjdssIVTl+W9K7ILt2jeTJWyVHgrQ0YqaedsZbXbnPXZg9UUQEaHGzbYwoFLtHYtOlSGDE/O
VdLPw9UUFams9VuZeQPJxdEBZHS4YYMODlyi5bw/N0px687X1U+AjGx96TSsBWyvyvSjl2LMSJXmLG5h
qV2/6h9xb8zrXcKMiSyFhyeZBFyiWe6tTQY3v9qmyzRwhSrpc9qEb9QjRnV2zg9GPOIiOov7T/eA4mNw
if2nvTmTk8mM+zY/Wjxi7CElRpVDn6eNlBDtt7EBgFzvpjYWfnd9j3PLcImDZ2ccV3RJzvyi9FZtZYMD
Dn725th65PaT7ILWXgwBZHS4aSbYALoOdSIPlzikiMuOKJeFXgtDa6zFUN9EIaB3ckttA8nQPScXB8jo
cNPYiiFsD7fFeLj1X9ly5pni2NWMcEnHMHfGix9MU+x71dj3lVOqVAYgo1NLN2ywhVOXpbddYk/TAaX8
qPKd90Q3w5xsZ2vHrxXyrZ20ByCjww0bbOE0XGKbxI5GsU+iWaJJYpfEzga7JfZK4IYNtnDg/tNHED8B
40iprvh5KYkAAAAASUVORK5CYII=
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI+SURBVDhPzZHvaxJxHMePetaDKGjBehgRwoLoUbCI6AcS
RQx00Vq/GO1B4CBi6UgZlTutnBs9qDFM3WXuQiUkdbM52+bSxmJxujlnK9MT7855Dm0PfdS9zYj+gvrC
i3vz/rxfj474f94NgyjrJkX7zQEx236fq+HbTZYd4O9OtGPb0H69S/eyik4tK2gtJeGFr/zN8/5H/pFD
ZK7ocwmAjA43bLCFU5flPUuyC7cZwUSXMnRoK+0MV1LUVGW1y5Tx2gLVJEBGhxs22MKBS7R2ztlVZFpw
TldSr0LVJB2urPVZ2BnSycfQAWR0uGGDDg5couW8LztE8+vUu+oycIa3vnSQa37r2zLz9I0YNdClabOr
ON+uX/UNujZm9I7ipNFZCg2MsXG4RLPcUxsLbH61TpQZ4AhWUue0ce+QW4zobLwPDLrFOXRm15/uMS1E
4RL7T3uyRopNj3g3P5vdYvQJLUaUD1YmDHQx0mfl/AC53o1vzP7uep9lF+ESB89O2q/qErzpdemD2sIF
+u3C1K3h9fCd55lZra0QBMjocNOMcn50F9XxHFzikCImO6JcLPaYWUZjKQR7R/N+PcXPt/Ungg8pPgaQ
0eGmsRaC2B5uiwpw67+y5cxLxbFr6eJlHcveHSl8Mo5zC6rh70unVMk0QEanlm7YYAunLktvu8SepgNK
+VHlR8+JLpY9qeRqx6/nc60djBsgo8MNG2zhNFxim8SORrFPolmiSWKXxM4GuyX2SuCGDbZw4P7TRxA/
AdqiqapqVOQNAAAAAElFTkSuQmCC
</value>
</data>
<data name="_tbFindAny.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
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bUhwOrJTAfu
nwj/8fRK4v9Xt4r/71+lceH9w+b/t08GftoHZL+8WQB0TeJ/kBqQWqg2BFg+kcFqeT/jyj0rlG+e3Gbx
4tGl1P8gfOd08P+HF5P/g8RAciA1ILVQbZhgYRezy4JupkOHN1l9uHbU4z8Ig9ggMZAcVBkmmN3KYD2n
jXH1jpVGN09utn955bDLfxC+ccIfTB/bbP1yxxKtmyA1ILVQbQgwtZ7pyF1ggN066f3/+jGX/0snCV8+
ucX0871zYWA2SOzGCY//J476/ACphWpDgL4KpqN3Trv8P3HI7MeibqEr/ZWMG04cNvtx/3zgf5AcSAwk
B1ID4kO1IUB7AUNKSw7jiZZcxvVAtjeIvrDf/u/TKz7/QeIwMSg7BaoNFVgZMkhBmQyVyYzHrh6x/3t3
v/3PyiTGU1BhFDXYAC8QKwKxup89Q0VdJscFELY3YUgEiQGxMhALADEjEGMFHEAsBsQgW7BhcSDmAmKc
BpAIGBgAf2IcXUMiPSkAAAAASUVORK5CYII=
</value>
</data>
<data name="_tbFindByte.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
@ -733,16 +733,16 @@
<data name="_tbReplaceCompound.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFySURBVDhPrdFPRINxHMfx7+M3OnaMDl06dU7XKUYlpUMl
k/5RRjqkGE22dailSGwpox1aG5tmbGO2smRRmQ7dOswWFSVbiuiQX/vM7/l5ntuTenh7+P0+r+fy0L88
OSeZctMm29kU21RzmqmgTXuHLYzgRKfjDa3Xjraj6skGr2Q99fy2Dl3qOTbYwghOlJlk3Xfevrz2A+Gl
Lllwwaz7ALYwghOlJ0zzpdBc+Snh4mpJ94As5uiR5whbGMGJUmPMVy2Ev3kxwtWKEbussD8rzxG2MIIT
Jaxs7+s2wD8ufbKsZ1iWcPXr7rCFEZwobmX+zxs/f8vvyAAjdkv9HVrs1N1hCyM4UXSUBd6vdvlrbksG
rH1rwxZGcKLwCDusnG/z58y6obCFEZwoOKSEXmq/6DG1aihsYQQnCgwq0Yekm9/HVwyFLYzgRN5eJV2O
OXjpeNlQ2MIITi0z7crBmkW5+E0wsPhAY62mWs2/DAb2Lw/RDxmp3YCQ0WllAAAAAElFTkSuQmCC
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFzSURBVDhPrdFPRINxHMfx7+M3OnaMDl06dU7XKUYlpUMl
k/5RRjqkGE22dailSKyU0Q6tjU0ztjFbWbLoz3To1mG2qChZKaJDfu0zv+fneW7P1MPbw+/3eT2Xh/7l
yTrJlJ002U4n2Lqa00x5bdo7bGEEJzoZrWu+crQcvh2v8XLGU81na9OlnmODLYzgROlx1nnn7clpPxBa
6JAF5sy6D2ALIzhRasw0WwzOlJ7iLq6WcPfJoo4ueY6whRGcKDnCtsvXoR9eCHO1Qtguy+9Ny3OELYzg
RHEr2/2+9fPPi21ZxjMoi7t6dXfYwghOFLMy39eNj7/ntmSAYbul+g7Ot+vusIURnCgyzPwflzv8Nbsh
A9a+tWELIzhRaIgdlM82+XN61VDYwghOFBhQgi+VX/SYXDYUtjCCE/n7lchDws3vY0uGwhZGcCJvt5Iq
RR28eLRoKGxhBKemqVZlf8WinNcSDCw+UF+poVJjjcHA/uUh+gUO+918FI/WkQAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="_explorerStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>345, 17</value>
</metadata>
</root>
</root>