From c722a1ef9ff1fd5c726244aefa350ab07e7f2c6f Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 16 Dec 2019 18:03:26 -0600 Subject: [PATCH] code cleanup in ZxSpectrum config dialogs --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 10 +++---- .../ZXSpectrumAudioSettings.Designer.cs | 4 +-- .../ZXSpectrum/ZXSpectrumAudioSettings.cs | 8 ++--- ...XSpectrumCoreEmulationSettings.Designer.cs | 6 ++-- .../ZXSpectrumCoreEmulationSettings.cs | 14 ++++----- .../ZXSpectrumJoystickSettings.Designer.cs | 6 ++-- .../ZXSpectrum/ZXSpectrumJoystickSettings.cs | 29 +++++++++---------- .../ZXSpectrumNonSyncSettings.Designer.cs | 4 +-- .../ZXSpectrum/ZXSpectrumNonSyncSettings.cs | 26 ++++++++--------- .../ZXSpectrumPokeMemory.Designer.cs | 4 +-- .../config/ZXSpectrum/ZXSpectrumPokeMemory.cs | 8 ++--- 11 files changed, 54 insertions(+), 65 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 7d6ae199bd..2843b1d42c 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2612,31 +2612,31 @@ namespace BizHawk.Client.EmuHawk private void ZXSpectrumControllerConfigurationMenuItem_Click(object sender, EventArgs e) { - using var form = new ZXSpectrumJoystickSettings(); + using var form = new ZxSpectrumJoystickSettings(); form.ShowDialog(); } private void ZXSpectrumCoreEmulationSettingsMenuItem_Click(object sender, EventArgs e) { - using var form = new ZXSpectrumCoreEmulationSettings(); + using var form = new ZxSpectrumCoreEmulationSettings(); form.ShowDialog(); } private void ZXSpectrumNonSyncSettingsMenuItem_Click(object sender, EventArgs e) { - using var form = new ZXSpectrumNonSyncSettings(); + using var form = new ZxSpectrumNonSyncSettings(); form.ShowDialog(); } private void ZXSpectrumAudioSettingsMenuItem_Click(object sender, EventArgs e) { - using var form = new ZXSpectrumAudioSettings(); + using var form = new ZxSpectrumAudioSettings(); form.ShowDialog(); } private void ZXSpectrumPokeMemoryMenuItem_Click(object sender, EventArgs e) { - using var form = new ZXSpectrumPokeMemory(); + using var form = new ZxSpectrumPokeMemory(); form.ShowDialog(); } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.Designer.cs index f84713123e..97c4da8953 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class ZXSpectrumAudioSettings + partial class ZxSpectrumAudioSettings { /// /// Required designer variable. @@ -180,7 +180,7 @@ this.Controls.Add(this.OkBtn); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; - this.Name = "ZXSpectrumAudioSettings"; + this.Name = "ZxSpectrumAudioSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Audio Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs index 305fcb55f9..086ddd4808 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs @@ -1,18 +1,16 @@ using System; -using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class ZXSpectrumAudioSettings : Form + public partial class ZxSpectrumAudioSettings : Form { private ZXSpectrum.ZXSpectrumSettings _settings; - public ZXSpectrumAudioSettings() + public ZxSpectrumAudioSettings() { InitializeComponent(); } @@ -37,8 +35,6 @@ namespace BizHawk.Client.EmuHawk // ay volume ayVolumetrackBar.Value = _settings.AYVolume; - - } private void OkBtn_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.Designer.cs index 2180af2b5e..ed7fe41a1e 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class ZXSpectrumCoreEmulationSettings + partial class ZxSpectrumCoreEmulationSettings { /// /// Required designer variable. @@ -124,7 +124,7 @@ this.borderTypecomboBox1.Name = "borderTypecomboBox1"; this.borderTypecomboBox1.Size = new System.Drawing.Size(220, 21); this.borderTypecomboBox1.TabIndex = 22; - this.borderTypecomboBox1.SelectedIndexChanged += new System.EventHandler(this.borderTypecomboBox1_SelectedIndexChanged); + this.borderTypecomboBox1.SelectedIndexChanged += new System.EventHandler(this.BorderTypeComboBox_SelectedIndexChanged); // // lblBorderInfo // @@ -191,7 +191,7 @@ this.Controls.Add(this.OkBtn); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; - this.Name = "ZXSpectrumCoreEmulationSettings"; + this.Name = "ZxSpectrumCoreEmulationSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Core Emulation Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs index 20834ad90e..61eee12831 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs @@ -1,18 +1,16 @@ using System; -using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class ZXSpectrumCoreEmulationSettings : Form + public partial class ZxSpectrumCoreEmulationSettings : Form { private ZXSpectrum.ZXSpectrumSyncSettings _syncSettings; - public ZXSpectrumCoreEmulationSettings() + public ZxSpectrumCoreEmulationSettings() { InitializeComponent(); } @@ -30,7 +28,7 @@ namespace BizHawk.Client.EmuHawk MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); - // border selecton + // border selection var borderTypes = Enum.GetNames(typeof(ZXSpectrum.BorderType)); foreach (var val in borderTypes) { @@ -82,7 +80,7 @@ namespace BizHawk.Client.EmuHawk private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) { - ComboBox cb = sender as ComboBox; + var cb = (ComboBox)sender; UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); } @@ -91,9 +89,9 @@ namespace BizHawk.Client.EmuHawk textBoxCoreDetails.Text = ZXMachineMetaData.GetMetaString(type); } - private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) + private void BorderTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { - ComboBox cb = sender as ComboBox; + var cb = (ComboBox)sender; UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), cb.SelectedItem.ToString())); } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.Designer.cs index 15d3ceeb85..e37ec32aa7 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class ZXSpectrumJoystickSettings + partial class ZxSpectrumJoystickSettings { /// /// Required designer variable. @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ZXSpectrumJoystickSettings)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ZxSpectrumJoystickSettings)); this.OkBtn = new System.Windows.Forms.Button(); this.CancelBtn = new System.Windows.Forms.Button(); this.label5 = new System.Windows.Forms.Label(); @@ -160,7 +160,7 @@ this.Controls.Add(this.OkBtn); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; - this.Name = "ZXSpectrumJoystickSettings"; + this.Name = "ZxSpectrumJoystickSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Joystick Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs index f672d8a563..d6494ca8ab 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs @@ -7,24 +7,23 @@ using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; namespace BizHawk.Client.EmuHawk { - public partial class ZXSpectrumJoystickSettings : Form + public partial class ZxSpectrumJoystickSettings : Form { private ZXSpectrum.ZXSpectrumSyncSettings _syncSettings; + private string[] _possibleControllers; - public ZXSpectrumJoystickSettings() + public ZxSpectrumJoystickSettings() { InitializeComponent(); } - private string[] possibleControllers; - private void IntvControllerSettings_Load(object sender, EventArgs e) { _syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone(); - possibleControllers = Enum.GetNames(typeof(JoystickType)); + _possibleControllers = Enum.GetNames(typeof(JoystickType)); - foreach (var val in possibleControllers) + foreach (var val in _possibleControllers) { Port1ComboBox.Items.Add(val); Port2ComboBox.Items.Add(val); @@ -50,46 +49,46 @@ namespace BizHawk.Client.EmuHawk bool selectionValid = true; var j1 = Port1ComboBox.SelectedItem.ToString(); - if (j1 != possibleControllers.First()) + if (j1 != _possibleControllers.First()) { if (j1 == Port2ComboBox.SelectedItem.ToString()) { - Port2ComboBox.SelectedItem = possibleControllers.First(); + Port2ComboBox.SelectedItem = _possibleControllers.First(); selectionValid = false; } if (j1 == Port3ComboBox.SelectedItem.ToString()) { - Port3ComboBox.SelectedItem = possibleControllers.First(); + Port3ComboBox.SelectedItem = _possibleControllers.First(); selectionValid = false; } } var j2 = Port2ComboBox.SelectedItem.ToString(); - if (j2 != possibleControllers.First()) + if (j2 != _possibleControllers.First()) { if (j2 == Port1ComboBox.SelectedItem.ToString()) { - Port1ComboBox.SelectedItem = possibleControllers.First(); + Port1ComboBox.SelectedItem = _possibleControllers.First(); selectionValid = false; } if (j2 == Port3ComboBox.SelectedItem.ToString()) { - Port3ComboBox.SelectedItem = possibleControllers.First(); + Port3ComboBox.SelectedItem = _possibleControllers.First(); selectionValid = false; } } var j3 = Port3ComboBox.SelectedItem.ToString(); - if (j3 != possibleControllers.First()) + if (j3 != _possibleControllers.First()) { if (j3 == Port1ComboBox.SelectedItem.ToString()) { - Port1ComboBox.SelectedItem = possibleControllers.First(); + Port1ComboBox.SelectedItem = _possibleControllers.First(); selectionValid = false; } if (j3 == Port2ComboBox.SelectedItem.ToString()) { - Port2ComboBox.SelectedItem = possibleControllers.First(); + Port2ComboBox.SelectedItem = _possibleControllers.First(); selectionValid = false; } } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.Designer.cs index 69e091f997..cf6a44746b 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class ZXSpectrumNonSyncSettings + partial class ZxSpectrumNonSyncSettings { /// /// Required designer variable. @@ -149,7 +149,7 @@ this.Controls.Add(this.OkBtn); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; - this.Name = "ZXSpectrumNonSyncSettings"; + this.Name = "ZxSpectrumNonSyncSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Other Non-Sync Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs index 005f54363d..969ce405b3 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs @@ -1,19 +1,17 @@ using System; -using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class ZXSpectrumNonSyncSettings : Form + public partial class ZxSpectrumNonSyncSettings : Form { private ZXSpectrum.ZXSpectrumSettings _settings; - private int bgColor; + private int _bgColor; - public ZXSpectrumNonSyncSettings() + public ZxSpectrumNonSyncSettings() { InitializeComponent(); } @@ -22,7 +20,7 @@ namespace BizHawk.Client.EmuHawk { _settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone(); - bgColor = _settings.BackgroundColor; + _bgColor = _settings.BackgroundColor; SetBtnColor(); @@ -40,22 +38,22 @@ namespace BizHawk.Client.EmuHawk private void SetBtnColor() { - var c = System.Drawing.Color.FromArgb(bgColor); + var c = System.Drawing.Color.FromArgb(_bgColor); buttonChooseBGColor.ForeColor = c; buttonChooseBGColor.BackColor = c; } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = + bool changed = _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() || - _settings.BackgroundColor != bgColor || + _settings.BackgroundColor != _bgColor || _settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked; if (changed) { _settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()); - _settings.BackgroundColor = bgColor; + _settings.BackgroundColor = _bgColor; _settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked; GlobalWin.MainForm.PutCoreSettings(_settings); @@ -95,7 +93,7 @@ namespace BizHawk.Client.EmuHawk private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) { - ComboBox cb = sender as ComboBox; + var cb = (ComboBox)sender; UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString())); } @@ -105,7 +103,7 @@ namespace BizHawk.Client.EmuHawk System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor); using var cd = new ColorDialog(); - System.Drawing.Color[] colors = new System.Drawing.Color[] + System.Drawing.Color[] colors = { System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7), @@ -125,7 +123,7 @@ namespace BizHawk.Client.EmuHawk System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF), }; - cd.CustomColors = new int[] + cd.CustomColors = new[] { System.Drawing.ColorTranslator.ToOle(colors[0]), System.Drawing.ColorTranslator.ToOle(colors[1]), @@ -151,7 +149,7 @@ namespace BizHawk.Client.EmuHawk { var color = cd.Color; var col = color.ToArgb(); - bgColor = col; + _bgColor = col; SetBtnColor(); } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.Designer.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.Designer.cs index 729b6e1489..64a37c24a4 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class ZXSpectrumPokeMemory + partial class ZxSpectrumPokeMemory { /// /// Required designer variable. @@ -140,7 +140,7 @@ this.Controls.Add(this.OkBtn); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; - this.Name = "ZXSpectrumPokeMemory"; + this.Name = "ZxSpectrumPokeMemory"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Poke Memory"; ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddress)).EndInit(); diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs index 777ec61315..253894ef7f 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs @@ -1,16 +1,14 @@ using System; -using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class ZXSpectrumPokeMemory : Form + public partial class ZxSpectrumPokeMemory : Form { - public ZXSpectrumPokeMemory() + public ZxSpectrumPokeMemory() { InitializeComponent(); } @@ -24,7 +22,7 @@ namespace BizHawk.Client.EmuHawk speccy.PokeMemory(addr, val); DialogResult = DialogResult.OK; - Close(); + Close(); } private void CancelBtn_Click(object sender, EventArgs e)