private void btnGenerate_Click(object sender, EventArgs e)
{
int monday = 0;
int tuesday = 0;
int wednesday = 0;
int thursday = 0;
int friday = 0;
try
{
monday = int.Parse(txtMonday.Text) / 100;
}
catch (FormatException)
{
MessageBox.Show("Invalid value");
}
try
{
tuesday = int.Parse(txtTuesday.Text) / 100;
}
catch (FormatException)
{
MessageBox.Show("Invalid value");
}
try
{
wednesday = int.Parse(txtWednesday.Text) / 100;
}
catch (FormatException)
{
MessageBox.Show("Invalid value");
}
try
{
thursday = int.Parse(txtThursday.Text) / 100;
}
catch (FormatException)
{
MessageBox.Show("Invalid value");
}
try
{
friday = int.Parse(txtFriday.Text) / 100;
}
catch (FormatException)
{
MessageBox.Show("Invalid value");
}
graphDrawingArea.Clear(this.BackColor);
graphDrawingArea.FillRectangle(new SolidBrush(Color.Red),
this.txtMonday.Left + 5,
280 - monday, 40, monday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black),
this.txtMonday.Left + 5,
280 - monday, 40, monday);
graphDrawingArea.FillRectangle(new SolidBrush(Color.Blue),
this.txtTuesday.Left + 5,
280 - tuesday, 40, tuesday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black),
this.txtTuesday.Left + 5,
280 - tuesday, 40, tuesday);
graphDrawingArea.FillRectangle(new SolidBrush(Color.Fuchsia),
this.txtWednesday.Left + 5,
280 - wednesday, 40, wednesday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black),
this.txtWednesday.Left + 5,
280 - wednesday, 40, wednesday);
graphDrawingArea.FillRectangle(new SolidBrush(Color.Brown),
this.txtThursday.Left + 5,
280 - thursday, 40, thursday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black),
this.txtThursday.Left + 5,
280 - thursday, 40, thursday);
graphDrawingArea.FillRectangle(new SolidBrush(Color.Turquoise),
this.txtFriday.Left + 5,
280 - friday, 40, friday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black),
this.txtFriday.Left + 5,
280 - friday, 40, friday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black),
10, 280, Width - 30, 1);
Invalidate();
}
|