lab6_2
This commit is contained in:
45
lab6_1/lab6_1_CalebFontenot/Form1.cs
Executable file
45
lab6_1/lab6_1_CalebFontenot/Form1.cs
Executable file
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user