Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ConwaysLife/LifeForm.Designer.cs

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

26 changes: 26 additions & 0 deletions ConwaysLife/LifeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public LifeForm()

private void LifeForm_Load(object sender, EventArgs e)
{
UpdateFormTitle();
Initialize();
Draw();
// The mouse wheel event handler is not automatically generated
Expand Down Expand Up @@ -206,6 +207,11 @@ private void DrawDisplay()
}

private void timer_Tick(object sender, EventArgs e)
{
StepGeneration();
}

private void StepGeneration()
{
life.Step();
Draw();
Expand Down Expand Up @@ -239,7 +245,27 @@ private void LifeForm_KeyDown(object sender, KeyEventArgs e)
case Keys.Space:
timer.Enabled = !timer.Enabled;
break;
case Keys.G:
if (!timer.Enabled)
StepGeneration();
break;
}
}

private void display_Click(object sender, EventArgs e)
{
ToggleTimer();
}

private void ToggleTimer()
{
timer.Enabled = !timer.Enabled;
UpdateFormTitle();
}

private void UpdateFormTitle()
{
Text = $"LifeForm - {(timer.Enabled ? "Automatic" : "Manual")}";
}
}
}