更新
This commit is contained in:
117
WPFDark/Controls/Effects/HsvBoxBackgroundEffect.cs
Normal file
117
WPFDark/Controls/Effects/HsvBoxBackgroundEffect.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using WPFDark.Internals;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
using System.Windows.Media.Media3D;
|
||||
namespace WPFDark.Controls.Effects
|
||||
{
|
||||
internal class HsvBoxBackgroundEffect : ShaderEffect
|
||||
{
|
||||
static HsvBoxBackgroundEffect()
|
||||
{
|
||||
_PixelShader = new PixelShader
|
||||
{
|
||||
UriSource = new Uri($"pack://application:,,,/{ThemeManager.LibraryNamespace};component/Controls/Effects/HsvBoxBackgroundEffect.ps")
|
||||
};
|
||||
|
||||
_PixelShader.Freeze();
|
||||
}
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly PixelShader _PixelShader;
|
||||
|
||||
internal HsvBoxBackgroundEffect()
|
||||
{
|
||||
base.PixelShader = _PixelShader;
|
||||
UpdateShaderValue(ValueProperty);
|
||||
UpdateShaderValue(IsEnabledProperty);
|
||||
UpdateShaderValue(DisableColorProperty);
|
||||
}
|
||||
|
||||
#region Value
|
||||
|
||||
public double Value
|
||||
{
|
||||
get => value;
|
||||
set
|
||||
{
|
||||
if (NumberHelper.AreClose(value, Value) == false)
|
||||
SetValue(ValueProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double value;
|
||||
|
||||
public static readonly DependencyProperty ValueProperty =
|
||||
DependencyProperty.Register(nameof(Value), typeof(double), typeof(HsvBoxBackgroundEffect),
|
||||
new PropertyMetadata(
|
||||
0.0,
|
||||
(s, e) =>
|
||||
{
|
||||
var self = (HsvBoxBackgroundEffect)s;
|
||||
self.value = (double)e.NewValue;
|
||||
|
||||
PixelShaderConstantCallback(0)(s, e);
|
||||
}));
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEnabled
|
||||
|
||||
public float IsEnabled
|
||||
{
|
||||
get => isEnabled;
|
||||
set
|
||||
{
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
if (value != isEnabled)
|
||||
SetValue(IsEnabledProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private float isEnabled = 1.0f;
|
||||
|
||||
public static readonly DependencyProperty IsEnabledProperty =
|
||||
DependencyProperty.Register(nameof(IsEnabled), typeof(float), typeof(HsvBoxBackgroundEffect),
|
||||
new PropertyMetadata(
|
||||
1.0f,
|
||||
(s, e) =>
|
||||
{
|
||||
var self = (HsvBoxBackgroundEffect)s;
|
||||
self.isEnabled = (float)e.NewValue;
|
||||
|
||||
PixelShaderConstantCallback(6)(s, e);
|
||||
}));
|
||||
|
||||
#endregion
|
||||
|
||||
#region DisableColor
|
||||
|
||||
public Point3D DisableColor
|
||||
{
|
||||
get => disableColor;
|
||||
set
|
||||
{
|
||||
if (value != disableColor)
|
||||
SetValue(DisableColorProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private Point3D disableColor = new Point3D(1.0, 0.0, 0.0);
|
||||
|
||||
public static readonly DependencyProperty DisableColorProperty =
|
||||
DependencyProperty.Register(nameof(DisableColor), typeof(Point3D), typeof(HsvBoxBackgroundEffect),
|
||||
new PropertyMetadata(
|
||||
new Point3D(1.0, 0.0, 0.0),
|
||||
(s, e) =>
|
||||
{
|
||||
var self = (HsvBoxBackgroundEffect)s;
|
||||
self.disableColor = (Point3D)e.NewValue;
|
||||
|
||||
PixelShaderConstantCallback(7)(s, e);
|
||||
}));
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user