Refactor various numeric textboxes in ram tools to use new better built in methods and properties

This commit is contained in:
adelikat 2013-10-11 17:57:58 +00:00
parent 400e01cc0e
commit 7fa89b89b3
6 changed files with 1451 additions and 1456 deletions

View File

@ -34,7 +34,7 @@
this.Cancel = new System.Windows.Forms.Button();
this.OutputLabel = new System.Windows.Forms.Label();
this.ValeLabel = new System.Windows.Forms.Label();
this.ValueBox = new WatchValueBox();
this.ValueBox = new BizHawk.MultiClient.WatchValueBox();
this.ValueHexLabel = new System.Windows.Forms.Label();
this.DisplayTypeLabel = new System.Windows.Forms.Label();
this.SizeLabel = new System.Windows.Forms.Label();
@ -99,13 +99,16 @@
//
// ValueBox
//
this.ValueBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte;
this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.ValueBox.Location = new System.Drawing.Point(82, 57);
this.ValueBox.MaxLength = 9;
this.ValueBox.Name = "ValueBox";
this.ValueBox.Nullable = false;
this.ValueBox.Size = new System.Drawing.Size(116, 20);
this.ValueBox.TabIndex = 10;
this.ValueBox.Text = "0000";
this.ValueBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex;
//
// ValueHexLabel
//
@ -150,6 +153,7 @@
this.AddressBox.Location = new System.Drawing.Point(82, 30);
this.AddressBox.MaxLength = 8;
this.AddressBox.Name = "AddressBox";
this.AddressBox.Nullable = false;
this.AddressBox.Size = new System.Drawing.Size(116, 20);
this.AddressBox.TabIndex = 5;
this.AddressBox.Text = "0000";
@ -199,7 +203,7 @@
this.DomainLabel.TabIndex = 45;
this.DomainLabel.Text = "Main Memory";
//
// NewRamPoke
// RamPoke
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -226,7 +230,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NewRamPoke";
this.Name = "RamPoke";
this.Text = "Ram Poke";
this.Load += new System.EventHandler(this.RamPoke_Load);
this.ResumeLayout(false);

View File

@ -56,7 +56,7 @@ namespace BizHawk.MultiClient
UnSupportedConfiguration();
}
}
AddressBox.SetHexProperties(_watchList[0].Domain.Size);
AddressBox.Text = _watchList.Select(a => a.AddressString).Distinct().Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr));
ValueHexLabel.Text = _watchList[0].Type == Watch.DisplayType.Hex ? "0x" : String.Empty;
ValueBox.Text = _watchList[0].ValueString.Replace(" ", "");

File diff suppressed because it is too large Load Diff

View File

@ -106,13 +106,6 @@ namespace BizHawk.MultiClient
SpecificValueBox.ByteSize = Settings.Size;
SpecificValueBox.Type = Settings.Type;
SpecificValueBox.Nullable =
SpecificAddressBox.Nullable =
NumberOfChangesBox.Nullable =
DifferenceBox.Nullable =
DifferentByBox.Nullable =
false;
MessageLabel.Text = String.Empty;
SpecificAddressBox.MaxLength = IntHelpers.GetNumDigits(Global.Emulator.MainMemory.Size);
HardSetSizeDropDown(Settings.Size);

View File

@ -28,183 +28,184 @@
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.AddressBox = new BizHawk.HexTextBox();
this.NotesBox = new System.Windows.Forms.TextBox();
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.DomainDropDown = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.SizeDropDown = new System.Windows.Forms.ComboBox();
this.DisplayTypeLael = new System.Windows.Forms.Label();
this.DisplayTypeDropDown = new System.Windows.Forms.ComboBox();
this.BigEndianCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Address: 0x";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 35);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(38, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Notes:";
//
// AddressBox
//
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.AddressBox.Location = new System.Drawing.Point(69, 6);
this.AddressBox.MaxLength = 8;
this.AddressBox.Name = "AddressBox";
this.AddressBox.Size = new System.Drawing.Size(100, 20);
this.AddressBox.TabIndex = 1;
this.AddressBox.Text = "00000000";
//
// NotesBox
//
this.NotesBox.Location = new System.Drawing.Point(69, 32);
this.NotesBox.MaxLength = 256;
this.NotesBox.Name = "NotesBox";
this.NotesBox.Size = new System.Drawing.Size(100, 20);
this.NotesBox.TabIndex = 5;
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.OK.Location = new System.Drawing.Point(12, 260);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 30;
this.OK.Text = "Ok";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(123, 260);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 35;
this.Cancel.Text = "Cancel";
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(11, 214);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(83, 13);
this.label6.TabIndex = 15;
this.label6.Text = "Memory Domain";
//
// DomainDropDown
//
this.DomainDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.DomainDropDown.FormattingEnabled = true;
this.DomainDropDown.Location = new System.Drawing.Point(12, 230);
this.DomainDropDown.Name = "DomainDropDown";
this.DomainDropDown.Size = new System.Drawing.Size(141, 21);
this.DomainDropDown.TabIndex = 25;
this.DomainDropDown.SelectedIndexChanged += new System.EventHandler(this.DomainComboBox_SelectedIndexChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(9, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(27, 13);
this.label3.TabIndex = 17;
this.label3.Text = "Size";
//
// SizeDropDown
//
this.SizeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.SizeDropDown.FormattingEnabled = true;
this.SizeDropDown.Items.AddRange(new object[] {
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.AddressBox = new BizHawk.HexTextBox();
this.NotesBox = new System.Windows.Forms.TextBox();
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.DomainDropDown = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.SizeDropDown = new System.Windows.Forms.ComboBox();
this.DisplayTypeLael = new System.Windows.Forms.Label();
this.DisplayTypeDropDown = new System.Windows.Forms.ComboBox();
this.BigEndianCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Address: 0x";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 35);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(38, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Notes:";
//
// AddressBox
//
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.AddressBox.Location = new System.Drawing.Point(69, 6);
this.AddressBox.MaxLength = 8;
this.AddressBox.Name = "AddressBox";
this.AddressBox.Nullable = false;
this.AddressBox.Size = new System.Drawing.Size(100, 20);
this.AddressBox.TabIndex = 1;
this.AddressBox.Text = "00000000";
//
// NotesBox
//
this.NotesBox.Location = new System.Drawing.Point(69, 32);
this.NotesBox.MaxLength = 256;
this.NotesBox.Name = "NotesBox";
this.NotesBox.Size = new System.Drawing.Size(100, 20);
this.NotesBox.TabIndex = 5;
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.OK.Location = new System.Drawing.Point(12, 260);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 30;
this.OK.Text = "Ok";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(123, 260);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 35;
this.Cancel.Text = "Cancel";
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(11, 214);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(83, 13);
this.label6.TabIndex = 15;
this.label6.Text = "Memory Domain";
//
// DomainDropDown
//
this.DomainDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.DomainDropDown.FormattingEnabled = true;
this.DomainDropDown.Location = new System.Drawing.Point(12, 230);
this.DomainDropDown.Name = "DomainDropDown";
this.DomainDropDown.Size = new System.Drawing.Size(141, 21);
this.DomainDropDown.TabIndex = 25;
this.DomainDropDown.SelectedIndexChanged += new System.EventHandler(this.DomainComboBox_SelectedIndexChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(9, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(27, 13);
this.label3.TabIndex = 17;
this.label3.Text = "Size";
//
// SizeDropDown
//
this.SizeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.SizeDropDown.FormattingEnabled = true;
this.SizeDropDown.Items.AddRange(new object[] {
"1 Byte",
"2 Byte",
"4 Byte"});
this.SizeDropDown.Location = new System.Drawing.Point(10, 80);
this.SizeDropDown.Name = "SizeDropDown";
this.SizeDropDown.Size = new System.Drawing.Size(141, 21);
this.SizeDropDown.TabIndex = 10;
this.SizeDropDown.SelectedIndexChanged += new System.EventHandler(this.SizeDropDown_SelectedIndexChanged);
//
// DisplayTypeLael
//
this.DisplayTypeLael.AutoSize = true;
this.DisplayTypeLael.Location = new System.Drawing.Point(11, 106);
this.DisplayTypeLael.Name = "DisplayTypeLael";
this.DisplayTypeLael.Size = new System.Drawing.Size(68, 13);
this.DisplayTypeLael.TabIndex = 19;
this.DisplayTypeLael.Text = "Display Type";
//
// DisplayTypeDropDown
//
this.DisplayTypeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.DisplayTypeDropDown.FormattingEnabled = true;
this.DisplayTypeDropDown.Items.AddRange(new object[] {
this.SizeDropDown.Location = new System.Drawing.Point(10, 80);
this.SizeDropDown.Name = "SizeDropDown";
this.SizeDropDown.Size = new System.Drawing.Size(141, 21);
this.SizeDropDown.TabIndex = 10;
this.SizeDropDown.SelectedIndexChanged += new System.EventHandler(this.SizeDropDown_SelectedIndexChanged);
//
// DisplayTypeLael
//
this.DisplayTypeLael.AutoSize = true;
this.DisplayTypeLael.Location = new System.Drawing.Point(11, 106);
this.DisplayTypeLael.Name = "DisplayTypeLael";
this.DisplayTypeLael.Size = new System.Drawing.Size(68, 13);
this.DisplayTypeLael.TabIndex = 19;
this.DisplayTypeLael.Text = "Display Type";
//
// DisplayTypeDropDown
//
this.DisplayTypeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.DisplayTypeDropDown.FormattingEnabled = true;
this.DisplayTypeDropDown.Items.AddRange(new object[] {
"1 Byte",
"2 Byte",
"4 Byte"});
this.DisplayTypeDropDown.Location = new System.Drawing.Point(12, 122);
this.DisplayTypeDropDown.Name = "DisplayTypeDropDown";
this.DisplayTypeDropDown.Size = new System.Drawing.Size(141, 21);
this.DisplayTypeDropDown.TabIndex = 15;
this.DisplayTypeDropDown.SelectedIndexChanged += new System.EventHandler(this.DisplayTypeDropDown_SelectedIndexChanged);
//
// BigEndianCheckBox
//
this.BigEndianCheckBox.AutoSize = true;
this.BigEndianCheckBox.Location = new System.Drawing.Point(14, 159);
this.BigEndianCheckBox.Name = "BigEndianCheckBox";
this.BigEndianCheckBox.Size = new System.Drawing.Size(77, 17);
this.BigEndianCheckBox.TabIndex = 20;
this.BigEndianCheckBox.Text = "Big Endian";
this.BigEndianCheckBox.UseVisualStyleBackColor = true;
//
// WatchEditor
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(213, 296);
this.Controls.Add(this.BigEndianCheckBox);
this.Controls.Add(this.DisplayTypeLael);
this.Controls.Add(this.DisplayTypeDropDown);
this.Controls.Add(this.label3);
this.Controls.Add(this.SizeDropDown);
this.Controls.Add(this.label6);
this.Controls.Add(this.DomainDropDown);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Controls.Add(this.NotesBox);
this.Controls.Add(this.AddressBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "WatchEditor";
this.Text = "New Watch";
this.Load += new System.EventHandler(this.RamWatchNewWatch_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.DisplayTypeDropDown.Location = new System.Drawing.Point(12, 122);
this.DisplayTypeDropDown.Name = "DisplayTypeDropDown";
this.DisplayTypeDropDown.Size = new System.Drawing.Size(141, 21);
this.DisplayTypeDropDown.TabIndex = 15;
this.DisplayTypeDropDown.SelectedIndexChanged += new System.EventHandler(this.DisplayTypeDropDown_SelectedIndexChanged);
//
// BigEndianCheckBox
//
this.BigEndianCheckBox.AutoSize = true;
this.BigEndianCheckBox.Location = new System.Drawing.Point(14, 159);
this.BigEndianCheckBox.Name = "BigEndianCheckBox";
this.BigEndianCheckBox.Size = new System.Drawing.Size(77, 17);
this.BigEndianCheckBox.TabIndex = 20;
this.BigEndianCheckBox.Text = "Big Endian";
this.BigEndianCheckBox.UseVisualStyleBackColor = true;
//
// WatchEditor
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(213, 296);
this.Controls.Add(this.BigEndianCheckBox);
this.Controls.Add(this.DisplayTypeLael);
this.Controls.Add(this.DisplayTypeDropDown);
this.Controls.Add(this.label3);
this.Controls.Add(this.SizeDropDown);
this.Controls.Add(this.label6);
this.Controls.Add(this.DomainDropDown);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Controls.Add(this.NotesBox);
this.Controls.Add(this.AddressBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "WatchEditor";
this.Text = "New Watch";
this.Load += new System.EventHandler(this.RamWatchNewWatch_Load);
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@ -13,7 +13,6 @@ namespace BizHawk.MultiClient
private readonly List<Watch> _watchList = new List<Watch>();
private Mode _mode = Mode.New;
private bool _loading = true;
private string _addressFormatStr = "{0:X2}";
private bool _changedSize = false;
private bool _changedDisplayType = false;
@ -62,7 +61,7 @@ namespace BizHawk.MultiClient
if (_watchList.Count > 1)
{
NotesBox.Enabled = false;
NotesBox.Text = "";
NotesBox.Text = String.Empty;
AddressBox.Enabled = false;
AddressBox.Text = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr));
@ -77,7 +76,7 @@ namespace BizHawk.MultiClient
else
{
NotesBox.Text = _watchList[0].Notes;
AddressBox.Text = _watchList[0].AddressString;
AddressBox.SetFromRawInt(_watchList[0].Address.Value);
}
SetBigEndianCheckBox();
@ -121,9 +120,7 @@ namespace BizHawk.MultiClient
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
if (domain != null)
{
AddressBox.MaxLength = IntHelpers.GetNumDigits(domain.Size - 1);
_addressFormatStr = "{0:X" + AddressBox.MaxLength.ToString() + "}";
AddressBox.Text = String.Format(_addressFormatStr, 0);
AddressBox.SetHexProperties(domain.Size);
}
}
}