WinFormsPopupAlerts/CustomTooltipAlertRenderer.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace WinFormsPopupAlerts
{
/// <summary>
///
/// </summary>
[ToolboxBitmapAttribute(typeof(CustomTooltipAlertRenderer))]
public class CustomTooltipAlertRenderer : TooltipAlertRenderer
{
private Color backColor;
private Color titleForeColor;
private Color foreColor;
private Color borderColor;
private Font font;
private Font titleFont;
private CornerRadius cornerRadius;
private Brush backBrush;
private Brush titleForeBrush;
private Brush foreBrush;
private Pen borderPen;
private int borderThickness = 1;
public CustomTooltipAlertRenderer()
{
BackColor = Color.Gray;
TitleForeColor = Color.White;
ForeColor = Color.White;
BorderColor = Color.Black;
TitleFont = new Font(SystemFonts.DefaultFont, FontStyle.Bold);
Font = SystemFonts.DefaultFont;
CornerRadius = new CornerRadius(15, 0, 0, 15);
}
protected override void Draw(System.Drawing.Graphics dc, string title, string text, Rectangle rect, Rectangle titleRect, Rectangle bodyRect, Image img, int iconWidth)
{
Rectangle borderRect = new Rectangle(rect.X + borderThickness / 2, rect.Y + borderThickness / 2, rect.Width - borderThickness, rect.Height - borderThickness);
dc.FillPath(backBrush, GetCapsule(borderRect, CornerRadius));
dc.DrawPath(borderPen, GetCapsule(borderRect, CornerRadius));
StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
format.Trimming = StringTrimming.EllipsisCharacter;
dc.DrawString(title, titleFont, titleForeBrush,
new RectangleF(Padding.Left + iconWidth, Padding.Top, Math.Min(titleRect.Width, bodyRect.Width), titleRect.Height), format);
dc.DrawString(text, font, foreBrush,
new RectangleF(Padding.Left + iconWidth, Padding.Top + titleRect.Height, bodyRect.Width, bodyRect.Height),
new StringFormat());
}
protected override Rectangle GetBodyTextRect(System.Drawing.Graphics dc, string text, Rectangle rect)
{
SizeF size = dc.MeasureString(text, font, rect.Size.Width,
new StringFormat());
return new Rectangle(new Point(0, 0), Size.Ceiling(size));
}
后面还有 156 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。