diff --git a/MemoryNumbers/Game.cs b/MemoryNumbers/Game.cs
index cc69866..6a5fa89 100644
--- a/MemoryNumbers/Game.cs
+++ b/MemoryNumbers/Game.cs
@@ -323,7 +323,7 @@ public void Sequence(int length)
int nLength = _nSequence == null ? 0 : _nSequence.Length;
int nNewLength = length + 1;
- Random rnd = new Random();
+ Random rnd = new();
// Clear the array if it's not empty
if (nLength > 0) Array.Clear(_nSequence, 0, nLength);
@@ -347,17 +347,17 @@ public void Sequence(int length)
/// A random number
private int GetRandomNumber()
{
- Random rnd = new Random();
+ Random rnd = new();
int nNumber;
- Func Contains = (value) =>
+ bool Contains(int value)
{
for (int i = 0; i < _nSequence.Length; i++)
{
if (_nSequence[i] == value) return true;
}
return false;
- };
+ }
while (true)
{
diff --git a/MemoryNumbers/controls/CountDown.cs b/MemoryNumbers/controls/CountDown.cs
index 2aa1783..14c7634 100644
--- a/MemoryNumbers/controls/CountDown.cs
+++ b/MemoryNumbers/controls/CountDown.cs
@@ -13,7 +13,7 @@ public partial class CountDown: Controls.RoundButton
private double _dInterval = 1000; // 1 s
private double _dCounter;
private bool _sound;
- private System.Media.SoundPlayer _soundPlayer;
+ private readonly System.Media.SoundPlayer _soundPlayer;
public event EventHandler TimerEnding;
@@ -82,13 +82,13 @@ public CountDown()
// Timer initialization
t = new System.Timers.Timer();
- t.Elapsed += onTimeEvent;
+ t.Elapsed += OnTimeEvent;
string _path = System.IO.Path.GetDirectoryName(Environment.ProcessPath);
_soundPlayer = System.IO.File.Exists(_path + @"\audio\Count down.wav") ? new(_path + @"\audio\Count down.wav") : null;
}
- private void onTimeEvent(object sender, ElapsedEventArgs e)
+ private void OnTimeEvent(object sender, ElapsedEventArgs e)
{
_dCounter -= _dInterval / 1000;
diff --git a/MemoryNumbers/frmMain.Designer.cs b/MemoryNumbers/frmMain.Designer.cs
index fbd1144..3080e0d 100644
--- a/MemoryNumbers/frmMain.Designer.cs
+++ b/MemoryNumbers/frmMain.Designer.cs
@@ -133,7 +133,7 @@ private void InitializeComponent()
this.toolStripMain_Exit.Text = "Exit";
this.toolStripMain_Exit.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.toolStripMain_Exit.ToolTipText = "Exit application";
- this.toolStripMain_Exit.Click += new System.EventHandler(this.toolStripMain_Exit_Click);
+ this.toolStripMain_Exit.Click += new System.EventHandler(this.Exit_Click);
//
// toolStripSeparator1
//
@@ -149,7 +149,7 @@ private void InitializeComponent()
this.toolStripMain_Start.Text = "Start";
this.toolStripMain_Start.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.toolStripMain_Start.ToolTipText = "Start the game";
- this.toolStripMain_Start.Click += new System.EventHandler(this.toolStripMain_Start_Click);
+ this.toolStripMain_Start.Click += new System.EventHandler(this.Start_Click);
//
// toolStripMain_Stop
//
@@ -160,7 +160,7 @@ private void InitializeComponent()
this.toolStripMain_Stop.Text = "Stop";
this.toolStripMain_Stop.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.toolStripMain_Stop.ToolTipText = "Stop the game and reset";
- this.toolStripMain_Stop.Click += new System.EventHandler(this.toolStripMain_Stop_Click);
+ this.toolStripMain_Stop.Click += new System.EventHandler(this.Stop_Click);
//
// toolStripSeparator2
//
@@ -179,7 +179,7 @@ private void InitializeComponent()
this.toolStripMain_Sound.Text = "Sound";
this.toolStripMain_Sound.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.toolStripMain_Sound.ToolTipText = "Game sounds off";
- this.toolStripMain_Sound.CheckedChanged += new System.EventHandler(this.toolStripMain_Sound_CheckedChanged);
+ this.toolStripMain_Sound.CheckedChanged += new System.EventHandler(this.Sound_CheckedChanged);
//
// toolStripMain_Stats
//
@@ -191,7 +191,7 @@ private void InitializeComponent()
this.toolStripMain_Stats.Text = "Stats";
this.toolStripMain_Stats.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.toolStripMain_Stats.ToolTipText = "Show stats plot";
- this.toolStripMain_Stats.CheckedChanged += new System.EventHandler(this.toolStripMain_Stats_CheckedChanged);
+ this.toolStripMain_Stats.CheckedChanged += new System.EventHandler(this.Stats_CheckedChanged);
//
// toolStripSeparator3
//
@@ -206,7 +206,7 @@ private void InitializeComponent()
this.toolStripMain_Settings.Size = new System.Drawing.Size(53, 67);
this.toolStripMain_Settings.Text = "Settings";
this.toolStripMain_Settings.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
- this.toolStripMain_Settings.Click += new System.EventHandler(this.toolStripMain_Settings_Click);
+ this.toolStripMain_Settings.Click += new System.EventHandler(this.Settings_Click);
//
// toolStripSeparator4
//
@@ -222,7 +222,7 @@ private void InitializeComponent()
this.toolStripMain_About.Text = "About";
this.toolStripMain_About.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.toolStripMain_About.ToolTipText = "About this software";
- this.toolStripMain_About.Click += new System.EventHandler(this.toolStripMain_About_Click);
+ this.toolStripMain_About.Click += new System.EventHandler(this.About_Click);
//
// tabGame
//
diff --git a/MemoryNumbers/frmMain.cs b/MemoryNumbers/frmMain.cs
index a298230..b8f3381 100644
--- a/MemoryNumbers/frmMain.cs
+++ b/MemoryNumbers/frmMain.cs
@@ -183,7 +183,7 @@ private async void OnCorrectSequence(object sender, Game.CorrectEventArgs e)
{
if (await board1.Start(_game.GetSequence, _game.TimeTotal) == false)
{
- toolStripMain_Stop_Click(null, null);
+ Stop_Click(null, null);
using (new CenterWinDialog(this))
MessageBox.Show("Could not place the buttons on the screen.\n" +
"Please, try reducing the 'numbers ratio' paremeter in\n" +
@@ -216,7 +216,7 @@ private async void OnWrongSequence(object sender, Game.WrongEventArgs e)
{
if (await board1.Start(_game.GetSequence, _game.TimeTotal) == false)
{
- toolStripMain_Stop_Click(null, null);
+ Stop_Click(null, null);
using (new CenterWinDialog(this))
MessageBox.Show("Could not place the buttons on the screen.\nPlease, try reducing the 'numbers ratio' paremeter in\nthe Settings (between 0.25 - 0.30).", "Error placing numbers", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
@@ -249,12 +249,12 @@ private void OnGameOver(object sender, Game.OverEventArgs e)
#region toolStripMain
- private void toolStripMain_Exit_Click(object sender, EventArgs e)
+ private void Exit_Click(object sender, EventArgs e)
{
Close();
}
- private async void toolStripMain_Start_Click(object sender, EventArgs e)
+ private async void Start_Click(object sender, EventArgs e)
{
// Commute visibility of the strip buttons
this.toolStripMain_Start.Enabled = false;
@@ -277,7 +277,7 @@ private async void toolStripMain_Start_Click(object sender, EventArgs e)
board1.Visible = true;
if (await board1.Start(_game.GetSequence, _game.TimeTotal) == false)
{
- toolStripMain_Stop_Click(null, null);
+ Stop_Click(null, null);
using (new CenterWinDialog(this))
MessageBox.Show("Could not place the buttons on the screen.\nPlease, try reducing the 'numbers ratio' paremeter in\nthe Settings (between 0.25 - 0.30).", "Error placing numbers", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
@@ -290,7 +290,7 @@ private async void toolStripMain_Start_Click(object sender, EventArgs e)
}
- private void toolStripMain_Stop_Click(object sender, EventArgs e)
+ private void Stop_Click(object sender, EventArgs e)
{
board1.ClearBoard();
this.toolStripStatusLabel_Secuence.Text = "";
@@ -306,17 +306,17 @@ private void toolStripMain_Stop_Click(object sender, EventArgs e)
ChartStatsTime_Update();
}
- private void toolStripMain_Sound_CheckedChanged(object sender, EventArgs e)
+ private void Sound_CheckedChanged(object sender, EventArgs e)
{
this.board1.PlaySounds = !toolStripMain_Sound.Checked;
}
- private void toolStripMain_Stats_CheckedChanged(object sender, EventArgs e)
+ private void Stats_CheckedChanged(object sender, EventArgs e)
{
this.tabGame.SelectedIndex = toolStripMain_Stats.Checked ? 1 : 0;
}
- private void toolStripMain_Settings_Click(object sender, EventArgs e)
+ private void Settings_Click(object sender, EventArgs e)
{
FrmSettings form = new(_settings);
form.ShowDialog(this);
@@ -327,7 +327,7 @@ private void toolStripMain_Settings_Click(object sender, EventArgs e)
}
}
- private void toolStripMain_About_Click(object sender, EventArgs e)
+ private void About_Click(object sender, EventArgs e)
{
frmAbout form = new();
form.ShowDialog(this);