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); } }
/// <summary> /// Adds tooltips to the parameter controls based on BaseParameter.Description property. /// </summary> public static void AddTooltips(this SuperToolTip tooltip, IEnumerable <BaseParameter> parameters) { foreach (var p in parameters) { if (string.IsNullOrWhiteSpace(p.Description) || p.Control == null) { continue; } var info = new ToolTipInfo { BackColor = Color.White }; info.Header.Text = p.DisplayName; info.Body.Text = p.Description; // Syncfusion doesn't take into account header to determine the width of tooltip, // so let's add some padding const int minTextLength = 75; if (p.Description.Length < minTextLength) { info.Body.Text += new string(' ', minTextLength - p.Description.Length); } tooltip.SetToolTip(p.Control.ToolTipControl, info); } }