LitDev.LDDialogs.ToolTip C# (CSharp) Method

ToolTip() public static method

Set a tooltip popup for common shapes and controls.
public static ToolTip ( Primitive shapeName, Primitive tip ) : void
shapeName Primitive The shape or control.
tip Primitive The text content of the tooltip.
return void
        public static void ToolTip(Primitive shapeName, Primitive tip)
        {
            Type GraphicsWindowType = typeof(GraphicsWindow);
            Dictionary<string, UIElement> _objectsMap;
            UIElement obj;

            try
            {
                _objectsMap = (Dictionary<string, UIElement>)GraphicsWindowType.GetField("_objectsMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                if (!_objectsMap.TryGetValue(shapeName, out obj))
                {
                    Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
                    return;
                }

                InvokeHelper ret = new InvokeHelper(delegate
                {
                    ToolTip toolTip = new ToolTip();
                    toolTip.Content = tip;

                    try
                    {
                        ((FrameworkElement)obj).ToolTip = toolTip;
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                    }
                });
                FastThread.Invoke(ret);
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }