From c0386ee9f8c1302d8bb6f6742a55d2df5a13ea2d Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 30 Sep 2022 23:24:10 +0800 Subject: [PATCH] V3.2.5 --- SunnyUI/Common/UIniConfig.cs | 134 ------ SunnyUI/Common/UIniFile.cs | 850 ----------------------------------- SunnyUI/Common/UOther.cs | 88 ---- SunnyUI/Controls/UIGlobal.cs | 2 +- SunnyUI/Frames/UIPage.cs | 5 +- SunnyUI/SunnyUI.csproj | 8 +- SunnyUI/Win32/Win32.Added.cs | 17 + 7 files changed, 26 insertions(+), 1078 deletions(-) delete mode 100644 SunnyUI/Common/UIniConfig.cs delete mode 100644 SunnyUI/Common/UIniFile.cs delete mode 100644 SunnyUI/Common/UOther.cs diff --git a/SunnyUI/Common/UIniConfig.cs b/SunnyUI/Common/UIniConfig.cs deleted file mode 100644 index 6df51ce8..00000000 --- a/SunnyUI/Common/UIniConfig.cs +++ /dev/null @@ -1,134 +0,0 @@ -/****************************************************************************** - * SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。 - * CopyRight (C) 2012-2022 ShenYongHua(沈永华). - * QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com - * - * Blog: https://www.cnblogs.com/yhuse - * Gitee: https://gitee.com/yhuse/SunnyUI - * GitHub: https://github.com/yhuse/SunnyUI - * - * SunnyUI.dll can be used for free under the GPL-3.0 license. - * If you use this code, please keep this note. - * 如果您使用此代码,请保留此说明。 - ****************************************************************************** - * 文件名称: UIniConfig.cs - * 文件说明: INI 配置文件类 - * 当前版本: V3.1 - * 创建日期: 2020-01-01 - * - * 2020-01-01: V2.2.0 增加文件说明 -******************************************************************************/ - -using System; -using System.Collections.Concurrent; -using System.Collections.Specialized; -using System.IO; -using System.Text; - -namespace Sunny.UI -{ - /// - /// INI 配置文件类 - /// - /// 类型 - public class IniConfig : BaseConfig where TConfig : IniConfig, new() - { - #region 加载 - - /// 加载指定配置文件 - /// 文件名 - /// 结果 - public override bool Load(string filename) - { - if (filename.IsNullOrWhiteSpace()) - { - filename = DirEx.CurrentDir() + ConfigFile; - } - - if (filename.IsNullOrWhiteSpace()) - { - throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!"); - } - - if (!File.Exists(filename)) - { - return false; - } - - try - { - ConcurrentDictionary idents = ConfigHelper.InitIdents(current); - foreach (var ident in idents.Values) - { - if (ident.Section.IsNullOrEmpty()) - { - ident.Section = "Setup"; - } - } - - IniFile ini = new IniFile(filename, Encoding.Unicode); - foreach (var ident in idents.Values) - { - if (ident.IsList) - { - ident.Values.Clear(); - NameValueCollection list = ini.GetSectionValues(ident.Section + "-" + ident.Key); - foreach (var pair in list) - { - ident.Values.Add(ini.ReadString(ident.Section + "-" + ident.Key, pair.ToString(), "")); - } - } - else - { - ident.Value = ini.ReadString(ident.Section, ident.Key, ""); - } - } - - ConfigHelper.LoadConfigValue(current, idents); - return true; - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - return false; - } - } - - /// 保存到配置文件中去 - /// 文件名 - public override void Save(string filename) - { - if (filename.IsNullOrWhiteSpace()) - { - filename = DirEx.CurrentDir() + ConfigFile; - } - - if (filename.IsNullOrWhiteSpace()) - { - throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!"); - } - - ConcurrentDictionary idents = ConfigHelper.InitIdents(current); - foreach (var ident in idents.Values) - { - if (ident.Section.IsNullOrEmpty()) - { - ident.Section = "Setup"; - } - } - - ConfigHelper.SaveConfigValue(Current, idents); - IniFile ini = new IniFile(filename, Encoding.Unicode); - ini.BeginUpdate(); - - foreach (var ident in idents.Values) - { - ini.Write(ident.Section, ident.Key, ident.Value); - } - - ini.EndUpdate(); - } - - #endregion 加载 - } -} \ No newline at end of file diff --git a/SunnyUI/Common/UIniFile.cs b/SunnyUI/Common/UIniFile.cs deleted file mode 100644 index c96843d7..00000000 --- a/SunnyUI/Common/UIniFile.cs +++ /dev/null @@ -1,850 +0,0 @@ -/****************************************************************************** - * SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。 - * CopyRight (C) 2012-2022 ShenYongHua(沈永华). - * QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com - * - * Blog: https://www.cnblogs.com/yhuse - * Gitee: https://gitee.com/yhuse/SunnyUI - * GitHub: https://github.com/yhuse/SunnyUI - * - * SunnyUI.dll can be used for free under the GPL-3.0 license. - * If you use this code, please keep this note. - * 如果您使用此代码,请保留此说明。 - ****************************************************************************** - * 文件名称: UIniFile.cs - * 文件说明: INI 文件读取类 - * 当前版本: V3.1 - * 创建日期: 2020-01-01 - * - * 2020-01-01: V2.2.0 增加文件说明 - * 2022-09-13: V3.2.4 修改IniFile,改WinApi读取为直接C#代码读取 -******************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Text; - -namespace Sunny.UI -{ - /// - /// INI 文件读取基类 - /// - public abstract class IniBase : IDisposable - { - public IniBase(string fileName) : this(fileName, Encoding.Unicode) { } - - public IniBase(string fileName, Encoding encoding) - { - Load(fileName, encoding); - } - - public void Dispose() - { - Save(); - } - - private IDictionary> ini; - - public string FileName { get; private set; } - - private Encoding Encoding; - - public void Load(string fileName) - { - Load(fileName, Encoding.Unicode); - } - - public void Load(string fileName, Encoding encoding) - { - FileName = fileName; - Encoding = encoding; - - if (!File.Exists(fileName)) - { - ini = CreateDefault(); - return; - } - - using (var sr = new StreamReader(fileName, encoding)) - { - ini = Read(sr); - } - } - - public void Save() - { - File.WriteAllText(FileName, ToString(), Encoding); - } - - public void SaveAs(string fileName, Encoding encoding) - { - File.WriteAllText(fileName, ToString(), encoding); - } - - public void Write(string section, string key, string value) - { - if (!ini.ContainsKey(section)) - { - ini.Add(section, new Dictionary(StringComparer.OrdinalIgnoreCase)); - } - - if (ini[section].ContainsKey(key)) - { - ini[section][key] = value; - } - else - { - ini[section].Add(key, value); - } - - if (saveNow) - { - Save(); - } - } - - private bool saveNow = true; - public void BeginUpdate() - { - saveNow = false; - } - - public void EndUpdate() - { - saveNow = true; - Save(); - } - - public string ReadString(string section, string key, string Default = "") - { - return Read(section, key, Default); - } - - protected string Read(string section, string key, string Default = "") - { - if (ini.ContainsKey(section) && ini[section].ContainsKey(key)) - { - return ini[section][key].ToString(); - } - - return Default; - } - - public override string ToString() - { - var sb = new StringBuilder(); - foreach (var sentry in ini) - { - sb.AppendLine("[" + sentry.Key + "]"); - var d = sentry.Value; - foreach (var entry in d) - { - if (entry.Value is IList) - { - var l = ((IList)entry.Value); - sb.AppendLine(string.Format("{0}={1}", entry.Key, l[0])); - for (var i = 1; i < l.Count; ++i) - { - sb.AppendLine("\t" + l[i]); - } - - sb.AppendLine(); - } - else - { - sb.AppendLine(string.Format("{0}={1}", entry.Key, entry.Value)); - } - } - } - - return sb.ToString(); - } - - private IDictionary> CreateDefault() - { - return new Dictionary>(StringComparer.OrdinalIgnoreCase); - } - - private IDictionary> Read(TextReader reader) - { - var result = CreateDefault(); - - int lc = 1; - string section = ""; - string name = null; - string line; - while (null != (line = reader.ReadLine())) - { - var i = line.IndexOf(';'); - if (i > -1) - { - line = line.Substring(0, i); - } - - line = line.Trim(); - if (!string.IsNullOrEmpty(line)) - { - if (line.Length > 2 && line[0] == '[' && line[line.Length - 1] == ']') - { - section = line.Substring(1, line.Length - 2); - if (!result.ContainsKey(section)) - { - result.Add(section, new Dictionary(StringComparer.OrdinalIgnoreCase)); - } - } - else - { - var d = result[section]; - i = line.IndexOf('='); - if (i > -1) - { - name = line.Substring(0, i).TrimEnd(); - if (d.TryGetValue(name, out object o)) - { - AddIniEntryValue(d, line, name, i, o); - } - else - { - d.Add(name, line.Substring(i + 1).TrimStart()); - } - } - else if (null == name) - { - throw new IOException("Invalid INI file at line " + lc.ToString()); - } - else - { - var o = d[name]; - AddIniEntryValue(d, line, name, i, o); - } - } - } - - ++lc; - } - - return result; - } - - private void AddIniEntryValue(IDictionary d, string line, string name, int i, object o) - { - if (o is string) - { - var s = (string)o; - d.Remove(name); - var col = new List(); - d.Add(name, col); - col.Add(s); - col.Add(line.Substring(i + 1).TrimStart()); - } - else - { - ((List)o).Add(line.Substring(i + 1).TrimStart()); - } - } - - /// - /// 获取指定的Section名称中的所有Key - /// - /// section - /// 结果 - public string[] GetKeys(string section) - { - return ini.ContainsKey(section) && ini[section].Count > 0 ? (string[])ini[section].Keys : new string[0]; - } - - /// - /// 从Ini文件中,读取所有的Sections的名称 - /// - /// - public string[] Sections() - { - return ini != null ? (string[])ini.Keys : new string[0]; - } - - /// - /// 读取指定的Section的所有Value到列表中 - /// - /// section - public NameValueCollection GetSectionValues(string section) - { - NameValueCollection values = new NameValueCollection(); - string[] keys = GetKeys(section); - foreach (string key in keys) - { - values.Add(key, ini[section][key].ToString()); - } - - return values; - } - - /// - /// 清除某个Section - /// - /// section - public void EraseSection(string section) - { - if (ini.ContainsKey(section)) - { - ini.Remove(section); - Save(); - } - } - - /// - /// 删除某个Section下的键 - /// - /// section - /// key - public void DeleteKey(string section, string key) - { - if (KeyExists(section, key)) - { - ini[section].Remove(key); - if (ini[section].Count == 0) - { - ini.Remove(section); - } - - Save(); - } - } - - /// - /// 检查某个Section下的某个键值是否存在 - /// - /// section - /// key - /// 结果 - public bool KeyExists(string section, string key) - { - return ini.ContainsKey(section) && ini[section].ContainsKey(key); - } - } - - /// - /// IniFile的类 - /// - public class IniFile : IniBase - { - public IniFile(string fileName) : base(fileName, Encoding.Unicode) { } - - public IniFile(string fileName, Encoding encoding) : base(fileName, encoding) { } - - /// - /// 写结构 - /// - /// section - /// key - /// value - /// T - public void WriteStruct(string section, string key, T value) where T : struct - { - Write(section, key, value.StructToBytes()); - } - - /// - /// 读结构 - /// - /// T - /// section - /// key - /// Normal - /// 结果 - public T ReadStruct(string section, string key, T Default) where T : struct - { - //得到结构体的大小 - int size = Default.Size(); - byte[] bytes = Read(section, key, "").ToHexBytes(); - return size > bytes.Length ? Default : bytes.ToStruct(); - } - - /// - /// 写Byte数组 - /// - /// section - /// key - /// value - public void Write(string section, string key, byte[] value) - { - Write(section, key, value.ToHexString()); - } - - /// - /// 读Byte数组 - /// - /// section - /// key - /// Normal - /// 结果 - public byte[] ReadBytes(string section, string key, byte[] Default) - { - return Read(section, key, Default.ToHexString()).ToHexBytes(); - } - - /// - /// 写Char - /// - /// section - /// key - /// value - public void Write(string section, string key, char value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读Char - /// - /// section - /// key - /// Normal - /// 结果 - public char ReadChar(string section, string key, char Default = ' ') - { - return Read(section, key, Default.ToString()).ToChar(Default); - } - - /// - /// 写Decimal - /// - /// section - /// key - /// value - public void Write(string section, string key, decimal value) - { - Write(section, key, value.ToString(CultureInfo.InvariantCulture)); - } - - /// - /// 读Decimal - /// - /// section - /// key - /// Normal - /// 结果 - public decimal ReadDecimal(string section, string key, decimal Default = 0) - { - return Read(section, key, Default.ToString(CultureInfo.InvariantCulture)).ToDecimal(Default); - } - - /// - /// 写整数 - /// - /// section - /// key - /// value - public void Write(string section, string key, short value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读整数 - /// - /// section - /// key - /// Normal - /// 结果 - public short ReadShort(string section, string key, short Default = 0) - { - return Read(section, key, Default.ToString()).ToShort(Default); - } - - /// - /// 写整数 - /// - /// section - /// key - /// value - public void Write(string section, string key, ushort value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读整数 - /// - /// section - /// key - /// Normal - /// 结果 - public ushort ReadUShort(string section, string key, ushort Default = 0) - { - return Read(section, key, Default.ToString()).ToUShort(Default); - } - - /// - /// 写整数 - /// - /// section - /// key - /// value - public void Write(string section, string key, int value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读整数 - /// - /// section - /// key - /// Normal - /// 结果 - public int ReadInt(string section, string key, int Default = 0) - { - return Read(section, key, Default.ToString()).ToInt(Default); - } - - /// - /// 写整数 - /// - /// section - /// key - /// value - public void Write(string section, string key, uint value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读整数 - /// - /// section - /// key - /// Normal - /// 结果 - public uint ReadUInt(string section, string key, uint Default = 0) - { - return Read(section, key, Default.ToString()).ToUInt(Default); - } - - /// - /// 写整数 - /// - /// section - /// key - /// value - public void Write(string section, string key, ulong value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读整数 - /// - /// section - /// key - /// Normal - /// 结果 - public ulong ReadULong(string section, string key, ulong Default = 0) - { - return Read(section, key, Default.ToString()).ToULong(Default); - } - - /// - /// 写整数 - /// - /// section - /// key - /// value - public void Write(string section, string key, long value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读整数 - /// - /// section - /// key - /// Normal - /// 结果 - public long ReadLong(string section, string key, long Default = 0) - { - return Read(section, key, Default.ToString()).ToLong(Default); - } - - /// - /// 写布尔 - /// - /// section - /// key - /// value - public void Write(string section, string key, bool value) - { - Write(section, key, value ? bool.TrueString : bool.FalseString); - } - - /// - /// 读布尔 - /// - /// section - /// key - /// Normal - /// 结果 - public bool ReadBool(string section, string key, bool Default = false) - { - string str = Read(section, key, Default.ToString()); - if (string.Equals(str, bool.TrueString, StringComparison.CurrentCultureIgnoreCase)) - { - return true; - } - - if (string.Equals(str, bool.FalseString, StringComparison.CurrentCultureIgnoreCase)) - { - return false; - } - - return Default; - } - - /// - /// 写Double - /// - /// section - /// key - /// value - public void Write(string section, string key, double value) - { - Write(section, key, value.ToString(CultureInfo.InvariantCulture)); - } - - /// - /// 读Double - /// - /// section - /// key - /// Normal - /// 结果 - public double ReadDouble(string section, string key, double Default = 0) - { - return Read(section, key, Default.ToString(CultureInfo.InvariantCulture)).ToDouble(Default); - } - - /// - /// 写Float - /// - /// section - /// key - /// value - public void Write(string section, string key, float value) - { - Write(section, key, value.ToString(CultureInfo.InvariantCulture)); - } - - /// - /// 读Float - /// - /// section - /// key - /// Normal - /// 结果 - public float ReadFloat(string section, string key, float Default = 0) - { - return Read(section, key, Default.ToString(CultureInfo.InvariantCulture)).ToFloat(Default); - } - - /// - /// 写Byte - /// - /// section - /// key - /// value - public void Write(string section, string key, byte value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读Byte - /// - /// section - /// key - /// Normal - /// 结果 - public byte ReadByte(string section, string key, byte Default = 0) - { - return Read(section, key, Default.ToString()).ToByte(Default); - } - - /// - /// 写SByte - /// - /// section - /// key - /// value - public void Write(string section, string key, sbyte value) - { - Write(section, key, value.ToString()); - } - - /// - /// 读Byte - /// - /// section - /// key - /// Normal - /// 结果 - public sbyte ReadSByte(string section, string key, sbyte Default = 0) - { - return Read(section, key, Default.ToString()).ToSByte(Default); - } - - /// - /// 写DateTime - /// - /// section - /// key - /// value - public void Write(string section, string key, DateTime value) - { - Write(section, key, value.ToString(DateTimeEx.DateTimeFormat)); - } - - /// - /// 读DateTime - /// - /// section - /// key - /// Normal - /// 结果 - public DateTime ReadDateTime(string section, string key, DateTime Default) - { - string str = Read(section, key, Default.ToString(CultureInfo.InvariantCulture)); - try - { - return str.ToDateTime(DateTimeEx.DateTimeFormat); - } - catch (Exception) - { - return Default; - } - } - - /// - /// 写Point - /// - /// section - /// key - /// value - public void Write(string section, string key, Point value) - { - Write(section, key, ConvertEx.ObjectToString(value, typeof(Point))); - } - - /// - /// 读Point - /// - /// section - /// key - /// Normal - /// 结果 - public Point ReadPoint(string section, string key, Point Default) - { - string str = Read(section, key, ""); - return (Point)ConvertEx.StringToObject(str, typeof(Point), Default); - } - - /// - /// 写PointF - /// - /// section - /// key - /// value - public void Write(string section, string key, PointF value) - { - Write(section, key, ConvertEx.ObjectToString(value, typeof(PointF))); - } - - /// - /// 读PointF - /// - /// section - /// key - /// Normal - /// 结果 - public PointF ReadPointF(string section, string key, PointF Default) - { - string str = Read(section, key, ""); - return (PointF)ConvertEx.StringToObject(str, typeof(PointF), Default); - } - - /// - /// 写Size - /// - /// section - /// key - /// value - public void Write(string section, string key, Size value) - { - Write(section, key, ConvertEx.ObjectToString(value, typeof(Size))); - } - - /// - /// 读Size - /// - /// section - /// key - /// Normal - /// 结果 - public Size ReadSize(string section, string key, Size Default) - { - string str = Read(section, key, ""); - return (Size)ConvertEx.StringToObject(str, typeof(Size), Default); - } - - /// - /// 写SizeF - /// - /// section - /// key - /// value - public void Write(string section, string key, SizeF value) - { - Write(section, key, ConvertEx.ObjectToString(value, typeof(SizeF))); - } - - /// - /// 读SizeF - /// - /// section - /// key - /// Normal - /// 结果 - public SizeF ReadSizeF(string section, string key, SizeF Default) - { - string str = Read(section, key, ""); - return (SizeF)ConvertEx.StringToObject(str, typeof(SizeF), Default); - } - - /// - /// 写Color - /// - /// section - /// key - /// value - public void Write(string section, string key, Color value) - { - Write(section, key, ConvertEx.ObjectToString(value, typeof(Color))); - } - - /// - /// 读Color - /// - /// section - /// key - /// Normal - /// 结果 - public Color ReadColor(string section, string key, Color Default) - { - string str = Read(section, key, ""); - return (Color)ConvertEx.StringToObject(str, typeof(Color), Default); - } - } -} \ No newline at end of file diff --git a/SunnyUI/Common/UOther.cs b/SunnyUI/Common/UOther.cs deleted file mode 100644 index 0493e495..00000000 --- a/SunnyUI/Common/UOther.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Sunny.UI.Win32; -using System.Collections.Generic; -using System.Linq; - -namespace Sunny.UI -{ - /// - /// 其他 - /// - public static class UIOther - { - /// - /// 值不为数字 - /// - /// 值 - /// 不为数字 - public static bool IsNan(this double d) - { - return double.IsNaN(d); - } - - /// - /// 值不为数字 - /// - /// 值 - /// 不为数字 - public static bool IsNan(this float d) - { - return float.IsNaN(d); - } - - /// - /// 值负无穷或者正无穷 - /// - /// 值 - /// 负无穷或者正无穷 - public static bool IsInfinity(this double d) - { - return double.IsInfinity(d); - } - - /// - /// 值负无穷或者正无穷 - /// - /// 值 - /// 负无穷或者正无穷 - public static bool IsInfinity(this float d) - { - return float.IsInfinity(d); - } - - /// - /// 值不为数字或者负无穷或者正无穷 - /// - /// 值 - /// 不为数字或者负无穷或者正无穷 - public static bool IsNanOrInfinity(this double d) - { - return d.IsNan() || d.IsInfinity(); - } - - /// - /// 值不为数字或者负无穷或者正无穷 - /// - /// 值 - /// 不为数字或者负无穷或者正无穷 - public static bool IsNanOrInfinity(this float d) - { - return d.IsNan() || d.IsInfinity(); - } - - /// - /// 自然排序 - /// - /// 字符串列表 - /// 自然排序结果 - /// var names = new [] { "2.log", "10.log", "1.log" }; - /// 排序结果: - /// 1.log - /// 2.log - /// 10.log - public static IOrderedEnumerable NatualOrdering(this IEnumerable strs) - { - if (strs == null) return null; - return strs.OrderBy(s => s, new NatualOrderingComparer()); - } - } -} diff --git a/SunnyUI/Controls/UIGlobal.cs b/SunnyUI/Controls/UIGlobal.cs index e1b68f07..5ddcea98 100644 --- a/SunnyUI/Controls/UIGlobal.cs +++ b/SunnyUI/Controls/UIGlobal.cs @@ -31,7 +31,7 @@ namespace Sunny.UI /// /// 版本 /// - public const string Version = "SunnyUI.Net V3.2.4"; + public const string Version = "SunnyUI.Net V3.2.5"; public const int EditorMinHeight = 20; public const int EditorMaxHeight = 60; diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs index a0572152..fe6d3ef4 100644 --- a/SunnyUI/Frames/UIPage.cs +++ b/SunnyUI/Frames/UIPage.cs @@ -371,13 +371,16 @@ namespace Sunny.UI { get { +#if NETFRAMEWORK var ReturnFlag = false; if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) ReturnFlag = true; else if (Process.GetCurrentProcess().ProcessName == "devenv") ReturnFlag = true; - return ReturnFlag; +#else + return IsAncestorSiteInDesignMode; +#endif } } diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index fbed6dd9..483217cf 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -1,7 +1,7 @@  - net472;net40 + net6.0-windows;net472;net40 8.0 {AB1CB247-E20B-4CBE-B269-570ADDD96C53} true @@ -9,7 +9,7 @@ SunnyUI.Net 是基于.Net Framework 4.0~4.8、.Net 6 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。 CopyRight © SunnyUI.Net 2012-2022 GPL-3.0-only - 3.2.4 + 3.2.5 ShenYonghua SunnyUI.Net SunnyUI @@ -17,7 +17,7 @@ https://gitee.com/yhuse/SunnyUI False SunnyUI.png - False + True D:\MyDocuments\SunnyUI.pfx False False @@ -75,7 +75,7 @@ - + diff --git a/SunnyUI/Win32/Win32.Added.cs b/SunnyUI/Win32/Win32.Added.cs index 67063462..8ca383d4 100644 --- a/SunnyUI/Win32/Win32.Added.cs +++ b/SunnyUI/Win32/Win32.Added.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; +using System.Linq; using System.Runtime.InteropServices; namespace Sunny.UI.Win32 @@ -10,6 +11,22 @@ namespace Sunny.UI.Win32 #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 public static class Win32Helper { + /// + /// 自然排序 + /// + /// 字符串列表 + /// 自然排序结果 + /// var names = new [] { "2.log", "10.log", "1.log" }; + /// 排序结果: + /// 1.log + /// 2.log + /// 10.log + public static IOrderedEnumerable NatualOrdering(this IEnumerable strs) + { + if (strs == null) return null; + return strs.OrderBy(s => s, new NatualOrderingComparer()); + } + public static readonly IntPtr TRUE = new IntPtr(1); public static IntPtr IntPtr(this int value)