diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 3380b47d..bbf3b8d9 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index cfde0b10..42261dad 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 2b773e75..61da0321 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 b3ecdb7d..ecb26907 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 39553f98..713d32ba 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 7c7b2e05..77cba153 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 50d00a35..d7f262da 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -54,7 +54,6 @@ namespace Sunny.UI DrawMode = TabDrawMode.OwnerDrawFixed; Font = UIFontColor.Font; AfterSetFillColor(FillColor); - Size = new Size(450, 270); Version = UIGlobal.Version; Helper = new UITabControlHelper(this); diff --git a/SunnyUI/Static/UGDI.cs b/SunnyUI/Static/UGDI.cs index bd7a5497..7a584807 100644 --- a/SunnyUI/Static/UGDI.cs +++ b/SunnyUI/Static/UGDI.cs @@ -17,6 +17,7 @@ * 创建日期: 2020-01-01 * * 2020-01-01: V2.2.0 增加文件说明 + * 2021-08-19: V3.0.5 修复CreateRoundedRectanglePath参数radius=0时的错误 ******************************************************************************/ using System; @@ -1312,5 +1313,166 @@ namespace Sunny.UI TwoPoints.Clear(); } + + public static bool IsNullOrEmpty(this Color color) + { + return color == Color.Empty || color == Color.Transparent; + } + + public static bool IsValid(this Color color) + { + return !color.IsNullOrEmpty(); + } + + /// + /// 设置GDI高质量模式抗锯齿 + /// + /// + public static void SetHighQuality(this Graphics g) + { + g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿 + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.CompositingQuality = CompositingQuality.HighQuality; + } + + /// + /// 设置GDI默认值 + /// + /// + public static void SetDefaultQuality(this Graphics g) + { + g.SmoothingMode = SmoothingMode.Default; + g.InterpolationMode = InterpolationMode.Default; + g.CompositingQuality = CompositingQuality.Default; + } + + /// + /// 设置递进颜色 + /// + /// 颜色 + /// alpha + /// 颜色 + public static Color StepColor(this Color color, int alpha) + { + if (alpha == 100) + { + return color; + } + + byte a = color.A; + byte r = color.R; + byte g = color.G; + byte b = color.B; + float bg; + + int _alpha = Math.Max(alpha, 0); + double d = (_alpha - 100.0) / 100.0; + + if (d > 100) + { + // blend with white + bg = 255.0F; + d = 1.0F - d; // 0 = transparent fg; 1 = opaque fg + } + else + { + // blend with black + bg = 0.0F; + d = 1.0F + d; // 0 = transparent fg; 1 = opaque fg + } + + r = (byte)(BlendColor(r, bg, d)); + g = (byte)(BlendColor(g, bg, d)); + b = (byte)(BlendColor(b, bg, d)); + + return Color.FromArgb(a, r, g, b); + } + + private static double BlendColor(double fg, double bg, double alpha) + { + double result = bg + (alpha * (fg - bg)); + if (result < 0.0) + { + result = 0.0; + } + + if (result > 255) + { + result = 255; + } + + return result; + } + + public static Color RandomColor() + { + Random random = new Random(); + return Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + } + + /// + /// 平移 + /// + public static Point Offset(this Point point, Size size) + { + point.Offset(size.Width, size.Height); + return point; + } + + /// + /// 宽度放大 + /// + public static Size MultiplyWidth(this Size size, int multiple) + { + return new Size(size.Width * multiple, size.Height); + } + + /// + /// 高度放大 + /// + public static Size MultiplyHeight(this Size size, int multiple) + { + return new Size(size.Width, size.Height * multiple); + } + + /// + /// 宽度和高度放大 + /// + public static Size MultiplyAll(this Size size, int multiple) + { + return new Size(size.Width * multiple, size.Height * multiple); + } + + /// + /// 宽度放大 + /// + public static Size MultiplyWidth(this Size size, double multiple) + { + return new Size((int)(size.Width * multiple), size.Height); + } + + /// + /// 高度放大 + /// + public static Size MultiplyHeight(this Size size, double multiple) + { + return new Size(size.Width, (int)(size.Height * multiple)); + } + + /// + /// 宽度和高度放大 + /// + public static Size MultiplyAll(this Size size, double multiple) + { + return new Size((int)(size.Width * multiple), (int)(size.Height * multiple)); + } + + /// + /// 区域是否可见 + /// + public static bool IsVisible(this Rectangle rect) + { + return rect.Width > 0 && rect.Height > 0; + } } } \ No newline at end of file diff --git a/SunnyUI/Static/UImage.cs b/SunnyUI/Static/UImage.cs index 94f6b1d0..5e6b538d 100644 --- a/SunnyUI/Static/UImage.cs +++ b/SunnyUI/Static/UImage.cs @@ -104,12 +104,6 @@ namespace Sunny.UI } } - public static Color RandomColor() - { - Random random = new Random(); - return Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - } - public static Bitmap ChangeOpacity(Image img, float opacity) { Bitmap bmp = new Bitmap(img.Width, img.Height); // Determining Width and Height of Source Image @@ -232,38 +226,6 @@ namespace Sunny.UI } } - public static bool IsNullOrEmpty(this Color color) - { - return color == Color.Empty || color == Color.Transparent; - } - - public static bool IsValid(this Color color) - { - return !color.IsNullOrEmpty(); - } - - /// - /// 设置GDI高质量模式抗锯齿 - /// - /// - public static void SetHighQuality(this Graphics g) - { - g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿 - g.InterpolationMode = InterpolationMode.HighQualityBicubic; - g.CompositingQuality = CompositingQuality.HighQuality; - } - - /// - /// 设置GDI默认值 - /// - /// - public static void SetDefaultQuality(this Graphics g) - { - g.SmoothingMode = SmoothingMode.Default; - g.InterpolationMode = InterpolationMode.Default; - g.CompositingQuality = CompositingQuality.Default; - } - /// /// 旋转图片 /// @@ -304,79 +266,6 @@ namespace Sunny.UI return dst; } - /// - /// 设置递进颜色 - /// - /// 颜色 - /// alpha - /// 颜色 - public static Color StepColor(this Color color, int alpha) - { - if (alpha == 100) - { - return color; - } - - byte a = color.A; - byte r = color.R; - byte g = color.G; - byte b = color.B; - float bg; - - int _alpha = Math.Max(alpha, 0); - double d = (_alpha - 100.0) / 100.0; - - if (d > 100) - { - // blend with white - bg = 255.0F; - d = 1.0F - d; // 0 = transparent fg; 1 = opaque fg - } - else - { - // blend with black - bg = 0.0F; - d = 1.0F + d; // 0 = transparent fg; 1 = opaque fg - } - - r = (byte)(BlendColor(r, bg, d)); - g = (byte)(BlendColor(g, bg, d)); - b = (byte)(BlendColor(b, bg, d)); - - return Color.FromArgb(a, r, g, b); - } - - private static double BlendColor(double fg, double bg, double alpha) - { - double result = bg + (alpha * (fg - bg)); - if (result < 0.0) - { - result = 0.0; - } - - if (result > 255) - { - result = 255; - } - - return result; - } - - /// - /// 文件转换为Byte数组 - /// - /// 文件名 - /// 结果 - public static byte[] FileToBytes(this string filename) - { - if (!File.Exists(filename)) - { - return null; - } - - return File.ReadAllBytes(filename); - } - /// /// 缩放图像 /// @@ -402,16 +291,6 @@ namespace Sunny.UI return b; } - /// - /// Byte数组保存为文件 - /// - /// bytes - /// 文件名 - public static void ToFile(this byte[] bytes, string filename) - { - File.WriteAllBytes(filename, bytes); - } - /// /// Serializes the image in an byte array /// diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index bafed0f9..decf40f2 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -15,7 +15,7 @@ SunnyUI https://gitee.com/yhuse/SunnyUI https://gitee.com/yhuse/SunnyUI - true + false false SunnyUI.png