chore: use file-scoped namespace

This commit is contained in:
NaBian committed 2022-03-13 20:28:58 +08:00
1 parent 99d2fafb72
commit bbf1b7d4c6
748 files changed
+57929 -58678

No files matched your search

@@ -4,42 +4,41 @@ using System.Windows.Shapes;
using HandyControl.Data;
using HandyControl.Tools.Converter;
namespace HandyControl.Controls
{
public class RectangleAttach
{
public static readonly DependencyProperty CircularProperty = DependencyProperty.RegisterAttached(
"Circular", typeof(bool), typeof(RectangleAttach), new PropertyMetadata(ValueBoxes.FalseBox, OnCircularChanged));
namespace HandyControl.Controls;
private static void OnCircularChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
public class RectangleAttach
{
public static readonly DependencyProperty CircularProperty = DependencyProperty.RegisterAttached(
"Circular", typeof(bool), typeof(RectangleAttach), new PropertyMetadata(ValueBoxes.FalseBox, OnCircularChanged));
private static void OnCircularChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Rectangle rectangle)
{
if (d is Rectangle rectangle)
if ((bool) e.NewValue)
{
if ((bool) e.NewValue)
var binding = new MultiBinding
{
var binding = new MultiBinding
{
Converter = new RectangleCircularConverter()
};
binding.Bindings.Add(new Binding(FrameworkElement.ActualWidthProperty.Name) { Source = rectangle });
binding.Bindings.Add(new Binding(FrameworkElement.ActualHeightProperty.Name) { Source = rectangle });
rectangle.SetBinding(Rectangle.RadiusXProperty, binding);
rectangle.SetBinding(Rectangle.RadiusYProperty, binding);
}
else
{
BindingOperations.ClearBinding(rectangle, FrameworkElement.ActualWidthProperty);
BindingOperations.ClearBinding(rectangle, FrameworkElement.ActualHeightProperty);
BindingOperations.ClearBinding(rectangle, Rectangle.RadiusXProperty);
BindingOperations.ClearBinding(rectangle, Rectangle.RadiusYProperty);
}
Converter = new RectangleCircularConverter()
};
binding.Bindings.Add(new Binding(FrameworkElement.ActualWidthProperty.Name) { Source = rectangle });
binding.Bindings.Add(new Binding(FrameworkElement.ActualHeightProperty.Name) { Source = rectangle });
rectangle.SetBinding(Rectangle.RadiusXProperty, binding);
rectangle.SetBinding(Rectangle.RadiusYProperty, binding);
}
else
{
BindingOperations.ClearBinding(rectangle, FrameworkElement.ActualWidthProperty);
BindingOperations.ClearBinding(rectangle, FrameworkElement.ActualHeightProperty);
BindingOperations.ClearBinding(rectangle, Rectangle.RadiusXProperty);
BindingOperations.ClearBinding(rectangle, Rectangle.RadiusYProperty);
}
}
public static void SetCircular(DependencyObject element, bool value)
=> element.SetValue(CircularProperty, ValueBoxes.BooleanBox(value));
public static bool GetCircular(DependencyObject element)
=> (bool) element.GetValue(CircularProperty);
}
}
public static void SetCircular(DependencyObject element, bool value)
=> element.SetValue(CircularProperty, ValueBoxes.BooleanBox(value));
public static bool GetCircular(DependencyObject element)
=> (bool) element.GetValue(CircularProperty);
}