* UIToolTip:更新绘制
This commit is contained in:
parent
0a3a0ca63e
commit
3a042a1798
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
@ -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)
|
||||
|
@ -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));
|
||||
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);
|
||||
e.Graphics.DrawFontImage(tooltip.Symbol, tooltip.SymbolSize, tooltip.SymbolColor, new Rectangle(5, 5, tooltip.SymbolSize, tooltip.SymbolSize));
|
||||
}
|
||||
|
||||
e.Graphics.DrawString(e.ToolTipText, Font, ForeColor, 6, TitleHeight + 6);
|
||||
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())
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
17
Updates.txt
17
Updates.txt
@ -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:重写下拉窗体,缩短创建时间
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user