namespace NeoUI.Assists;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
///
/// 提供各种控件的附加属性帮助类。
///
public static class ControlAssist
{
#region Border
///
/// 获取与指定依赖对象关联的几何图形。
///
/// 要获取其几何图形属性的依赖对象。
/// 与指定依赖对象关联的几何图形。
public static Geometry GetGeometry(DependencyObject obj)
{
return (Geometry)obj.GetValue(GeometryProperty);
}
///
/// 设置与指定依赖对象关联的几何图形。
///
/// 要设置其几何图形属性的依赖对象。
/// 要与此依赖对象关联的新几何图形值。
public static void SetGeometry(DependencyObject obj, Geometry value)
{
obj.SetValue(GeometryProperty, value);
}
///
/// 代表附加到控件的几何图形属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取几何图形。
///
public static readonly DependencyProperty GeometryProperty =
DependencyProperty.RegisterAttached("Geometry",
typeof(Geometry), typeof(ControlAssist));
///
/// 代表附加到控件的圆角半径属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取圆角半径,影响控件的测量和渲染。
///
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached(
"CornerRadius",
typeof(CornerRadius),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
default(CornerRadius),
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender
));
///
/// 获取与指定依赖对象关联的圆角半径。
///
/// 要获取其圆角半径属性的依赖对象。
/// 与指定依赖对象关联的圆角半径。
[Category("NeuAssists")]
public static CornerRadius GetCornerRadius(DependencyObject obj)
{
return (CornerRadius)obj.GetValue(CornerRadiusProperty);
}
///
/// Sets a value that represents the degree to which the corners of a control border are rounded.
///
public static void SetCornerRadius(DependencyObject obj, CornerRadius value)
{
obj.SetValue(CornerRadiusProperty, value);
}
#endregion
#region Brushes
///
/// 代表当鼠标悬停在控件上时前景色的属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取鼠标悬停状态下的前景色刷。
///
public static readonly DependencyProperty MouseOverForegroundProperty = DependencyProperty.RegisterAttached(
"MouseOverForeground",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取与指定依赖对象关联的鼠标悬停前景色。
///
/// 要获取其鼠标悬停前景色属性的依赖对象。
/// 与指定依赖对象关联的鼠标悬停前景色。
public static Brush GetMouseOverForeground(DependencyObject obj)
{
return (Brush)obj.GetValue(MouseOverForegroundProperty);
}
///
/// 设置指定依赖对象在鼠标悬停时的前景色。
///
/// 要设置其鼠标悬停前景色属性的依赖对象。
/// 表示鼠标悬停时前景色的Brush对象。
public static void SetMouseOverForeground(DependencyObject obj, Brush value)
{
obj.SetValue(MouseOverForegroundProperty, value);
}
///
/// 代表当鼠标悬停在控件上时边框的颜色属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取鼠标悬停状态下的边框画刷。
///
public static readonly DependencyProperty MouseOverBorderBrushProperty = DependencyProperty.RegisterAttached(
"MouseOverBorderBrush",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取指定依赖对象的鼠标悬停时边框画刷。
///
/// 要获取其鼠标悬停时边框画刷属性的依赖对象。
/// 指定依赖对象的鼠标悬停时边框画刷。
public static Brush GetMouseOverBorderBrush(DependencyObject obj)
{
return (Brush)obj.GetValue(MouseOverBorderBrushProperty);
}
///
/// 设置指定依赖对象的鼠标悬停边框画刷。
///
/// 要设置其鼠标悬停边框画刷属性的依赖对象。
/// 要应用到依赖对象上的鼠标悬停边框画刷。
public static void SetMouseOverBorderBrush(DependencyObject obj, Brush value)
{
obj.SetValue(MouseOverBorderBrushProperty, value);
}
///
/// 代表控件在鼠标悬停时的背景画刷属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取鼠标悬停时的背景颜色或图案。
///
public static readonly DependencyProperty MouseOverBackgroundProperty = DependencyProperty.RegisterAttached(
"MouseOverBackground",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取指定依赖对象的鼠标悬停时的背景画刷。
///
/// 要获取其鼠标悬停背景画刷属性的依赖对象。
/// 指定依赖对象的鼠标悬停背景画刷。
public static Brush GetMouseOverBackground(DependencyObject obj)
{
return (Brush)obj.GetValue(MouseOverBackgroundProperty);
}
///
/// 设置指定依赖对象的鼠标悬停背景画刷。
///
/// 要设置其鼠标悬停背景画刷属性的依赖对象。
/// 新的鼠标悬停背景画刷值。
public static void SetMouseOverBackground(DependencyObject obj, Brush value)
{
obj.SetValue(MouseOverBackgroundProperty, value);
}
///
/// 代表控件在获得焦点时的前景色属性。此依赖属性允许为WPF应用程序中的控件设置和获取焦点状态下的前景色,支持继承,并影响渲染。
///
public static readonly DependencyProperty FocusedForegroundProperty = DependencyProperty.RegisterAttached(
"FocusedForeground",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取与指定依赖对象关联的聚焦前景色。
///
/// 要获取其聚焦前景色属性的依赖对象。
/// 与指定依赖对象关联的聚焦前景色。
public static Brush GetFocusedForeground(DependencyObject obj)
{
return (Brush)obj.GetValue(FocusedForegroundProperty);
}
///
/// 设置指定依赖对象的聚焦前景色。
///
/// 要设置其聚焦前景色属性的依赖对象。
/// 新聚焦前景色值。
public static void SetFocusedForeground(DependencyObject obj, Brush value)
{
obj.SetValue(FocusedForegroundProperty, value);
}
///
/// 代表控件在获得焦点时边框的画刷属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取焦点状态下的边框画刷。
///
public static readonly DependencyProperty FocusedBorderBrushProperty = DependencyProperty.RegisterAttached(
"FocusedBorderBrush",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取与指定依赖对象关联的聚焦边框画刷。
///
/// 要获取其聚焦边框画刷属性的依赖对象。
/// 与指定依赖对象关联的聚焦边框画刷。
public static Brush GetFocusedBorderBrush(DependencyObject obj)
{
return (Brush)obj.GetValue(FocusedBorderBrushProperty);
}
///
/// 设置指定依赖对象的焦点边框画刷。
///
/// 要设置其焦点边框画刷属性的依赖对象。
/// 要设置的焦点边框画刷值。
public static void SetFocusedBorderBrush(DependencyObject obj, Brush value)
{
obj.SetValue(FocusedBorderBrushProperty, value);
}
///
/// 代表控件获得焦点时的背景颜色属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取当其处于焦点状态下的背景颜色,支持继承。
///
public static readonly DependencyProperty FocusedBackgroundProperty = DependencyProperty.RegisterAttached(
"FocusedBackground",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取指定依赖对象的聚焦背景画刷。
///
/// 要获取其聚焦背景画刷属性的依赖对象。
/// 指定依赖对象的聚焦背景画刷。
public static Brush GetFocusedBackground(DependencyObject obj)
{
return (Brush)obj.GetValue(FocusedBackgroundProperty);
}
///
/// 设置指定依赖对象的焦点背景。
///
/// 要设置其焦点背景属性的依赖对象。
/// 要设置的焦点背景画刷。
public static void SetFocusedBackground(DependencyObject obj, Brush value)
{
obj.SetValue(FocusedBackgroundProperty, value);
}
///
/// 代表控件被按下时的前景色属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取按下的前景色,并且支持继承。
///
public static readonly DependencyProperty PressedForegroundProperty = DependencyProperty.RegisterAttached(
"PressedForeground",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取指定依赖对象的按下状态前景色。
///
/// 要获取其按下状态前景色属性的依赖对象。
/// 指定依赖对象的按下状态前景色。
public static Brush GetPressedForeground(DependencyObject obj)
{
return (Brush)obj.GetValue(PressedForegroundProperty);
}
///
/// 设置指定依赖对象的按下状态前景色。
///
/// 要设置其按下状态前景色属性的依赖对象。
/// 新的按下状态前景色。
public static void SetPressedForeground(DependencyObject obj, Brush value)
{
obj.SetValue(PressedForegroundProperty, value);
}
///
/// 代表控件在按下状态时的边框画刷属性。此依赖属性允许在WPF应用程序中为任意控件设置和获取按下状态下的边框颜色或纹理。
///
public static readonly DependencyProperty PressedBorderBrushProperty = DependencyProperty.RegisterAttached(
"PressedBorderBrush",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取指定依赖对象的按下状态边框画刷。
///
/// 要获取其按下状态边框画刷属性的依赖对象。
/// 指定依赖对象的按下状态边框画刷。
public static Brush GetPressedBorderBrush(DependencyObject obj)
{
return (Brush)obj.GetValue(PressedBorderBrushProperty);
}
///
/// 设置指定依赖对象的按下状态边框画刷。
///
/// 要设置其按下状态边框画刷属性的依赖对象。
/// 要设置的按下状态边框画刷。
public static void SetPressedBorderBrush(DependencyObject obj, Brush value)
{
obj.SetValue(PressedBorderBrushProperty, value);
}
///
/// 代表控件在按下状态时的背景色属性。此依赖属性允许为WPF应用程序中的任意控件设置和获取按下状态时的背景颜色,支持继承并影响渲染。
///
public static readonly DependencyProperty PressedBackgroundProperty = DependencyProperty.RegisterAttached(
"PressedBackground",
typeof(Brush),
typeof(ControlAssist),
new FrameworkPropertyMetadata(
Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits
));
///
/// 获取指定依赖对象的按下背景画刷。
///
/// 要获取其按下背景画刷属性的依赖对象。
/// 指定依赖对象的按下背景画刷。
public static Brush GetPressedBackground(DependencyObject obj)
{
return (Brush)obj.GetValue(PressedBackgroundProperty);
}
///
/// 设置指定依赖对象的按下状态背景。
///
/// 要设置其按下状态背景的依赖对象。
/// 按下状态时使用的背景画刷。
public static void SetPressedBackground(DependencyObject obj, Brush value)
{
obj.SetValue(PressedBackgroundProperty, value);
}
#endregion
}