diff --git a/Screenbox/Converters/ThicknessFiltersConverter.cs b/Screenbox/Converters/ThicknessFiltersConverter.cs
index ccc56b8de..afceca224 100644
--- a/Screenbox/Converters/ThicknessFiltersConverter.cs
+++ b/Screenbox/Converters/ThicknessFiltersConverter.cs
@@ -39,9 +39,23 @@ public enum ThicknessFilterKinds
///
Bottom = 8,
- //Horizontal = Left | Right,
+ ///
+ /// Filters Left and Right values, sets Top and Bottom to 0.
+ ///
+ /// This value combines the and flags.
+ Horizontal = Left | Right,
+
+ ///
+ /// Filters Top and Bottom values, sets Left and Right to 0.
+ ///
+ /// This value combines the and flags.
+ Vertical = Top | Bottom,
- //Vertical = Top | Bottom,
+ ///
+ /// Filters Left, Top, Right, and Bottom values.
+ ///
+ /// This value combines the , , , and flags.
+ All = Left | Top | Right | Bottom
}
///
@@ -87,16 +101,16 @@ public enum ThicknessFilterKinds
/// var thicknessFilter = ThicknessFilterKinds.Top | ThicknessFilterKinds.Bottom;
///
/// // Attach the converter to the target. For example:
-/// myBorder.BorderThickness = thicknessConverter.Convert(exampleThickness, thicknessFilter);
+/// myBorder.BorderThickness = thicknessConverter.Extract(exampleThickness, thicknessFilter);
///
///
-public sealed partial class ThicknessFiltersConverter : DependencyObject, IValueConverter
+public sealed class ThicknessFiltersConverter : DependencyObject, IValueConverter
{
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty FiltersProperty = DependencyProperty.Register(
- nameof(Filters), typeof(ThicknessFilterKinds), typeof(ThicknessFiltersConverter), new PropertyMetadata(null));
+ nameof(Filters), typeof(ThicknessFilterKinds), typeof(ThicknessFiltersConverter), new PropertyMetadata(ThicknessFilterKinds.None));
///
/// Gets or sets the type of the filter applied to the .
@@ -108,25 +122,23 @@ public ThicknessFilterKinds Filters
}
///
- /// Converts the specified based on the provided filter type.
+ /// Extracts the specified fields based on the provided combination.
///
- /// The source to convert.
- /// An enumeration that specifies the filter type.
- /// A new with only the fields specified by the , while the rest are set to 0.
- public Thickness Convert(Thickness thickness, ThicknessFilterKinds filterKinds)
+ /// The source instance to extract values from.
+ /// A combination of values specifying the extraction behavior.
+ /// A containing only the specified fields from , the others are set to 0.
+ public static Thickness Extract(Thickness thickness, ThicknessFilterKinds filterKinds)
{
- var result = thickness;
-
- if (filterKinds is not ThicknessFilterKinds.None)
+ if (filterKinds != ThicknessFilterKinds.None)
{
return new Thickness(
- filterKinds.HasFlag(ThicknessFilterKinds.Left) ? result.Left : 0,
- filterKinds.HasFlag(ThicknessFilterKinds.Top) ? result.Top : 0,
- filterKinds.HasFlag(ThicknessFilterKinds.Right) ? result.Right : 0,
- filterKinds.HasFlag(ThicknessFilterKinds.Bottom) ? result.Bottom : 0);
+ filterKinds.HasFlag(ThicknessFilterKinds.Left) ? thickness.Left : 0,
+ filterKinds.HasFlag(ThicknessFilterKinds.Top) ? thickness.Top : 0,
+ filterKinds.HasFlag(ThicknessFilterKinds.Right) ? thickness.Right : 0,
+ filterKinds.HasFlag(ThicknessFilterKinds.Bottom) ? thickness.Bottom : 0);
}
- return result;
+ return new Thickness();
}
///
@@ -142,11 +154,10 @@ public object Convert(object value, Type targetType, object parameter, string la
{
if (value is Thickness thickness)
{
- var filtersType = Filters;
- return Convert(thickness, filtersType);
+ return Extract(thickness, Filters);
}
- return null;
+ return DependencyProperty.UnsetValue;
}
///