I have been working on having my form change the background color immediately depending on the option a user selects. He can choose between red, green and blue. I was trying to use the system.drawing.color but I can´t seem to make the form change it's color. It is supposed to use delegates.
I am just learning about modeless dialog boxes. Help please...
So far this is whatI have done:
public partial class ChangeColors : Form
{
//Delegate the observer needs to notify if something changes
public delegate void ChangeColorEvent(Color nameColor);
// Name of the event which is tied to the delegate
public event ChangeColorEvent ChangeColor;
public enum color { Red, Green, Blue };
private color selectedColor;
public color SelectedColor
{
get
{
return selectedColor;
}
set
{
selectedColor = value;
}
}
public ChangeColors()
{
InitializeComponent();
selectedColor = color.Blue;
}
private void backColor_ColorChanged(Control control)
{
if (redRadioButton.Checked)
this.BackColor = System.Drawing.Color.Red;
else if (blueRadioButton.Checked)
this.BackColor = System.Drawing.Color.Blue;
else
this.BackColor = System.Drawing.Color.Green;
}
private void okButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
I not know how to do this with delgete but with events is the code: