* UIHeaderButton: 增加图片与文字的位置

This commit is contained in:
Sunny 2021-06-01 22:34:37 +08:00
parent 1d9b3c4f48
commit 53f3159e0e
9 changed files with 21 additions and 18 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Bin/net45/SunnyUI.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -354,9 +354,10 @@ namespace Sunny.UI
}
}
}
public TextImageRelation textImageRelation = TextImageRelation.ImageAboveText;
[DefaultValue(typeof(TextImageRelation), "ImageAboveText")]
[DefaultValue(TextImageRelation.ImageAboveText)]
[Description("指定图像与文本的相对位置"), Category("SunnyUI")]
public TextImageRelation TextImageRelation
{
@ -367,6 +368,7 @@ namespace Sunny.UI
Invalidate();
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
@ -439,15 +441,10 @@ namespace Sunny.UI
switch (textImageRelation)
{
/*case TextImageRelation.Overlay:
{
}
break; */
case TextImageRelation.TextAboveImage:
{
#region
e.Graphics.DrawString(Text, Font, color, (Width - sf.Width) / 2, Padding.Top );
e.Graphics.DrawString(Text, Font, color, (Width - sf.Width) / 2, Padding.Top);
//字体图标
if (Symbol > 0 && Image == null)
@ -458,7 +455,7 @@ namespace Sunny.UI
bcColor = CircleHoverColor;
}
e.Graphics.FillEllipse(bcColor, (Width - CircleSize) / 2.0f, Height - Padding.Bottom- CircleSize, CircleSize, CircleSize);
e.Graphics.FillEllipse(bcColor, (Width - CircleSize) / 2.0f, Height - Padding.Bottom - CircleSize, CircleSize, CircleSize);
e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor,
new RectangleF(
symbolOffset.X + (Width - CircleSize) / 2.0f,
@ -468,7 +465,7 @@ namespace Sunny.UI
}
else if (Image != null)
{
e.Graphics.DrawImage(Image, (Width - ImageSize.Width) / 2.0f, Height - Padding.Bottom - ImageSize.Height+imageTop, ImageSize.Width, ImageSize.Height);
e.Graphics.DrawImage(Image, (Width - ImageSize.Width) / 2.0f, Height - Padding.Bottom - ImageSize.Height + imageTop, ImageSize.Width, ImageSize.Height);
}
#endregion
}
@ -502,7 +499,7 @@ namespace Sunny.UI
#endregion
}
break;
case TextImageRelation.TextBeforeImage :
case TextImageRelation.TextBeforeImage:
{
#region
e.Graphics.DrawString(Text, Font, color, Padding.Left, (Height - sf.Height) / 2);
@ -531,7 +528,7 @@ namespace Sunny.UI
#endregion
}
break;
default :
default:
{
#region
//字体图标

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0-windows;netcoreapp3.1;net40</TargetFrameworks>
<TargetFrameworks>net5.0-windows;netcoreapp3.1;net40;net45</TargetFrameworks>
<ProjectGuid>{AB1CB247-E20B-4CBE-B269-570ADDD96C53}</ProjectGuid>
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>Sunny.UI</RootNamespace>
@ -66,6 +66,12 @@
<Reference Include="System.Design" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Design" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>