This commit is contained in:
NaBian committed 2020-07-14 23:09:13 +08:00
1 parent 25a6117ee1
commit d4e32272a2
19 files changed
+349 -148

No files matched your search

@@ -1,75 +0,0 @@
using System.Windows.Media;
namespace HandyControl.Data
{
/// <summary>
/// 颜色范围
/// </summary>
public class ColorRange
{
/// <summary>
/// 颜色1
/// </summary>
private Color _color1;
/// <summary>
/// 颜色1
/// </summary>
public Color Color1
{
get => _color1;
set
{
_color1 = value;
Update();
}
}
/// <summary>
/// 颜色2
/// </summary>
private Color _color2;
/// <summary>
/// 颜色2
/// </summary>
public Color Color2
{
get => _color2;
set
{
_color2 = value;
Update();
}
}
/// <summary>
/// 颜色差值
/// </summary>
private readonly int[] _subColorArr = new int[4];
/// <summary>
/// 更新
/// </summary>
private void Update()
{
_subColorArr[0] = Color1.A - Color2.A;
_subColorArr[1] = Color1.R - Color2.R;
_subColorArr[2] = Color1.G - Color2.G;
_subColorArr[3] = Color1.B - Color2.B;
}
/// <summary>
/// 获取指定比例处的颜色
/// </summary>
/// <param name="range">范围(0-1)</param>
/// <returns></returns>
public Color GetColor(double range)
{
if (range < 0 || range > 1) return default;
return Color.FromArgb((byte)(_color1.A - _subColorArr[0] * range), (byte)(_color1.R - _subColorArr[1] * range),
(byte)(_color1.G - _subColorArr[2] * range), (byte)(_color1.B - _subColorArr[3] * range));
}
}
}
@@ -5,7 +5,7 @@ using System;
namespace HandyControl.Data
{
public struct SystemVersionInfo
public readonly struct SystemVersionInfo
{
public static SystemVersionInfo Windows10 => new SystemVersionInfo(10, 0, 10240);
@@ -0,0 +1,63 @@
using System.Windows.Media;
namespace HandyControl.Data
{
/// <summary>
/// 颜色范围
/// </summary>
public class ColorRange : IValueRange<Color>
{
private Color _start;
public Color Start
{
get => _start;
set
{
_start = value;
Update();
}
}
private Color _end;
public Color End
{
get => _end;
set
{
_end = value;
Update();
}
}
/// <summary>
/// 颜色差值
/// </summary>
private readonly int[] _subColorArr = new int[4];
/// <summary>
/// 更新
/// </summary>
private void Update()
{
_subColorArr[0] = _start.A - _end.A;
_subColorArr[1] = _start.R - _end.R;
_subColorArr[2] = _start.G - _end.G;
_subColorArr[3] = _start.B - _end.B;
}
/// <summary>
/// 获取指定比例处的颜色
/// </summary>
/// <param name="range">范围(0-1)</param>
/// <returns></returns>
public Color GetColor(double range)
{
if (range < 0 || range > 1) return default;
return Color.FromArgb((byte)(_start.A - _subColorArr[0] * range), (byte)(_start.R - _subColorArr[1] * range),
(byte)(_start.G - _subColorArr[2] * range), (byte)(_start.B - _subColorArr[3] * range));
}
}
}
@@ -0,0 +1,25 @@
using System;
namespace HandyControl.Data
{
public struct DateTimeRange : IValueRange<DateTime>
{
public DateTimeRange(DateTime start)
{
Start = start;
End = start;
}
public DateTimeRange(DateTime start, DateTime end)
{
Start = start;
End = end;
}
public DateTime Start { get; set; }
public DateTime End { get; set; }
public double TotalMilliseconds => (End - Start).TotalMilliseconds;
}
}
@@ -0,0 +1,9 @@
namespace HandyControl.Data
{
public struct DoubleRange : IValueRange<double>
{
public double Start { get; set; }
public double End { get; set; }
}
}
@@ -0,0 +1,9 @@
namespace HandyControl.Data
{
public interface IValueRange<T>
{
T Start { get; set; }
T End { get; set; }
}
}