From 8dff368bcc2438c23b6d1fbbd900b1bc86b229f4 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 27 Aug 2011 14:49:13 +0000 Subject: [PATCH] misc code cleanup on some tool dialogs --- BizHawk.MultiClient/tools/HexEditor.cs | 33 +++------ .../tools/RamSearch.Designer.cs | 31 ++++---- BizHawk.MultiClient/tools/RamSearch.cs | 73 ++++++++----------- BizHawk.MultiClient/tools/RamSearch.resx | 21 +++--- 4 files changed, 70 insertions(+), 88 deletions(-) diff --git a/BizHawk.MultiClient/tools/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor.cs index 56a9d0530c..85742d4507 100644 --- a/BizHawk.MultiClient/tools/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor.cs @@ -126,12 +126,9 @@ namespace BizHawk.MultiClient static char Remap(byte val) { - unchecked - { - if (val < ' ') return '.'; - else if (val >= 0x80) return '.'; - else return (char)val; - } + if (val < ' ') return '.'; + else if (val >= 0x80) return '.'; + else return (char)val; } private int MakeValue(int addr) @@ -279,12 +276,9 @@ namespace BizHawk.MultiClient private int GetNumDigits(Int32 i) { - unchecked - { - if (i <= 0x10000) return 4; - if (i <= 0x1000000) return 6; - else return 8; - } + if (i <= 0x10000) return 4; + if (i <= 0x1000000) return 6; + else return 8; } public void GoToSpecifiedAddress() @@ -357,15 +351,12 @@ namespace BizHawk.MultiClient public bool IsVisible(int addr) { - unchecked - { - int row = addr >> 4; + int row = addr >> 4; - if (row >= vScrollBar1.Value && row < (RowsVisible + vScrollBar1.Value)) - return true; - else - return false; - } + if (row >= vScrollBar1.Value && row < (RowsVisible + vScrollBar1.Value)) + return true; + else + return false; } private void HexEditor_Resize(object sender, EventArgs e) @@ -720,7 +711,7 @@ namespace BizHawk.MultiClient if (row >= 0 && row <= maxRow && column >= 0 && column < (16 / Global.Config.HexEditorDataSize)) { addressOver = row * 16 + (column * Global.Config.HexEditorDataSize); - info = String.Format("{0:X" + GetNumDigits(Domain.Size).ToString() + "}", addressOver); + info = String.Format(NumDigitsStr, addressOver); } else { diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs index ffeae2ff2b..4a63496bab 100644 --- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs @@ -43,10 +43,10 @@ this.FreezeAddressToolStrip = new System.Windows.Forms.ToolStripButton(); this.TotalSearchLabel = new System.Windows.Forms.Label(); this.SearchListView = new BizHawk.VirtualListView(); - this.Address = new System.Windows.Forms.ColumnHeader(); - this.Value = new System.Windows.Forms.ColumnHeader(); - this.Previous = new System.Windows.Forms.ColumnHeader(); - this.Changes = new System.Windows.Forms.ColumnHeader(); + this.Address = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.Value = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.Previous = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.Changes = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.startNewSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.searchToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); @@ -297,20 +297,19 @@ this.SearchListView.UseCompatibleStateImageBehavior = false; this.SearchListView.View = System.Windows.Forms.View.Details; this.SearchListView.VirtualMode = true; - this.SearchListView.Enter += new System.EventHandler(this.SearchListView_Enter); - this.SearchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.SearchListView_ColumnClick); - this.SearchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SearchListView_MouseDoubleClick); this.SearchListView.QueryItemBkColor += new BizHawk.QueryItemBkColorHandler(this.SearchListView_QueryItemBkColor); - this.SearchListView.ColumnReordered += new System.Windows.Forms.ColumnReorderedEventHandler(this.SearchListView_ColumnReordered); - this.SearchListView.QueryItemIndent += new BizHawk.QueryItemIndentHandler(this.SearchListView_QueryItemIndent); - this.SearchListView.QueryItemImage += new BizHawk.QueryItemImageHandler(this.SearchListView_QueryItemImage); this.SearchListView.QueryItemText += new BizHawk.QueryItemTextHandler(this.SearchListView_QueryItemText); + + this.SearchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.SearchListView_ColumnClick); + this.SearchListView.ColumnReordered += new System.Windows.Forms.ColumnReorderedEventHandler(this.SearchListView_ColumnReordered); + this.SearchListView.Enter += new System.EventHandler(this.SearchListView_Enter); this.SearchListView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.SearchListView_KeyUp); + this.SearchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SearchListView_MouseDoubleClick); // // Address // this.Address.Text = "Address"; - this.Address.Width = 66; + this.Address.Width = 65; // // Value // @@ -969,8 +968,8 @@ this.NumberOfChangesBox.Size = new System.Drawing.Size(65, 20); this.NumberOfChangesBox.TabIndex = 28; this.NumberOfChangesBox.TextChanged += new System.EventHandler(this.NumberOfChangesBox_TextChanged); - this.NumberOfChangesBox.Leave += new System.EventHandler(this.NumberOfChangesBox_Leave); this.NumberOfChangesBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.NumberOfChangesBox_KeyPress); + this.NumberOfChangesBox.Leave += new System.EventHandler(this.NumberOfChangesBox_Leave); // // SpecificAddressBox // @@ -982,8 +981,8 @@ this.SpecificAddressBox.Size = new System.Drawing.Size(65, 20); this.SpecificAddressBox.TabIndex = 26; this.SpecificAddressBox.TextChanged += new System.EventHandler(this.SpecificAddressBox_TextChanged); - this.SpecificAddressBox.Leave += new System.EventHandler(this.SpecificAddressBox_Leave); this.SpecificAddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SpecificAddressBox_KeyPress); + this.SpecificAddressBox.Leave += new System.EventHandler(this.SpecificAddressBox_Leave); // // SpecificValueBox // @@ -994,8 +993,8 @@ this.SpecificValueBox.Size = new System.Drawing.Size(65, 20); this.SpecificValueBox.TabIndex = 24; this.SpecificValueBox.TextChanged += new System.EventHandler(this.SpecificValueBox_TextChanged); - this.SpecificValueBox.Leave += new System.EventHandler(this.SpecificValueBox_Leave); this.SpecificValueBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SpecificValueBox_KeyPress); + this.SpecificValueBox.Leave += new System.EventHandler(this.SpecificValueBox_Leave); // // NumberOfChangesRadio // @@ -1070,8 +1069,8 @@ this.DifferentByBox.Size = new System.Drawing.Size(50, 20); this.DifferentByBox.TabIndex = 34; this.DifferentByBox.TextChanged += new System.EventHandler(this.DifferentByBox_TextChanged); - this.DifferentByBox.Leave += new System.EventHandler(this.DifferentByBox_Leave); this.DifferentByBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.DifferentByBox_KeyPress); + this.DifferentByBox.Leave += new System.EventHandler(this.DifferentByBox_Leave); // // DifferentByRadio // @@ -1207,8 +1206,8 @@ this.MainMenuStrip = this.menuStrip1; this.Name = "RamSearch"; this.Text = "Ram Search"; - this.Load += new System.EventHandler(this.RamSearch_Load); this.Activated += new System.EventHandler(this.RamSearch_Activated); + this.Load += new System.EventHandler(this.RamSearch_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.RamSearch_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.RamSearch_DragEnter); this.SearchtoolStrip1.ResumeLayout(false); diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 5895fd0ff7..4725349945 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -73,31 +73,28 @@ namespace BizHawk.MultiClient public void UpdateValues() { - unchecked + if (!this.IsHandleCreated || this.IsDisposed) return; + + if (searchList.Count > 8) + SearchListView.BlazingFast = true; + sortReverse = false; + sortedCol = ""; + for (int x = 0; x < searchList.Count; x++) { - if (!this.IsHandleCreated || this.IsDisposed) return; + searchList[x].prev = searchList[x].value; + searchList[x].PeekAddress(Domain); - if (searchList.Count > 8) - SearchListView.BlazingFast = true; - sortReverse = false; - sortedCol = ""; - for (int x = 0; x < searchList.Count; x++) - { - searchList[x].prev = searchList[x].value; - searchList[x].PeekAddress(Domain); + if (searchList[x].prev != searchList[x].value) + searchList[x].changecount++; - if (searchList[x].prev != searchList[x].value) - searchList[x].changecount++; - - } - if (AutoSearchCheckBox.Checked) - DoSearch(); - else if (Global.Config.RamSearchPreviewMode) - DoPreview(); - - SearchListView.Refresh(); - SearchListView.BlazingFast = false; } + if (AutoSearchCheckBox.Checked) + DoSearch(); + else if (Global.Config.RamSearchPreviewMode) + DoPreview(); + + SearchListView.Refresh(); + SearchListView.BlazingFast = false; } private void RamSearch_Load(object sender, EventArgs e) @@ -547,20 +544,22 @@ namespace BizHawk.MultiClient private void SearchListView_QueryItemBkColor(int index, int column, ref Color color) { - if (column == 0) + if (IsAWeededList && column == 0) { - if (IsAWeededList) + if (!weededList.Contains(searchList[index])) { - if (!weededList.Contains(searchList[index])) - { - color = Color.Pink; - if (Global.CheatList.IsActiveCheat(Domain, searchList[index].address)) - color = Color.Purple; - } - else if (Global.CheatList.IsActiveCheat(Domain, searchList[index].address)) - color = Color.LightCyan; + if (color == Color.Pink) return; + if (Global.CheatList.IsActiveCheat(Domain, searchList[index].address)) + color = Color.Purple; else - color = Color.White; + color = Color.Pink; + } + else if (Global.CheatList.IsActiveCheat(Domain, searchList[index].address)) + color = Color.LightCyan; + else + { + if (color == Color.White) return; + color = Color.White; } } } @@ -650,16 +649,6 @@ namespace BizHawk.MultiClient } } - private void SearchListView_QueryItemIndent(int index, out int itemIndent) - { - itemIndent = 0; - } - - private void SearchListView_QueryItemImage(int index, int column, out int imageIndex) - { - imageIndex = -1; - } - private void ClearChangeCounts() { SaveUndo(); diff --git a/BizHawk.MultiClient/tools/RamSearch.resx b/BizHawk.MultiClient/tools/RamSearch.resx index bc8e28ab66..169072ebaa 100644 --- a/BizHawk.MultiClient/tools/RamSearch.resx +++ b/BizHawk.MultiClient/tools/RamSearch.resx @@ -112,15 +112,15 @@ 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 @@ -154,13 +154,13 @@ Cv71r/4OTrQ4xWMwWlcAAAAASUVORK5CYII= - + 457, 17 - + 150, 17 - + 259, 17 @@ -194,7 +194,7 @@ s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - + 358, 17 @@ -242,7 +242,10 @@ s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - + + 602, 17 + + 602, 17