* UIToolTip:更新绘制

This commit is contained in:
Sunny 2020-07-25 22:16:50 +08:00
parent 0a3a0ca63e
commit 3a042a1798
6 changed files with 67 additions and 17 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -106,14 +106,28 @@ namespace Sunny.UI
protected override void OnPaintFore(Graphics g, GraphicsPath path)
{
//设置按钮标题位置
Padding = new Padding(_imageSize + _imageInterval * 2, Padding.Top, Padding.Right, Padding.Bottom);
if (RightToLeft == RightToLeft.Yes)
{
//设置按钮标题位置
Padding = new Padding(Padding.Left, Padding.Top, Padding.Right- _imageSize - _imageInterval * 2, Padding.Bottom);
//填充文字
Color color = foreColor;
color = Enabled ? color : UIDisableColor.Fore;
//填充文字
Color color = foreColor;
color = Enabled ? color : UIDisableColor.Fore;
g.DrawString(Text, Font, color, Size, Padding, ContentAlignment.MiddleLeft);
g.DrawString(Text, Font, color, Size, Padding, ContentAlignment.MiddleLeft);
}
else
{
//设置按钮标题位置
Padding = new Padding(_imageSize + _imageInterval * 2, Padding.Top, Padding.Right, Padding.Bottom);
//填充文字
Color color = foreColor;
color = Enabled ? color : UIDisableColor.Fore;
g.DrawString(Text, Font, color, Size, Padding, ContentAlignment.MiddleLeft);
}
}
protected override void OnPaintFill(Graphics g, GraphicsPath path)

View File

@ -164,38 +164,57 @@ namespace Sunny.UI
}
SizeF textSize = g.MeasureString(tooltip.Description, Font);
TitleHeight = (int)Math.Max(symbolHeight, titleSize.Height);
e.ToolTipSize = new Size((int)Math.Max(textSize.Width, symbolWidth + titleSize.Width) + 10, (int)textSize.Height + TitleHeight + 10);
int allWidth = (int) Math.Max(textSize.Width, titleSize.Width) + 10;
if (symbolWidth > 0) allWidth = allWidth + symbolWidth + 5;
int allHeight = titleSize.Height > 0 ?
(int)titleSize.Height + (int)textSize.Height + 15 :
(int)textSize.Height + 10;
e.ToolTipSize = new Size(allWidth, allHeight);
bmp.Dispose();
}
}
}
}
private int TitleHeight;
private void ToolTipExDraw(object sender, DrawToolTipEventArgs e)
{
if (ToolTipControls.ContainsKey(e.AssociatedControl))
{
var tooltip = ToolTipControls[e.AssociatedControl];
var bounds = new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1);
e.Graphics.FillRectangle(BackColor, bounds);
e.Graphics.DrawRectangle(RectColor, bounds);
if (tooltip.Symbol > 0)
{
e.Graphics.DrawFontImage(tooltip.Symbol, tooltip.SymbolSize, tooltip.SymbolColor, new Rectangle(5, 5, tooltip.SymbolSize, tooltip.SymbolSize));
}
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
int symbolHeight = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
SizeF titleSize = new SizeF(0, 0);
if (tooltip.Title.IsValid())
{
SizeF sf = e.Graphics.MeasureString(tooltip.Title, TitleFont);
e.Graphics.DrawString(tooltip.Title,TitleFont,ForeColor, tooltip.Symbol>0?tooltip.SymbolSize+5:5, (TitleHeight-sf.Height)/2);
if (tooltip.Title.IsValid())
{
titleSize = e.Graphics.MeasureString(tooltip.Title, TitleFont);
}
e.Graphics.DrawString(tooltip.Title,TitleFont,ForeColor,
tooltip.Symbol>0?tooltip.SymbolSize+5:5, 5);
}
e.Graphics.DrawString(e.ToolTipText, Font, ForeColor, 6, TitleHeight + 6);
if (titleSize.Height > 0)
{
e.Graphics.DrawLine(ForeColor,
symbolWidth==0?5:symbolWidth+5, 5+ titleSize.Height + 3,
e.Bounds.Width - 5, 5 + titleSize.Height + 3);
}
e.Graphics.DrawString(e.ToolTipText, Font, ForeColor,
tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5,
titleSize.Height > 0? 10+ titleSize.Height : 5);
}
else
{

View File

@ -1,5 +1,22 @@
+ 增加; - 删除; * 修改
2020-07-21
+ UIToolTip新增控件可修改字体
* UIForm.cs 支持点击窗体任务栏图标,可以进行最小化
2020-07-20
+ UIWaitingBar新增等待滚动条控件
2020-07-18
* UIDataGridView重绘水平滚动条
+ UIHorScrollBar新增水平滚动条
2020-07-15
* UIDataGridView更新默认设置为原生控件设置
2020-07-10
* UIForm增加标题栏ICON图标绘制
2020-07-08
* UIDateTimePicker重写下拉窗体缩短创建时间