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

@@ -5,104 +5,103 @@ using System.Windows.Media.Animation;
using HandyControl.Data;
using HandyControl.Tools;
namespace HandyControl.Controls
namespace HandyControl.Controls;
public class TransitioningContentControl : ContentControl
{
public class TransitioningContentControl : ContentControl
private FrameworkElement _contentPresenter;
private static Storyboard StoryboardBuildInDefault;
private Storyboard _storyboardBuildIn;
public TransitioningContentControl()
{
private FrameworkElement _contentPresenter;
Loaded += TransitioningContentControl_Loaded;
Unloaded += TransitioningContentControl_Unloaded;
}
private static Storyboard StoryboardBuildInDefault;
public static readonly DependencyProperty TransitionModeProperty = DependencyProperty.Register(
"TransitionMode", typeof(TransitionMode), typeof(TransitioningContentControl), new PropertyMetadata(default(TransitionMode), OnTransitionModeChanged));
private Storyboard _storyboardBuildIn;
private static void OnTransitionModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (TransitioningContentControl) d;
ctl.OnTransitionModeChanged((TransitionMode) e.NewValue);
}
public TransitioningContentControl()
private void OnTransitionModeChanged(TransitionMode newValue)
{
_storyboardBuildIn = ResourceHelper.GetResourceInternal<Storyboard>($"{newValue}Transition");
StartTransition();
}
public TransitionMode TransitionMode
{
get => (TransitionMode) GetValue(TransitionModeProperty);
set => SetValue(TransitionModeProperty, value);
}
public static readonly DependencyProperty TransitionStoryboardProperty = DependencyProperty.Register(
"TransitionStoryboard", typeof(Storyboard), typeof(TransitioningContentControl), new PropertyMetadata(default(Storyboard)));
public Storyboard TransitionStoryboard
{
get => (Storyboard) GetValue(TransitionStoryboardProperty);
set => SetValue(TransitionStoryboardProperty, value);
}
private void TransitioningContentControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) => StartTransition();
private void TransitioningContentControl_Loaded(object sender, RoutedEventArgs e)
{
IsVisibleChanged += TransitioningContentControl_IsVisibleChanged;
}
private void TransitioningContentControl_Unloaded(object sender, RoutedEventArgs e)
{
IsVisibleChanged -= TransitioningContentControl_IsVisibleChanged;
}
private void StartTransition()
{
if (_contentPresenter == null || !IsVisible) return;
if (TransitionStoryboard != null)
{
Loaded += TransitioningContentControl_Loaded;
Unloaded += TransitioningContentControl_Unloaded;
TransitionStoryboard.Begin(_contentPresenter);
}
public static readonly DependencyProperty TransitionModeProperty = DependencyProperty.Register(
"TransitionMode", typeof(TransitionMode), typeof(TransitioningContentControl), new PropertyMetadata(default(TransitionMode), OnTransitionModeChanged));
private static void OnTransitionModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
else if (_storyboardBuildIn != null)
{
var ctl = (TransitioningContentControl) d;
ctl.OnTransitionModeChanged((TransitionMode) e.NewValue);
_storyboardBuildIn?.Begin(_contentPresenter);
}
private void OnTransitionModeChanged(TransitionMode newValue)
else
{
_storyboardBuildIn = ResourceHelper.GetResourceInternal<Storyboard>($"{newValue}Transition");
StartTransition();
}
public TransitionMode TransitionMode
{
get => (TransitionMode) GetValue(TransitionModeProperty);
set => SetValue(TransitionModeProperty, value);
}
public static readonly DependencyProperty TransitionStoryboardProperty = DependencyProperty.Register(
"TransitionStoryboard", typeof(Storyboard), typeof(TransitioningContentControl), new PropertyMetadata(default(Storyboard)));
public Storyboard TransitionStoryboard
{
get => (Storyboard) GetValue(TransitionStoryboardProperty);
set => SetValue(TransitionStoryboardProperty, value);
}
private void TransitioningContentControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) => StartTransition();
private void TransitioningContentControl_Loaded(object sender, RoutedEventArgs e)
{
IsVisibleChanged += TransitioningContentControl_IsVisibleChanged;
}
private void TransitioningContentControl_Unloaded(object sender, RoutedEventArgs e)
{
IsVisibleChanged -= TransitioningContentControl_IsVisibleChanged;
}
private void StartTransition()
{
if (_contentPresenter == null || !IsVisible) return;
if (TransitionStoryboard != null)
{
TransitionStoryboard.Begin(_contentPresenter);
}
else if (_storyboardBuildIn != null)
{
_storyboardBuildIn?.Begin(_contentPresenter);
}
else
{
StoryboardBuildInDefault ??= ResourceHelper.GetResourceInternal<Storyboard>($"{default(TransitionMode)}Transition");
StoryboardBuildInDefault?.Begin(_contentPresenter);
}
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_contentPresenter = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;
if (_contentPresenter != null)
{
_contentPresenter.RenderTransformOrigin = new Point(0.5, 0.5);
_contentPresenter.RenderTransform = new TransformGroup
{
Children =
{
new ScaleTransform(),
new SkewTransform(),
new RotateTransform(),
new TranslateTransform()
}
};
}
StartTransition();
StoryboardBuildInDefault ??= ResourceHelper.GetResourceInternal<Storyboard>($"{default(TransitionMode)}Transition");
StoryboardBuildInDefault?.Begin(_contentPresenter);
}
}
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_contentPresenter = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;
if (_contentPresenter != null)
{
_contentPresenter.RenderTransformOrigin = new Point(0.5, 0.5);
_contentPresenter.RenderTransform = new TransformGroup
{
Children =
{
new ScaleTransform(),
new SkewTransform(),
new RotateTransform(),
new TranslateTransform()
}
};
}
StartTransition();
}
}