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

@@ -2,41 +2,40 @@
using System.Windows.Controls;
using System.Windows.Media;
namespace HandyControl.Controls
namespace HandyControl.Controls;
public class ImageAttach
{
public class ImageAttach
public static readonly DependencyProperty SourceFailedProperty = DependencyProperty.RegisterAttached(
"SourceFailed", typeof(ImageSource), typeof(ImageAttach), new FrameworkPropertyMetadata(default(ImageSource), FrameworkPropertyMetadataOptions.Inherits, OnSourceFailedChanged));
private static void OnSourceFailedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
public static readonly DependencyProperty SourceFailedProperty = DependencyProperty.RegisterAttached(
"SourceFailed", typeof(ImageSource), typeof(ImageAttach), new FrameworkPropertyMetadata(default(ImageSource), FrameworkPropertyMetadataOptions.Inherits, OnSourceFailedChanged));
private static void OnSourceFailedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
if (d is Image image)
{
if (d is Image image)
if (e.NewValue is ImageSource)
{
if (e.NewValue is ImageSource)
{
image.ImageFailed += Image_ImageFailed;
}
else
{
image.ImageFailed -= Image_ImageFailed;
}
image.ImageFailed += Image_ImageFailed;
}
}
private static void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
{
if (sender is Image image)
else
{
image.SetCurrentValue(Image.SourceProperty, GetSourceFailed(image));
image.ImageFailed -= Image_ImageFailed;
}
}
public static void SetSourceFailed(DependencyObject element, ImageSource value)
=> element.SetValue(SourceFailedProperty, value);
public static ImageSource GetSourceFailed(DependencyObject element)
=> (ImageSource) element.GetValue(SourceFailedProperty);
}
}
private static void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
{
if (sender is Image image)
{
image.SetCurrentValue(Image.SourceProperty, GetSourceFailed(image));
image.ImageFailed -= Image_ImageFailed;
}
}
public static void SetSourceFailed(DependencyObject element, ImageSource value)
=> element.SetValue(SourceFailedProperty, value);
public static ImageSource GetSourceFailed(DependencyObject element)
=> (ImageSource) element.GetValue(SourceFailedProperty);
}