In my Winform the user has the option to pick sets of colors depending on the button clicked.
The colors themselves are stored in a different class. Using reflection the Method that is called depends on the the button clicked while all buttons use the same event.
Code in form:
private void Button_Theme__Click(object sender, EventArgs e)
{
Button button = sender as Button;
string[] Color = Regex.Split(button.Name.ToString(), "_");
Type thisType = this.GetType();
ColorTheme ColorTheme = new ColorTheme();
MethodInfo ColorMethod = thisType.GetMethod("ColorTheme.Theme_" + Color[2]);
Color[] ColorThemes = (Color[])ColorMethod.Invoke(this, null);
ColorThemeLight = ColorThemes[0];
ColorThemeMedium = ColorThemes[1];
ColorThemeDark = ColorThemes[2];
}
Code in the class:
public Color[] Theme_Yellow()
{
ColorThemeLight = Color.FromArgb(255, 255, 255, 200);
ColorThemeMedium = Color.FromArgb(255, 191, 191, 150);
ColorThemeDark = Color.FromArgb(255, 127, 127, 100);
Color[] Colors = { ColorThemeLight, ColorThemeMedium, ColorThemeDark };
return Colors;
}
I am getting the following error but i can't seem to pinpoint where the problem lies and how to fix it.
Aucun commentaire:
Enregistrer un commentaire