This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -0,0 +1,107 @@
using System.Windows;
using System.Windows.Controls;
using WPFDark.Controls.Converters;
namespace WPFDark.Controls
{
public class BiaToggleSwitch : ContentControl
{
public static BoolInverseConverter InverseConverter { get; } = new BoolInverseConverter();
#region IsChecked
public bool IsChecked
{
get => _IsChecked;
set
{
if (value != _IsChecked)
SetValue(IsCheckedProperty, value);
}
}
private bool _IsChecked;
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register(nameof(IsChecked), typeof(bool), typeof(BiaToggleSwitch),
new FrameworkPropertyMetadata(
false,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
(s, e) =>
{
var self = (BiaToggleSwitch) s;
self._IsChecked = (bool) e.NewValue;
})
{
BindsTwoWayByDefault = true
}
);
#endregion
#region EnabledLabel
public string? EnabledLabel
{
get => _EnabledLabel;
set
{
if (value != _EnabledLabel)
SetValue(EnabledLabelProperty, value);
}
}
private string? _EnabledLabel;
public static readonly DependencyProperty EnabledLabelProperty =
DependencyProperty.Register(
nameof(EnabledLabel),
typeof(string),
typeof(BiaToggleSwitch),
new PropertyMetadata(
default,
(s, e) =>
{
var self = (BiaToggleSwitch) s;
self._EnabledLabel = (string)e.NewValue;
}));
#endregion
#region DisabledLabel
public string? DisabledLabel
{
get => _DisabledLabel;
set
{
if (value != _DisabledLabel)
SetValue(DisabledLabelProperty, value);
}
}
private string? _DisabledLabel;
public static readonly DependencyProperty DisabledLabelProperty =
DependencyProperty.Register(
nameof(DisabledLabel),
typeof(string),
typeof(BiaToggleSwitch),
new PropertyMetadata(
default,
(s, e) =>
{
var self = (BiaToggleSwitch) s;
self._DisabledLabel = (string)e.NewValue;
}));
#endregion
static BiaToggleSwitch()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(BiaToggleSwitch),
new FrameworkPropertyMetadata(typeof(BiaToggleSwitch)));
}
}
}