This commit is contained in:
Sunny 2022-11-03 23:26:32 +08:00
parent 04a1e69233
commit 7df32605a7
11 changed files with 193 additions and 26 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>

Binary file not shown.

View File

@ -166,7 +166,7 @@ namespace Sunny.UI
head = new BmpHead();
head.Init(bitmap);
data = new byte[head.FileSize];
Array.Copy(head.StructToBytes(), 0, data, 0, (int)head.BitmapDataOffset);
Array.Copy(head.ToBytes(), 0, data, 0, (int)head.BitmapDataOffset);
var sourceArea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
var bitmapData = bitmap.LockBits(sourceArea, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
@ -203,7 +203,7 @@ namespace Sunny.UI
head = new BmpHead();
head.Init(width, height);
data = new byte[head.FileSize];
Array.Copy(head.StructToBytes(), 0, data, 0, (int)head.BitmapDataOffset);
Array.Copy(head.ToBytes(), 0, data, 0, (int)head.BitmapDataOffset);
if (bmpData.Length != width * height * 3) return;
//BMP文件的数据从左下角开始每行向上。System.Drawing.Bitmap数据是从左上角开始每行向下

View File

@ -0,0 +1,167 @@
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

@ -293,7 +293,7 @@ namespace Sunny.UI
/// <typeparam name="T">T</typeparam>
public void WriteStruct<T>(string section, string key, T value) where T : struct
{
Write(section, key, value.StructToBytes());
Write(section, key, value.ToBytes());
}
/// <summary>

View File

@ -20,6 +20,7 @@
******************************************************************************/
using System;
using System.Reflection;
namespace Sunny.UI
{
@ -28,10 +29,12 @@ namespace Sunny.UI
/// </summary>
public static class UIGlobal
{
//public const string Version = "SunnyUI.Net V3.2.6";
/// <summary>
/// 版本
/// </summary>
public const string Version = "SunnyUI.Net V3.2.6";
public static string Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
public const int EditorMinHeight = 20;
public const int EditorMaxHeight = 60;

View File

@ -51,7 +51,7 @@ namespace Sunny.UI
get => maximum;
set
{
maximum = value.CheckLowerLimit(2);
maximum = value.GetLowerLimit(2);
Invalidate();
}
}
@ -67,8 +67,8 @@ namespace Sunny.UI
get => thisValue;
set
{
thisValue = value.CheckLowerLimit(0);
thisValue = value.CheckUpperLimit(Maximum - BoundsWidth);
thisValue = value.GetLowerLimit(0);
thisValue = value.GetUpperLimit(Maximum - BoundsWidth);
Invalidate();
}
}
@ -80,7 +80,7 @@ namespace Sunny.UI
get => boundsWidth;
set
{
boundsWidth = value.CheckLowerLimit(1);
boundsWidth = value.GetLowerLimit(1);
Invalidate();
}
}
@ -143,14 +143,14 @@ namespace Sunny.UI
if (inLeftArea)
{
int value = (Value - LargeChange).CheckInRange(0, Maximum - BoundsWidth);
int value = (Value - LargeChange).GetLimit(0, Maximum - BoundsWidth);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
if (inRightArea)
{
int value = (Value + LargeChange).CheckInRange(0, Maximum - BoundsWidth);
int value = (Value + LargeChange).GetLimit(0, Maximum - BoundsWidth);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
@ -159,7 +159,7 @@ namespace Sunny.UI
{
int x = BoundsWidth * (Width - 32) / Maximum;
int value = (e.Location.X - x / 2) * maximum / (Width - 32);
value = value.CheckInRange(0, Maximum - BoundsWidth);
value = value.GetLimit(0, Maximum - BoundsWidth);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
@ -246,7 +246,7 @@ namespace Sunny.UI
{
int x = BoundsWidth * (Width - 32) / Maximum;
int value = (e.Location.X - x / 2) * maximum / (Width - 32);
value = value.CheckInRange(0, Maximum - BoundsWidth);
value = value.GetLimit(0, Maximum - BoundsWidth);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}

View File

@ -65,7 +65,7 @@ namespace Sunny.UI
get => maximum;
set
{
maximum = value.CheckLowerLimit(2);
maximum = value.GetLowerLimit(2);
Invalidate();
}
}
@ -82,8 +82,8 @@ namespace Sunny.UI
get => thisValue;
set
{
thisValue = value.CheckLowerLimit(0);
thisValue = value.CheckUpperLimit(Maximum - BoundsHeight);
thisValue = value.GetLowerLimit(0);
thisValue = value.GetUpperLimit(Maximum - BoundsHeight);
Invalidate();
}
}
@ -95,7 +95,7 @@ namespace Sunny.UI
get => boundsHeight;
set
{
boundsHeight = value.CheckLowerLimit(1);
boundsHeight = value.GetLowerLimit(1);
Invalidate();
}
}
@ -159,14 +159,14 @@ namespace Sunny.UI
if (inLeftArea)
{
int value = (Value - LargeChange).CheckInRange(0, Maximum - BoundsHeight);
int value = (Value - LargeChange).GetLimit(0, Maximum - BoundsHeight);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
if (inRightArea)
{
int value = (Value + LargeChange).CheckInRange(0, Maximum - BoundsHeight);
int value = (Value + LargeChange).GetLimit(0, Maximum - BoundsHeight);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
@ -175,7 +175,7 @@ namespace Sunny.UI
{
int y = BoundsHeight * (Height - 32) / Maximum;
int value = (e.Location.Y - y / 2) * maximum / (Height - 32);
value = value.CheckInRange(0, Maximum - BoundsHeight);
value = value.GetLimit(0, Maximum - BoundsHeight);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
@ -262,7 +262,7 @@ namespace Sunny.UI
{
int y = BoundsHeight * (Height - 32) / Maximum;
int value = (e.Location.Y - y / 2) * maximum / (Height - 32);
value = value.CheckInRange(0, Maximum - BoundsHeight);
value = value.GetLimit(0, Maximum - BoundsHeight);
Value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}

View File

@ -9,7 +9,7 @@
<Description>SunnyUI.Net 是基于.Net Framework 4.0~4.8、.Net 6 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。</Description>
<Copyright>CopyRight © SunnyUI.Net 2012-2022</Copyright>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<Version>3.2.6.1</Version>
<Version>3.2.8.0</Version>
<Authors>ShenYonghua</Authors>
<Company>SunnyUI.Net</Company>
<PackageId>SunnyUI</PackageId>
@ -18,7 +18,7 @@
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<PackageIcon>SunnyUI.png</PackageIcon>
<SignAssembly>False</SignAssembly>
<AssemblyOriginatorKeyFile>C:\Users\Administrator\Documents\SunnyUI.pfx</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>C:\Key\SunnyUI.pfx</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
@ -75,7 +75,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SunnyUI.Common" Version="3.2.6" />
<PackageReference Include="SunnyUI.Common" Version="3.2.8" />
</ItemGroup>
<ItemGroup>