diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index a296d648..234db8cd 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net462/SunnyUI.dll b/Bin/net462/SunnyUI.dll index ee21bed5..1ee097b6 100644 Binary files a/Bin/net462/SunnyUI.dll and b/Bin/net462/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 5ce4530c..addeb1d3 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index 99d7f246..d2e2dee1 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index e4dbd985..fd862bfb 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index 7b679286..f444d6e5 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -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) diff --git a/SunnyUI/Controls/UIPanel.cs b/SunnyUI/Controls/UIPanel.cs index 919d8e37..3103e5f0 100644 --- a/SunnyUI/Controls/UIPanel.cs +++ b/SunnyUI/Controls/UIPanel.cs @@ -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(); diff --git a/SunnyUI/Static/UImage.cs b/SunnyUI/Static/UImage.cs index cfccaa12..f5741095 100644 --- a/SunnyUI/Static/UImage.cs +++ b/SunnyUI/Static/UImage.cs @@ -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); + } + } + } } } \ No newline at end of file