Theme definitions at runtime.

0
0

Hi

So I have a theme and have defined some new Colours and Fonts.
The InitializeComponent code seems to reference these like this:

this.label1.BackColor = System.Drawing.Color.FromName(“@CMSToolBarButtonBackgroundHover”);

And that works, it displays in the desired colour.
But when I put the same code in my application, for example in a MouseHover event handler, it returns “{Name=@CMSToolBarButtonBackgroundHover, ARGB=(0, 0, 0, 0)}” which seems right compared to other places, but it has no effect in the UI.

this.MouseHover += (s, ex) =>
{
this.BackColor = System.Drawing.Color.FromName(“@CMSToolBarButtonBackgroundHover”);
};

I can change the colour name in InitializeComponent and it changes the initial colour in the UI, I can also change the colour in the event handler to a non-theme colour (eg.FromARGB or Color.Black) but nothing I do in the event handler with the theme defined colour seems to have any effect.

In some cases I can setup buttons and use the theme designer to provide hover effects, but there are instances I need to do this programatically.

Any idea why this doesn’t work ?

Thanks,

Andi Gordon

  • You must to post comments
0
0

I added

“colors”: {
“CMSToolBarButtonBackgroundHover”: “red”
}

to a theme mixin and attached to the mouse hover event like this:

private void Button_MouseHover(object sender, EventArgs e)
{
((Button)sender).BackColor = System.Drawing.Color.FromName(“@CMSToolBarButtonBackgroundHover”);
}

It works here. I also tried to assign a BackColor to the button to something different than the default. Can you reproduce in a small test case?

Thanks,

Luca

Attachment
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.