public static void ShowTip(this Control ctl, string content, ToolTipLocation tipLocation = ToolTipLocation.BottomCenter, ToolTipType toolTipType = ToolTipType.Standard, int showTime = 2000, bool isAutoHide = true, ToolTipIconType tipIconType = ToolTipIconType.Application, ImageList imgList = null, int imgIndex = 0) { try { var myToolTipClt = new ToolTipController(); ToolTipControllerShowEventArgs args = myToolTipClt.CreateShowArgs(); myToolTipClt.ImageList = imgList; myToolTipClt.ImageIndex = (imgList == null ? 0 : imgIndex); args.AutoHide = isAutoHide; myToolTipClt.Appearance.BackColor = Color.FromArgb(254, 254, 254); myToolTipClt.ShowBeak = true; myToolTipClt.AllowHtmlText = true; myToolTipClt.ShowShadow = true; myToolTipClt.Rounded = true; myToolTipClt.AutoPopDelay = (showTime == 0 ? 2000 : showTime); myToolTipClt.SetToolTip(ctl, content); myToolTipClt.SetToolTipIconType(ctl, tipIconType); myToolTipClt.Active = true; myToolTipClt.ToolTipType = toolTipType; myToolTipClt.HideHint(); myToolTipClt.ShowHint(content, null, ctl, tipLocation); } catch (Exception ex) { LogUtil.WriteException(ex); } }
/// <summary> /// 展现ToolTip /// </summary> /// <param name="toolTip">ToolTipController</param> /// <param name="title">ToolTip标题</param> /// <param name="contnent">ToolTip内容</param> /// <param name="point">Point</param> /// <param name="toolTipRule">委托</param> public static void ShowToolTip(ToolTipController toolTip, string title, string content, Point point, Action <ToolTipController> toolTipRule) { ToolTipControllerShowEventArgs _args = toolTip.CreateShowArgs(); toolTip.ShowBeak = true; toolTip.ShowShadow = true; toolTip.Rounded = true; _args.Title = title; _args.ToolTip = content; _args.Rounded = true; _args.ToolTipType = ToolTipType.Default; if (toolTipRule != null) { toolTipRule(toolTip); } toolTip.ShowHint(_args, point); }
/// <summary> /// ToolTip消息提示 /// </summary> /// <param name="title">标题</param> /// <param name="content">内容</param> /// <param name="showTime">显示时长</param> /// <param name="isAutoHide">自动隐藏</param> public static void NewToolTip(string title, string content, int showTime, bool isAutoHide) { try { MyToolTipClt = new ToolTipController(); args = MyToolTipClt.CreateShowArgs(); title = string.IsNullOrEmpty(title) ? "温馨提示" : title; args.AutoHide = isAutoHide; MyToolTipClt.ShowBeak = true; MyToolTipClt.ShowShadow = true; MyToolTipClt.Rounded = true; MyToolTipClt.AutoPopDelay = (showTime == 0 ? 2000 : showTime); MyToolTipClt.Active = true; MyToolTipClt.HideHint(); MyToolTipClt.ShowHint(content, title, Control.MousePosition); } catch (Exception ex) { throw ex; } }