diff --git a/.editorconfig b/.editorconfig
index f0cb93b7..a040e8f1 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -591,6 +591,8 @@ dotnet_diagnostic.MA0091.severity = none # Sender should be 'this' for
dotnet_diagnostic.MA0131.severity = none # ArgumentNullException.ThrowIfNull should not be used with non-nullable types
dotnet_diagnostic.SA1010.severity = none # Opening square brackets must be spaced correctly
+dotnet_diagnostic.SA1311.severity = none # Static readonly fields must begin with upper case letter
+dotnet_diagnostic.IDE1006.severity = none # Static readonly fields must begin with upper case letter
dotnet_diagnostic.S107.severity = none # Methods should not have too many parameters
dotnet_diagnostic.S1144.severity = none # Remove the unused internal class
diff --git a/README.md b/README.md
index ce97abaa..0df37bee 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ This is a base libraries for building WPF application with the MVVM design patte
| Nuget package | Description | Dependencies |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|----------------------------------------------|
| [](https://www.nuget.org/packages/Atc.Wpf) | Base Controls, ValueConverters, Extensions etc. |
|
| [](https://www.nuget.org/packages/Atc.Wpf.FontIcons) | Render Svg and Img resources based on fonts |
Atc.Wpf
|
| [](https://www.nuget.org/packages/Atc.Wpf.Theming) | Theming for Light & Dark mode for WPF base controls |
Atc.Wpf
Atc.XamlToolkit
Atc.XamlToolkit.Wpf
|
diff --git a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj
index 534ab2d4..a2af611e 100644
--- a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj
+++ b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj
@@ -51,8 +51,8 @@
-
-
+
+
diff --git a/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageButtonView.xaml b/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageButtonView.xaml
index 1a26fdb3..594bbef5 100644
--- a/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageButtonView.xaml
+++ b/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageButtonView.xaml
@@ -39,7 +39,10 @@
Orientation="Horizontal"
Spacing="10">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageToggledButton.xaml.cs b/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageToggledButton.xaml.cs
new file mode 100644
index 00000000..3274ca13
--- /dev/null
+++ b/sample/Atc.Wpf.Sample/SamplesWpfTheming/InputButton/ImageToggledButton.xaml.cs
@@ -0,0 +1,53 @@
+namespace Atc.Wpf.Sample.SamplesWpfTheming.InputButton;
+
+public partial class ImageToggledButton
+{
+ public ImageToggledButton()
+ {
+ InitializeComponent();
+
+ DataContext = this;
+ }
+
+ [DependencyProperty]
+ private bool isBusy;
+
+ [DependencyProperty]
+ private bool isConnected;
+
+ [RelayCommand]
+ private async Task Connect()
+ {
+ IsBusy = true;
+
+ await Task
+ .Delay(2_000)
+ .ConfigureAwait(false);
+
+ await Application.Current.Dispatcher
+ .InvokeAsyncIfRequired(() =>
+ {
+ IsConnected = true;
+ IsBusy = false;
+ })
+ .ConfigureAwait(false);
+ }
+
+ [RelayCommand]
+ private async Task Disconnect()
+ {
+ IsBusy = true;
+
+ await Task
+ .Delay(500)
+ .ConfigureAwait(false);
+
+ await Application.Current.Dispatcher
+ .InvokeAsyncIfRequired(() =>
+ {
+ IsConnected = false;
+ IsBusy = false;
+ })
+ .ConfigureAwait(false);
+ }
+}
\ No newline at end of file
diff --git a/sample/Atc.Wpf.Sample/SamplesWpfThemingTreeView.xaml b/sample/Atc.Wpf.Sample/SamplesWpfThemingTreeView.xaml
index afc9ecdd..37c2e03a 100644
--- a/sample/Atc.Wpf.Sample/SamplesWpfThemingTreeView.xaml
+++ b/sample/Atc.Wpf.Sample/SamplesWpfThemingTreeView.xaml
@@ -29,6 +29,10 @@
Header="ImageButton"
IsExpanded="True"
SamplePath="InputButton.ImageButtonView" />
+
-
-
+
+
diff --git a/src/Atc.Wpf.Controls/BaseControls/ClockPanelPicker.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/ClockPanelPicker.xaml.cs
index 9140bb85..7a24f52d 100644
--- a/src/Atc.Wpf.Controls/BaseControls/ClockPanelPicker.xaml.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/ClockPanelPicker.xaml.cs
@@ -1,3 +1,4 @@
+// ReSharper disable InconsistentNaming
namespace Atc.Wpf.Controls.BaseControls;
public partial class ClockPanelPicker : INotifyPropertyChanged
@@ -9,19 +10,12 @@ public partial class ClockPanelPicker : INotifyPropertyChanged
public event PropertyChangedEventHandler? PropertyChanged;
- public static readonly RoutedEvent SelectedClockChangedEvent = EventManager.RegisterRoutedEvent(
- nameof(SelectedClockChanged),
+ [RoutedEvent(
RoutingStrategy.Direct,
- typeof(EventHandler),
- typeof(ClockPanelPicker));
+ HandlerType = typeof(EventHandler))]
+ private static readonly RoutedEvent selectedClockChanged;
- public event EventHandler SelectedClockChanged
- {
- add => AddHandler(SelectedClockChangedEvent, value);
- remove => RemoveHandler(SelectedClockChangedEvent, value);
- }
-
- [DependencyProperty(DefaultValue = "default(DateTime?)")]
+ [DependencyProperty]
private DateTime? selectedDateTime;
public ClockPanelPicker()
@@ -43,7 +37,8 @@ public ClockPanelPicker()
SelectedKeyMinute = "0";
}
- protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+ protected virtual void OnPropertyChanged(
+ [CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
diff --git a/src/Atc.Wpf.Controls/BaseControls/ColorPicker.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/ColorPicker.xaml.cs
index 2f278abe..f9d964bc 100644
--- a/src/Atc.Wpf.Controls/BaseControls/ColorPicker.xaml.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/ColorPicker.xaml.cs
@@ -6,12 +6,12 @@ public partial class ColorPicker
private RenderColorIndicatorType renderColorIndicatorType;
[DependencyProperty(
- DefaultValue = "Black",
+ DefaultValue = nameof(Brushes.Black),
PropertyChangedCallback = nameof(OnColorValueChanged))]
private Color? colorValue;
[DependencyProperty(
- DefaultValue = "Black",
+ DefaultValue = nameof(Brushes.Black),
PropertyChangedCallback = nameof(OnBrushValueChanged))]
private SolidColorBrush? brushValue;
diff --git a/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs
index dce09ccb..d327ad24 100644
--- a/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs
@@ -26,123 +26,49 @@ public event RoutedPropertyChangedEventHandler ValueYChanged
remove => RemoveHandler(ValueYChangedEvent, value);
}
- public static readonly DependencyProperty HideUpDownButtonsProperty = DependencyProperty.Register(
- nameof(HideUpDownButtons),
- typeof(bool),
- typeof(DecimalXyBox),
- new PropertyMetadata(BooleanBoxes.FalseBox));
-
- public bool HideUpDownButtons
- {
- get => (bool)GetValue(HideUpDownButtonsProperty);
- set => SetValue(HideUpDownButtonsProperty, value);
- }
-
- public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
- nameof(Maximum),
- typeof(decimal),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- decimal.MaxValue,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public decimal Maximum
- {
- get => (decimal)GetValue(MaximumProperty);
- set => SetValue(MaximumProperty, value);
- }
-
- public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(
- nameof(Minimum),
- typeof(decimal),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- decimal.MinValue,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public decimal Minimum
- {
- get => (decimal)GetValue(MinimumProperty);
- set => SetValue(MinimumProperty, value);
- }
-
- public static readonly DependencyProperty PrefixTextXProperty = DependencyProperty.Register(
- nameof(PrefixTextX),
- typeof(string),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- string.Empty,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public string PrefixTextX
- {
- get => (string)GetValue(PrefixTextXProperty);
- set => SetValue(PrefixTextXProperty, value);
- }
-
- public static readonly DependencyProperty PrefixTextYProperty = DependencyProperty.Register(
- nameof(PrefixTextY),
- typeof(string),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- string.Empty,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public string PrefixTextY
- {
- get => (string)GetValue(PrefixTextYProperty);
- set => SetValue(PrefixTextYProperty, value);
- }
-
- public static readonly DependencyProperty SuffixTextProperty = DependencyProperty.Register(
- nameof(SuffixText),
- typeof(string),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- string.Empty,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public string SuffixText
- {
- get => (string)GetValue(SuffixTextProperty);
- set => SetValue(SuffixTextProperty, value);
- }
-
- public static readonly DependencyProperty ValueXProperty = DependencyProperty.Register(
- nameof(ValueX),
- typeof(decimal),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- defaultValue: 0m,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
- OnValueXLostFocus,
- coerceValueCallback: null,
- isAnimationProhibited: true,
- UpdateSourceTrigger.LostFocus));
-
- public decimal ValueX
- {
- get => (decimal)GetValue(ValueXProperty);
- set => SetValue(ValueXProperty, value);
- }
-
- public static readonly DependencyProperty ValueYProperty = DependencyProperty.Register(
- nameof(ValueY),
- typeof(decimal),
- typeof(DecimalXyBox),
- new FrameworkPropertyMetadata(
- defaultValue: 0m,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
- OnValueYLostFocus,
- coerceValueCallback: null,
- isAnimationProhibited: true,
- UpdateSourceTrigger.LostFocus));
-
- public decimal ValueY
- {
- get => (decimal)GetValue(ValueYProperty);
- set => SetValue(ValueYProperty, value);
- }
+ [DependencyProperty(DefaultValue = false)]
+ private bool hideUpDownButtons;
+
+ [DependencyProperty(
+ DefaultValue = PropertyDefaultValueConstants.MinValue,
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private decimal minimum;
+
+ [DependencyProperty(
+ DefaultValue = PropertyDefaultValueConstants.MaxValue,
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private decimal maximum;
+
+ [DependencyProperty(
+ DefaultValue = "",
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private string prefixTextX;
+
+ [DependencyProperty(
+ DefaultValue = "",
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private string prefixTextY;
+
+ [DependencyProperty(
+ DefaultValue = "",
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private string suffixText;
+
+ [DependencyProperty(
+ DefaultValue = 0,
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
+ PropertyChangedCallback = nameof(OnValueXLostFocus),
+ IsAnimationProhibited = true,
+ DefaultUpdateSourceTrigger = UpdateSourceTrigger.LostFocus)]
+ private decimal valueX;
+
+ [DependencyProperty(
+ DefaultValue = 0,
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
+ PropertyChangedCallback = nameof(OnValueYLostFocus),
+ IsAnimationProhibited = true,
+ DefaultUpdateSourceTrigger = UpdateSourceTrigger.LostFocus)]
+ private decimal valueY;
public event EventHandler>? ValueXLostFocus;
@@ -162,7 +88,11 @@ private void OnValueXChanged(
return;
}
- RaiseEvent(new RoutedPropertyChangedEventArgs((decimal)e.OldValue, (decimal)e.NewValue, ValueXChangedEvent));
+ RaiseEvent(
+ new RoutedPropertyChangedEventArgs(
+ (decimal)e.OldValue,
+ (decimal)e.NewValue,
+ ValueXChangedEvent));
}
private void OnValueYChanged(
@@ -174,7 +104,11 @@ private void OnValueYChanged(
return;
}
- RaiseEvent(new RoutedPropertyChangedEventArgs((decimal)e.OldValue, (decimal)e.NewValue, ValueYChangedEvent));
+ RaiseEvent(
+ new RoutedPropertyChangedEventArgs(
+ (decimal)e.OldValue,
+ (decimal)e.NewValue,
+ ValueYChangedEvent));
}
private static void OnValueXLostFocus(
diff --git a/src/Atc.Wpf.Controls/BaseControls/DirectoryPicker.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/DirectoryPicker.xaml.cs
index 7d1336f0..fa5e5f6d 100644
--- a/src/Atc.Wpf.Controls/BaseControls/DirectoryPicker.xaml.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/DirectoryPicker.xaml.cs
@@ -1,4 +1,5 @@
// ReSharper disable UnusedParameter.Local
+// ReSharper disable InconsistentNaming
namespace Atc.Wpf.Controls.BaseControls;
[SuppressMessage("Naming", "CA1721:Property names should not match get methods", Justification = "OK.")]
@@ -22,7 +23,7 @@ public event RoutedPropertyChangedEventHandler ValueChanged
typeof(DirectoryInfo),
typeof(DirectoryPicker),
new FrameworkPropertyMetadata(
- default(DirectoryInfo?),
+ defaultValue: null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnValuePropertyChanged,
(o, value) => CoerceValue(o, value).Item1));
@@ -38,7 +39,7 @@ public DirectoryInfo? Value
typeof(string),
typeof(DirectoryPicker),
new FrameworkPropertyMetadata(
- default(string?),
+ defaultValue: null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnDisplayValuePropertyChanged,
(o, value) => CoerceDisplayValue(o, value).Item1));
@@ -49,101 +50,29 @@ public string? DisplayValue
set => SetValue(FullNameProperty, value);
}
- public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
- nameof(Title),
- typeof(string),
- typeof(DirectoryPicker),
- new PropertyMetadata(default(string)));
+ [DependencyProperty]
+ private string title;
- public string Title
- {
- get => (string)GetValue(TitleProperty);
- set => SetValue(TitleProperty, value);
- }
+ [DependencyProperty]
+ private bool showClearTextButton;
- public static readonly DependencyProperty ShowClearTextButtonProperty = DependencyProperty.Register(
- nameof(ShowClearTextButton),
- typeof(bool),
- typeof(DirectoryPicker),
- new PropertyMetadata(default(bool)));
+ [DependencyProperty(DefaultValue = "")]
+ private string watermarkText;
- public bool ShowClearTextButton
- {
- get => (bool)GetValue(ShowClearTextButtonProperty);
- set => SetValue(ShowClearTextButtonProperty, value);
- }
+ [DependencyProperty(DefaultValue = TextAlignment.Left)]
+ private TextAlignment watermarkAlignment;
- public static readonly DependencyProperty WatermarkTextProperty = DependencyProperty.Register(
- nameof(WatermarkText),
- typeof(string),
- typeof(DirectoryPicker),
- new PropertyMetadata(defaultValue: string.Empty));
+ [DependencyProperty(DefaultValue = TextTrimming.None)]
+ private TextTrimming watermarkTrimming;
- public string WatermarkText
- {
- get => (string)GetValue(WatermarkTextProperty);
- set => SetValue(WatermarkTextProperty, value);
- }
-
- public static readonly DependencyProperty WatermarkAlignmentProperty = DependencyProperty.Register(
- nameof(WatermarkAlignment),
- typeof(TextAlignment),
- typeof(DirectoryPicker),
- new PropertyMetadata(default(TextAlignment)));
+ [DependencyProperty(DefaultValue = "")]
+ private string defaultDirectory;
- public TextAlignment WatermarkAlignment
- {
- get => (TextAlignment)GetValue(WatermarkAlignmentProperty);
- set => SetValue(WatermarkAlignmentProperty, value);
- }
+ [DependencyProperty(DefaultValue = "")]
+ private string initialDirectory;
- public static readonly DependencyProperty WatermarkTrimmingProperty = DependencyProperty.Register(
- nameof(WatermarkTrimming),
- typeof(TextTrimming),
- typeof(DirectoryPicker),
- new PropertyMetadata(default(TextTrimming)));
-
- public TextTrimming WatermarkTrimming
- {
- get => (TextTrimming)GetValue(WatermarkTrimmingProperty);
- set => SetValue(WatermarkTrimmingProperty, value);
- }
-
- public static readonly DependencyProperty DefaultDirectoryProperty = DependencyProperty.Register(
- nameof(DefaultDirectory),
- typeof(string),
- typeof(DirectoryPicker),
- new PropertyMetadata(string.Empty));
-
- public string DefaultDirectory
- {
- get => (string)GetValue(DefaultDirectoryProperty);
- set => SetValue(DefaultDirectoryProperty, value);
- }
-
- public static readonly DependencyProperty InitialDirectoryProperty = DependencyProperty.Register(
- nameof(InitialDirectory),
- typeof(string),
- typeof(DirectoryPicker),
- new PropertyMetadata(string.Empty));
-
- public string InitialDirectory
- {
- get => (string)GetValue(InitialDirectoryProperty);
- set => SetValue(InitialDirectoryProperty, value);
- }
-
- public static readonly DependencyProperty RootDirectoryProperty = DependencyProperty.Register(
- nameof(RootDirectory),
- typeof(string),
- typeof(DirectoryPicker),
- new PropertyMetadata(string.Empty));
-
- public string RootDirectory
- {
- get => (string)GetValue(RootDirectoryProperty);
- set => SetValue(RootDirectoryProperty, value);
- }
+ [DependencyProperty(DefaultValue = "")]
+ private string rootDirectory;
public DirectoryPicker()
{
diff --git a/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs
index e4a6eb74..720c52bf 100644
--- a/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs
@@ -22,7 +22,7 @@ public event RoutedPropertyChangedEventHandler ValueChanged
typeof(FileInfo),
typeof(FilePicker),
new FrameworkPropertyMetadata(
- default(FileInfo?),
+ defaultValue: null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnValuePropertyChanged,
(o, value) => CoerceValue(o, value).Item1));
@@ -38,7 +38,7 @@ public FileInfo? Value
typeof(string),
typeof(FilePicker),
new FrameworkPropertyMetadata(
- default(string?),
+ defaultValue: null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnDisplayValuePropertyChanged,
(o, value) => CoerceDisplayValue(o, value).Item1));
@@ -49,138 +49,38 @@ public string? DisplayValue
set => SetValue(FullNameProperty, value);
}
- public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
- nameof(Title),
- typeof(string),
- typeof(FilePicker),
- new PropertyMetadata(default(string)));
-
- public string Title
- {
- get => (string)GetValue(TitleProperty);
- set => SetValue(TitleProperty, value);
- }
-
- public static readonly DependencyProperty ShowClearTextButtonProperty = DependencyProperty.Register(
- nameof(ShowClearTextButton),
- typeof(bool),
- typeof(FilePicker),
- new PropertyMetadata(BooleanBoxes.FalseBox));
-
- public bool ShowClearTextButton
- {
- get => (bool)GetValue(ShowClearTextButtonProperty);
- set => SetValue(ShowClearTextButtonProperty, value);
- }
-
- public static readonly DependencyProperty WatermarkTextProperty = DependencyProperty.Register(
- nameof(WatermarkText),
- typeof(string),
- typeof(FilePicker),
- new PropertyMetadata(defaultValue: string.Empty));
+ [DependencyProperty]
+ private string title;
- public string WatermarkText
- {
- get => (string)GetValue(WatermarkTextProperty);
- set => SetValue(WatermarkTextProperty, value);
- }
+ [DependencyProperty]
+ private bool showClearTextButton;
- public static readonly DependencyProperty WatermarkAlignmentProperty = DependencyProperty.Register(
- nameof(WatermarkAlignment),
- typeof(TextAlignment),
- typeof(FilePicker),
- new PropertyMetadata(default(TextAlignment)));
+ [DependencyProperty(DefaultValue = "")]
+ private string watermarkText;
- public TextAlignment WatermarkAlignment
- {
- get => (TextAlignment)GetValue(WatermarkAlignmentProperty);
- set => SetValue(WatermarkAlignmentProperty, value);
- }
+ [DependencyProperty(DefaultValue = TextAlignment.Left)]
+ private TextAlignment watermarkAlignment;
- public static readonly DependencyProperty WatermarkTrimmingProperty = DependencyProperty.Register(
- nameof(WatermarkTrimming),
- typeof(TextTrimming),
- typeof(FilePicker),
- new PropertyMetadata(default(TextTrimming)));
+ [DependencyProperty(DefaultValue = TextTrimming.None)]
+ private TextTrimming watermarkTrimming;
- public TextTrimming WatermarkTrimming
- {
- get => (TextTrimming)GetValue(WatermarkTrimmingProperty);
- set => SetValue(WatermarkTrimmingProperty, value);
- }
+ [DependencyProperty]
+ private bool allowOnlyExisting;
- public static readonly DependencyProperty AllowOnlyExistingProperty = DependencyProperty.Register(
- nameof(AllowOnlyExisting),
- typeof(bool),
- typeof(FilePicker),
- new PropertyMetadata(BooleanBoxes.FalseBox));
+ [DependencyProperty]
+ private bool usePreviewPane;
- public bool AllowOnlyExisting
- {
- get => (bool)GetValue(AllowOnlyExistingProperty);
- set => SetValue(AllowOnlyExistingProperty, value);
- }
+ [DependencyProperty(DefaultValue = "")]
+ private string filter;
- public static readonly DependencyProperty UsePreviewPaneProperty = DependencyProperty.Register(
- nameof(UsePreviewPane),
- typeof(bool),
- typeof(FilePicker),
- new PropertyMetadata(BooleanBoxes.FalseBox));
+ [DependencyProperty(DefaultValue = "")]
+ private string defaultDirectory;
- public bool UsePreviewPane
- {
- get => (bool)GetValue(UsePreviewPaneProperty);
- set => SetValue(UsePreviewPaneProperty, value);
- }
-
- public static readonly DependencyProperty FilterProperty = DependencyProperty.Register(
- nameof(Filter),
- typeof(string),
- typeof(FilePicker),
- new PropertyMetadata(string.Empty));
-
- public string Filter
- {
- get => (string)GetValue(FilterProperty);
- set => SetValue(FilterProperty, value);
- }
-
- public static readonly DependencyProperty DefaultDirectoryProperty = DependencyProperty.Register(
- nameof(DefaultDirectory),
- typeof(string),
- typeof(FilePicker),
- new PropertyMetadata(string.Empty));
-
- public string DefaultDirectory
- {
- get => (string)GetValue(DefaultDirectoryProperty);
- set => SetValue(DefaultDirectoryProperty, value);
- }
-
- public static readonly DependencyProperty InitialDirectoryProperty = DependencyProperty.Register(
- nameof(InitialDirectory),
- typeof(string),
- typeof(FilePicker),
- new PropertyMetadata(string.Empty));
-
- public string InitialDirectory
- {
- get => (string)GetValue(InitialDirectoryProperty);
- set => SetValue(InitialDirectoryProperty, value);
- }
-
- public static readonly DependencyProperty RootDirectoryProperty = DependencyProperty.Register(
- nameof(RootDirectory),
- typeof(string),
- typeof(FilePicker),
- new PropertyMetadata(string.Empty));
-
- public string RootDirectory
- {
- get => (string)GetValue(RootDirectoryProperty);
- set => SetValue(RootDirectoryProperty, value);
- }
+ [DependencyProperty(DefaultValue = "")]
+ private string initialDirectory;
+ [DependencyProperty(DefaultValue = "")]
+ private string rootDirectory;
public FilePicker()
{
InitializeComponent();
diff --git a/src/Atc.Wpf.Controls/BaseControls/ImageButton.cs b/src/Atc.Wpf.Controls/BaseControls/ImageButton.cs
index 7cb72ae4..e7244e9c 100644
--- a/src/Atc.Wpf.Controls/BaseControls/ImageButton.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/ImageButton.cs
@@ -1,130 +1,44 @@
-using Atc.Wpf.Controls.Progressing;
-
namespace Atc.Wpf.Controls.BaseControls;
-public sealed class ImageButton : Button
+public partial class ImageButton : Button
{
- public static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register(
- nameof(ImageWidth),
- typeof(int),
- typeof(ImageButton),
- new PropertyMetadata(16));
+ [DependencyProperty(
+ DefaultValue = null,
+ PropertyChangedCallback = nameof(OnImageLocationChanged))]
+ private ImageLocation? imageLocation;
- public int ImageWidth
- {
- get => (int)GetValue(ImageWidthProperty);
- set => SetValue(ImageWidthProperty, value);
- }
+ [DependencyProperty(DefaultValue = 16)]
+ private int imageWidth;
- public static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register(
- nameof(ImageHeight),
- typeof(int),
- typeof(ImageButton),
- new PropertyMetadata(16));
+ [DependencyProperty(DefaultValue = 16)]
+ private int imageHeight;
- public int ImageHeight
- {
- get => (int)GetValue(ImageHeightProperty);
- set => SetValue(ImageHeightProperty, value);
- }
+ [DependencyProperty(DefaultValue = 5d)]
+ private double imageContentSpacing;
- public static readonly DependencyProperty ImageLocationProperty = DependencyProperty.Register(
- nameof(ImageLocation),
- typeof(ImageLocation?),
- typeof(ImageButton),
- new PropertyMetadata(
- defaultValue: null,
- PropertyChangedCallback));
+ [DependencyProperty(DefaultValue = 0d)]
+ private double imageBorderSpacing;
- public ImageLocation? ImageLocation
- {
- get => (ImageLocation)GetValue(ImageLocationProperty);
- set => SetValue(ImageLocationProperty, value);
- }
+ [DependencyProperty]
+ private ImageSource? imageSource;
- public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
- nameof(ImageSource),
- typeof(ImageSource),
- typeof(ImageButton),
- new PropertyMetadata(defaultValue: default));
+ [DependencyProperty(DefaultValue = "")]
+ private string svgImageSource;
- public ImageSource ImageSource
- {
- get => (ImageSource)GetValue(ImageSourceProperty);
- set => SetValue(ImageSourceProperty, value);
- }
-
- public static readonly DependencyProperty SvgImageSourceProperty = DependencyProperty.Register(
- nameof(SvgImageSource),
- typeof(string),
- typeof(ImageButton),
- new PropertyMetadata(defaultValue: string.Empty));
+ [DependencyProperty]
+ private Color? svgImageOverrideColor;
- public string SvgImageSource
- {
- get => (string)GetValue(ImageSourceProperty);
- set => SetValue(ImageSourceProperty, value);
- }
+ [DependencyProperty]
+ private int rowIndex;
- public static readonly DependencyProperty SvgImageOverrideColorProperty = DependencyProperty.Register(
- nameof(SvgImageOverrideColor),
- typeof(Color?),
- typeof(ImageButton),
- new PropertyMetadata(default(Color?)));
-
- public Color? SvgImageOverrideColor
- {
- get => (Color?)GetValue(SvgImageOverrideColorProperty);
- set => SetValue(SvgImageOverrideColorProperty, value);
- }
+ [DependencyProperty]
+ private int columnIndex;
- public static readonly DependencyProperty RowIndexProperty = DependencyProperty.Register(
- nameof(RowIndex),
- typeof(int),
- typeof(ImageButton),
- new PropertyMetadata(0));
+ [DependencyProperty(DefaultValue = LoadingIndicatorType.ArcsRing)]
+ private LoadingIndicatorType loadingIndicatorMode;
- public int RowIndex
- {
- get => (int)GetValue(RowIndexProperty);
- set => SetValue(RowIndexProperty, value);
- }
-
- public static readonly DependencyProperty ColumnIndexProperty = DependencyProperty.Register(
- nameof(ColumnIndex),
- typeof(int),
- typeof(ImageButton),
- new PropertyMetadata(0));
-
- public int ColumnIndex
- {
- get => (int)GetValue(ColumnIndexProperty);
- set => SetValue(ColumnIndexProperty, value);
- }
-
- public static readonly DependencyProperty LoadingIndicatorModeProperty = DependencyProperty.Register(
- nameof(LoadingIndicatorMode),
- typeof(LoadingIndicatorType),
- typeof(ImageButton),
- new PropertyMetadata(LoadingIndicatorType.ArcsRing));
-
- public LoadingIndicatorType LoadingIndicatorMode
- {
- get => (LoadingIndicatorType)GetValue(LoadingIndicatorModeProperty);
- set => SetValue(LoadingIndicatorModeProperty, value);
- }
-
- public static readonly DependencyProperty IsBusyProperty = DependencyProperty.Register(
- nameof(IsBusy),
- typeof(bool),
- typeof(ImageButton),
- new PropertyMetadata(BooleanBoxes.FalseBox));
-
- public bool IsBusy
- {
- get => (bool)GetValue(IsBusyProperty);
- set => SetValue(IsBusyProperty, value);
- }
+ [DependencyProperty]
+ private bool isBusy;
static ImageButton()
{
@@ -135,10 +49,10 @@ static ImageButton()
public ImageButton()
{
- this.SetCurrentValue(ImageLocationProperty, Controls.ImageLocation.Left);
+ SetCurrentValue(ImageLocationProperty, Controls.ImageLocation.Left);
}
- private static void PropertyChangedCallback(
+ private static void OnImageLocationChanged(
DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
diff --git a/src/Atc.Wpf.Controls/BaseControls/ImageButton.xaml b/src/Atc.Wpf.Controls/BaseControls/ImageButton.xaml
index 9a7fa299..7d3bd52c 100644
--- a/src/Atc.Wpf.Controls/BaseControls/ImageButton.xaml
+++ b/src/Atc.Wpf.Controls/BaseControls/ImageButton.xaml
@@ -9,6 +9,9 @@
+
+
+
@@ -35,34 +38,56 @@
x:Name="PART_LoadingIndicator"
Width="{Binding Path=ImageWidth, RelativeSource={RelativeSource AncestorType=baseControls:ImageButton}}"
Height="{Binding Path=ImageHeight, RelativeSource={RelativeSource AncestorType=baseControls:ImageButton}}"
- Margin="{Binding Path=ImageLocation, RelativeSource={RelativeSource AncestorType=baseControls:ImageButton}, Converter={x:Static valueConverters:ImageLocationToMarginValueConverter.Instance}}"
Padding="2"
IsActive="False"
Mode="{Binding Path=LoadingIndicatorMode, RelativeSource={RelativeSource AncestorType=baseControls:ImageButton}}"
- Visibility="Collapsed" />
+ Visibility="Collapsed">
+
+
+
+
+
+
+
+
+ Visibility="Collapsed">
+
+
+
+
+
+
+
+
+ Visibility="Collapsed">
+
+
+
+
+
+
+
+
+
@@ -89,6 +115,7 @@
+
@@ -99,11 +126,17 @@
+
+
+
+
+
+
+ Source="{Binding ImageSource, RelativeSource={RelativeSource AncestorType=baseControls:ImageButton}}">
+
+
+
+
+
+
+
+
ApplyVisualState(IsToggled);
+ }
+
+ protected override void OnClick()
+ {
+ base.OnClick();
+
+ IsToggled = !IsToggled;
+
+ ExecuteCurrentCommand();
+ }
+
+ private static void OnToggledChanged(
+ DependencyObject d,
+ DependencyPropertyChangedEventArgs e)
+ {
+ var ctl = (ImageToggledButton)d;
+ ctl.ApplyVisualState((bool)e.NewValue);
+ }
+
+ private void ApplyVisualState(
+ bool toggled)
+ {
+ if (toggled)
+ {
+ // ON state
+ if (OnContent is not null)
+ {
+ SetCurrentValue(ContentProperty, OnContent);
+ }
+
+ if (OnImageSource is not null)
+ {
+ SetCurrentValue(ImageSourceProperty, OnImageSource);
+ }
+
+ if (!string.IsNullOrEmpty(OnSvgImageSource))
+ {
+ SetCurrentValue(SvgImageSourceProperty, OnSvgImageSource);
+ }
+
+ if (OnSvgImageOverrideColor is not null)
+ {
+ SetCurrentValue(SvgImageOverrideColorProperty, OnSvgImageOverrideColor);
+ }
+ }
+ else
+ {
+ // OFF state
+ if (OffContent is not null)
+ {
+ SetCurrentValue(ContentProperty, OffContent);
+ }
+
+ if (OffImageSource is not null)
+ {
+ SetCurrentValue(ImageSourceProperty, OffImageSource);
+ }
+
+ if (!string.IsNullOrEmpty(OffSvgImageSource))
+ {
+ SetCurrentValue(SvgImageSourceProperty, OffSvgImageSource);
+ }
+
+ if (OffSvgImageOverrideColor is not null)
+ {
+ SetCurrentValue(SvgImageOverrideColorProperty, OffSvgImageOverrideColor);
+ }
+ }
+ }
+
+ private void ExecuteCurrentCommand()
+ {
+ var cmd = IsToggled
+ ? OffCommand
+ : OnCommand;
+
+ if (cmd?.CanExecute(parameter: null) == true)
+ {
+ cmd.Execute(parameter: null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginMultiValueConverter.cs b/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginMultiValueConverter.cs
new file mode 100644
index 00000000..a685f164
--- /dev/null
+++ b/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginMultiValueConverter.cs
@@ -0,0 +1,67 @@
+namespace Atc.Wpf.Controls.BaseControls.Internal.ValueConverters;
+
+///
+/// ValueConverter: ImageLocation to Thickness (Margin).
+///
+[ValueConversion(typeof(ImageLocation), typeof(Thickness))]
+internal sealed class ImageLocationToMarginMultiValueConverter : IMultiValueConverter
+{
+ public static readonly ImageLocationToMarginMultiValueConverter Instance = new();
+
+ public double SpacingToContent { get; set; } = 5.0;
+
+ public double SpacingToBorder { get; set; } = 1.0;
+
+ public object Convert(
+ object[] values,
+ Type targetType,
+ object? parameter,
+ CultureInfo culture)
+ {
+ if (values.Length < 1 || values[0] is not ImageLocation imageLocation)
+ {
+ return new Thickness(0);
+ }
+
+ var spacingToContent = SpacingToContent;
+ if (values.Length > 1)
+ {
+ spacingToContent = values[1] switch
+ {
+ double d => d,
+ string s when double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var parsed) =>
+ parsed,
+ _ => SpacingToContent,
+ };
+ }
+
+ var spacingToBorder = SpacingToBorder;
+ if (values.Length > 2)
+ {
+ spacingToBorder = values[2] switch
+ {
+ double d => d,
+ string s when double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var parsed) =>
+ parsed,
+ _ => SpacingToBorder,
+ };
+ }
+
+ return imageLocation switch
+ {
+ ImageLocation.Left => new Thickness(spacingToBorder, 0, spacingToContent, 0),
+ ImageLocation.Top => new Thickness(0, spacingToBorder, 0, spacingToContent),
+ ImageLocation.Right => new Thickness(spacingToContent, 0, spacingToBorder, 0),
+ ImageLocation.Bottom => new Thickness(0, spacingToContent, 0, spacingToBorder),
+ ImageLocation.Center => new Thickness(0, 0, 0, 0),
+ _ => throw new SwitchCaseDefaultException(imageLocation),
+ };
+ }
+
+ public object[] ConvertBack(
+ object? value,
+ Type[] targetTypes,
+ object? parameter,
+ CultureInfo culture)
+ => throw new NotSupportedException("This is a OneWay converter.");
+}
\ No newline at end of file
diff --git a/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs b/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs
index e2609644..e9d28324 100644
--- a/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs
@@ -8,6 +8,8 @@ internal sealed class ImageLocationToMarginValueConverter : IValueConverter
{
public static readonly ImageLocationToMarginValueConverter Instance = new();
+ public double Spacing { get; set; } = 5.0;
+
public object Convert(
object? value,
Type targetType,
@@ -19,12 +21,20 @@ public object Convert(
throw new InvalidEnumArgumentException(nameof(value), 0, typeof(ImageLocation));
}
+ var spacing = parameter switch
+ {
+ double d => d,
+ string s when double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var parsed) =>
+ parsed,
+ _ => Spacing,
+ };
+
return imageLocation switch
{
- ImageLocation.Left => new Thickness(0, 0, 5, 0),
- ImageLocation.Top => new Thickness(0, 0, 0, 5),
- ImageLocation.Right => new Thickness(5, 0, 0, 0),
- ImageLocation.Bottom => new Thickness(0, 5, 0, 0),
+ ImageLocation.Left => new Thickness(0, 0, spacing, 0),
+ ImageLocation.Top => new Thickness(0, 0, 0, spacing),
+ ImageLocation.Right => new Thickness(spacing, 0, 0, 0),
+ ImageLocation.Bottom => new Thickness(0, spacing, 0, 0),
ImageLocation.Center => new Thickness(0, 0, 0, 0),
_ => throw new SwitchCaseDefaultException(imageLocation),
};
diff --git a/src/Atc.Wpf.Controls/BaseControls/NumericBox.cs b/src/Atc.Wpf.Controls/BaseControls/NumericBox.cs
index 8675564f..0b096c69 100644
--- a/src/Atc.Wpf.Controls/BaseControls/NumericBox.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/NumericBox.cs
@@ -9,7 +9,7 @@ namespace Atc.Wpf.Controls.BaseControls;
[TemplatePart(Name = PART_NumericDown, Type = typeof(RepeatButton))]
[TemplatePart(Name = PART_TextBox, Type = typeof(TextBox))]
[StyleTypedProperty(Property = nameof(SpinButtonStyle), StyleTargetType = typeof(ButtonBase))]
-public class NumericBox : Control
+public partial class NumericBox : Control
{
private const string PART_NumericDown = "PART_NumericDownButton";
private const string PART_NumericUp = "PART_NumericUpButton";
@@ -34,92 +34,29 @@ public class NumericBox : Control
private TextBox? valueTextBox;
private ScrollViewer? scrollViewer;
- public static readonly RoutedEvent ValueIncrementedEvent = EventManager.RegisterRoutedEvent(
- nameof(ValueIncremented),
- RoutingStrategy.Bubble,
- typeof(NumericBoxChangedRoutedEventHandler),
- typeof(NumericBox));
+ [RoutedEvent(HandlerType = typeof(NumericBoxChangedRoutedEventHandler))]
+ private static readonly RoutedEvent valueIncremented;
- public event NumericBoxChangedRoutedEventHandler ValueIncremented
- {
- add => AddHandler(ValueIncrementedEvent, value);
- remove => RemoveHandler(ValueIncrementedEvent, value);
- }
+ [RoutedEvent(HandlerType = typeof(NumericBoxChangedRoutedEventHandler))]
+ private static readonly RoutedEvent valueDecremented;
- public static readonly RoutedEvent ValueDecrementedEvent = EventManager.RegisterRoutedEvent(
- nameof(ValueDecremented),
- RoutingStrategy.Bubble,
- typeof(NumericBoxChangedRoutedEventHandler),
- typeof(NumericBox));
+ [RoutedEvent]
+ private static readonly RoutedEvent delayChanged;
- public event NumericBoxChangedRoutedEventHandler ValueDecremented
- {
- add => AddHandler(ValueDecrementedEvent, value);
- remove => RemoveHandler(ValueDecrementedEvent, value);
- }
+ [RoutedEvent]
+ private static readonly RoutedEvent maximumReached;
- public static readonly RoutedEvent DelayChangedEvent = EventManager.RegisterRoutedEvent(
- nameof(DelayChanged),
- RoutingStrategy.Bubble,
- typeof(RoutedEventHandler),
- typeof(NumericBox));
+ [RoutedEvent]
+ private static readonly RoutedEvent minimumReached;
- public event RoutedEventHandler DelayChanged
- {
- add => AddHandler(DelayChangedEvent, value);
- remove => RemoveHandler(DelayChangedEvent, value);
- }
+ [RoutedEvent(HandlerType = typeof(RoutedPropertyChangedEventHandler))]
+ private static readonly RoutedEvent valueChanged;
- public static readonly RoutedEvent MaximumReachedEvent = EventManager.RegisterRoutedEvent(
- nameof(MaximumReached),
- RoutingStrategy.Bubble,
- typeof(RoutedEventHandler),
- typeof(NumericBox));
-
- public event RoutedEventHandler MaximumReached
- {
- add => AddHandler(MaximumReachedEvent, value);
- remove => RemoveHandler(MaximumReachedEvent, value);
- }
-
- public static readonly RoutedEvent MinimumReachedEvent = EventManager.RegisterRoutedEvent(
- nameof(MinimumReached),
- RoutingStrategy.Bubble,
- typeof(RoutedEventHandler),
- typeof(NumericBox));
-
- public event RoutedEventHandler MinimumReached
- {
- add => AddHandler(MinimumReachedEvent, value);
- remove => RemoveHandler(MinimumReachedEvent, value);
- }
-
- public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent(
- nameof(ValueChanged),
- RoutingStrategy.Bubble,
- typeof(RoutedPropertyChangedEventHandler),
- typeof(NumericBox));
-
- public event RoutedPropertyChangedEventHandler ValueChanged
- {
- add => AddHandler(ValueChangedEvent, value);
- remove => RemoveHandler(ValueChangedEvent, value);
- }
-
- public static readonly DependencyProperty DelayProperty = DependencyProperty.Register(
- nameof(Delay),
- typeof(int),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- DefaultDelay,
- OnDelayPropertyChanged),
- value => Convert.ToInt32(value, GlobalizationConstants.EnglishCultureInfo) >= 0);
-
- public int Delay
- {
- get => (int)GetValue(DelayProperty);
- set => SetValue(DelayProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = DefaultDelay,
+ PropertyChangedCallback = nameof(OnDelayPropertyChanged),
+ ValidateValueCallback = nameof(ValidateDefaultDelay))]
+ private int delay;
public static readonly DependencyProperty TextAlignmentProperty = TextBox.TextAlignmentProperty.AddOwner(typeof(NumericBox));
@@ -129,19 +66,10 @@ public TextAlignment TextAlignment
set => SetValue(TextAlignmentProperty, value);
}
- public static readonly DependencyProperty SpeedupProperty = DependencyProperty.Register(
- nameof(Speedup),
- typeof(bool),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- BooleanBoxes.TrueBox,
- OnSpeedupPropertyChanged));
-
- public bool Speedup
- {
- get => (bool)GetValue(SpeedupProperty);
- set => SetValue(SpeedupProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(
+ DefaultValue = true,
+ PropertyChangedCallback = nameof(OnSpeedupPropertyChanged))]
+ private bool speedup;
public static readonly DependencyProperty IsReadOnlyProperty = TextBoxBase.IsReadOnlyProperty.AddOwner(
typeof(NumericBox),
@@ -156,394 +84,122 @@ public bool IsReadOnly
set => SetValue(IsReadOnlyProperty, BooleanBoxes.Box(value));
}
- public static readonly DependencyProperty StringFormatProperty = DependencyProperty.Register(
- nameof(StringFormat),
- typeof(string),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- string.Empty,
- OnStringFormatPropertyChanged,
- CoerceStringFormat));
-
- public string StringFormat
- {
- get => (string)GetValue(StringFormatProperty);
- set => SetValue(StringFormatProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = "",
+ PropertyChangedCallback = nameof(OnStringFormatPropertyChanged),
+ CoerceValueCallback = nameof(CoerceStringFormat))]
+ private string stringFormat;
- public static readonly DependencyProperty InterceptArrowKeysProperty = DependencyProperty.Register(
- nameof(InterceptArrowKeys),
- typeof(bool),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(DefaultValue = true)]
+ private bool interceptArrowKeys;
- public bool InterceptArrowKeys
- {
- get => (bool)GetValue(InterceptArrowKeysProperty);
- set => SetValue(InterceptArrowKeysProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(DefaultValue = true)]
+ private bool interceptMouseWheel;
- public static readonly DependencyProperty InterceptMouseWheelProperty = DependencyProperty.Register(
- nameof(InterceptMouseWheel),
- typeof(bool),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(
+ DefaultValue = true,
+ PropertyChangedCallback = nameof(OnInterceptManualEnterPropertyChanged))]
+ private bool interceptManualEnter;
- public bool InterceptMouseWheel
- {
- get => (bool)GetValue(InterceptMouseWheelProperty);
- set => SetValue(InterceptMouseWheelProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
+ PropertyChangedCallback = nameof(OnValuePropertyChanged),
+ CoerceValueCallback = nameof(CoerceValueItem1))]
+ private double? value;
- public static readonly DependencyProperty InterceptManualEnterProperty = DependencyProperty.Register(
- nameof(InterceptManualEnter),
- typeof(bool),
- typeof(NumericBox),
- new PropertyMetadata(
- BooleanBoxes.TrueBox,
- OnInterceptManualEnterPropertyChanged));
+ [DependencyProperty(
+ PropertyChangedCallback = nameof(OnDefaultValuePropertyChanged),
+ CoerceValueCallback = nameof(CoerceDefaultValue))]
+ private double? defaultValue;
- public bool InterceptManualEnter
- {
- get => (bool)GetValue(InterceptManualEnterProperty);
- set => SetValue(InterceptManualEnterProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(
+ DefaultValue = double.MinValue,
+ PropertyChangedCallback = nameof(OnMinimumPropertyChanged))]
+ private double minimum;
- public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
- nameof(Value),
- typeof(double?),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- default(double?),
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
- OnValuePropertyChanged,
- (o, value) => CoerceValue(o, value).Item1));
+ [DependencyProperty(
+ DefaultValue = double.MaxValue,
+ PropertyChangedCallback = nameof(OnMaximumPropertyChanged),
+ CoerceValueCallback = nameof(CoerceMaximum))]
+ private double maximum;
- [SuppressMessage("Naming", "CA1721:Property names should not match get methods", Justification = "OK.")]
- public double? Value
- {
- get => (double?)GetValue(ValueProperty);
- set => SetValue(ValueProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = DefaultInterval,
+ PropertyChangedCallback = nameof(OnIntervalPropertyChanged))]
+ private double interval;
- public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register(
- nameof(DefaultValue),
- typeof(double?),
- typeof(NumericBox),
- new PropertyMetadata(
- defaultValue: null,
- OnDefaultValuePropertyChanged,
- CoerceDefaultValue));
+ [DependencyProperty(DefaultValue = true)]
+ private bool trackMouseWheelWhenMouseOver;
- public double? DefaultValue
- {
- get => (double?)GetValue(DefaultValueProperty);
- set => SetValue(DefaultValueProperty, value);
- }
+ [DependencyProperty]
+ private Style? spinButtonStyle;
- public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(
- nameof(Minimum),
- typeof(double),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- double.MinValue,
- OnMinimumPropertyChanged));
+ [DependencyProperty(
+ DefaultValue = ButtonsAlignment.Right,
+ Flags = FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)]
+ private ButtonsAlignment buttonsAlignment;
- public double Minimum
- {
- get => (double)GetValue(MinimumProperty);
- set => SetValue(MinimumProperty, value);
- }
+ [DependencyProperty(DefaultValue = false)]
+ private bool hideUpDownButtons;
- public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
- nameof(Maximum),
- typeof(double),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- double.MaxValue,
- OnMaximumPropertyChanged,
- CoerceMaximum));
+ [DependencyProperty(DefaultValue = "new Thickness(0, -0.5, -0.5, 0)")]
+ private Thickness upDownButtonsMargin;
- public double Maximum
- {
- get => (double)GetValue(MaximumProperty);
- set => SetValue(MaximumProperty, value);
- }
+ [DependencyProperty(DefaultValue = 20d)]
+ private double upDownButtonsWidth;
- public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register(
- nameof(Interval),
- typeof(double),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- DefaultInterval,
- OnIntervalPropertyChanged));
+ [DependencyProperty(DefaultValue = true)]
+ private bool upDownButtonsFocusable;
- public double Interval
- {
- get => (double)GetValue(IntervalProperty);
- set => SetValue(IntervalProperty, value);
- }
+ [DependencyProperty(DefaultValue = false)]
+ private bool switchUpDownButtons;
- public static readonly DependencyProperty TrackMouseWheelWhenMouseOverProperty = DependencyProperty.Register(
- nameof(TrackMouseWheelWhenMouseOver),
- typeof(bool),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(BooleanBoxes.FalseBox));
+ [DependencyProperty]
+ private object? buttonUpContent;
- public bool TrackMouseWheelWhenMouseOver
- {
- get => (bool)GetValue(TrackMouseWheelWhenMouseOverProperty);
- set => SetValue(TrackMouseWheelWhenMouseOverProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty]
+ private DataTemplate? buttonUpContentTemplate;
- public static readonly DependencyProperty SpinButtonStyleProperty = DependencyProperty.Register(
- nameof(SpinButtonStyle),
- typeof(Style),
- typeof(NumericBox),
- new PropertyMetadata(propertyChangedCallback: null));
+ [DependencyProperty]
+ private string? buttonUpContentStringFormat;
- public Style? SpinButtonStyle
- {
- get => (Style?)GetValue(SpinButtonStyleProperty);
- set => SetValue(SpinButtonStyleProperty, value);
- }
+ [DependencyProperty]
+ private object? buttonDownContent;
- public static readonly DependencyProperty ButtonsAlignmentProperty = DependencyProperty.Register(
- nameof(ButtonsAlignment),
- typeof(ButtonsAlignment),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- ButtonsAlignment.Right,
- FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ [DependencyProperty]
+ private DataTemplate? buttonDownContentTemplate;
- public ButtonsAlignment ButtonsAlignment
- {
- get => (ButtonsAlignment)GetValue(ButtonsAlignmentProperty);
- set => SetValue(ButtonsAlignmentProperty, value);
- }
+ [DependencyProperty]
+ private string? buttonDownContentStringFormat;
- public static readonly DependencyProperty HideUpDownButtonsProperty = DependencyProperty.Register(
- nameof(HideUpDownButtons),
- typeof(bool),
- typeof(NumericBox),
- new PropertyMetadata(BooleanBoxes.FalseBox));
+ [DependencyProperty(PropertyChangedCallback = nameof(OnCulturePropertyChanged))]
+ private CultureInfo? culture;
- public bool HideUpDownButtons
- {
- get => (bool)GetValue(HideUpDownButtonsProperty);
- set => SetValue(HideUpDownButtonsProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(
+ DefaultValue = NumericInput.All,
+ PropertyChangedCallback = nameof(OnNumericInputModePropertyChanged))]
+ private NumericInput numericInputMode;
- public static readonly DependencyProperty UpDownButtonsMarginProperty = DependencyProperty.Register(
- nameof(UpDownButtonsMargin),
- typeof(Thickness),
- typeof(NumericBox),
- new PropertyMetadata(new Thickness(0, -0.5, -0.5, 0)));
+ [DependencyProperty(DefaultValue = DecimalPointCorrectionMode.Inherits)]
+ private DecimalPointCorrectionMode decimalPointCorrection;
- public Thickness UpDownButtonsMargin
- {
- get => (Thickness)GetValue(UpDownButtonsMarginProperty);
- set => SetValue(UpDownButtonsMarginProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = false,
+ PropertyChangedCallback = nameof(OnSnapToMultipleOfIntervalPropertyChanged))]
+ private bool snapToMultipleOfInterval;
- public static readonly DependencyProperty UpDownButtonsWidthProperty = DependencyProperty.Register(
- nameof(UpDownButtonsWidth),
- typeof(double),
- typeof(NumericBox),
- new PropertyMetadata(20d));
+ [DependencyProperty(DefaultValue = NumberStyles.Any)]
+ private NumberStyles parsingNumberStyle;
- public double UpDownButtonsWidth
- {
- get => (double)GetValue(UpDownButtonsWidthProperty);
- set => SetValue(UpDownButtonsWidthProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = "",
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private string prefixText;
- public static readonly DependencyProperty UpDownButtonsFocusableProperty = DependencyProperty.Register(
- nameof(UpDownButtonsFocusable),
- typeof(bool),
- typeof(NumericBox),
- new PropertyMetadata(BooleanBoxes.TrueBox));
-
- public bool UpDownButtonsFocusable
- {
- get => (bool)GetValue(UpDownButtonsFocusableProperty);
- set => SetValue(UpDownButtonsFocusableProperty, BooleanBoxes.Box(value));
- }
-
- public static readonly DependencyProperty SwitchUpDownButtonsProperty = DependencyProperty.Register(
- nameof(SwitchUpDownButtons),
- typeof(bool),
- typeof(NumericBox),
- new PropertyMetadata(BooleanBoxes.FalseBox));
-
- public bool SwitchUpDownButtons
- {
- get => (bool)GetValue(SwitchUpDownButtonsProperty);
- set => SetValue(SwitchUpDownButtonsProperty, BooleanBoxes.Box(value));
- }
-
- public static readonly DependencyProperty ButtonUpContentProperty = DependencyProperty.Register(
- nameof(ButtonUpContent),
- typeof(object),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(propertyChangedCallback: null));
-
- public object? ButtonUpContent
- {
- get => GetValue(ButtonUpContentProperty);
- set => SetValue(ButtonUpContentProperty, value);
- }
-
- public static readonly DependencyProperty ButtonUpContentTemplateProperty = DependencyProperty.Register(
- nameof(ButtonUpContentTemplate),
- typeof(DataTemplate),
- typeof(NumericBox));
-
- public DataTemplate? ButtonUpContentTemplate
- {
- get => (DataTemplate?)GetValue(ButtonUpContentTemplateProperty);
- set => SetValue(ButtonUpContentTemplateProperty, value);
- }
-
- public static readonly DependencyProperty ButtonUpContentStringFormatProperty = DependencyProperty.Register(
- nameof(ButtonUpContentStringFormat),
- typeof(string),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(propertyChangedCallback: null));
-
- public string? ButtonUpContentStringFormat
- {
- get => (string?)GetValue(ButtonUpContentStringFormatProperty);
- set => SetValue(ButtonUpContentStringFormatProperty, value);
- }
-
- public static readonly DependencyProperty ButtonDownContentProperty = DependencyProperty.Register(
- nameof(ButtonDownContent),
- typeof(object),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(propertyChangedCallback: null));
-
- public object? ButtonDownContent
- {
- get => GetValue(ButtonDownContentProperty);
- set => SetValue(ButtonDownContentProperty, value);
- }
-
- public static readonly DependencyProperty ButtonDownContentTemplateProperty = DependencyProperty.Register(
- nameof(ButtonDownContentTemplate),
- typeof(DataTemplate),
- typeof(NumericBox));
-
- public DataTemplate? ButtonDownContentTemplate
- {
- get => (DataTemplate?)GetValue(ButtonDownContentTemplateProperty);
- set => SetValue(ButtonDownContentTemplateProperty, value);
- }
-
- public static readonly DependencyProperty ButtonDownContentStringFormatProperty = DependencyProperty.Register(
- nameof(ButtonDownContentStringFormat),
- typeof(string),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(propertyChangedCallback: null));
-
- public string? ButtonDownContentStringFormat
- {
- get => (string?)GetValue(ButtonDownContentStringFormatProperty);
- set => SetValue(ButtonDownContentStringFormatProperty, value);
- }
-
- public static readonly DependencyProperty CultureProperty = DependencyProperty.Register(
- nameof(Culture),
- typeof(CultureInfo),
- typeof(NumericBox),
- new PropertyMetadata(
- defaultValue: null,
- OnCulturePropertyChanged));
-
- public CultureInfo? Culture
- {
- get => (CultureInfo?)GetValue(CultureProperty);
- set => SetValue(CultureProperty, value);
- }
-
- public static readonly DependencyProperty NumericInputModeProperty = DependencyProperty.Register(
- nameof(NumericInputMode),
- typeof(NumericInput),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- NumericInput.All, OnNumericInputModePropertyChanged));
-
- public NumericInput NumericInputMode
- {
- get => (NumericInput)GetValue(NumericInputModeProperty);
- set => SetValue(NumericInputModeProperty, value);
- }
-
- public static readonly DependencyProperty DecimalPointCorrectionProperty = DependencyProperty.Register(
- nameof(DecimalPointCorrection),
- typeof(DecimalPointCorrectionMode),
- typeof(NumericBox),
- new PropertyMetadata(default(DecimalPointCorrectionMode)));
-
- public DecimalPointCorrectionMode DecimalPointCorrection
- {
- get => (DecimalPointCorrectionMode)GetValue(DecimalPointCorrectionProperty);
- set => SetValue(DecimalPointCorrectionProperty, value);
- }
-
- public static readonly DependencyProperty SnapToMultipleOfIntervalProperty = DependencyProperty.Register(
- nameof(SnapToMultipleOfInterval),
- typeof(bool),
- typeof(NumericBox),
- new PropertyMetadata(
- BooleanBoxes.FalseBox,
- OnSnapToMultipleOfIntervalPropertyChanged));
-
- public bool SnapToMultipleOfInterval
- {
- get => (bool)GetValue(SnapToMultipleOfIntervalProperty);
- set => SetValue(SnapToMultipleOfIntervalProperty, BooleanBoxes.Box(value));
- }
-
- public static readonly DependencyProperty ParsingNumberStyleProperty = DependencyProperty.Register(
- nameof(ParsingNumberStyle),
- typeof(NumberStyles),
- typeof(NumericBox),
- new PropertyMetadata(NumberStyles.Any));
-
- public NumberStyles ParsingNumberStyle
- {
- get => (NumberStyles)GetValue(ParsingNumberStyleProperty);
- set => SetValue(ParsingNumberStyleProperty, value);
- }
-
- public static readonly DependencyProperty PrefixTextProperty = DependencyProperty.Register(
- nameof(PrefixText),
- typeof(string),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- string.Empty,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public string PrefixText
- {
- get => (string)GetValue(PrefixTextProperty);
- set => SetValue(PrefixTextProperty, value);
- }
-
- public static readonly DependencyProperty SuffixTextProperty = DependencyProperty.Register(
- nameof(SuffixText),
- typeof(string),
- typeof(NumericBox),
- new FrameworkPropertyMetadata(
- string.Empty,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
-
- public string SuffixText
- {
- get => (string)GetValue(SuffixTextProperty);
- set => SetValue(SuffixTextProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = "",
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)]
+ private string suffixText;
private CultureInfo SpecificCultureInfo => Culture ?? Language.GetSpecificCulture();
@@ -686,24 +342,31 @@ private static void OnValuePropertyChanged(
return new Tuple(numericBox.DefaultValue, item2: false);
}
- var value = ((double?)baseValue).Value;
+ var val = ((double?)baseValue).Value;
if (!numericBox.NumericInputMode.HasFlag(NumericInput.Decimal))
{
- value = System.Math.Truncate(value);
+ val = System.Math.Truncate(val);
}
- if (value < numericBox.Minimum)
+ if (val < numericBox.Minimum)
{
return new Tuple(numericBox.Minimum, item2: true);
}
- if (value > numericBox.Maximum)
+ if (val > numericBox.Maximum)
{
return new Tuple(numericBox.Maximum, item2: true);
}
- return new Tuple(value, item2: false);
+ return new Tuple(val, item2: false);
+ }
+
+ private static object? CoerceValueItem1(
+ DependencyObject d,
+ object? baseValue)
+ {
+ return CoerceValue(d, baseValue).Item1;
}
private static void OnDefaultValuePropertyChanged(
@@ -727,17 +390,17 @@ private static void OnDefaultValuePropertyChanged(
return baseValue;
}
- var minimum = ((NumericBox)d).Minimum;
- var maximum = ((NumericBox)d).Maximum;
+ var minimumValue = ((NumericBox)d).Minimum;
+ var maximumValue = ((NumericBox)d).Maximum;
- if (val < minimum)
+ if (val < minimumValue)
{
- return minimum;
+ return minimumValue;
}
- if (val > maximum)
+ if (val > maximumValue)
{
- return maximum;
+ return maximumValue;
}
return baseValue;
@@ -772,10 +435,10 @@ private static object CoerceMaximum(
DependencyObject d,
object value)
{
- var minimum = ((NumericBox)d).Minimum;
+ var minimumValue = ((NumericBox)d).Minimum;
var val = (double)value;
- return val < minimum
- ? minimum
+ return val < minimumValue
+ ? minimumValue
: val;
}
@@ -837,8 +500,8 @@ e.NewValue is not bool snap ||
return;
}
- var value = numericBox.Value.GetValueOrDefault();
- numericBox.Value = System.Math.Round(value / numericBox.Interval) * numericBox.Interval;
+ var val = numericBox.Value.GetValueOrDefault();
+ numericBox.Value = System.Math.Round(val / numericBox.Interval) * numericBox.Interval;
}
private static void OnGotFocus(
@@ -1142,6 +805,11 @@ protected virtual void OnValueChanged(
}
}
+ private static bool ValidateDefaultDelay(
+ object value)
+ => value is int intValue &&
+ Convert.ToInt32(intValue, GlobalizationConstants.EnglishCultureInfo) >= 0;
+
private void InternalSetText(
double? newValue)
{
@@ -1293,7 +961,7 @@ private void ChangeValueWithSpeedUp(
}
private void ChangeValueInternal(
- double interval)
+ double interVal)
{
if (IsReadOnly)
{
@@ -1302,7 +970,9 @@ private void ChangeValueInternal(
manualChange = false;
- var routedEvent = interval > 0 ? new NumericBoxChangedRoutedEventArgs(ValueIncrementedEvent, interval) : new NumericBoxChangedRoutedEventArgs(ValueDecrementedEvent, interval);
+ var routedEvent = interVal > 0
+ ? new NumericBoxChangedRoutedEventArgs(ValueIncrementedEvent, interVal)
+ : new NumericBoxChangedRoutedEventArgs(ValueDecrementedEvent, interVal);
RaiseEvent(routedEvent);
@@ -1331,23 +1001,23 @@ private void ChangeValueBy(
private void SetValueTo(
double newValue)
{
- var value = newValue;
+ var val = newValue;
if (SnapToMultipleOfInterval && System.Math.Abs(Interval) > 0)
{
- value = System.Math.Round(newValue / Interval) * Interval;
+ val = System.Math.Round(newValue / Interval) * Interval;
}
- if (value > Maximum)
+ if (val > Maximum)
{
- value = Maximum;
+ val = Maximum;
}
- else if (value < Minimum)
+ else if (val < Minimum)
{
- value = Minimum;
+ val = Minimum;
}
- SetCurrentValue(ValueProperty, CoerceValue(this, value).Item1);
+ SetCurrentValue(ValueProperty, CoerceValue(this, val).Item1);
}
private void EnableDisableDown()
@@ -1400,10 +1070,10 @@ Key.OemComma or
var correctionMode = DecimalPointCorrection;
// And the culture of the NUD
- var culture = SpecificCultureInfo;
+ var cultureInfo = SpecificCultureInfo;
// Surrogate the blocked key pressed
- SimulateDecimalPointKeyPress(textBox, correctionMode, culture);
+ SimulateDecimalPointKeyPress(textBox, correctionMode, cultureInfo);
}
private static void SimulateDecimalPointKeyPress(
diff --git a/src/Atc.Wpf.Controls/BaseControls/NumericBoxChangedRoutedEventArgs.cs b/src/Atc.Wpf.Controls/BaseControls/NumericBoxChangedRoutedEventArgs.cs
index 4220a3d0..eefb9082 100644
--- a/src/Atc.Wpf.Controls/BaseControls/NumericBoxChangedRoutedEventArgs.cs
+++ b/src/Atc.Wpf.Controls/BaseControls/NumericBoxChangedRoutedEventArgs.cs
@@ -1,14 +1,9 @@
namespace Atc.Wpf.Controls.BaseControls;
-public sealed class NumericBoxChangedRoutedEventArgs : RoutedEventArgs
+public sealed class NumericBoxChangedRoutedEventArgs(
+ RoutedEvent routedEvent,
+ double interval)
+ : RoutedEventArgs(routedEvent)
{
- public double Interval { get; set; }
-
- public NumericBoxChangedRoutedEventArgs(
- RoutedEvent routedEvent,
- double interval)
- : base(routedEvent)
- {
- Interval = interval;
- }
+ public double Interval { get; set; } = interval;
}
\ No newline at end of file
diff --git a/src/Atc.Wpf.Controls/GlobalUsings.cs b/src/Atc.Wpf.Controls/GlobalUsings.cs
index 95749b7c..25022486 100644
--- a/src/Atc.Wpf.Controls/GlobalUsings.cs
+++ b/src/Atc.Wpf.Controls/GlobalUsings.cs
@@ -59,6 +59,7 @@
global using Atc.Wpf.Controls.Notifications;
global using Atc.Wpf.Controls.Notifications.Messages;
global using Atc.Wpf.Controls.Options;
+global using Atc.Wpf.Controls.Progressing;
global using Atc.Wpf.Controls.Progressing.Internal;
global using Atc.Wpf.Controls.Resources;
global using Atc.Wpf.Controls.Selectors;
@@ -73,6 +74,7 @@
global using Atc.Wpf.Theming.Themes.Dialogs;
global using Atc.Wpf.Translation;
global using Atc.Wpf.ValueConverters;
+global using Atc.XamlToolkit;
global using Atc.XamlToolkit.Command;
global using Atc.XamlToolkit.Controls.Attributes;
global using Atc.XamlToolkit.Messaging;
diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelCheckBox.xaml.cs b/src/Atc.Wpf.Controls/LabelControls/LabelCheckBox.xaml.cs
index c9a6043a..cfb2c5fe 100644
--- a/src/Atc.Wpf.Controls/LabelControls/LabelCheckBox.xaml.cs
+++ b/src/Atc.Wpf.Controls/LabelControls/LabelCheckBox.xaml.cs
@@ -2,20 +2,11 @@ namespace Atc.Wpf.Controls.LabelControls;
public partial class LabelCheckBox : ILabelCheckBox
{
- public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(
- nameof(IsChecked),
- typeof(bool),
- typeof(LabelCheckBox),
- new FrameworkPropertyMetadata(
- defaultValue: false,
- FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
- OnIsCheckedChanged));
-
- public bool IsChecked
- {
- get => (bool)GetValue(IsCheckedProperty);
- set => SetValue(IsCheckedProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = false,
+ Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
+ PropertyChangedCallback = nameof(OnIsCheckedChanged))]
+ private bool isChecked;
public event EventHandler>? IsCheckedChanged;
diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelControl.cs b/src/Atc.Wpf.Controls/LabelControls/LabelControl.cs
index bc12b1df..8594b9d7 100644
--- a/src/Atc.Wpf.Controls/LabelControls/LabelControl.cs
+++ b/src/Atc.Wpf.Controls/LabelControls/LabelControl.cs
@@ -1,66 +1,21 @@
namespace Atc.Wpf.Controls.LabelControls;
-public class LabelControl : LabelControlBase, ILabelControl
+public partial class LabelControl : LabelControlBase, ILabelControl
{
- public static readonly DependencyProperty ShowAsteriskOnMandatoryProperty = DependencyProperty.Register(
- nameof(ShowAsteriskOnMandatory),
- typeof(bool),
- typeof(LabelControl),
- new PropertyMetadata(defaultValue: BooleanBoxes.TrueBox));
+ [DependencyProperty(DefaultValue = true)]
+ private bool showAsteriskOnMandatory;
- public bool ShowAsteriskOnMandatory
- {
- get => (bool)GetValue(ShowAsteriskOnMandatoryProperty);
- set => SetValue(ShowAsteriskOnMandatoryProperty, value);
- }
+ [DependencyProperty(DefaultValue = false)]
+ private bool isMandatory;
- public static readonly DependencyProperty IsMandatoryProperty = DependencyProperty.Register(
- nameof(IsMandatory),
- typeof(bool),
- typeof(LabelControl),
- new PropertyMetadata(defaultValue: BooleanBoxes.FalseBox));
+ [DependencyProperty(DefaultValue = nameof(Colors.Red))]
+ private SolidColorBrush mandatoryColor;
- public bool IsMandatory
- {
- get => (bool)GetValue(IsMandatoryProperty);
- set => SetValue(IsMandatoryProperty, value);
- }
+ [DependencyProperty(DefaultValue = "Application.Current?.Resources[\"AtcApps.Brushes.Control.Validation\"] as SolidColorBrush ?? new SolidColorBrush(Colors.Red)")]
+ private SolidColorBrush validationColor;
- public static readonly DependencyProperty MandatoryColorProperty = DependencyProperty.Register(
- nameof(MandatoryColor),
- typeof(SolidColorBrush),
- typeof(LabelControl),
- new PropertyMetadata(new SolidColorBrush(Colors.Red)));
-
- public SolidColorBrush MandatoryColor
- {
- get => (SolidColorBrush)GetValue(MandatoryColorProperty);
- set => SetValue(MandatoryColorProperty, value);
- }
-
- public static readonly DependencyProperty ValidationColorProperty = DependencyProperty.Register(
- nameof(ValidationColor),
- typeof(SolidColorBrush),
- typeof(LabelControl),
- new PropertyMetadata(Application.Current?.Resources["AtcApps.Brushes.Control.Validation"] as SolidColorBrush ?? new SolidColorBrush(Colors.Red)));
-
- public SolidColorBrush ValidationColor
- {
- get => (SolidColorBrush)GetValue(ValidationColorProperty);
- set => SetValue(ValidationColorProperty, value);
- }
-
- public static readonly DependencyProperty ValidationTextProperty = DependencyProperty.Register(
- nameof(ValidationText),
- typeof(string),
- typeof(LabelControl),
- new PropertyMetadata(default(string)));
-
- public string ValidationText
- {
- get => (string)GetValue(ValidationTextProperty);
- set => SetValue(ValidationTextProperty, value);
- }
+ [DependencyProperty(DefaultValue = "")]
+ private string validationText;
public virtual bool IsValid() => true;
}
\ No newline at end of file
diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelControlBase.cs b/src/Atc.Wpf.Controls/LabelControls/LabelControlBase.cs
index 11399f92..dff007ed 100644
--- a/src/Atc.Wpf.Controls/LabelControls/LabelControlBase.cs
+++ b/src/Atc.Wpf.Controls/LabelControls/LabelControlBase.cs
@@ -1,145 +1,44 @@
namespace Atc.Wpf.Controls.LabelControls;
-public class LabelControlBase : UserControl, ILabelControlBase
+public partial class LabelControlBase : UserControl, ILabelControlBase
{
public string Identifier
=> LabelText == Constants.DefaultLabelControlLabel
? LabelText
: ControlHelper.GetIdentifier(this, LabelText.PascalCase(removeSeparators: true));
- public static readonly DependencyProperty GroupIdentifierProperty = DependencyProperty.Register(
- nameof(GroupIdentifier),
- typeof(string),
- typeof(LabelControlBase),
- new PropertyMetadata(default(string?)));
+ [DependencyProperty]
+ private string? groupIdentifier;
- public string? GroupIdentifier
- {
- get => (string?)GetValue(GroupIdentifierProperty);
- set => SetValue(GroupIdentifierProperty, value);
- }
+ [DependencyProperty]
+ private Type? inputDataType;
- public static readonly DependencyProperty InputDataTypeProperty = DependencyProperty.Register(
- nameof(InputDataType),
- typeof(Type),
- typeof(LabelControlBase),
- new PropertyMetadata(default(Type?)));
+ [DependencyProperty(DefaultValue = LabelControlHideAreasType.None)]
+ private LabelControlHideAreasType hideAreas;
- public Type? InputDataType
- {
- get => (Type?)GetValue(InputDataTypeProperty);
- set => SetValue(InputDataTypeProperty, value);
- }
+ [DependencyProperty(DefaultValue = Orientation.Horizontal)]
+ private Orientation orientation;
- public static readonly DependencyProperty HideAreasProperty = DependencyProperty.Register(
- nameof(HideAreas),
- typeof(LabelControlHideAreasType),
- typeof(LabelControlBase),
- new PropertyMetadata(LabelControlHideAreasType.None));
+ [DependencyProperty(DefaultValue = 120)]
+ private int labelWidthNumber;
- public LabelControlHideAreasType HideAreas
- {
- get => (LabelControlHideAreasType)GetValue(HideAreasProperty);
- set => SetValue(HideAreasProperty, value);
- }
+ [DependencyProperty(DefaultValue = SizeDefinitionType.Pixel)]
+ private SizeDefinitionType labelWidthSizeDefinition;
- public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
- nameof(Orientation),
- typeof(Orientation),
- typeof(LabelControlBase),
- new PropertyMetadata(default(Orientation)));
+ [DependencyProperty(DefaultValue = "")]
+ private string labelText;
- public Orientation Orientation
- {
- get => (Orientation)GetValue(OrientationProperty);
- set => SetValue(OrientationProperty, value);
- }
+ [DependencyProperty(DefaultValue = 26d)]
+ private double contentMinHeight;
- public static readonly DependencyProperty LabelWidthNumberProperty = DependencyProperty.Register(
- nameof(LabelWidthNumber),
- typeof(int),
- typeof(LabelControlBase),
- new PropertyMetadata(120));
+ [DependencyProperty(DefaultValue = "")]
+ private string informationText;
- public int LabelWidthNumber
- {
- get => (int)GetValue(LabelWidthNumberProperty);
- set => SetValue(LabelWidthNumberProperty, value);
- }
+ [DependencyProperty(Flags = FrameworkPropertyMetadataOptions.AffectsMeasure)]
+ private object? informationContent;
- public static readonly DependencyProperty LabelWidthSizeDefinitionProperty = DependencyProperty.Register(
- nameof(LabelWidthSizeDefinition),
- typeof(SizeDefinitionType),
- typeof(LabelControlBase),
- new PropertyMetadata(SizeDefinitionType.Pixel));
-
- public SizeDefinitionType LabelWidthSizeDefinition
- {
- get => (SizeDefinitionType)GetValue(LabelWidthSizeDefinitionProperty);
- set => SetValue(LabelWidthSizeDefinitionProperty, value);
- }
-
- public static readonly DependencyProperty LabelTextProperty = DependencyProperty.Register(
- nameof(LabelText),
- typeof(string),
- typeof(LabelControlBase),
- new PropertyMetadata(Constants.DefaultLabelControlLabel));
-
- public string LabelText
- {
- get => (string)GetValue(LabelTextProperty);
- set => SetValue(LabelTextProperty, value);
- }
-
- public static readonly DependencyProperty ContentMinHeightProperty = DependencyProperty.Register(
- nameof(ContentMinHeight),
- typeof(double),
- typeof(LabelControlBase),
- new PropertyMetadata(26d));
-
- public double ContentMinHeight
- {
- get => (double)GetValue(ContentMinHeightProperty);
- set => SetValue(ContentMinHeightProperty, value);
- }
-
- public static readonly DependencyProperty InformationTextProperty = DependencyProperty.Register(
- nameof(InformationText),
- typeof(string),
- typeof(LabelControlBase),
- new PropertyMetadata(defaultValue: string.Empty));
-
- public string InformationText
- {
- get => (string)GetValue(InformationTextProperty);
- set => SetValue(InformationTextProperty, value);
- }
-
- public static readonly DependencyProperty InformationContentProperty = DependencyProperty.Register(
- nameof(InformationContent),
- typeof(object),
- typeof(LabelControlBase),
- new FrameworkPropertyMetadata(
- defaultValue: null,
- FrameworkPropertyMetadataOptions.AffectsMeasure));
-
- public object? InformationContent
- {
- get => (object?)GetValue(InformationContentProperty);
- set => SetValue(InformationContentProperty, value);
- }
-
- public static readonly DependencyProperty InformationColorProperty = DependencyProperty.Register(
- nameof(InformationColor),
- typeof(Color),
- typeof(LabelControlBase),
- new PropertyMetadata(Colors.DodgerBlue));
-
- public Color InformationColor
- {
- get => (Color)GetValue(InformationColorProperty);
- set => SetValue(InformationColorProperty, value);
- }
+ [DependencyProperty(DefaultValue = nameof(Colors.DodgerBlue))]
+ private Color informationColor;
public string GetFullIdentifier()
=> string.IsNullOrEmpty(GroupIdentifier)
diff --git a/src/Atc.Wpf.Controls/Styles/Controls.xaml b/src/Atc.Wpf.Controls/Styles/Controls.xaml
index bab98355..b62ab283 100644
--- a/src/Atc.Wpf.Controls/Styles/Controls.xaml
+++ b/src/Atc.Wpf.Controls/Styles/Controls.xaml
@@ -18,6 +18,7 @@
+
diff --git a/src/Atc.Wpf.Theming/Controls/Windows/NiceWindow.cs b/src/Atc.Wpf.Theming/Controls/Windows/NiceWindow.cs
index ca77d966..b3c285bd 100644
--- a/src/Atc.Wpf.Theming/Controls/Windows/NiceWindow.cs
+++ b/src/Atc.Wpf.Theming/Controls/Windows/NiceWindow.cs
@@ -1,6 +1,7 @@
// ReSharper disable InconsistentNaming
// ReSharper disable InvertIf
// ReSharper disable NotAccessedField.Global
+// ReSharper disable NotDisposedResourceIsReturnedByProperty
namespace Atc.Wpf.Theming.Controls.Windows;
///
@@ -19,7 +20,7 @@ namespace Atc.Wpf.Theming.Controls.Windows;
[TemplatePart(Name = PART_NiceActiveDialogContainer, Type = typeof(Grid))]
[TemplatePart(Name = PART_NiceInactiveDialogsContainer, Type = typeof(Grid))]
[TemplatePart(Name = PART_Content, Type = typeof(NiceContentControl))]
-public class NiceWindow : WindowChromeWindow
+public partial class NiceWindow : WindowChromeWindow
{
private const string PART_Icon = "PART_Icon";
private const string PART_TitleBar = "PART_TitleBar";
@@ -50,1050 +51,765 @@ public class NiceWindow : WindowChromeWindow
private EventHandler? onOverlayFadeInStoryboardCompleted;
private EventHandler? onOverlayFadeOutStoryboardCompleted;
- public static readonly DependencyProperty ShowIconOnTitleBarProperty = DependencyProperty.Register(
- nameof(ShowIconOnTitleBar),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(
- BooleanBoxes.TrueBox,
- OnShowIconOnTitleBarPropertyChangedCallback));
+ [DependencyProperty(
+ DefaultValue = true,
+ PropertyChangedCallback = nameof(OnShowIconOnTitleBarPropertyChanged))]
+ private bool showIconOnTitleBar;
- private static void OnShowIconOnTitleBarPropertyChangedCallback(
- DependencyObject d,
- DependencyPropertyChangedEventArgs e)
- {
- var window = (NiceWindow)d;
- if (e.NewValue != e.OldValue)
- {
- window.UpdateIconVisibility();
- }
- }
+ [DependencyProperty(DefaultValue = 20.0d)]
+ private double iconWidth;
- ///
- /// Get or sets whether the TitleBar icon is visible or not.
- ///
- public bool ShowIconOnTitleBar
- {
- get => (bool)GetValue(ShowIconOnTitleBarProperty);
- set => SetValue(ShowIconOnTitleBarProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(DefaultValue = 20.0d)]
+ private double iconHeight;
- public static readonly DependencyProperty IconWidthProperty = DependencyProperty.Register(
- nameof(IconWidth),
- typeof(double),
- typeof(NiceWindow),
- new PropertyMetadata(20.0));
+ [DependencyProperty(DefaultValue = "new Thickness(10, 3, 10, 3)")]
+ private Thickness iconMargin;
- ///
- /// Gets or sets the width for the icon.
- ///
- public double IconWidth
- {
- get => (double)GetValue(IconWidthProperty);
- set => SetValue(IconWidthProperty, value);
- }
+ [DependencyProperty(DefaultValue = EdgeMode.Aliased)]
+ private EdgeMode iconEdgeMode;
- public static readonly DependencyProperty IconHeightProperty = DependencyProperty.Register(
- nameof(IconHeight),
- typeof(double),
- typeof(NiceWindow),
- new PropertyMetadata(20.0));
+ [DependencyProperty(DefaultValue = BitmapScalingMode.HighQuality)]
+ private BitmapScalingMode iconBitmapScalingMode;
- ///
- /// Gets or sets the height for the icon.
- ///
- public double IconHeight
- {
- get => (double)GetValue(IconHeightProperty);
- set => SetValue(IconHeightProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = MultiFrameImageMode.ScaleDownLargerFrame,
+ Flags = FrameworkPropertyMetadataOptions.AffectsRender)]
+ private MultiFrameImageMode iconScalingMode;
- public static readonly DependencyProperty IconMarginProperty = DependencyProperty.Register(
- nameof(IconMargin),
- typeof(Thickness),
- typeof(NiceWindow),
- new PropertyMetadata(new Thickness(10, 3, 10, 3)));
+ [DependencyProperty(
+ DefaultValue = true,
+ PropertyChangedCallback = nameof(OnShowTitleBarPropertyChanged),
+ CoerceValueCallback = nameof(OnShowTitleBarCoerceValue))]
+ private bool showTitleBar;
- ///
- /// Gets or sets the margin for the icon.
- ///
- public Thickness IconMargin
- {
- get => (Thickness)GetValue(IconMarginProperty);
- set => SetValue(IconMarginProperty, value);
- }
+ [DependencyProperty(
+ DefaultValue = true,
+ Flags = FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)]
+ private bool showDialogsOverTitleBar;
- public static readonly DependencyProperty IconEdgeModeProperty = DependencyProperty.Register(
- nameof(IconEdgeMode),
- typeof(EdgeMode),
- typeof(NiceWindow),
- new PropertyMetadata(EdgeMode.Aliased));
+ [DependencyProperty(DefaultValue = false)]
+ private bool isAnyDialogOpen;
- ///
- /// Gets or sets the edge mode for the TitleBar icon.
- ///
- public EdgeMode IconEdgeMode
- {
- get => (EdgeMode)GetValue(IconEdgeModeProperty);
- set => SetValue(IconEdgeModeProperty, value);
- }
+ [DependencyProperty(DefaultValue = true)]
+ private bool showCloseButton;
- public static readonly DependencyProperty IconBitmapScalingModeProperty = DependencyProperty.Register(
- nameof(IconBitmapScalingMode),
- typeof(BitmapScalingMode),
- typeof(NiceWindow),
- new PropertyMetadata(BitmapScalingMode.HighQuality));
+ [DependencyProperty(DefaultValue = true)]
+ private bool isMinButtonEnabled;
- ///
- /// Gets or sets the bitmap scaling mode for the TitleBar icon.
- ///
- public BitmapScalingMode IconBitmapScalingMode
- {
- get => (BitmapScalingMode)GetValue(IconBitmapScalingModeProperty);
- set => SetValue(IconBitmapScalingModeProperty, value);
- }
+ [DependencyProperty(DefaultValue = true)]
+ private bool isMaxRestoreButtonEnabled;
- public static readonly DependencyProperty IconScalingModeProperty = DependencyProperty.Register(
- nameof(IconScalingMode),
- typeof(MultiFrameImageMode),
- typeof(NiceWindow),
- new FrameworkPropertyMetadata(
- MultiFrameImageMode.ScaleDownLargerFrame,
- FrameworkPropertyMetadataOptions.AffectsRender));
+ [DependencyProperty(DefaultValue = true)]
+ private bool isCloseButtonEnabled;
- ///
- /// Gets or sets the scaling mode for the TitleBar icon.
- ///
- public MultiFrameImageMode IconScalingMode
- {
- get => (MultiFrameImageMode)GetValue(IconScalingModeProperty);
- set => SetValue(IconScalingModeProperty, value);
- }
+ [DependencyProperty(DefaultValue = true)]
+ private bool showSystemMenu;
- public static readonly DependencyProperty ShowTitleBarProperty = DependencyProperty.Register(
- nameof(ShowTitleBar),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(
- BooleanBoxes.TrueBox,
- OnShowTitleBarPropertyChangedCallback,
- OnShowTitleBarCoerceValueCallback));
+ [DependencyProperty(DefaultValue = true)]
+ private bool showSystemMenuOnRightClick;
- [SuppressMessage("Minor Code Smell", "S1125:Boolean literals should not be redundant", Justification = "OK.")]
- private static object? OnShowTitleBarCoerceValueCallback(
- DependencyObject d,
- object? value)
- {
- // if UseNoneWindowStyle = true no title bar should be shown
- return ((NiceWindow)d).UseNoneWindowStyle
- ? false
- : value;
- }
+ [DependencyProperty(
+ DefaultValue = 30,
+ PropertyChangedCallback = nameof(TitleBarHeightPropertyChanged))]
+ private int titleBarHeight;
- ///
- /// Gets or sets whether the TitleBar is visible or not.
- ///
- public bool ShowTitleBar
- {
- get => (bool)GetValue(ShowTitleBarProperty);
- set => SetValue(ShowTitleBarProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(
+ DefaultValue = CharacterCasing.Normal,
+ Flags = FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure,
+ ValidateValueCallback = nameof(ValidateTitleCharacterCasing))]
+ private CharacterCasing titleCharacterCasing;
- public static readonly DependencyProperty ShowDialogsOverTitleBarProperty = DependencyProperty.Register(
- nameof(ShowDialogsOverTitleBar),
- typeof(bool),
- typeof(NiceWindow),
- new FrameworkPropertyMetadata(
- BooleanBoxes.TrueBox,
- FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
+ [DependencyProperty(
+ DefaultValue = HorizontalAlignment.Stretch,
+ PropertyChangedCallback = nameof(OnTitleAlignmentChanged))]
+ private HorizontalAlignment titleAlignment;
- ///
- /// Get or sets whether a dialog will be shown over the TitleBar.
- ///
- public bool ShowDialogsOverTitleBar
- {
- get => (bool)GetValue(ShowDialogsOverTitleBarProperty);
- set => SetValue(ShowDialogsOverTitleBarProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(DefaultValue = false)]
+ private bool saveWindowPosition;
- internal static readonly DependencyPropertyKey IsAnyDialogOpenPropertyKey = DependencyProperty.RegisterReadOnly(
- nameof(IsAnyDialogOpen),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.FalseBox));
+ [DependencyProperty]
+ private IWindowPlacementSettings? windowPlacementSettings;
- public static readonly DependencyProperty IsAnyDialogOpenProperty = IsAnyDialogOpenPropertyKey.DependencyProperty;
+ [DependencyProperty]
+ private Brush? titleForeground;
- ///
- /// Gets whether that there are one or more dialogs open.
- ///
- public bool IsAnyDialogOpen
- {
- get => (bool)GetValue(IsAnyDialogOpenProperty);
- protected set => SetValue(IsAnyDialogOpenPropertyKey, BooleanBoxes.Box(value));
- }
+ [DependencyProperty]
+ private DataTemplate? titleTemplate;
- public static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.Register(
- nameof(ShowCloseButton),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(DefaultValue = nameof(Brushes.Transparent))]
+ private Brush windowTitleBrush;
- ///
- /// Gets or sets whether if the close button is visible.
- ///
- public bool ShowCloseButton
- {
- get => (bool)GetValue(ShowCloseButtonProperty);
- set => SetValue(ShowCloseButtonProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(DefaultValue = nameof(Brushes.Gray))]
+ private Brush nonActiveWindowTitleBrush;
- public static readonly DependencyProperty IsMinButtonEnabledProperty = DependencyProperty.Register(
- nameof(IsMinButtonEnabled),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(DefaultValue = nameof(Brushes.Gray))]
+ private Brush nonActiveBorderBrush;
- ///
- /// Gets or sets if the minimize button is enabled.
- ///
- public bool IsMinButtonEnabled
- {
- get => (bool)GetValue(IsMinButtonEnabledProperty);
- set => SetValue(IsMinButtonEnabledProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty]
+ private Brush? overlayBrush;
- public static readonly DependencyProperty IsMaxRestoreButtonEnabledProperty = DependencyProperty.Register(
- nameof(IsMaxRestoreButtonEnabled),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(DefaultValue = 0.7d)]
+ private double overlayOpacity;
- ///
- /// Gets or sets if the maximize/restore button is enabled.
- ///
- public bool IsMaxRestoreButtonEnabled
- {
- get => (bool)GetValue(IsMaxRestoreButtonEnabledProperty);
- set => SetValue(IsMaxRestoreButtonEnabledProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty]
+ private Storyboard? overlayFadeIn;
- public static readonly DependencyProperty IsCloseButtonEnabledProperty = DependencyProperty.Register(
- nameof(IsCloseButtonEnabled),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty]
+ private Storyboard? overlayFadeOut;
- ///
- /// Gets or sets if the close button is enabled.
- ///
- public bool IsCloseButtonEnabled
- {
- get => (bool)GetValue(IsCloseButtonEnabledProperty);
- set => SetValue(IsCloseButtonEnabledProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(DefaultValue = false)]
+ private bool windowTransitionsEnabled;
- public static readonly DependencyProperty ShowSystemMenuProperty = DependencyProperty.Register(
- nameof(ShowSystemMenu),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(PropertyChangedCallback = nameof(OnIconTemplatePropertyChanged))]
+ private DataTemplate? iconTemplate;
- ///
- /// Gets or sets a value that indicates whether the system menu should popup with left mouse click on the window icon.
- ///
- public bool ShowSystemMenu
- {
- get => (bool)GetValue(ShowSystemMenuProperty);
- set => SetValue(ShowSystemMenuProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(PropertyChangedCallback = nameof(OnLeftWindowCommandsPropertyChanged))]
+ private WindowCommands? leftWindowCommands;
- public static readonly DependencyProperty ShowSystemMenuOnRightClickProperty = DependencyProperty.Register(
- nameof(ShowSystemMenuOnRightClick),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ [DependencyProperty(PropertyChangedCallback = nameof(OnRightWindowCommandsPropertyChanged))]
+ private WindowCommands? rightWindowCommands;
- ///
- /// Gets or sets a value that indicates whether the system menu should popup with right mouse click if the mouse position is on title bar or on the entire window if it has no TitleBar (and no TitleBar height).
- ///
- public bool ShowSystemMenuOnRightClick
- {
- get => (bool)GetValue(ShowSystemMenuOnRightClickProperty);
- set => SetValue(ShowSystemMenuOnRightClickProperty, BooleanBoxes.Box(value));
- }
+ [DependencyProperty(PropertyChangedCallback = nameof(UpdateLogicalChildren))]
+ private WindowButtonCommands? windowButtonCommands;
- public static readonly DependencyProperty TitleBarHeightProperty = DependencyProperty.Register(
- nameof(TitleBarHeight),
- typeof(int),
- typeof(NiceWindow),
- new PropertyMetadata(
- 30,
- TitleBarHeightPropertyChangedCallback));
+ [DependencyProperty(
+ DefaultValue = WindowCommandsOverlayBehaviorType.Never,
+ PropertyChangedCallback = nameof(OnShowTitleBarPropertyChanged))]
+ private WindowCommandsOverlayBehaviorType leftWindowCommandsOverlayBehavior;
- private static void TitleBarHeightPropertyChangedCallback(
- DependencyObject d,
- DependencyPropertyChangedEventArgs e)
- {
- if (e.NewValue == e.OldValue)
- {
- return;
- }
+ [DependencyProperty(
+ DefaultValue = WindowCommandsOverlayBehaviorType.Never,
+ PropertyChangedCallback = nameof(OnShowTitleBarPropertyChanged))]
+ private WindowCommandsOverlayBehaviorType rightWindowCommandsOverlayBehavior;
- ((NiceWindow)d).UpdateTitleBarElementsVisibility();
- }
+ [DependencyProperty(
+ DefaultValue = OverlayBehavior.Always,
+ PropertyChangedCallback = nameof(OnShowTitleBarPropertyChanged))]
+ private OverlayBehavior windowButtonCommandsOverlayBehavior;
+
+ [DependencyProperty(
+ DefaultValue = OverlayBehavior.Never,
+ PropertyChangedCallback = nameof(OnShowTitleBarPropertyChanged))]
+ private OverlayBehavior iconOverlayBehavior;
+
+ [DependencyProperty(
+ DefaultValue = false,
+ PropertyChangedCallback = nameof(OnUseNoneWindowStylePropertyChanged))]
+ private bool useNoneWindowStyle;
+
+ [DependencyProperty]
+ private Brush? overrideDefaultWindowCommandsBrush;
+
+ [DependencyProperty(DefaultValue = true)]
+ private bool isWindowDraggable;
+
+ [RoutedEvent]
+ private static readonly RoutedEvent windowTransitionCompleted;
///
- /// Gets or sets the TitleBar's height.
+ /// Gets the window placement settings (can be overwritten).
///
- public int TitleBarHeight
- {
- get => (int)GetValue(TitleBarHeightProperty);
- set => SetValue(TitleBarHeightProperty, value);
- }
-
- public static readonly DependencyProperty TitleCharacterCasingProperty = DependencyProperty.Register(
- nameof(TitleCharacterCasing),
- typeof(CharacterCasing),
- typeof(NiceWindow),
- new FrameworkPropertyMetadata(
- CharacterCasing.Normal,
- FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure),
- value => (CharacterCasing)value >= CharacterCasing.Normal && (CharacterCasing)value <= CharacterCasing.Upper);
+ public virtual IWindowPlacementSettings GetWindowPlacementSettings()
+ => WindowPlacementSettings ?? new WindowApplicationSettings(this);
///
- /// Gets or sets the Character casing of the title.
+ /// Starts the overlay fade in effect.
///
- public CharacterCasing TitleCharacterCasing
+ /// A task representing the process.
+ public async Task ShowOverlayAsync()
{
- get => (CharacterCasing)GetValue(TitleCharacterCasingProperty);
- set => SetValue(TitleCharacterCasingProperty, value);
- }
-
- public static readonly DependencyProperty TitleAlignmentProperty = DependencyProperty.Register(
- nameof(TitleAlignment),
- typeof(HorizontalAlignment),
- typeof(NiceWindow),
- new PropertyMetadata(
- HorizontalAlignment.Stretch,
- OnTitleAlignmentChanged));
+ if (OverlayBox is null)
+ {
+ throw new InvalidOperationException("OverlayBox can not be founded in this NiceWindow's template. Are you calling this before the window has loaded?");
+ }
- private static void OnTitleAlignmentChanged(
- DependencyObject dependencyObject,
- DependencyPropertyChangedEventArgs e)
- {
- if (e.OldValue == e.NewValue)
+ if (IsOverlayVisible() && overlayStoryboard is null)
{
return;
}
- var window = (NiceWindow)dependencyObject;
+ Dispatcher.VerifyAccess();
- window.SizeChanged -= window.OnSizeChanged;
- if (e.NewValue is HorizontalAlignment.Center &&
- window.titleBar is not null)
+ var sb = OverlayFadeIn?.Clone();
+
+ if (!CanUseOverlayFadingStoryboard(sb, out var animation))
{
- window.SizeChanged += window.OnSizeChanged;
+ await ShowOverlayAsync().ConfigureAwait(true);
+ return;
}
- }
- ///
- /// Gets or sets the horizontal alignment of the title.
- ///
- public HorizontalAlignment TitleAlignment
- {
- get => (HorizontalAlignment)GetValue(TitleAlignmentProperty);
- set => SetValue(TitleAlignmentProperty, value);
- }
-
- public static readonly DependencyProperty SaveWindowPositionProperty = DependencyProperty.Register(
- nameof(SaveWindowPosition),
- typeof(bool),
- typeof(NiceWindow),
- new PropertyMetadata(BooleanBoxes.FalseBox));
+ overlayStoryboard = sb;
- ///
- /// Gets or sets whether the window will save it's position and size.
- ///
- public bool SaveWindowPosition
- {
- get => (bool)GetValue(SaveWindowPositionProperty);
- set => SetValue(SaveWindowPositionProperty, BooleanBoxes.Box(value));
- }
+ var tcs = new TaskCompletionSource
-public sealed class MessageListener : DependencyObject
+public sealed partial class MessageListener : DependencyObject
{
- ///
- /// Message Property.
- ///
- public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
- nameof(Message),
- typeof(string),
- typeof(MessageListener),
- new UIPropertyMetadata(propertyChangedCallback: null));
+ [DependencyProperty]
+ private string message;
private static MessageListener? messageListener;
@@ -29,22 +23,13 @@ private MessageListener()
///
public static MessageListener Instance => messageListener ??= new MessageListener();
- ///
- /// Gets or sets received message.
- ///
- public string Message
- {
- get => (string)GetValue(MessageProperty);
- set => SetValue(MessageProperty, value);
- }
-
///
/// Receives the message.
///
- /// The message.
- public void ReceiveMessage(string message)
+ /// The message value.
+ public void ReceiveMessage(string messageValue)
{
- SetCurrentValue(MessageProperty, message);
+ SetCurrentValue(MessageProperty, messageValue);
DispatcherHelper.DoEvents();
}
}
\ No newline at end of file
diff --git a/src/Atc.Wpf/DependencyObjects/PercentListener.cs b/src/Atc.Wpf/DependencyObjects/PercentListener.cs
index 754d9f2f..bcf150e9 100644
--- a/src/Atc.Wpf/DependencyObjects/PercentListener.cs
+++ b/src/Atc.Wpf/DependencyObjects/PercentListener.cs
@@ -4,16 +4,10 @@ namespace Atc.Wpf.DependencyObjects;
/// Message listener, singleton pattern.
/// Inherit from DependencyObject to implement DataBinding.
///
-public sealed class PercentListener : DependencyObject
+public sealed partial class PercentListener : DependencyObject
{
- ///
- /// Percent Property.
- ///
- public static readonly DependencyProperty PercentProperty = DependencyProperty.Register(
- nameof(Percent),
- typeof(int),
- typeof(PercentListener),
- new UIPropertyMetadata(propertyChangedCallback: null));
+ [DependencyProperty]
+ private double percent;
private static PercentListener? percentListener;
@@ -29,27 +23,18 @@ private PercentListener()
///
public static PercentListener Instance => percentListener ??= new PercentListener();
- ///
- /// Gets or sets received percent.
- ///
- public int Percent
- {
- get => (int)GetValue(PercentProperty);
- set => SetValue(PercentProperty, value);
- }
-
///
/// Receives the percent.
///
- /// The percent.
- public void ReceivePercent(int percent)
+ /// The percent value.
+ public void ReceivePercent(double percentValue)
{
- if (percent < 0 || percent > 100)
+ if (percent is < 0 or > 100)
{
- throw new ArgumentException("Percent have to be between 0 and 100", nameof(percent));
+ throw new ArgumentException("Percent have to be between 0 and 100", nameof(percentValue));
}
- SetCurrentValue(PercentProperty, percent);
+ SetCurrentValue(PercentProperty, percentValue);
DispatcherHelper.DoEvents();
}
}
\ No newline at end of file
diff --git a/src/Atc.Wpf/Media/ShaderEffects/FadeShaderEffect.cs b/src/Atc.Wpf/Media/ShaderEffects/FadeShaderEffect.cs
index 23fa127a..979d9a94 100644
--- a/src/Atc.Wpf/Media/ShaderEffects/FadeShaderEffect.cs
+++ b/src/Atc.Wpf/Media/ShaderEffects/FadeShaderEffect.cs
@@ -2,14 +2,12 @@ namespace Atc.Wpf.Media.ShaderEffects;
public sealed class FadeShaderEffect : ShaderEffectBase
{
- public static readonly DependencyProperty InputProperty =
- RegisterPixelShaderSamplerProperty(
+ public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(
"Input",
typeof(FadeShaderEffect),
0);
- public static readonly DependencyProperty StrengthProperty =
- DependencyProperty.Register(
+ public static readonly DependencyProperty StrengthProperty = DependencyProperty.Register(
nameof(Strength),
typeof(double),
typeof(FadeShaderEffect),
diff --git a/src/Atc.Wpf/ValueConverters/@Readme.md b/src/Atc.Wpf/ValueConverters/@Readme.md
index 2df5ca89..d634ec03 100644
--- a/src/Atc.Wpf/ValueConverters/@Readme.md
+++ b/src/Atc.Wpf/ValueConverters/@Readme.md
@@ -47,6 +47,7 @@ Or by the ValueConverter's Instance:
| String -> Bool | StringNullOrEmptyToInverseBoolValueConverter | NULL or empty -> False | Not supported |
| String -> Visibility | StringNullOrEmptyToVisibilityCollapsedValueConverter | NULL or empty -> Collapsed | Not supported |
| String -> Visibility | StringNullOrEmptyToVisibilityVisibleValueConverter | NULL or empty -> Visible | Not supported |
+| String -> List | StringToSplitStringListValueConverter | String -> List | Not supported |
| String -> String | ToLowerValueConverter | String -> String | Binding.DoNothing |
| String -> String | ToUpperValueConverter | String -> String | Binding.DoNothing |
diff --git a/src/Atc.Wpf/ValueConverters/ColorNameToBrushValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/ColorNameToBrushValueConverter.cs
similarity index 97%
rename from src/Atc.Wpf/ValueConverters/ColorNameToBrushValueConverter.cs
rename to src/Atc.Wpf/ValueConverters/StringTo/ColorNameToBrushValueConverter.cs
index 441eb3aa..d6cd17e0 100644
--- a/src/Atc.Wpf/ValueConverters/ColorNameToBrushValueConverter.cs
+++ b/src/Atc.Wpf/ValueConverters/StringTo/ColorNameToBrushValueConverter.cs
@@ -1,3 +1,4 @@
+// ReSharper disable CheckNamespace
namespace Atc.Wpf.ValueConverters;
///
diff --git a/src/Atc.Wpf/ValueConverters/ColorNameToColorValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/ColorNameToColorValueConverter.cs
similarity index 97%
rename from src/Atc.Wpf/ValueConverters/ColorNameToColorValueConverter.cs
rename to src/Atc.Wpf/ValueConverters/StringTo/ColorNameToColorValueConverter.cs
index 922d2d1f..e84fb34e 100644
--- a/src/Atc.Wpf/ValueConverters/ColorNameToColorValueConverter.cs
+++ b/src/Atc.Wpf/ValueConverters/StringTo/ColorNameToColorValueConverter.cs
@@ -1,3 +1,4 @@
+// ReSharper disable CheckNamespace
namespace Atc.Wpf.ValueConverters;
///
diff --git a/test/Atc.Wpf.Tests/ValueConverters/ColorNameToBrushValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/StringTo/ColorNameToBrushValueConverterTests.cs
similarity index 97%
rename from test/Atc.Wpf.Tests/ValueConverters/ColorNameToBrushValueConverterTests.cs
rename to test/Atc.Wpf.Tests/ValueConverters/StringTo/ColorNameToBrushValueConverterTests.cs
index 8d947734..85720717 100644
--- a/test/Atc.Wpf.Tests/ValueConverters/ColorNameToBrushValueConverterTests.cs
+++ b/test/Atc.Wpf.Tests/ValueConverters/StringTo/ColorNameToBrushValueConverterTests.cs
@@ -1,3 +1,4 @@
+// ReSharper disable once CheckNamespace
namespace Atc.Wpf.Tests.ValueConverters;
public sealed class ColorNameToBrushValueConverterTests
diff --git a/test/Atc.Wpf.Tests/ValueConverters/ColorNameToColorValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/StringTo/ColorNameToColorValueConverterTests.cs
similarity index 100%
rename from test/Atc.Wpf.Tests/ValueConverters/ColorNameToColorValueConverterTests.cs
rename to test/Atc.Wpf.Tests/ValueConverters/StringTo/ColorNameToColorValueConverterTests.cs
diff --git a/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj b/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj
index 081e7753..d0fe3fce 100644
--- a/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj
+++ b/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj
@@ -9,8 +9,8 @@
-
-
+
+ NU1701