I'm trying to determine which GalleryToolItem the mouse is hovering over from the ToolBarsManager MouseEnterEvent. I've been able to get to the UIElement that is Infragistics.Win.UltraWinToolbars.PopupGalleryItemUIElement and its cooresponding System.Drawing.Point but I don't see any methods for determining the galleryToolItem from that information.
Is there a better way to find the item or am I missing something?
Thanks,
JL
Please disregard...found the GalleryToolActiveItemChange event. Works great!
Well, I was wrong.
The ActiveItemChange event does give me the correct item, but unfortunately I need more.
I'm trying to determine the mouse pointer location when hovering over the ActiveItem with respect to the form it's contained in. What I'm attempting is to provide my own balloon style tooltip when the mouse hovers over the GalleryItem.
I tried using the GetUiElement in the GalleryToolActiveItemChange event and then walk up the UIElement parent chain. What I got was:
Once I got to the last entry above, there was no more parent property set. Obviously this won't give me what I need.
If anyone has a suggestion or solution, I would be most grateful.
I'm still being hopeful that someone has a suggestion for this.
I hope this helps:
Private Function GetGalleryToolItemFromScreenPoint(ByVal myToolbar As UltraToolbarsManager, ByVal myGallery As PopupGalleryTool, _
ByVal myGroup As GalleryToolItemGroup, ByVal screenPoint As Point) As GalleryToolItem
Dim myElement As UIElement = myToolbar.UIElementFromPoint(screenPoint)
For Each myItem As GalleryToolItem In myGallery.Items
Dim relatedUI As UIElement = myItem.GetUIElement(myGallery, myGroup, GalleryArea.Preview)
If relatedUI IsNot Nothing Then
If myElement.IsDescendantOf(relatedUI) Then
Return myItem '* This GalleryToolItem relates to this UI Element.
End If
Next
Return Nothing '* The item was not found.
End Function
Here is the same code in C#, if you prefer that:
Mike,
Thanks for the info. The Cursor.Position seems to be working fine in this case, but this is definitely good information to know. I'm sure I'll find a use for it.
Thanks!
Jim
If you have the item's UIElement, you can ask for it's Control property. The Rect of the element is always in client coordinates of this Control. Then you can just get the Form of the Control and add the Control's location relative to the Form to the element Rect's Location relative to the Control.
Mark,
Thanks for the reply. However, the problem was that I had the item, but couldn't get its position in relation to the form.
After getting your reply, I went back and worked on this some more and was able to position the tooltip using the System.Windows.Forms.Cursor.Position x and y coordinates.