I'm trying to override the color and rectangle size of the selected main menu item. However I can't tell if the mouse is over that element.
In the BeforeDrawBackColor phase of the Drawfilter on the UltraToolbarsManager:
if (drawParams.Element is PopupMenuItemUIElement){ PopupMenuItemUIElement popupMenuItemUIElement = (PopupMenuItemUIElement)drawParams.Element; if(true) // I'd like to replace this with a check if the mouse is over this menu item { Rectangle originalRect = popupMenuItemUIElement.DrawingRectInsideBorders; SolidBrush solidBrush = drawParams.CreateSolidBrush(DefaultHoverMenuBackgroundColor); Int32 verticalCenteringShift = (originalRect.Height - 20) / 2; Rectangle drawingRect = new Rectangle(originalRect.X+24, originalRect.Y + verticalCenteringShift, originalRect.Width-24, 20); drawParams.Graphics.FillRectangle(solidBrush, drawingRect); allPaintingHandled = true; }}
Thanks.
Hello Abdul,
I am just checking about the progress of this issue. Let me know if you need my further assistance on it.
Thank you for using Infragistics Components.
Sincerely,
Milko
Developer Support Engineer
Infragistics
www.infragistics.com/support
So it seems I didn't ask the correct question for the problem I had. I was really trying to track the active menu item to paint the selected color. Because if I hover over an item it all works with your suggested logic, but if I press key up, then it moves selection to the menu item above and I can't detect that its "active". I stepped through the code and found the DrawAsActive property is set to true in the cases I care about. I played around with some Reflection in the draw filter, which I would like to avoid doing to prove that its the property I care about and it worked.
However is there a better way to check the DrawAsActive flag without the two Reflection calls as in the following:
if(drawingElement is PopupMenuItemUIElement) { object context = drawingElement.GetContext(); PropertyInfo propertyInfo = context.GetType().GetProperty("Tool", BindingFlags.Instance | BindingFlags.NonPublic); ToolBase tool = (ToolBase)propertyInfo.GetValue(context, null); propertyInfo = tool.GetType().GetProperty("DrawAsActive", BindingFlags.Instance | BindingFlags.NonPublic); Boolean drawAsActive = (Boolean)propertyInfo.GetValue(tool, null); if(drawAsActive) {