From 307ace2d85bd2b5abc03c7d51f6cb01b2d955fdf Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 30 Jun 2022 10:20:53 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E5=A2=9E=E5=8A=A0XML=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Common/UBmp.cs | 23 +++ SunnyUI/Common/UControl.cs | 70 +++++--- SunnyUI/Common/UDefine.cs | 83 +++++++++ SunnyUI/Common/UEnvironment.cs | 93 +--------- SunnyUI/Common/UFastLZ.cs | 30 +++- SunnyUI/Common/UFile.cs | 5 + SunnyUI/Common/UFolderBrowserDialogEx.cs | 13 ++ SunnyUI/Common/UGDI.cs | 206 +++++++++++++++++++++-- SunnyUI/Common/UGif.cs | 58 +++++++ SunnyUI/SunnyUI.csproj | 2 +- 10 files changed, 463 insertions(+), 120 deletions(-) diff --git a/SunnyUI/Common/UBmp.cs b/SunnyUI/Common/UBmp.cs index ed04c06e..a813c6ba 100644 --- a/SunnyUI/Common/UBmp.cs +++ b/SunnyUI/Common/UBmp.cs @@ -108,6 +108,10 @@ namespace Sunny.UI /// public uint ImportantColors { get; set; } + /// + /// 以图片初始化类 + /// + /// 图片 public void Init(Bitmap bitmap) { Head = 0x4D42; @@ -123,6 +127,11 @@ namespace Sunny.UI FileSize = BitmapDataOffset + BitmapDataSize; } + /// + /// 以宽高初始化类 + /// + /// 宽 + /// 高 public void Init(int width, int height) { Head = 0x4D42; @@ -139,6 +148,9 @@ namespace Sunny.UI } } + /// + /// 24bit 真彩色位图文件 + /// public class BmpFile { BmpHead head; @@ -205,13 +217,24 @@ namespace Sunny.UI } } + /// + /// 二进制数据 + /// public byte[] Data => data; + /// + /// 保存文件 + /// + /// 文件名 public void SaveToFile(string fileName) { File.WriteAllBytes(fileName, data); } + /// + /// 图片 + /// + /// 图片 public Bitmap Bitmap() { MemoryStream ms = new MemoryStream(data); diff --git a/SunnyUI/Common/UControl.cs b/SunnyUI/Common/UControl.cs index 12719cbb..41d4f819 100644 --- a/SunnyUI/Common/UControl.cs +++ b/SunnyUI/Common/UControl.cs @@ -36,6 +36,11 @@ namespace Sunny.UI /// public static class ControlEx { + /// + /// 定时器重置 + /// + /// 定时器 + /// 定时器 public static Timer ReStart(this Timer timer) { timer.Stop(); @@ -43,26 +48,51 @@ namespace Sunny.UI return timer; } + /// + /// 控件是否为空 + /// + /// 控件 + /// 是否为空 public static bool IsNull(this Control ctrl) { return ctrl == null; } + /// + /// 控件是否有效 + /// + /// 控件 + /// 是否有效 public static bool IsValid(this Control ctrl) { return ctrl != null; } + /// + /// 控件位于屏幕的区域 + /// + /// 控件 + /// 区域 public static Rectangle ScreenRectangle(this Control ctrl) { return ctrl.RectangleToScreen(ctrl.ClientRectangle); } + /// + /// 控件位于屏幕的位置 + /// + /// 控件 + /// 位置 public static Point ScreenLocation(this Control ctrl) { return ctrl.PointToScreen(new Point(0, 0)); } + /// + /// 控件的根窗体 + /// + /// 控件 + /// 根窗体 public static Form RootForm(this Control ctrl) { if (ctrl == null) return null; @@ -74,11 +104,21 @@ namespace Sunny.UI return ctrl as Form; } + /// + /// 设置控件位于容器的中心 + /// + /// 控件 + /// 控件 public static Control SetToTheCenterOfParent(this Control ctrl) { return ctrl.SetToTheHorizontalCenterOfParent().SetToTheVerticalCenterOfParent(); } + /// + /// 设置控件位于容器的水平方向的中心 + /// + /// 控件 + /// 控件 public static Control SetToTheHorizontalCenterOfParent(this Control ctrl) { if (ctrl != null && ctrl.Parent != null) @@ -87,6 +127,11 @@ namespace Sunny.UI return ctrl; } + /// + /// 设置控件位于容器的垂直方向的中心 + /// + /// 控件 + /// 控件 public static Control SetToTheVerticalCenterOfParent(this Control ctrl) { if (ctrl != null && ctrl.Parent != null) @@ -95,26 +140,11 @@ namespace Sunny.UI return ctrl; } - public static Form GetParentForm(this Control ctrl) - { - while (!IsForm(ctrl.Parent)) - { - ctrl = ctrl.Parent; - } - - return ctrl.Parent as Form; - } - - private static bool IsForm(Control ctrl) - { - return ctrl is Form; - } - /// - /// 边框宽度 + /// 窗体边框宽度 /// - /// - /// + /// 窗体 + /// 边框宽度 public static int BorderSize(this Form form) { return (form.Width - form.ClientSize.Width) / 2; @@ -123,8 +153,8 @@ namespace Sunny.UI /// /// 标题栏高度 /// - /// - /// + /// 窗体 + /// 标题栏高度 public static int TitleHeight(this Form form) { return (form.Height - form.ClientSize.Height) - form.BorderSize(); diff --git a/SunnyUI/Common/UDefine.cs b/SunnyUI/Common/UDefine.cs index b8c67776..d916f627 100644 --- a/SunnyUI/Common/UDefine.cs +++ b/SunnyUI/Common/UDefine.cs @@ -3,41 +3,124 @@ using System.Windows.Forms; namespace Sunny.UI { + /// + /// 日期控件选择类型 + /// public enum UIDateType { + /// + /// 年月日 + /// YearMonthDay, + + /// + /// 年月 + /// YearMonth, + + /// + /// 年 + /// Year } + /// + /// 接口 + /// public interface IToolTip { + /// + /// 需要额外设置工具提示的控件 + /// + /// 控件 Control ExToolTipControl(); } + /// + /// 线头部类型 + /// public enum UILineCap { + /// + /// 无 + /// None, + + /// + /// 正方形 + /// Square, + + /// + /// 菱形 + /// Diamond, + + /// + /// 三角形 + /// Triangle, + + /// + /// 圆形 + /// Circle } + /// + /// 线型 + /// public enum UILineDashStyle { + /// + /// 实线 + /// Solid, + + /// + /// 虚线 + /// Dash, + + /// + /// 由重复的点图案构成的直线 + /// Dot, + + /// + /// 由重复的点划线图案构成的直线 + /// DashDot, + + /// + /// 由重复的双点划线图案构成的直线 + /// DashDotDot, + + /// + /// 自定义 + /// Custom, + + /// + /// 不设置线型 + /// None } + /// + /// 树节点绘制 + /// public class UITreeNodePainter { + /// + /// 背景色 + /// public Color BackColor; + + /// + /// 前景色 + /// public Color ForeColor; } } diff --git a/SunnyUI/Common/UEnvironment.cs b/SunnyUI/Common/UEnvironment.cs index f5ac7a96..16ef7040 100644 --- a/SunnyUI/Common/UEnvironment.cs +++ b/SunnyUI/Common/UEnvironment.cs @@ -20,14 +20,15 @@ ******************************************************************************/ using Microsoft.Win32; -using System; namespace Sunny.UI { + /// + /// .Net版本 + /// public static class UEnvironment { - // Checking the version using >= enables forward compatibility. - public static string CheckFor45PlusVersion(int releaseKey) + private static string CheckFor45PlusVersion(int releaseKey) { if (releaseKey >= 528040) return "4.8 or later"; @@ -54,6 +55,10 @@ namespace Sunny.UI return "No 4.5 or later version detected"; } + /// + /// 检查.Net版本 + /// + /// .Net版本 public static string CheckVersion() { const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"; @@ -69,87 +74,5 @@ namespace Sunny.UI } } } - - public static void CheckOtherVersion() - { - // Open the registry key for the .NET Framework entry. - using (RegistryKey ndpKey = - RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32) - .OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\")) - { - foreach (var versionKeyName in ndpKey.GetSubKeyNames()) - { - // Skip .NET Framework 4.5 version information. - if (versionKeyName == "v4") - { - continue; - } - - if (versionKeyName.StartsWith("v")) - { - RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName); - - // Get the .NET Framework version value. - var name = (string)versionKey.GetValue("Version", ""); - // Get the service pack (SP) number. - var sp = versionKey.GetValue("SP", "").ToString(); - - // Get the installation flag. - var install = versionKey.GetValue("Install", "").ToString(); - if (string.IsNullOrEmpty(install)) - { - // No install info; it must be in a child subkey. - Console.WriteLine($"{versionKeyName} {name}"); - } - else if (install == "1") - { - // Install = 1 means the version is installed. - - if (!string.IsNullOrEmpty(sp)) - { - Console.WriteLine($"{versionKeyName} {name} SP{sp}"); - } - else - { - Console.WriteLine($"{versionKeyName} {name}"); - } - } - - if (!string.IsNullOrEmpty(name)) - { - continue; - } - // else print out info from subkeys... - - // Iterate through the subkeys of the version subkey. - foreach (var subKeyName in versionKey.GetSubKeyNames()) - { - RegistryKey subKey = versionKey.OpenSubKey(subKeyName); - name = (string)subKey.GetValue("Version", ""); - if (!string.IsNullOrEmpty(name)) - sp = subKey.GetValue("SP", "").ToString(); - - install = subKey.GetValue("Install", "").ToString(); - if (string.IsNullOrEmpty(install)) - { - // No install info; it must be later. - Console.WriteLine($"{versionKeyName} {name}"); - } - else if (install == "1") - { - if (!string.IsNullOrEmpty(sp)) - { - Console.WriteLine($"{subKeyName} {name} SP{sp}"); - } - else - { - Console.WriteLine($" {subKeyName} {name}"); - } - } - } - } - } - } - } } } diff --git a/SunnyUI/Common/UFastLZ.cs b/SunnyUI/Common/UFastLZ.cs index 0485aa64..0ffae9ef 100644 --- a/SunnyUI/Common/UFastLZ.cs +++ b/SunnyUI/Common/UFastLZ.cs @@ -28,11 +28,7 @@ ******************************************************************************/ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Sunny.UI { @@ -60,6 +56,9 @@ namespace Sunny.UI public static extern int FastLZ_Decompress(void* input, int length, void* output, int maxout); } + /// + /// FastLZ压缩解压类 + /// public static unsafe class FastLZ { /// @@ -71,6 +70,13 @@ namespace Sunny.UI return IntPtr.Size == 8; } + /// + /// 压缩 + /// + /// 输入 + /// 起始位置 + /// 长度 + /// 压缩结果 public static byte[] Compress(byte[] input, int begin, int len) { byte[] output = new byte[input.Length]; @@ -84,6 +90,14 @@ namespace Sunny.UI } } + /// + /// 压缩 + /// + /// 压缩级别 + /// 输入 + /// 起始位置 + /// 长度 + /// 压缩结果 public static byte[] Compress(int level, byte[] input, int begin, int len) { byte[] output = new byte[input.Length]; @@ -97,6 +111,14 @@ namespace Sunny.UI } } + /// + /// 解压缩 + /// + /// 输入 + /// 起始位置 + /// 长度 + /// 解压结果最大长度 + /// 解压缩结果 public static byte[] Decompress(byte[] input, int begin, int length, int maxout) { byte[] output = new byte[maxout]; diff --git a/SunnyUI/Common/UFile.cs b/SunnyUI/Common/UFile.cs index 4b4c91bb..55d970d7 100644 --- a/SunnyUI/Common/UFile.cs +++ b/SunnyUI/Common/UFile.cs @@ -770,6 +770,11 @@ namespace Sunny.UI return crc.ToString("X").PadLeft(8, '0'); } + /// + /// 文件名是否有效 + /// + /// 文件名 + /// 是否有效 public static bool IsValidFileName(string name) { if (name.IsNullOrEmpty()) diff --git a/SunnyUI/Common/UFolderBrowserDialogEx.cs b/SunnyUI/Common/UFolderBrowserDialogEx.cs index a50cd2a1..f0bee641 100644 --- a/SunnyUI/Common/UFolderBrowserDialogEx.cs +++ b/SunnyUI/Common/UFolderBrowserDialogEx.cs @@ -13,10 +13,23 @@ namespace Sunny.UI /// public class FolderNameEditorEx : UITypeEditor { + /// + /// GetEditStyle + /// + /// + /// public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { return UITypeEditorEditStyle.Modal; } + + /// + /// EditValue + /// + /// + /// + /// + /// public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { FolderBrowserDialogEx browser = new FolderBrowserDialogEx(); diff --git a/SunnyUI/Common/UGDI.cs b/SunnyUI/Common/UGDI.cs index c398fdd5..be659653 100644 --- a/SunnyUI/Common/UGDI.cs +++ b/SunnyUI/Common/UGDI.cs @@ -27,6 +27,9 @@ using System.Drawing.Drawing2D; namespace Sunny.UI { + /// + /// GDI扩展类 + /// public static class GDI { /// @@ -57,6 +60,11 @@ namespace Sunny.UI } } + /// + /// 颜色是否是浅色 + /// + /// 颜色 + /// 是否是浅色 public static bool IsLightColor(this Color color) { return (0.299 * color.R + 0.587 * color.G + 0.114 * color.B) / 255 > 0.5; @@ -65,29 +73,53 @@ namespace Sunny.UI /// /// 根据背景色判断前景色 /// - /// - /// + /// 背景色 + /// 前景色 public static Color ForeColor(Color backColor) { - double gray = (0.299 * backColor.R + 0.587 * backColor.G + 0.114 * backColor.B) / 255; - return gray > 0.5 ? Color.Black : Color.White; + return backColor.IsLightColor() ? Color.Black : Color.White; } + /// + /// SizeF转Size + /// + /// SizeF + /// Size public static Size Size(this SizeF size) { return new Size(size.Width.RoundEx(), size.Height.RoundEx()); } + /// + /// PointF转Point + /// + /// PointF + /// Point public static Point Point(this PointF point) { return new Point(point.X.RoundEx(), point.Y.RoundEx()); } + /// + /// Size增加长宽 + /// + /// Size + /// 宽 + /// 长 + /// 结果 public static Size Add(this Size size, int width, int height) { return new Size(size.Width + width, size.Height + height); } + + /// + /// SizeF增加长宽 + /// + /// SizeF + /// 宽 + /// 长 + /// 结果 public static SizeF Add(this SizeF size, float width, float height) { return new SizeF(size.Width + width, size.Height + height); @@ -177,6 +209,13 @@ namespace Sunny.UI return Graphics().MeasureString(text, font); } + /// + /// 获取起始颜色到终止颜色之间的渐变颜色 + /// + /// 起始颜色 + /// 终止颜色 + /// 个数 + /// 渐变颜色列表 public static Color[] GradientColors(this Color startColor, Color endColor, int count) { count = Math.Max(count, 2); @@ -208,6 +247,12 @@ namespace Sunny.UI return colors; } + /// + /// 开启高质量绘图 + /// + /// 绘图图面 + /// 是否平滑 + /// 绘图图面 public static Graphics Smooth(this Graphics g, bool smooth = true) { if (smooth) @@ -222,17 +267,43 @@ namespace Sunny.UI return g; } - + /// + /// 创建圆角路径 + /// + /// 绘图图面 + /// 区域 + /// 圆角大小 + /// 圆角的方位 + /// 路径 public static GraphicsPath CreateRoundedRectanglePath(this Graphics g, Rectangle rect, int radius, UICornerRadiusSides radiusSides) { return rect.CreateRoundedRectanglePath(radius, radiusSides); } + /// + /// 创建圆角路径 + /// + /// 绘图图面 + /// 区域 + /// 圆角大小 + /// 左上角 + /// 右上角 + /// 右下角 + /// 左下角 + /// 路径 public static GraphicsPath CreateRoundedRectanglePath(this Graphics g, Rectangle rect, int radius, bool cornerLeftTop = true, bool cornerRightTop = true, bool cornerRightBottom = true, bool cornerLeftBottom = true) { return rect.CreateRoundedRectanglePath(radius, cornerLeftTop, cornerRightTop, cornerRightBottom, cornerLeftBottom); } + /// + /// 创建圆角路径 + /// + /// 区域 + /// 圆角大小 + /// 圆角的方位 + /// 线宽 + /// public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius, UICornerRadiusSides radiusSides, int lineSize = 1) { GraphicsPath path; @@ -257,6 +328,11 @@ namespace Sunny.UI return path; } + /// + /// 绘图路径 + /// + /// 区域 + /// 路径 public static GraphicsPath GraphicsPath(this Rectangle rect) { Point[] points = new Point[] { @@ -268,21 +344,59 @@ namespace Sunny.UI return points.Path(); } + /// + /// 创建扇形绘图路径 + /// + /// 绘图图面 + /// 圆心 + /// 内径 + /// 外径 + /// 起始角度 + /// 终止角度 + /// 扇形绘图路径 public static GraphicsPath CreateFanPath(this Graphics g, Point center, float d1, float d2, float startAngle, float sweepAngle) { return center.CreateFanPath(d1, d2, startAngle, sweepAngle); } + /// + /// 创建扇形绘图路径 + /// + /// 绘图图面 + /// 圆心 + /// 内径 + /// 外径 + /// 起始角度 + /// 终止角度 + /// 扇形绘图路径 public static GraphicsPath CreateFanPath(this Graphics g, PointF center, float d1, float d2, float startAngle, float sweepAngle) { return center.CreateFanPath(d1, d2, startAngle, sweepAngle); } + /// + /// 创建扇形绘图路径 + /// + /// 圆心 + /// 内径 + /// 外径 + /// 起始角度 + /// 终止角度 + /// 扇形绘图路径 public static GraphicsPath CreateFanPath(this Point center, float d1, float d2, float startAngle, float sweepAngle) { return new PointF(center.X, center.Y).CreateFanPath(d1, d2, startAngle, sweepAngle); } + /// + /// 创建扇形绘图路径 + /// + /// 圆心 + /// 内径 + /// 外径 + /// 起始角度 + /// 终止角度 + /// 扇形绘图路径 public static GraphicsPath CreateFanPath(this PointF center, float d1, float d2, float startAngle, float sweepAngle) { GraphicsPath path = new GraphicsPath(); @@ -292,6 +406,18 @@ namespace Sunny.UI return path; } + /// + /// 创建圆角路径 + /// + /// 绘图图面 + /// 区域 + /// 圆角大小 + /// 左上角 + /// 右上角 + /// 右下角 + /// 左下角 + /// 线宽 + /// 路径 public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius, bool cornerLeftTop = true, bool cornerRightTop = true, bool cornerRightBottom = true, bool cornerLeftBottom = true, int lineSize = 1) @@ -356,56 +482,116 @@ namespace Sunny.UI return g; } + /// + /// Color转HTML + /// + /// Color + /// HTML public static string ToHTML(this Color color) { return ColorTranslator.ToHtml(color); } + /// + /// HTML转Color + /// + /// HTML + /// 透明度 + /// Color public static Color ToColor(this string htmlColor, int alpha = 255) { return Color.FromArgb(alpha > 255 ? 255 : alpha, ColorTranslator.FromHtml(htmlColor)); } + /// + /// 颜色是否为空 + /// + /// 颜色 + /// 是否为空 public static bool IsNullOrEmpty(this Color color) { return color == Color.Empty || color == Color.Transparent; } + /// + /// 画刷 + /// + /// 颜色 + /// 画刷 public static SolidBrush Brush(this Color color) { return new SolidBrush(color); } + /// + /// 画笔 + /// + /// 颜色 + /// 线宽 + /// 画笔 public static Pen Pen(this Color color, float size = 1) { return new Pen(color, size); } + /// + /// HTML颜色生成画刷 + /// + /// HTML颜色 + /// 透明度 + /// 画刷 public static SolidBrush Brush(this string htmlColor, int alpha = 255) { return new SolidBrush(Color.FromArgb(alpha > 255 ? 255 : alpha, ColorTranslator.FromHtml(htmlColor))); } + /// + /// HTML颜色生成画笔 + /// + /// HTML颜色 + /// 透明度 + /// 线宽 + /// 起始线帽样式 + /// 结束线帽样式 + /// 画笔 public static Pen Pen(this string htmlColor, int alpha = 255, float size = 1, LineCap startCap = LineCap.Custom, LineCap endCap = LineCap.Custom) { return new Pen(Color.FromArgb(alpha > 255 ? 255 : alpha, ColorTranslator.FromHtml(htmlColor)), size) { StartCap = startCap, EndCap = endCap }; } - public static Font ToFont(this string fontName, float size, FontStyle fontStyle = FontStyle.Regular, GraphicsUnit unit = GraphicsUnit.Pixel) - { - return new Font(fontName, size, fontStyle, unit); - } - + /// + /// 渐变画刷 + /// + /// + /// + /// + /// + /// + /// public static Brush GlowBrush(Color centerColor, Color[] surroundColor, PointF point, GraphicsPath gp, WrapMode wrapMode = WrapMode.Clamp) { return new PathGradientBrush(gp) { CenterColor = centerColor, SurroundColors = surroundColor, FocusScales = point, WrapMode = wrapMode }; } + /// + /// 渐变画刷 + /// + /// + /// + /// + /// + /// public static Brush GlowBrush(Color centerColor, Color[] surroundColor, PointF[] point, WrapMode wrapMode = WrapMode.Clamp) { return new PathGradientBrush(point) { CenterColor = centerColor, SurroundColors = surroundColor, WrapMode = wrapMode }; } + /// + /// 文本布局 + /// + /// 水平方向 + /// 垂直方向 + /// 文本布局 public static StringFormat SetAlignment(StringAlignment horizontalAlignment = StringAlignment.Center, StringAlignment verticalAlignment = StringAlignment.Center) { return new StringFormat { Alignment = horizontalAlignment, LineAlignment = verticalAlignment }; diff --git a/SunnyUI/Common/UGif.cs b/SunnyUI/Common/UGif.cs index 42dd0a3a..1daf1417 100644 --- a/SunnyUI/Common/UGif.cs +++ b/SunnyUI/Common/UGif.cs @@ -41,8 +41,15 @@ using System.Windows.Forms; namespace Sunny.UI { + /// + /// GIF图片帮助类 + /// public class Gif : IDisposable { + /// + /// 构造函数 + /// + /// 文件名 public Gif(string fileName) { timer = new Timer(); @@ -54,6 +61,10 @@ namespace Sunny.UI } } + /// + /// 构造函数 + /// + /// 图片 public Gif(Image img) { timer = new Timer(); @@ -79,11 +90,18 @@ namespace Sunny.UI ShowImage = null; } + /// + /// 是否循环 + /// public bool Loop { get; set; } + /// + /// 跳帧 + /// + /// 帧号 public void JumpToFrame(int frameIndex) { if (ImageCount == 0) return; @@ -142,8 +160,16 @@ namespace Sunny.UI timer.Enabled = IsGif && active; } + /// + /// 图片切换事件 + /// + /// 对象 + /// 图片 public delegate void OnImageChanged(object sender, Image image); + /// + /// 图片切换事件 + /// public event OnImageChanged ImageChanged; private readonly Timer timer; @@ -151,8 +177,15 @@ namespace Sunny.UI private Image image; private int ImageCount => image == null ? 0 : image.GifFrameCount(); + + /// + /// 图片是否是GIF图片 + /// public bool IsGif => ImageCount > 0; + /// + /// 图片 + /// public Image Image { get => image; @@ -171,6 +204,9 @@ namespace Sunny.UI } } + /// + /// 刷新 + /// public void Invalidate() { if (!Active) @@ -181,6 +217,10 @@ namespace Sunny.UI private int FrameIndex; private bool active; + + /// + /// 图片动画 + /// public bool Active { get => active; @@ -193,13 +233,26 @@ namespace Sunny.UI } } + /// + /// GIF图片帮助类 + /// public static class GifHelper { + /// + /// 获取图像框架的维度 + /// + /// 图片 + /// 图像框架的维度 public static FrameDimension GifFrameDimension(this Image img) { return new FrameDimension(img.FrameDimensionsList[0]); } + /// + /// 获取图像的帧数 + /// + /// 图像 + /// 帧数 public static int GifFrameCount(this Image img) { if (img == null) return 0; @@ -207,6 +260,11 @@ namespace Sunny.UI return img.GetFrameCount(fd); } + /// + /// 获取图像的帧间隔 + /// + /// 图像 + /// 帧间隔 public static int GifFrameInterval(this Image img) { FrameDimension dim = new FrameDimension(img.FrameDimensionsList[0]); diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index 3e7e0fdd..4396d23a 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -21,7 +21,7 @@ D:\MyDocuments\SunnyUI.pfx False True - False + True