* 增加XML文档文件

This commit is contained in:
Sunny 2022-07-05 11:43:58 +08:00
parent 6509d0b251
commit cab4b45ad7
29 changed files with 403 additions and 50 deletions

View File

@ -31,9 +31,19 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 形状
/// </summary>
public enum UIShape public enum UIShape
{ {
/// <summary>
/// 圆形
/// </summary>
Circle, Circle,
/// <summary>
/// 方形
/// </summary>
Square Square
} }
@ -54,7 +64,7 @@ namespace Sunny.UI
/// All Files|*.* /// All Files|*.*
/// ------ /// ------
/// </summary> /// </summary>
/// <returns></returns> /// <returns>图片过滤字符串</returns>
public static string GetImageFilter() public static string GetImageFilter()
{ {
StringBuilder allImageExtensions = new StringBuilder(); StringBuilder allImageExtensions = new StringBuilder();
@ -84,6 +94,11 @@ namespace Sunny.UI
return sb.ToString(); return sb.ToString();
} }
/// <summary>
/// 根据文件名利用内存流生成图片,加载后文件不占用
/// </summary>
/// <param name="path">文件名</param>
/// <returns>图片</returns>
public static Image FromFile(string path) public static Image FromFile(string path)
{ {
if (File.Exists(path)) if (File.Exists(path))
@ -104,6 +119,12 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 设置图片不透明度
/// </summary>
/// <param name="img">图片</param>
/// <param name="opacity">不透明度</param>
/// <returns>图片</returns>
public static Bitmap ChangeOpacity(Image img, float opacity) public static Bitmap ChangeOpacity(Image img, float opacity)
{ {
Bitmap bmp = new Bitmap(img.Width, img.Height); // Determining Width and Height of Source Image Bitmap bmp = new Bitmap(img.Width, img.Height); // Determining Width and Height of Source Image
@ -117,7 +138,14 @@ namespace Sunny.UI
return bmp; return bmp;
} }
public static ImageList GetToolbarImageList(Type type, Image bitmap, Size imageSize, Color transparentColor) /// <summary>
/// 获取工具栏图片列表
/// </summary>
/// <param name="bitmap">图片</param>
/// <param name="imageSize">单图大小</param>
/// <param name="transparentColor">透明度</param>
/// <returns>图片列表</returns>
public static ImageList GetToolbarImageList(Image bitmap, Size imageSize, Color transparentColor)
{ {
ImageList imageList = new ImageList(); ImageList imageList = new ImageList();
imageList.ImageSize = imageSize; imageList.ImageSize = imageSize;
@ -127,6 +155,13 @@ namespace Sunny.UI
return imageList; return imageList;
} }
/// <summary>
/// 图片截取
/// </summary>
/// <param name="image">图片</param>
/// <param name="size">大小</param>
/// <param name="shape">形状</param>
/// <returns>图片</returns>
public static Bitmap Split(this Image image, int size, UIShape shape) public static Bitmap Split(this Image image, int size, UIShape shape)
{ {
//截图画板 //截图画板
@ -158,6 +193,12 @@ namespace Sunny.UI
return result; return result;
} }
/// <summary>
/// 图片截取
/// </summary>
/// <param name="image">图片</param>
/// <param name="path">路径</param>
/// <returns>图片</returns>
public static Bitmap Split(this Image image, GraphicsPath path) public static Bitmap Split(this Image image, GraphicsPath path)
{ {
//截图画板 //截图画板
@ -175,6 +216,11 @@ namespace Sunny.UI
return result; return result;
} }
/// <summary>
/// 图片的绘图图元
/// </summary>
/// <param name="image">图片</param>
/// <returns>绘图图元</returns>
public static Graphics Graphics(this Image image) public static Graphics Graphics(this Image image)
{ {
return System.Drawing.Graphics.FromImage(image); return System.Drawing.Graphics.FromImage(image);
@ -183,8 +229,8 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 图像水平翻转 /// 图像水平翻转
/// </summary> /// </summary>
/// <param name="image">原图像</param> /// <param name="image">原图像</param>
/// <returns></returns> /// <returns>图像</returns>
public static Bitmap HorizontalFlip(this Bitmap image) public static Bitmap HorizontalFlip(this Bitmap image)
{ {
try try
@ -206,8 +252,8 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 图像垂直翻转 /// 图像垂直翻转
/// </summary> /// </summary>
/// <param name="image">原图像</param> /// <param name="image">原图像</param>
/// <returns></returns> /// <returns>图像</returns>
public static Bitmap VerticalFlip(this Bitmap image) public static Bitmap VerticalFlip(this Bitmap image)
{ {
try try
@ -575,6 +621,12 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 从Base64数据绘图
/// </summary>
/// <param name="g">绘图图元</param>
/// <param name="base64Image">Base64</param>
/// <param name="rect">区域</param>
public static void DrawImageFromBase64(this Graphics g, string base64Image, Rectangle rect) public static void DrawImageFromBase64(this Graphics g, string base64Image, Rectangle rect)
{ {
using (var ms = new System.IO.MemoryStream(Convert.FromBase64String(base64Image))) using (var ms = new System.IO.MemoryStream(Convert.FromBase64String(base64Image)))
@ -585,6 +637,13 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 绘制透明图片
/// </summary>
/// <param name="g">绘图图元</param>
/// <param name="alpha">透明度</param>
/// <param name="image">图片</param>
/// <param name="rect">区域</param>
public static void DrawTransparentImage(this Graphics g, float alpha, Image image, Rectangle rect) public static void DrawTransparentImage(this Graphics g, float alpha, Image image, Rectangle rect)
{ {
var colorMatrix = new ColorMatrix { Matrix33 = alpha }; var colorMatrix = new ColorMatrix { Matrix33 = alpha };
@ -594,6 +653,14 @@ namespace Sunny.UI
imageAttributes.Dispose(); imageAttributes.Dispose();
} }
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="rect"></param>
/// <param name="bodyColor"></param>
/// <param name="strokeColor"></param>
/// <param name="strokeThickness"></param>
public static void DrawStrokedRectangle(this Graphics g, Rectangle rect, Color bodyColor, Color strokeColor, int strokeThickness = 1) public static void DrawStrokedRectangle(this Graphics g, Rectangle rect, Color bodyColor, Color strokeColor, int strokeThickness = 1)
{ {
using (var bodyBrush = new SolidBrush(bodyColor)) using (var bodyBrush = new SolidBrush(bodyColor))
@ -611,6 +678,14 @@ namespace Sunny.UI
} }
} }
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="rect"></param>
/// <param name="bodyColor"></param>
/// <param name="strokeColor"></param>
/// <param name="strokeThickness"></param>
public static void DrawStrokedEllipse(this Graphics g, Rectangle rect, Color bodyColor, Color strokeColor, int strokeThickness = 1) public static void DrawStrokedEllipse(this Graphics g, Rectangle rect, Color bodyColor, Color strokeColor, int strokeThickness = 1)
{ {
using (var bodyBrush = new SolidBrush(bodyColor)) using (var bodyBrush = new SolidBrush(bodyColor))
@ -628,6 +703,11 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 图片转Baase64字符串
/// </summary>
/// <param name="image">图片</param>
/// <returns>字符串</returns>
public static string ToBase64(this Image image) public static string ToBase64(this Image image)
{ {
using (var toBase64 = new MemoryStream()) using (var toBase64 = new MemoryStream())
@ -638,6 +718,11 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// Base64字符串转图片
/// </summary>
/// <param name="base64Image">字符串</param>
/// <returns>图片</returns>
public static Image ToImage(string base64Image) public static Image ToImage(string base64Image)
{ {
using (var toImage = new System.IO.MemoryStream(Convert.FromBase64String(base64Image))) using (var toImage = new System.IO.MemoryStream(Convert.FromBase64String(base64Image)))
@ -646,6 +731,12 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 图片存为图标
/// </summary>
/// <param name="img">图片</param>
/// <param name="size">大小</param>
/// <returns>图标</returns>
public static Icon SaveToIcon(this Image img, int size = 16) 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 }; 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 };

View File

@ -28,8 +28,17 @@ using System.Web.Script.Serialization;
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// Json扩展类
/// </summary>
public static class Json public static class Json
{ {
/// <summary>
/// 反序列化字符串为对象
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="input">字符串</param>
/// <returns>对象</returns>
public static T Deserialize<T>(string input) public static T Deserialize<T>(string input)
{ {
try try
@ -48,6 +57,11 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 序列号对象为字符串
/// </summary>
/// <param name="obj">对象</param>
/// <returns>字符串</returns>
public static string Serialize(object obj) public static string Serialize(object obj)
{ {
#if NETFRAMEWORK #if NETFRAMEWORK
@ -58,12 +72,26 @@ namespace Sunny.UI
#endif #endif
} }
/// <summary>
/// 从文件读取字符串反序列化为对象
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="filename">文件名</param>
/// <param name="encoding">文件编码</param>
/// <returns>对象</returns>
public static T DeserializeFromFile<T>(string filename, Encoding encoding) public static T DeserializeFromFile<T>(string filename, Encoding encoding)
{ {
string jsonStr = File.ReadAllText(filename, encoding); string jsonStr = File.ReadAllText(filename, encoding);
return Deserialize<T>(jsonStr); return Deserialize<T>(jsonStr);
} }
/// <summary>
/// 序列号对象为字符串并保存到文件
/// </summary>
/// <param name="obj">对象</param>
/// <param name="filename">文件名</param>
/// <param name="encoding">文件编码</param>
/// <returns>字符串</returns>
public static string SerializeToFile(object obj, string filename, Encoding encoding) public static string SerializeToFile(object obj, string filename, Encoding encoding)
{ {
string jsonStr = Serialize(obj); string jsonStr = Serialize(obj);

View File

@ -22,6 +22,9 @@
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 多语言字符串定义
/// </summary>
public static class UILocalize public static class UILocalize
{ {
/// <summary> /// <summary>
@ -94,37 +97,135 @@ namespace Sunny.UI
/// </summary> /// </summary>
public static string SystemProcessing = "系统正在处理中,请稍候..."; public static string SystemProcessing = "系统正在处理中,请稍候...";
/// <summary>
/// 星期一
/// </summary>
public static string Monday = "一"; public static string Monday = "一";
/// <summary>
/// 星期二
/// </summary>
public static string Tuesday = "二"; public static string Tuesday = "二";
/// <summary>
/// 星期三
/// </summary>
public static string Wednesday = "三"; public static string Wednesday = "三";
/// <summary>
/// 星期四
/// </summary>
public static string Thursday = "四"; public static string Thursday = "四";
/// <summary>
/// 星期五
/// </summary>
public static string Friday = "五"; public static string Friday = "五";
/// <summary>
/// 星期六
/// </summary>
public static string Saturday = "六"; public static string Saturday = "六";
/// <summary>
/// 星期日
/// </summary>
public static string Sunday = "日"; public static string Sunday = "日";
/// <summary>
/// 上一页
/// </summary>
public static string Prev = "上一页"; public static string Prev = "上一页";
/// <summary>
/// 下一页
/// </summary>
public static string Next = "下一页"; public static string Next = "下一页";
/// <summary>
/// 第
/// </summary>
public static string SelectPageLeft = "第"; public static string SelectPageLeft = "第";
/// <summary>
/// 页
/// </summary>
public static string SelectPageRight = "页"; public static string SelectPageRight = "页";
/// <summary>
/// 一月
/// </summary>
public static string January = "一月"; public static string January = "一月";
/// <summary>
/// 二月
/// </summary>
public static string February = "二月"; public static string February = "二月";
/// <summary>
/// 三月
/// </summary>
public static string March = "三月"; public static string March = "三月";
/// <summary>
/// 四月
/// </summary>
public static string April = "四月"; public static string April = "四月";
/// <summary>
/// 五月
/// </summary>
public static string May = "五月"; public static string May = "五月";
/// <summary>
/// 六月
/// </summary>
public static string June = "六月"; public static string June = "六月";
/// <summary>
/// 七月
/// </summary>
public static string July = "七月"; public static string July = "七月";
/// <summary>
/// 八月
/// </summary>
public static string August = "八月"; public static string August = "八月";
/// <summary>
/// 九月
/// </summary>
public static string September = "九月"; public static string September = "九月";
/// <summary>
/// 十月
/// </summary>
public static string October = "十月"; public static string October = "十月";
/// <summary>
/// 十一月
/// </summary>
public static string November = "十一月"; public static string November = "十一月";
/// <summary>
/// 十二月
/// </summary>
public static string December = "十二月"; public static string December = "十二月";
/// <summary>
/// 今天
/// </summary>
public static string Today = "今天"; public static string Today = "今天";
} }
/// <summary>
/// 多语言字符串帮助类
/// </summary>
public static class UILocalizeHelper public static class UILocalizeHelper
{ {
/// <summary>
/// 设置为英文
/// </summary>
public static void SetEN() public static void SetEN()
{ {
UILocalize.InfoTitle = "Info"; UILocalize.InfoTitle = "Info";
@ -173,6 +274,9 @@ namespace Sunny.UI
UIStyles.Translate(); UIStyles.Translate();
} }
/// <summary>
/// 设置为中文
/// </summary>
public static void SetCH() public static void SetCH()
{ {
UILocalize.InfoTitle = "提示"; UILocalize.InfoTitle = "提示";

View File

@ -67,11 +67,27 @@ using System.Threading;
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 多进程通信类
/// </summary>
public sealed class MMFile : BackgroundWorkerEx, IDisposable public sealed class MMFile : BackgroundWorkerEx, IDisposable
{ {
/// <summary>
/// 内存文件名
/// </summary>
public string MapName { get; } public string MapName { get; }
/// <summary>
/// 大小
/// </summary>
public int Capacity { get; } public int Capacity { get; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="mapName">内存文件名</param>
/// <param name="capacity">大小</param>
/// <exception cref="Exception">报错消息</exception>
public MMFile(string mapName, int capacity = 4096) public MMFile(string mapName, int capacity = 4096)
{ {
if (!FileEx.IsValidFileName(mapName)) if (!FileEx.IsValidFileName(mapName))
@ -91,8 +107,14 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 消息回调
/// </summary>
public event MMFileEventHandler OnMessage; public event MMFileEventHandler OnMessage;
/// <summary>
/// 线程运行
/// </summary>
protected override void DoWorker() protected override void DoWorker()
{ {
try try
@ -109,6 +131,11 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 给目标内存文件写字符串
/// </summary>
/// <param name="dest">目标内存文件名</param>
/// <param name="message">消息字符串</param>
public void Write(string dest, string message) public void Write(string dest, string message)
{ {
var mmf = MemoryMappedFile.CreateOrOpen(dest, Capacity, MemoryMappedFileAccess.ReadWrite); var mmf = MemoryMappedFile.CreateOrOpen(dest, Capacity, MemoryMappedFileAccess.ReadWrite);
@ -184,18 +211,42 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 析构函数
/// </summary>
~MMFile() ~MMFile()
{ {
Dispose(); Dispose();
} }
} }
/// <summary>
/// 回调事件定义
/// </summary>
/// <param name="sender">对象</param>
/// <param name="e">事件</param>
public delegate void MMFileEventHandler(object sender, MMFileEventArgs e); public delegate void MMFileEventHandler(object sender, MMFileEventArgs e);
/// <summary>
/// 内存文件事件
/// </summary>
public class MMFileEventArgs : EventArgs public class MMFileEventArgs : EventArgs
{ {
/// <summary>
/// 消息来源
/// </summary>
public string Source { get; set; } public string Source { get; set; }
/// <summary>
/// 消息字符串
/// </summary>
public string Value { get; set; } public string Value { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="source">消息来源</param>
/// <param name="value">消息字符串</param>
public MMFileEventArgs(string source, string value) public MMFileEventArgs(string source, string value)
{ {
Source = source; Source = source;

View File

@ -27,6 +27,9 @@ using System.Reflection;
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 轻量级的对象映射框架
/// </summary>
public static class Mapper public static class Mapper
{ {
private static void Execute<T1, T2>(T1 source, T2 dest) private static void Execute<T1, T2>(T1 source, T2 dest)
@ -157,6 +160,13 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// T1映射到T2
/// </summary>
/// <typeparam name="T1">T1</typeparam>
/// <typeparam name="T2">T2</typeparam>
/// <param name="source">源</param>
/// <param name="dest">目标</param>
public static void MapperTo<T1, T2>(this T1 source, T2 dest) public static void MapperTo<T1, T2>(this T1 source, T2 dest)
where T1 : class where T1 : class
where T2 : class where T2 : class
@ -164,6 +174,13 @@ namespace Sunny.UI
Execute(source, dest); Execute(source, dest);
} }
/// <summary>
/// T1从T2映射
/// </summary>
/// <typeparam name="T1">T1</typeparam>
/// <typeparam name="T2">T2</typeparam>
/// <param name="source">源</param>
/// <param name="dest">目标</param>
public static void MapperFrom<T1, T2>(this T1 dest, T2 source) public static void MapperFrom<T1, T2>(this T1 dest, T2 source)
where T1 : class where T1 : class
where T2 : class where T2 : class
@ -171,6 +188,11 @@ namespace Sunny.UI
Execute(source, dest); Execute(source, dest);
} }
/// <summary>
/// 获取数组的类类型
/// </summary>
/// <param name="t">类型</param>
/// <returns>类类型</returns>
public static Type GetArrayElementType(this Type t) public static Type GetArrayElementType(this Type t)
{ {
if (!t.IsArray) return null; if (!t.IsArray) return null;

View File

@ -33,6 +33,7 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
/// <summary> /// <summary>
/// 轻便消息窗 /// 轻便消息窗
/// </summary> /// </summary>
@ -1967,4 +1968,6 @@ namespace Sunny.UI
#endregion #endregion
} }
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -1,32 +1,65 @@
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 其他
/// </summary>
public static class UIOther public static class UIOther
{ {
/// <summary>
/// 值不为数字
/// </summary>
/// <param name="d">值</param>
/// <returns>不为数字</returns>
public static bool IsNan(this double d) public static bool IsNan(this double d)
{ {
return double.IsNaN(d); return double.IsNaN(d);
} }
/// <summary>
/// 值不为数字
/// </summary>
/// <param name="d">值</param>
/// <returns>不为数字</returns>
public static bool IsNan(this float d) public static bool IsNan(this float d)
{ {
return float.IsNaN(d); return float.IsNaN(d);
} }
/// <summary>
/// 值负无穷或者正无穷
/// </summary>
/// <param name="d">值</param>
/// <returns>负无穷或者正无穷</returns>
public static bool IsInfinity(this double d) public static bool IsInfinity(this double d)
{ {
return double.IsInfinity(d); return double.IsInfinity(d);
} }
/// <summary>
/// 值负无穷或者正无穷
/// </summary>
/// <param name="d">值</param>
/// <returns>负无穷或者正无穷</returns>
public static bool IsInfinity(this float d) public static bool IsInfinity(this float d)
{ {
return float.IsInfinity(d); return float.IsInfinity(d);
} }
/// <summary>
/// 值不为数字或者负无穷或者正无穷
/// </summary>
/// <param name="d">值</param>
/// <returns>不为数字或者负无穷或者正无穷</returns>
public static bool IsNanOrInfinity(this double d) public static bool IsNanOrInfinity(this double d)
{ {
return d.IsNan() || d.IsInfinity(); return d.IsNan() || d.IsInfinity();
} }
/// <summary>
/// 值不为数字或者负无穷或者正无穷
/// </summary>
/// <param name="d">值</param>
/// <returns>不为数字或者负无穷或者正无穷</returns>
public static bool IsNanOrInfinity(this float d) public static bool IsNanOrInfinity(this float d)
{ {
return d.IsNan() || d.IsInfinity(); return d.IsNan() || d.IsInfinity();

View File

@ -26,14 +26,19 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 滚动条信息获取类
/// </summary>
public static class ScrollBarInfo public static class ScrollBarInfo
{ {
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public const int SIF_RANGE = 1; public const int SIF_RANGE = 1;
public const int SIF_PAGE = 2; public const int SIF_PAGE = 2;
public const int SIF_POS = 4; public const int SIF_POS = 4;
public const int SIF_TRACKPOS = 16; public const int SIF_TRACKPOS = 16;
public const int SIF_DISABLENOSCROLL = 8; public const int SIF_DISABLENOSCROLL = 8;
public const int SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS; public const int SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
//私有方法 //私有方法
private static uint MakeLong(short lowPart, short highPart) private static uint MakeLong(short lowPart, short highPart)
@ -41,18 +46,26 @@ namespace Sunny.UI
return (ushort)lowPart | (uint)(highPart << 16); return (ushort)lowPart | (uint)(highPart << 16);
} }
/// <summary>
/// 垂直滚动条宽度
/// </summary>
/// <returns>宽度</returns>
public static int VerticalScrollBarWidth() public static int VerticalScrollBarWidth()
{ {
return SystemInformation.VerticalScrollBarWidth; return SystemInformation.VerticalScrollBarWidth;
} }
/// <summary>
/// 水平滚动条高度
/// </summary>
/// <returns>高度</returns>
public static int HorizontalScrollBarHeight() public static int HorizontalScrollBarHeight()
{ {
return SystemInformation.HorizontalScrollBarHeight; return SystemInformation.HorizontalScrollBarHeight;
} }
/// <summary> /// <summary>
/// 获取控件滚动条信息 /// 获取垂直控件滚动条信息
/// </summary> /// </summary>
/// <param name="handle">控件句柄</param> /// <param name="handle">控件句柄</param>
/// <returns>信息结构</returns> /// <returns>信息结构</returns>
@ -65,6 +78,11 @@ namespace Sunny.UI
return si; return si;
} }
/// <summary>
/// 获取水平控件滚动条信息
/// </summary>
/// <param name="handle">控件句柄</param>
/// <returns>信息结构</returns>
public static SCROLLINFO GetHorInfo(IntPtr handle) public static SCROLLINFO GetHorInfo(IntPtr handle)
{ {
SCROLLINFO si = new SCROLLINFO(); SCROLLINFO si = new SCROLLINFO();
@ -118,12 +136,22 @@ namespace Sunny.UI
User.SendMessage(handle, User.WM_VSCROLL, User.SB_LINEDOWN, 0); User.SendMessage(handle, User.WM_VSCROLL, User.SB_LINEDOWN, 0);
} }
/// <summary>
/// 垂直滚动条是否显示
/// </summary>
/// <param name="ctrl">控件</param>
/// <returns>垂直滚动条是否显示</returns>
public static bool IsVerticalScrollBarVisible(Control ctrl) public static bool IsVerticalScrollBarVisible(Control ctrl)
{ {
if (!ctrl.IsHandleCreated) return false; if (!ctrl.IsHandleCreated) return false;
return (Sunny.UI.Win32.User.GetWindowLong(ctrl.Handle, User.GWL_STYLE) & User.WS_VSCROLL) != 0; return (Sunny.UI.Win32.User.GetWindowLong(ctrl.Handle, User.GWL_STYLE) & User.WS_VSCROLL) != 0;
} }
/// <summary>
/// 水平滚动条是否显示
/// </summary>
/// <param name="ctrl">控件</param>
/// <returns>水平滚动条是否显示</returns>
public static bool IsHorizontalScrollBarVisible(Control ctrl) public static bool IsHorizontalScrollBarVisible(Control ctrl)
{ {
if (!ctrl.IsHandleCreated) return false; if (!ctrl.IsHandleCreated) return false;

View File

@ -34,6 +34,9 @@ namespace Sunny.UI
/// </summary> /// </summary>
public static class SuspendCtrlAltDelete public static class SuspendCtrlAltDelete
{ {
/// <summary>
/// 获取权限
/// </summary>
public static void GetSeDebugPrivilege() public static void GetSeDebugPrivilege()
{ {
IntPtr hToken; IntPtr hToken;
@ -78,6 +81,9 @@ namespace Sunny.UI
CloseHandle(hToken); CloseHandle(hToken);
} }
/// <summary>
/// 挂起
/// </summary>
public static void Suspend() public static void Suspend()
{ {
Process[] processes = Process.GetProcesses(); Process[] processes = Process.GetProcesses();
@ -93,6 +99,9 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 恢复
/// </summary>
public static void Resume() public static void Resume()
{ {
Process[] processes = Process.GetProcesses(); Process[] processes = Process.GetProcesses();

View File

@ -58,17 +58,23 @@ namespace Sunny.UI
User.SetProcessDPIAware(); User.SetProcessDPIAware();
} }
/// <summary>
/// 工具栏可用
/// </summary>
public static void EnabledTaskManager() public static void EnabledTaskManager()
{ {
RegistryDisableTaskMgr(0); RegistryDisableTaskMgr(0);
} }
/// <summary>
/// 工具栏不可用
/// </summary>
public static void DisabledTaskManager() public static void DisabledTaskManager()
{ {
RegistryDisableTaskMgr(1); RegistryDisableTaskMgr(1);
} }
public static void RegistryDisableTaskMgr(int value) private static void RegistryDisableTaskMgr(int value)
{ {
string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
RegistryKey mKey = Registry.CurrentUser.CreateSubKey(subKey); RegistryKey mKey = Registry.CurrentUser.CreateSubKey(subKey);
@ -76,6 +82,9 @@ namespace Sunny.UI
mKey?.Dispose(); mKey?.Dispose();
} }
/// <summary>
/// 设置键盘鼠标钩子超时
/// </summary>
public static void RegistryHooksTimeout() public static void RegistryHooksTimeout()
{ {
string subKey = @"Control Panel\Desktop"; string subKey = @"Control Panel\Desktop";
@ -106,6 +115,13 @@ namespace Sunny.UI
} }
} }
/// <summary>
/// 线程安全调用
/// </summary>
/// <typeparam name="T">类型</typeparam>
/// <param name="control">控件</param>
/// <param name="method">方法</param>
/// <returns>类型</returns>
public static T ThreadSafeCall<T>(this Control control, Func<T> method) public static T ThreadSafeCall<T>(this Control control, Func<T> method)
{ {
if (control.InvokeRequired) if (control.InvokeRequired)
@ -150,7 +166,7 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 是否64位 /// 是否64位
/// </summary> /// </summary>
/// <returns></returns> /// <returns>是否64位</returns>
public static bool Is64bitApp() public static bool Is64bitApp()
{ {
return IntPtr.Size == 8; return IntPtr.Size == 8;
@ -330,7 +346,7 @@ namespace Sunny.UI
HandleRunningInstance(instance, showStyle); HandleRunningInstance(instance, showStyle);
} }
public static Process RunningInstance() private static Process RunningInstance()
{ {
Process currentProcess = Process.GetCurrentProcess(); Process currentProcess = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName);

View File

@ -21,8 +21,14 @@
namespace Sunny.UI namespace Sunny.UI
{ {
/// <summary>
/// 多语翻译接口
/// </summary>
public interface ITranslate public interface ITranslate
{ {
/// <summary>
/// 多语翻译接口
/// </summary>
void Translate(); void Translate();
} }
} }

View File

@ -4,8 +4,6 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
internal class ColorSlider : LabelRotate internal class ColorSlider : LabelRotate
{ {
public event EventHandler SelectedValueChanged; public event EventHandler SelectedValueChanged;
@ -315,7 +313,4 @@ namespace Sunny.UI
SelectedHSLColor = m_selectedColor; SelectedHSLColor = m_selectedColor;
} }
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -7,7 +7,6 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
[ToolboxItem(false)] [ToolboxItem(false)]
public sealed class UIColorTable : LabelRotate public sealed class UIColorTable : LabelRotate
@ -394,6 +393,5 @@ namespace Sunny.UI
} }
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -7,7 +7,6 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
[ToolboxItem(false)] [ToolboxItem(false)]
public sealed class UIColorWheel : Control, IStyleInterface, IZoomScale public sealed class UIColorWheel : Control, IStyleInterface, IZoomScale
@ -366,6 +365,5 @@ namespace Sunny.UI
public string TagString { get; set; } public string TagString { get; set; }
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -5,7 +5,6 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct HSLColor public struct HSLColor
{ {
@ -316,9 +315,8 @@ namespace Sunny.UI
public static ImageList ImageList() public static ImageList ImageList()
{ {
Type t = typeof(SelectorImages);
if (m_imageList == null) if (m_imageList == null)
m_imageList = ImageEx.GetToolbarImageList(t, Properties.Resources.colorbarIndicators, new Size(12, 12), Color.Magenta); m_imageList = ImageEx.GetToolbarImageList(Properties.Resources.colorbarIndicators, new Size(12, 12), Color.Magenta);
return m_imageList; return m_imageList;
} }
@ -328,6 +326,5 @@ namespace Sunny.UI
} }
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -4,7 +4,6 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
[ToolboxItem(false)] [ToolboxItem(false)]
public class LabelRotate : Control, IStyleInterface, IZoomScale public class LabelRotate : Control, IStyleInterface, IZoomScale
@ -278,6 +277,5 @@ namespace Sunny.UI
public string TagString { get; set; } public string TagString { get; set; }
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -62,7 +62,6 @@ to represent the company, product, or service to which they refer.
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
/// <summary> /// <summary>
/// FontAwesome.ttf V4.7 /// FontAwesome.ttf V4.7
@ -1251,6 +1250,5 @@ namespace Sunny.UI
public const int icon_clipboard = 0xe0e6; public const int icon_clipboard = 0xe0e6;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -62,7 +62,6 @@ to represent the company, product, or service to which they refer.
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
/// <summary> /// <summary>
/// fa-regular-400.ttf /// fa-regular-400.ttf
@ -1702,6 +1701,5 @@ namespace Sunny.UI
public const int fa_yin_yang = 0xf6ad; public const int fa_yin_yang = 0xf6ad;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -25,7 +25,6 @@ using System.Drawing;
namespace Sunny.UI namespace Sunny.UI
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public class UIBaseStyle public class UIBaseStyle
{ {
@ -718,6 +717,5 @@ namespace Sunny.UI
} }
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -21,7 +21,7 @@
<AssemblyOriginatorKeyFile>D:\MyDocuments\SunnyUI.pfx</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>D:\MyDocuments\SunnyUI.pfx</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign> <DelaySign>False</DelaySign>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile> <GenerateDocumentationFile>False</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -5,7 +5,6 @@ using System.Runtime.InteropServices;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public static class Win32Helper public static class Win32Helper
{ {
@ -188,6 +187,5 @@ namespace Sunny.UI.Win32
public delegate void TimerSetEventCallback(int uTimerID, uint uMsg, uint dwUser, UIntPtr dw1, UIntPtr dw2); public delegate void TimerSetEventCallback(int uTimerID, uint uMsg, uint dwUser, UIntPtr dw1, UIntPtr dw2);
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -1,6 +1,5 @@
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public abstract class ERROR public abstract class ERROR
{ {
@ -928,6 +927,5 @@ namespace Sunny.UI.Win32
public const int VIEW_S_LAST = 0x4014F; public const int VIEW_S_LAST = 0x4014F;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -6,7 +6,6 @@ using HWND = System.IntPtr;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct XFORM public struct XFORM
{ {
@ -1999,6 +1998,5 @@ namespace Sunny.UI.Win32
public const int WINDING = 2; public const int WINDING = 2;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -7,7 +7,6 @@ using HWND = System.IntPtr;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct OVERLAPPED public struct OVERLAPPED
{ {
@ -2397,6 +2396,5 @@ namespace Sunny.UI.Win32
public const string SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"; public const string SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege";
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -7,7 +7,6 @@ using HWND = System.IntPtr;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct SMPTE public struct SMPTE
{ {
@ -1488,6 +1487,5 @@ namespace Sunny.UI.Win32
public const string CFSEPCHAR = "+"; public const string CFSEPCHAR = "+";
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -7,7 +7,6 @@ using HWND = System.IntPtr;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct NETRESOURCE public struct NETRESOURCE
{ {
@ -212,6 +211,5 @@ namespace Sunny.UI.Win32
public const int WN_WINDOWS_ERROR = ERROR.ERROR_UNEXP_NET_ERR; public const int WN_WINDOWS_ERROR = ERROR.ERROR_UNEXP_NET_ERR;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -4,7 +4,6 @@ using HWND = System.IntPtr;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct DRAGINFO public struct DRAGINFO
{ {
@ -189,6 +188,5 @@ namespace Sunny.UI.Win32
public const int SHGNLI_PREFIXNAME = 0x2; public const int SHGNLI_PREFIXNAME = 0x2;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -7,7 +7,6 @@ using HWND = System.IntPtr;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct CBTACTIVATESTRUCT public struct CBTACTIVATESTRUCT
{ {
@ -2539,6 +2538,5 @@ namespace Sunny.UI.Win32
public const string SZDDE_ITEM_ITEMLIST = "TopicItemList"; public const string SZDDE_ITEM_ITEMLIST = "TopicItemList";
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }

View File

@ -2,7 +2,6 @@ using System.Runtime.InteropServices;
namespace Sunny.UI.Win32 namespace Sunny.UI.Win32
{ {
#pragma warning disable CS0618 // 类型或成员已过时
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public struct RECT public struct RECT
{ {
@ -147,6 +146,5 @@ namespace Sunny.UI.Win32
public short wMilliseconds; public short wMilliseconds;
} }
#pragma warning restore CS0618 // 类型或成员已过时
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
} }