Skip to content

Commit

Permalink
Update syntax formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurits committed Apr 1, 2022
1 parent c315539 commit 8ccc29e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions MemoryNumbers/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -347,17 +347,17 @@ public void Sequence(int length)
/// <returns>A random number</returns>
private int GetRandomNumber()
{
Random rnd = new Random();
Random rnd = new();
int nNumber;

Func<int, bool> Contains = (value) =>
bool Contains(int value)
{
for (int i = 0; i < _nSequence.Length; i++)
{
if (_nSequence[i] == value) return true;
}
return false;
};
}

while (true)
{
Expand Down
6 changes: 3 additions & 3 deletions MemoryNumbers/controls/CountDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TimerEndingEventArgs> TimerEnding;

Expand Down Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions MemoryNumbers/frmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions MemoryNumbers/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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 = "";
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 8ccc29e

Please sign in to comment.