Hi,
I have been trying to solve this problem and create this program.
However, I am having difficulty creating it as I am a beginner and have
come here today, to this forum for your help.
My case study is this:
I have to create a picture for instance a balloon. Which I have done.
The form in C# needs to contain a password box for users to enter the
correct password. If incorrect it should display a message. Which I have
managed to get it done.
However, my problem is that I cannot get the balloon to light up. A
repeating sequence of ON/OFF periods for the light is to be determined
by a timer control.
The program can contain switch statements or if statements to construct
to establish the correct state for the light and the correct timer
interval as shown:
light = 0 light ON for 3 seconds
light = 1 and 3 light OFF for 1 second
light = 2 and 4 light ON for 1 second
light = 5 light OFF for 3 seconds
please help me re-write this code and I look forward to your response. Thank you
[code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace System_Graphics
{
public partial class Form1 : Form
{
public Graphics g;
public Form1()
{
InitializeComponent();
}
private static int lightstate = 0;
private void button1_Click(object sender, EventArgs e)
{
using (Graphics g = this.CreateGraphics())
{
String password = "password";
if ((txtPassword.Text == password))
{
g.FillEllipse(Brushes.DarkGray, new Rectangle(105, 105, 105, 105));
g.FillEllipse(Brushes.Silver, new Rectangle(100, 100, 100, 100));
lblLightOn.Visible = true;
tmrTimer_Tick(sender, e);
}
else
{
MessageBox.Show("Incorrect Password");
}
}
}
}
[/code]