* UIDropControl: 优化下拉框控件显示效果
This commit is contained in:
parent
22e519c195
commit
ee1fb615a8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -80,27 +80,10 @@ namespace Sunny.UI
|
||||
MouseLocation = e.Location;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
protected override void OnEnabledChanged(EventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (Enabled)
|
||||
{
|
||||
if (Radius == 0 || RadiusSides == UICornerRadiusSides.None)
|
||||
e.Graphics.DrawRectangle(RectColor, 0, 0, Width - 1, Height - 1);
|
||||
else
|
||||
e.Graphics.DrawRoundRectangle(RectColor, 0, 0, Width, Height, Radius);
|
||||
|
||||
edit.BackColor = Color.White;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Radius == 0 || RadiusSides == UICornerRadiusSides.None)
|
||||
e.Graphics.DrawRectangle(RectDisableColor, 0, 0, Width - 1, Height - 1);
|
||||
else
|
||||
e.Graphics.DrawRoundRectangle(RectDisableColor, 0, 0, Width, Height, Radius);
|
||||
|
||||
edit.BackColor = GetFillColor();
|
||||
}
|
||||
base.OnEnabledChanged(e);
|
||||
edit.BackColor = Enabled ? Color.White : GetFillColor();
|
||||
}
|
||||
|
||||
private void Edit_LostFocus(object sender, EventArgs e)
|
||||
@ -304,14 +287,13 @@ namespace Sunny.UI
|
||||
if (!edit.Visible)
|
||||
{
|
||||
base.OnPaintFore(g, path);
|
||||
g.FillRoundRectangle(GetFillColor(), new Rectangle(Width - 27, edit.Top, 26, edit.Height), Radius, false);
|
||||
g.DrawRoundRectangle(rectColor, new Rectangle(0, 0, Width, Height), Radius);
|
||||
}
|
||||
|
||||
g.FillRoundRectangle(GetFillColor(), new Rectangle(Width - 27, edit.Top, 25, edit.Height), Radius);
|
||||
g.FillRectangle(GetFillColor(), new Rectangle(Width - 27, Radius / 2, 26, Height - Radius));
|
||||
Color color = GetRectColor();
|
||||
SizeF sf = g.GetFontImageSize(dropSymbol, 24);
|
||||
g.DrawFontImage(dropSymbol, 24, color, Width - 28 + (12 - sf.Width / 2.0f), (Height - sf.Height) / 2.0f);
|
||||
g.DrawLine(RectColor, Width - 1, Radius / 2, Width - 1, Height - Radius);
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
|
@ -327,7 +327,11 @@ namespace Sunny.UI
|
||||
//填充文字
|
||||
if (ShowText)
|
||||
{
|
||||
OnPaintFore(e.Graphics, path);
|
||||
rect = new Rectangle(1, 1, Width - 3, Height - 3);
|
||||
using (var path1 = rect.GraphicsPath())
|
||||
{
|
||||
OnPaintFore(e.Graphics, path1);
|
||||
}
|
||||
}
|
||||
|
||||
path.Dispose();
|
||||
|
@ -643,5 +643,35 @@ namespace Sunny.UI
|
||||
return Image.FromStream(toImage);
|
||||
}
|
||||
}
|
||||
|
||||
public static Icon SaveToIcon(this Image img, int size = 16)
|
||||
{
|
||||
byte[] pngiconheader = new byte[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
using (Bitmap bmp = new Bitmap(img, new Size(size, size)))
|
||||
{
|
||||
byte[] png;
|
||||
using (System.IO.MemoryStream fs = new System.IO.MemoryStream())
|
||||
{
|
||||
bmp.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
|
||||
fs.Position = 0;
|
||||
png = fs.ToArray();
|
||||
}
|
||||
|
||||
using (System.IO.MemoryStream fs = new System.IO.MemoryStream())
|
||||
{
|
||||
if (size >= 256) size = 0;
|
||||
pngiconheader[6] = (byte)size;
|
||||
pngiconheader[7] = (byte)size;
|
||||
pngiconheader[14] = (byte)(png.Length & 255);
|
||||
pngiconheader[15] = (byte)(png.Length / 256);
|
||||
pngiconheader[18] = (byte)(pngiconheader.Length);
|
||||
|
||||
fs.Write(pngiconheader, 0, pngiconheader.Length);
|
||||
fs.Write(png, 0, png.Length);
|
||||
fs.Position = 0;
|
||||
return new Icon(fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user