diff --git a/Directory.Build.props b/Directory.Build.props index baeb35fe..d431ad27 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -45,10 +45,10 @@ - + - + \ No newline at end of file diff --git a/README.md b/README.md index 507b6b9c..a23510ec 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![NuGet Version](https://img.shields.io/nuget/v/Atc.Wpf.svg?logo=nuget&style=for-the-badge)](https://www.nuget.org/packages/atc.wpf) - # ATC.Net WPF This is a base libraries for building WPF application with the MVVM design pattern. @@ -10,15 +8,15 @@ This is a base libraries for building WPF application with the MVVM design patte ## NuGet Packages Provided in this Repository -| Nuget package | Description | Dependencies | -|----------------------------|-----------------------------------------------------|----------------------------------------------| -| 💟 Atc.Wpf | Base Controls, ValueConverters, Extensions etc. | Atc | -| 💟 Atc.Wpf.Controls | Miscellaneous UI Controls | Atc.Wpf & Atc.Wpf.Theming | -| 💟 Atc.Wpf.Controls.Sample | Controls for creating WPF sample apps | Atc.Wpf & Atc.Wpf.Theming & Atc.Wpf.Controls | -| 💟 Atc.Wpf.FontIcons | Render Svg and Img resources based on fonts | Atc.Wpf | -| 💟 Atc.Wpf.Theming | Theming for Light & Dark mode for WPF base controls | Atc.Wpf | +| Nuget package | Description | Dependencies | +|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|----------------------------------------------| +| [![NuGet Version](https://img.shields.io/nuget/v/Atc.Wpf.svg?label=Atc.Wpf&logo=nuget&style=for-the-badge)](https://www.nuget.org/packages/Atc.Wpf) | Base Controls, ValueConverters, Extensions etc. | Atc | +| [![NuGet Version](https://img.shields.io/nuget/v/Atc.Wpf.Controls.svg?label=Atc.Wpf.Controls&logo=nuget&style=for-the-badge)](https://www.nuget.org/packages/Atc.Wpf.Controls) | Miscellaneous UI Controls | Atc.Wpf & Atc.Wpf.Theming | +| [![NuGet Version](https://img.shields.io/nuget/v/Atc.Wpf.Controls.Sample.svg?label=Atc.Wpf.Controls.Sample&logo=nuget&style=for-the-badge)](https://www.nuget.org/packages/Atc.Wpf.Controls.Sample) | Controls for creating WPF sample apps | Atc.Wpf & Atc.Wpf.Theming & Atc.Wpf.Controls | +| [![NuGet Version](https://img.shields.io/nuget/v/Atc.Wpf.FontIcons.svg?label=Atc.Wpf.FontIcons&logo=nuget&style=for-the-badge)](https://www.nuget.org/packages/Atc.Wpf.FontIcons) | Render Svg and Img resources based on fonts | Atc.Wpf | +| [![NuGet Version](https://img.shields.io/nuget/v/Atc.Wpf.Theming.svg?label=Atc.Wpf.Theming&logo=nuget&style=for-the-badge)](https://www.nuget.org/packages/Atc.Wpf.Theming) | Theming for Light & Dark mode for WPF base controls | Atc.Wpf | -# 🔎 Demonstration Application +## 🔎 Demonstration Application The demonstration application, `Atc.Wpf.Sample`, functions as a control explorer. It provides quick visualization of a given control, along with options for diff --git a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj index cf5c1b2c..3c760d08 100644 --- a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj +++ b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj @@ -7,6 +7,10 @@ false + + $(NoWarn);WPF0001;CS0169;CS8618 + + @@ -47,13 +51,13 @@ - - + + - - - - + + + + diff --git a/sample/Atc.Wpf.Sample/GlobalUsings.cs b/sample/Atc.Wpf.Sample/GlobalUsings.cs index dd36a9b9..afddcfa6 100644 --- a/sample/Atc.Wpf.Sample/GlobalUsings.cs +++ b/sample/Atc.Wpf.Sample/GlobalUsings.cs @@ -19,6 +19,7 @@ global using System.Windows.Media.Imaging; global using System.Windows.Threading; +global using Atc.Data.Models; global using Atc.Helpers; global using Atc.Serialization.JsonConverters; global using Atc.Wpf.Collections; diff --git a/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestClassDependencyPropertiesView.xaml b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestClassDependencyPropertiesView.xaml new file mode 100644 index 00000000..6b585224 --- /dev/null +++ b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestClassDependencyPropertiesView.xaml @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestClassDependencyPropertiesView.xaml.cs b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestClassDependencyPropertiesView.xaml.cs new file mode 100644 index 00000000..883dafc1 --- /dev/null +++ b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestClassDependencyPropertiesView.xaml.cs @@ -0,0 +1,23 @@ +namespace Atc.Wpf.Sample.SamplesWpfSourceGenerators; + +[DependencyProperty("IsRunning", DefaultValue = true)] +[DependencyProperty("DecimalValue", DefaultValue = 1.1)] +[DependencyProperty("FloatValue", DefaultValue = 1.1)] +[DependencyProperty("IntValue", DefaultValue = 1)] +[DependencyProperty("LogItem")] +[DependencyProperty("LogCategory", DefaultValue = LogCategoryType.Debug)] +[DependencyProperty("StringValue", DefaultValue = "Hello world")] +[DependencyProperty>("ErrorTerms", DefaultValue = "error;err:")] +[DependencyProperty("ErrorTextColor", DefaultValue = "Red")] +[DependencyProperty("ErrorTextBrush", DefaultValue = "Red")] +[DependencyProperty("MyFontFamily", DefaultValue = "Consolas")] +[DependencyProperty("MyFontSize", DefaultValue = 12.2)] +public partial class TestClassDependencyPropertiesView +{ + public TestClassDependencyPropertiesView() + { + InitializeComponent(); + + IsRunning = false; + } +} \ No newline at end of file diff --git a/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestFieldsDependencyPropertiesView.xaml b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestFieldsDependencyPropertiesView.xaml new file mode 100644 index 00000000..903fe5c2 --- /dev/null +++ b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestFieldsDependencyPropertiesView.xaml @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestFieldsDependencyPropertiesView.xaml.cs b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestFieldsDependencyPropertiesView.xaml.cs new file mode 100644 index 00000000..d7fa5319 --- /dev/null +++ b/sample/Atc.Wpf.Sample/SamplesWpfSourceGenerators/TestFieldsDependencyPropertiesView.xaml.cs @@ -0,0 +1,50 @@ +namespace Atc.Wpf.Sample.SamplesWpfSourceGenerators; + +[SuppressMessage("", "CS0169:The field is never used", Justification = "OK - SourceGenerator declaration field")] +[SuppressMessage("", "CS8618:Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.", Justification = "OK - SourceGenerator declaration field")] +[SuppressMessage("", "CA1823:Avoid unused private fields", Justification = "OK - SourceGenerator declaration field")] +public partial class TestFieldsDependencyPropertiesView +{ + public TestFieldsDependencyPropertiesView() + { + InitializeComponent(); + + IsRunning = false; + } + + [DependencyProperty(DefaultValue = true)] + private bool isRunning; + + [DependencyProperty(DefaultValue = 1.1)] + private decimal decimalValue; + + [DependencyProperty(DefaultValue = 1.1)] + private float floatValue; + + [DependencyProperty(DefaultValue = 1)] + private int intValue; + + [DependencyProperty] + private LogItem logItem; + + [DependencyProperty(DefaultValue = LogCategoryType.Debug)] + private LogCategoryType logCategory; + + [DependencyProperty(DefaultValue = "Hello world")] + private string stringValue; + + [DependencyProperty(DefaultValue = "error;err:")] + private IList errorTerms; + + [DependencyProperty(DefaultValue = "Red")] + private Color errorTextColor; + + [DependencyProperty(DefaultValue = "Red")] + private Brush errorTextBrush; + + [DependencyProperty(DefaultValue = "Consolas")] + private FontFamily myFontFamily; + + [DependencyProperty(DefaultValue = 12.2)] + private double myFontSize; +} \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj b/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj index 340cb943..0c2b8db2 100644 --- a/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj +++ b/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj @@ -42,8 +42,8 @@ - - + + diff --git a/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs index 1411bae1..dce09ccb 100644 --- a/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs +++ b/src/Atc.Wpf.Controls/BaseControls/DecimalXyBox.xaml.cs @@ -30,7 +30,7 @@ public event RoutedPropertyChangedEventHandler ValueYChanged nameof(HideUpDownButtons), typeof(bool), typeof(DecimalXyBox), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool HideUpDownButtons { diff --git a/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs index cee0eebf..e4a6eb74 100644 --- a/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs +++ b/src/Atc.Wpf.Controls/BaseControls/FilePicker.xaml.cs @@ -65,7 +65,7 @@ public string Title nameof(ShowClearTextButton), typeof(bool), typeof(FilePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool ShowClearTextButton { @@ -113,7 +113,7 @@ public TextTrimming WatermarkTrimming nameof(AllowOnlyExisting), typeof(bool), typeof(FilePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool AllowOnlyExisting { @@ -125,7 +125,7 @@ public bool AllowOnlyExisting nameof(UsePreviewPane), typeof(bool), typeof(FilePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool UsePreviewPane { diff --git a/src/Atc.Wpf.Controls/BaseControls/IntegerXyBox.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/IntegerXyBox.xaml.cs index 29610434..8e300f2e 100644 --- a/src/Atc.Wpf.Controls/BaseControls/IntegerXyBox.xaml.cs +++ b/src/Atc.Wpf.Controls/BaseControls/IntegerXyBox.xaml.cs @@ -30,7 +30,7 @@ public event RoutedPropertyChangedEventHandler ValueYChanged nameof(HideUpDownButtons), typeof(bool), typeof(IntegerXyBox), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool HideUpDownButtons { diff --git a/src/Atc.Wpf.Controls/BaseControls/PixelSizeBox.xaml.cs b/src/Atc.Wpf.Controls/BaseControls/PixelSizeBox.xaml.cs index 1336f179..b9ed2656 100644 --- a/src/Atc.Wpf.Controls/BaseControls/PixelSizeBox.xaml.cs +++ b/src/Atc.Wpf.Controls/BaseControls/PixelSizeBox.xaml.cs @@ -30,7 +30,7 @@ public event RoutedPropertyChangedEventHandler ValueHeightChanged nameof(HideUpDownButtons), typeof(bool), typeof(PixelSizeBox), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool HideUpDownButtons { diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelDatePicker.xaml.cs b/src/Atc.Wpf.Controls/LabelControls/LabelDatePicker.xaml.cs index b1027478..8657c2a7 100644 --- a/src/Atc.Wpf.Controls/LabelControls/LabelDatePicker.xaml.cs +++ b/src/Atc.Wpf.Controls/LabelControls/LabelDatePicker.xaml.cs @@ -173,7 +173,7 @@ public TextTrimming WatermarkTrimming nameof(OpenCalender), typeof(bool), typeof(LabelDatePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool OpenCalender { diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelDateTimePicker.xaml.cs b/src/Atc.Wpf.Controls/LabelControls/LabelDateTimePicker.xaml.cs index eba6d880..cc8ab996 100644 --- a/src/Atc.Wpf.Controls/LabelControls/LabelDateTimePicker.xaml.cs +++ b/src/Atc.Wpf.Controls/LabelControls/LabelDateTimePicker.xaml.cs @@ -191,7 +191,7 @@ public TextTrimming WatermarkTrimming nameof(OpenCalender), typeof(bool), typeof(LabelDateTimePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool OpenCalender { @@ -203,7 +203,7 @@ public bool OpenCalender nameof(OpenClock), typeof(bool), typeof(LabelDateTimePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool OpenClock { diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelDirectoryPicker.xaml.cs b/src/Atc.Wpf.Controls/LabelControls/LabelDirectoryPicker.xaml.cs index 7a8a36c4..509f677d 100644 --- a/src/Atc.Wpf.Controls/LabelControls/LabelDirectoryPicker.xaml.cs +++ b/src/Atc.Wpf.Controls/LabelControls/LabelDirectoryPicker.xaml.cs @@ -20,7 +20,7 @@ public DirectoryInfo? Value nameof(ShowClearTextButton), typeof(bool), typeof(LabelDirectoryPicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool ShowClearTextButton { @@ -32,7 +32,7 @@ public bool ShowClearTextButton nameof(AllowOnlyExisting), typeof(bool), typeof(LabelDirectoryPicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool AllowOnlyExisting { diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelFilePicker.xaml.cs b/src/Atc.Wpf.Controls/LabelControls/LabelFilePicker.xaml.cs index d590f559..b7bbad3d 100644 --- a/src/Atc.Wpf.Controls/LabelControls/LabelFilePicker.xaml.cs +++ b/src/Atc.Wpf.Controls/LabelControls/LabelFilePicker.xaml.cs @@ -20,7 +20,7 @@ public FileInfo? Value nameof(ShowClearTextButton), typeof(bool), typeof(LabelFilePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool ShowClearTextButton { @@ -32,7 +32,7 @@ public bool ShowClearTextButton nameof(AllowOnlyExisting), typeof(bool), typeof(LabelFilePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool AllowOnlyExisting { @@ -56,7 +56,7 @@ public string Filter nameof(UsePreviewPane), typeof(bool), typeof(LabelFilePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool UsePreviewPane { diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelTimePicker.xaml.cs b/src/Atc.Wpf.Controls/LabelControls/LabelTimePicker.xaml.cs index 31a80940..f0bf59c9 100644 --- a/src/Atc.Wpf.Controls/LabelControls/LabelTimePicker.xaml.cs +++ b/src/Atc.Wpf.Controls/LabelControls/LabelTimePicker.xaml.cs @@ -99,7 +99,7 @@ public TextTrimming WatermarkTrimming nameof(OpenClock), typeof(bool), typeof(LabelTimePicker), - new PropertyMetadata(default(bool))); + new PropertyMetadata(BooleanBoxes.FalseBox)); public bool OpenClock { diff --git a/src/Atc.Wpf/BooleanBoxes.cs b/src/Atc.Wpf/BooleanBoxes.cs index 5487a040..fe3ae9f6 100644 --- a/src/Atc.Wpf/BooleanBoxes.cs +++ b/src/Atc.Wpf/BooleanBoxes.cs @@ -1,48 +1,47 @@ -namespace Atc.Wpf +namespace Atc.Wpf; + +/// +/// Helps boxing Boolean values. +/// +/// +/// https://xstatic2.wordpress.com/2011/10/21/tip-improving-boolean-dependency-properties-performance/ +/// +public static class BooleanBoxes { /// - /// Helps boxing Boolean values. + /// Gets a boxed representation for "true" value. /// - /// - /// https://xstatic2.wordpress.com/2011/10/21/tip-improving-boolean-dependency-properties-performance/ - /// - public static class BooleanBoxes - { - /// - /// Gets a boxed representation for "true" value. - /// - public static readonly object TrueBox = true; + public static readonly object TrueBox = true; - /// - /// Gets a boxed representation for "false" value. - /// - public static readonly object FalseBox = false; + /// + /// Gets a boxed representation for "false" value. + /// + public static readonly object FalseBox = false; - /// - /// Returns a boxed representation for the specified Boolean value. - /// - /// The value to box. - /// A boxed value. - public static object Box(bool value) - => value - ? TrueBox - : FalseBox; + /// + /// Returns a boxed representation for the specified Boolean value. + /// + /// The value to box. + /// A boxed value. + public static object Box(bool value) + => value + ? TrueBox + : FalseBox; - /// - /// Returns a boxed value for the specified nullable . - /// - /// The value. - /// A boxed nullable value. - public static object? Box(bool? value) + /// + /// Returns a boxed value for the specified nullable . + /// + /// The value. + /// A boxed nullable value. + public static object? Box(bool? value) + { + if (value.HasValue) { - if (value.HasValue) - { - return value.Value - ? TrueBox - : FalseBox; - } - - return null; + return value.Value + ? TrueBox + : FalseBox; } + + return null; } } \ No newline at end of file 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 3e5cfee4..9006ccf0 100644 --- a/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj +++ b/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj @@ -9,15 +9,15 @@ - - + + NU1701 - - - + + +