Hello,
I'm trying to change the color of the RadioButtons in a OptionSet. Therefore I use the DrawElement-Method, in which I want to get to know the state of the radioButton (if Mouse is Over or the element is pressed). For this I use drawParams.Element and the different "Is..."-Properties. For "IsMouseOver" it works fine. I get back true and can draw the element in the appropriate color, but for the otherones (IsMouseDownAndOver, IsPressed etc.) I always get back false.
Is there better way to detect in which state the RadioButton is? Or can anyone tell me way I always get back false?
I also tried to use the ButtonState Property but it also gives wrong states back.
Here is the code I used (Colors and Forms are just for exercise ;) ):
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams)
{
if (drawParams.Element is Infragistics.Win.OptionSetOptionButtonUIElement)
return Infragistics.Win.DrawPhase.BeforeDrawElement;
return Infragistics.Win.DrawPhase.None;
}
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
Rectangle elementRect = drawParams.Element.RectInsideBorders;
var elementToDraw = drawParams.Element as OptionSetOptionButtonUIElement;
drawParams.Graphics.FillEllipse(new SolidBrush(Color.Yellow), elementRect);
if(elementToDraw.IsMouseOver)
drawParams.Graphics.DrawEllipse(new Pen(Color.Orange), elementRect);
else if(elementToDraw.IsMouseDownAndOver)
drawParams.Graphics.FillEllipse(new SolidBrush(Color.GreenYellow), elementRect);
else if (elementToDraw.IsMouseDown)
drawParams.Graphics.FillEllipse(new SolidBrush(Color.DarkCyan), elementRect);
else if (elementToDraw.IsPressed)
drawParams.Graphics.FillEllipse(new SolidBrush(Color.DeepPink), elementRect);
else if (elementToDraw.IsStateButtonDown)
drawParams.Graphics.FillEllipse(new SolidBrush(Color.DeepSkyBlue), elementRect);
return true; //If returns true all other drawPhases will be skipped --> In Case DrawPhase = BeforeDrawElement nothing but what we did will be drawn
Hello Alex,
The color is part of the default glyphs used by the OS. Using a DrawFilter won't help as the entire glyph would need to be replaced.
Note, this has previously been discussed here:
http://es.infragistics.com/community/forums/t/77815.aspx
Let me know if you have any questions regarding this matter.