This commit is contained in:
Sunny 2023-10-16 17:26:23 +08:00
parent 9949f795f1
commit 96b64900d8
10 changed files with 22 additions and 478 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -45,15 +45,15 @@ namespace Sunny.UI.Demo
private void btnStatus2_Click(object sender, EventArgs e)
{
ShowStatusForm(100, "数据加载中......", 0);
this.ShowStatusForm(100, "数据加载中......", 0);
for (int i = 0; i < 88; i++)
{
SystemEx.Delay(50);
SetStatusFormDescription("数据加载中(" + i + "%)......");
StatusFormStepIt();
this.SetStatusFormDescription("数据加载中(" + i + "%)......");
this.SetStatusFormStepIt();
}
HideStatusForm();
this.HideStatusForm();
}
private void btnInfo_Click(object sender, EventArgs e)
@ -197,18 +197,18 @@ namespace Sunny.UI.Demo
private void uiSymbolButton11_Click(object sender, EventArgs e)
{
ShowWaitForm("准备开始...");
this.ShowWaitForm("准备开始...");
Thread.Sleep(1000);
SetWaitFormDescription(UILocalize.SystemProcessing + "20%");
this.SetWaitFormDescription(UILocalize.SystemProcessing + "20%");
Thread.Sleep(1000);
SetWaitFormDescription(UILocalize.SystemProcessing + "40%");
this.SetWaitFormDescription(UILocalize.SystemProcessing + "40%");
Thread.Sleep(1000);
SetWaitFormDescription(UILocalize.SystemProcessing + "60%");
this.SetWaitFormDescription(UILocalize.SystemProcessing + "60%");
Thread.Sleep(1000);
SetWaitFormDescription(UILocalize.SystemProcessing + "80%");
this.SetWaitFormDescription(UILocalize.SystemProcessing + "80%");
Thread.Sleep(1000);
SetWaitFormDescription(UILocalize.SystemProcessing + "100%");
HideWaitForm();
this.SetWaitFormDescription(UILocalize.SystemProcessing + "100%");
this.HideWaitForm();
}
private void uiSymbolButton13_Click(object sender, EventArgs e)
@ -222,9 +222,9 @@ namespace Sunny.UI.Demo
private void uiSymbolButton12_Click(object sender, EventArgs e)
{
ShowProcessForm(200);
this.ShowProcessForm(200);
Thread.Sleep(2000);
HideProcessForm();
this.HideProcessForm();
}
}
}

View File

@ -41,11 +41,11 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="SunnyUI, Version=3.5.0.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.3.5.0\lib\net472\SunnyUI.dll</HintPath>
<Reference Include="SunnyUI, Version=3.5.1.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.3.5.1\lib\net472\SunnyUI.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.Common, Version=3.5.0.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Common.3.5.0\lib\net472\SunnyUI.Common.dll</HintPath>
<Reference Include="SunnyUI.Common, Version=3.5.1.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Common.3.5.1\lib\net472\SunnyUI.Common.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SunnyUI" version="3.5.0" targetFramework="net472" />
<package id="SunnyUI.Common" version="3.5.0" targetFramework="net472" />
<package id="SunnyUI" version="3.5.1" targetFramework="net472" />
<package id="SunnyUI.Common" version="3.5.1" targetFramework="net472" />
</packages>

View File

@ -60,71 +60,6 @@ namespace Sunny.UI
}
}
/// <summary>
/// 颜色是否是浅色
/// </summary>
/// <param name="color">颜色</param>
/// <returns>是否是浅色</returns>
public static bool IsLightColor(this Color color)
{
return (0.299 * color.R + 0.587 * color.G + 0.114 * color.B) / 255 > 0.5;
}
/// <summary>
/// 根据背景色判断前景色
/// </summary>
/// <param name="backColor">背景色</param>
/// <returns>前景色</returns>
public static Color ForeColor(Color backColor)
{
return backColor.IsLightColor() ? Color.Black : Color.White;
}
/// <summary>
/// SizeF转Size
/// </summary>
/// <param name="size">SizeF</param>
/// <returns>Size</returns>
public static Size Size(this SizeF size)
{
return new Size(size.Width.RoundEx(), size.Height.RoundEx());
}
/// <summary>
/// PointF转Point
/// </summary>
/// <param name="point">PointF</param>
/// <returns>Point</returns>
public static Point Point(this PointF point)
{
return new Point(point.X.RoundEx(), point.Y.RoundEx());
}
/// <summary>
/// Size增加长宽
/// </summary>
/// <param name="size">Size</param>
/// <param name="width">宽</param>
/// <param name="height">长</param>
/// <returns>结果</returns>
public static Size Add(this Size size, int width, int height)
{
return new Size(size.Width + width, size.Height + height);
}
/// <summary>
/// SizeF增加长宽
/// </summary>
/// <param name="size">SizeF</param>
/// <param name="width">宽</param>
/// <param name="height">长</param>
/// <returns>结果</returns>
public static SizeF Add(this SizeF size, float width, float height)
{
return new SizeF(size.Width + width, size.Height + height);
}
/// <summary>
/// 点是否在区域内
/// </summary>
@ -543,27 +478,6 @@ namespace Sunny.UI
return g;
}
/// <summary>
/// Color转HTML
/// </summary>
/// <param name="color">Color</param>
/// <returns>HTML</returns>
public static string ToHTML(this Color color)
{
return ColorTranslator.ToHtml(color);
}
/// <summary>
/// HTML转Color
/// </summary>
/// <param name="htmlColor">HTML</param>
/// <param name="alpha">透明度</param>
/// <returns>Color</returns>
public static Color ToColor(this string htmlColor, int alpha = 255)
{
return Color.FromArgb(alpha > 255 ? 255 : alpha, ColorTranslator.FromHtml(htmlColor));
}
/// <summary>
/// 颜色是否为空
/// </summary>

View File

@ -1,167 +0,0 @@
using System;
using System.Collections;
namespace Sunny.UI
{
[Serializable]
public class UIObjectCollection : IList
{
private ArrayList data = new ArrayList();
public event EventHandler CountChange;
public object this[int index]
{
get => data[index];
set => data[index] = value;
}
public int Count => data.Count;
bool IList.IsReadOnly => false;
bool IList.IsFixedSize => false;
public int Add(object value)
{
int count = data.Add(value);
CountChange?.Invoke(this, new EventArgs());
return count;
}
public void AddRange(object[] value)
{
if (value == null)
{
throw new ArgumentNullException("value is null");
}
data.AddRange(value);
CountChange?.Invoke(this, new EventArgs());
}
public void Clear()
{
data.Clear();
CountChange?.Invoke(this, new EventArgs());
}
public bool Contains(object value)
{
return data.Contains(value);
}
public void CopyTo(object[] array, int index)
{
data.CopyTo(array, index);
}
public UIObjectEnumerator GetEnumerator()
{
return new UIObjectEnumerator(this);
}
public int IndexOf(object value)
{
return data.IndexOf(value);
}
public void Insert(int index, object value)
{
data.Insert(index, value);
CountChange?.Invoke(this, new EventArgs());
}
public bool IsReadOnly => false;
public bool IsSynchronized => false;
public void Remove(object value)
{
data.Remove(value);
CountChange?.Invoke(this, new EventArgs());
}
public void RemoveAt(int index)
{
data.RemoveAt(index);
CountChange?.Invoke(this, new EventArgs());
}
public object SyncRoot => data.SyncRoot;
object IList.this[int index]
{
get => this[index];
set => this[index] = value;
}
int IList.Add(object value)
{
int count = Add(value);
CountChange?.Invoke(this, new EventArgs());
return count;
}
bool IList.Contains(object value)
{
return Contains(value);
}
int IList.IndexOf(object value)
{
return IndexOf(value);
}
void IList.Insert(int index, object value)
{
Insert(index, value);
CountChange?.Invoke(this, new EventArgs());
}
void IList.Remove(object value)
{
Remove(value);
CountChange?.Invoke(this, new EventArgs());
}
void ICollection.CopyTo(Array array, int index)
{
data.CopyTo(array, index);
}
IEnumerator IEnumerable.GetEnumerator()
{
return data.GetEnumerator();
}
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public class UIObjectEnumerator
{
private readonly IEnumerator baseEnumerator;
private readonly IEnumerable temp;
internal UIObjectEnumerator(UIObjectCollection mappings)
{
this.temp = (IEnumerable)(mappings);
this.baseEnumerator = temp.GetEnumerator();
}
public object Current => baseEnumerator.Current;
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
public void Reset()
{
baseEnumerator.Reset();
}
}
}

View File

@ -1,203 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@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.
* 使
******************************************************************************
* : UMapper.cs
* : StructList和数组
* : V3.1
* : 2021-09-30
*
* 2021-09-30: V3.0.7
******************************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Sunny.UI
{
/// <summary>
/// 轻量级的对象映射框架
/// </summary>
public static class Mapper
{
private static void Execute<T1, T2>(T1 source, T2 dest)
where T1 : class
where T2 : class
{
if (source == null || dest == null)
{
return;
}
var listSource = source.GetType().GetNeedProperties().ToDictionary(prop => prop.Name);
var listDest = dest.GetType().GetNeedProperties().ToDictionary(prop => prop.Name);
foreach (var item in listDest)
{
if (listSource.NotContainsKey(item.Key)) continue;
var sourceInfo = listSource[item.Key];
Type sourceType = sourceInfo.PropertyType;
object sourceValue = sourceInfo.GetValue(source, null);
var destInfo = item.Value;
Type destType = item.Value.PropertyType;
if (!sourceType.Equals(destType)) continue;
if (sourceType.IsValueType)
{
//Console.WriteLine("ValueType: " + item.Key + ", " + sourceType.FullName);
destInfo.SetValue(dest, sourceValue, null);
}
else
{
if (sourceType == typeof(string))
{
//Console.WriteLine("String: " + item.Key + ", " + sourceType.FullName);
destInfo.SetValue(dest, sourceValue, null);
continue;
}
if (sourceType.IsList())
{
//Console.WriteLine("List: " + item.Key + ", " + sourceType.FullName);
Type[] sourceTypes = sourceType.GetGenericArguments();
Type[] destTypes = destType.GetGenericArguments();
if (sourceTypes.Length != 1) continue;
if (destTypes.Length != 1) continue;
if (!sourceTypes[0].Equals(destTypes[0])) continue;
if (sourceValue == null)
{
destInfo.SetValue(dest, null, null);
}
else
{
Type typeDataList = typeof(List<>).MakeGenericType(destTypes[0]);
MethodInfo AddInfo = typeDataList.GetMethod("Add", BindingFlags.Public | BindingFlags.Instance);
if (AddInfo == null) continue;
if (sourceTypes[0].IsValueType || sourceTypes[0] == typeof(string))
{
object listvalue = typeDataList.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] { });
IEnumerable sourceList = sourceValue as IEnumerable;
foreach (var listItem in sourceList)
{
AddInfo.Invoke(listvalue, new[] { listItem });
}
destInfo.SetValue(dest, listvalue, null);
}
else
{
//暂时不考虑
}
}
continue;
}
if (sourceType.IsArray)
{
//Console.WriteLine("Array: " + item.Key + ", " + sourceType.FullName);
if (sourceValue == null)
{
destInfo.SetValue(dest, null, null);
}
else
{
ICollection sourceList = sourceValue as ICollection;
Type type = sourceType.GetElementType();
var array = Array.CreateInstance(type, sourceList.Count);
int index = 0;
foreach (var listItem in sourceList)
{
array.SetValue(listItem, index++);
}
destInfo.SetValue(dest, array, null);
}
continue;
}
if (sourceType.IsDictionary())
{
continue;
}
//类没有无参构造函数的话,创建有问题
//if (sourceType.IsClass)
//{
// if (sourceValue == null)
// {
// destInfo.SetValue(dest, null, null);
// }
// else
// {
// object obj = Activator.CreateInstance(sourceType, null);
// obj.MapperFrom(sourceValue);
// destInfo.SetValue(dest, obj, null);
// }
//
// continue;
//}
}
}
}
/// <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)
where T1 : class
where T2 : class
{
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)
where T1 : class
where T2 : class
{
Execute(source, dest);
}
/// <summary>
/// 获取数组的类类型
/// </summary>
/// <param name="t">类型</param>
/// <returns>类类型</returns>
public static Type GetArrayElementType(this Type t)
{
if (!t.IsArray) return null;
string name = t.FullName.Replace("[]", string.Empty);
return t.Assembly.GetType(name);
}
}
}

View File

@ -9,7 +9,7 @@
<Description>SunnyUI.Net 是基于.Net Framework 4.0~4.8、.Net6、.Net7 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。</Description>
<Copyright>CopyRight © SunnyUI.Net 2012-2023</Copyright>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<Version>3.5.0.0</Version>
<Version>3.5.1.0</Version>
<Authors>ShenYonghua</Authors>
<Company>SunnyUI.Net</Company>
<PackageId>SunnyUI</PackageId>
@ -20,7 +20,7 @@
<SignAssembly>False</SignAssembly>
<AssemblyOriginatorKeyFile>D:\MyDocuments\Key\SunnyUI.pfx</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
@ -79,7 +79,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SunnyUI.Common" Version="3.5.0" />
<PackageReference Include="SunnyUI.Common" Version="3.5.1" />
</ItemGroup>
<ItemGroup>