From 1be99bcd68981ed45a493e79de41c4acdd006aec Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 19 Feb 2011 20:29:07 +0000 Subject: [PATCH] Ram Search - implement undo --- .../tools/RamSearch.Designer.cs | 7 +++-- BizHawk.MultiClient/tools/RamSearch.cs | 29 +++++++++++++++++++ BizHawk.MultiClient/tools/RamSearch.resx | 10 +++---- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs index bff3c841d3..cfa2670fcf 100644 --- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs @@ -120,7 +120,7 @@ this.PoketoolStripButton1}); this.SearchtoolStrip1.Location = new System.Drawing.Point(3, 0); this.SearchtoolStrip1.Name = "SearchtoolStrip1"; - this.SearchtoolStrip1.Size = new System.Drawing.Size(156, 25); + this.SearchtoolStrip1.Size = new System.Drawing.Size(154, 25); this.SearchtoolStrip1.TabIndex = 0; this.SearchtoolStrip1.Text = "Search"; // @@ -365,7 +365,7 @@ this.UndotoolStripButton}); this.toolStrip1.Location = new System.Drawing.Point(3, 25); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(104, 25); + this.toolStrip1.Size = new System.Drawing.Size(133, 25); this.toolStrip1.TabIndex = 1; // // NewSearchtoolStripButton @@ -406,6 +406,7 @@ this.UndotoolStripButton.Name = "UndotoolStripButton"; this.UndotoolStripButton.Size = new System.Drawing.Size(23, 22); this.UndotoolStripButton.Text = "Undo Search"; + this.UndotoolStripButton.Click += new System.EventHandler(this.UndotoolStripButton_Click); // // toolStrip2 // @@ -416,7 +417,7 @@ this.EndiantoolSplitButton}); this.toolStrip2.Location = new System.Drawing.Point(3, 50); this.toolStrip2.Name = "toolStrip2"; - this.toolStrip2.Size = new System.Drawing.Size(208, 25); + this.toolStrip2.Size = new System.Drawing.Size(206, 25); this.toolStrip2.TabIndex = 2; // // DataSizetoolStripSplitButton1 diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 8313b8aebb..e7a7ffada0 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -296,6 +296,7 @@ namespace BizHawk.MultiClient ListView.SelectedIndexCollection indexes = SearchListView.SelectedIndices; if (indexes.Count > 0) { + SaveUndo(); for (int x = 0; x < indexes.Count; x++) { searchList.Remove(searchList[indexes[x]-x]); @@ -308,5 +309,33 @@ namespace BizHawk.MultiClient { RemoveAddresses(); } + + /// + /// Saves the current search list to the undo list + /// This function should be called before any destructive operation to the list! + /// + private void SaveUndo() + { + undoList.Clear(); + for (int x = 0; x < searchList.Count; x++) + undoList.Add(searchList[x]); + } + + private void DoUndo() + { + if (undoList.Count > 0) + { + searchList.Clear(); + for (int x = 0; x < undoList.Count; x++) + searchList.Add(undoList[x]); + undoList.Clear(); + DisplaySearchList(); + } + } + + private void UndotoolStripButton_Click(object sender, EventArgs e) + { + DoUndo(); + } } } diff --git a/BizHawk.MultiClient/tools/RamSearch.resx b/BizHawk.MultiClient/tools/RamSearch.resx index cb545f6382..5c27046e06 100644 --- a/BizHawk.MultiClient/tools/RamSearch.resx +++ b/BizHawk.MultiClient/tools/RamSearch.resx @@ -171,9 +171,6 @@ 259, 17 - - 358, 17 - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 @@ -184,10 +181,10 @@ nwacI1lUVWkeyyF/Ztx0hAeDn4DoHOCl5MsAfgEYXgCeMXCIZ2da+rI0jxXqQGH3JRGg4H3P1tlIkJ1E ySh5Q8JfgKuul6DcVDDgbn8+oHM8XzlCKUk4CT6QGLnRKwV0FAy4cutFwM+2e96xXbYtVhZl3ic4AeLE ZOmeXzGgocF2wR5IYYB3IM4stj1F+DGkFZ/JoqLi+GjBEXJdh5oedTuemFsf4H4og+ccIfw138UYmUgJ - 0NS1TlO2EvWyERYfVtq+eVQItR2BTqt9q1bXx863eYXr7lfoGp7AbdvrXLVKM0bJRmrJtp8Bi86Dkhwx + 0NS1TlO2EvWyERYfVtq+eVQItR2BTqt9q1bXx863eYXr7lfoGp7AbevrXLVKM0bJRmrJtp8Bi86Dkhwx HoBDp8OpWnOCh+3kHLkoz3uNu0n+fKKc/5HEtuFVIWbaL8mNjfa5kpL1Lh6dJLvJFrKD7CRbyQayRpIX 3Idr4KleJiuV5b080pE9chUF919ZGr2v48RgwrwPzrN1UmVZ1vONvWStLC4Jvz8ZDAbPpXpRtqaVyrIe - nv+Q1/1TlsM2ypfSzF0rV/5v+Tuo+YISgo8SYgAAAABJRU5ErkJggg== + nv+Q1/1TlsM2ypfSzF0rV/5v+TunYIIRd07M4gAAAABJRU5ErkJggg== @@ -205,6 +202,9 @@ s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC + + 358, 17 + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8