Ejemplo n.º 1
0
        public static void UpdateTooltip(object sender)
        {
            if (_toolTipManager == null)
            {
                return;
            }

            var item = sender as IMenuItem;

            if (item == null)
            {
                return;
            }

            var dropDown = item as IDropDownMenuItem;

            if (dropDown != null)
            {
                return; // the tooltip would interfere with dropdown main function
            }

            var comp = item.GetInternalObject() as Component;

            var  info       = _toolTipManager.GetToolTip(comp);
            bool hasToolTip = info != null;

            if (info == null)
            {
                info = new ToolTipInfo();
            }

            info.Header.Text = item.Text;

            if (!hasToolTip)
            {
                info.Header.Font = new Font(info.Header.Font, FontStyle.Bold);
            }

            info.Body.Text = string.IsNullOrWhiteSpace(item.Description)
                ? "There is no description for the item."
                : item.Description;

            if (AppConfig.Instance.ShowPluginInToolTip && item.PluginIdentity != PluginIdentity.Default)
            {
                info.Footer.Text = "Plugin: " + item.PluginIdentity.Name;
                info.Separator   = false;
            }

            if (!hasToolTip)
            {
                _toolTipManager.SetToolTip(comp, info);
            }
        }