ASDV-C-Sharp/lab6_1/lab6_1_CalebFontenot/Form1.cs

45 lines
1.2 KiB
C#

namespace lab6_1_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
bool isLit = false;
private void switchButton_Click(object sender, EventArgs e)
{
// Update the light state according to what state we are currently in
if (isLit)
{
isLit = false;
} else
{
isLit = true;
}
lightState(isLit);
}
private void lightState(bool lightState)
{
if (lightState)
{
// Update the label
lightStateLabel.Text = "ON";
// Update the image.
lightPictureBox.Image = Properties.Resources.LightOn;
}
else
{
// Update the label
lightStateLabel.Text = "OFF";
// Update the image.
lightPictureBox.Image = Properties.Resources.LightOff;
}
}
}
}