为窗口抽屉添加代码注释
This commit is contained in:
@@ -19,7 +19,9 @@ namespace Deedy
|
||||
public class DrawerViewer : Adorner
|
||||
{
|
||||
private readonly VisualCollection _visualChildren;
|
||||
|
||||
/// <summary>
|
||||
/// 抽屉外边框
|
||||
/// </summary>
|
||||
private readonly Border _border;
|
||||
public Brush Background { get => (Brush)GetValue(BackgroundProperty); set => SetValue(BackgroundProperty, value); }
|
||||
public static readonly DependencyProperty BackgroundProperty = Border.BackgroundProperty.AddOwner(typeof(DrawerViewer));
|
||||
@@ -29,7 +31,9 @@ namespace Deedy
|
||||
public static readonly DependencyProperty BorderThicknessProperty = Border.BorderThicknessProperty.AddOwner(typeof(DrawerViewer));
|
||||
public CornerRadius CornerRadius { get => (CornerRadius)GetValue(CornerRadiusProperty); set => SetValue(CornerRadiusProperty, value); }
|
||||
public static readonly DependencyProperty CornerRadiusProperty = Border.CornerRadiusProperty.AddOwner(typeof(DrawerViewer));
|
||||
|
||||
/// <summary>
|
||||
/// 抽屉内容容器
|
||||
/// </summary>
|
||||
private readonly ContentPresenter _contentPresenter;
|
||||
public object Content { get => GetValue(ContentProperty); set => SetValue(ContentProperty, value); }
|
||||
public static readonly DependencyProperty ContentProperty = ContentPresenter.ContentProperty.AddOwner(typeof(DrawerViewer));
|
||||
@@ -100,8 +104,14 @@ namespace Deedy
|
||||
|
||||
_border.Child = _contentPresenter;
|
||||
}
|
||||
/// <summary>
|
||||
/// 要注册的事件
|
||||
/// </summary>
|
||||
[AllowNull]
|
||||
private readonly RoutedEvent[] _routedEvents;
|
||||
/// <summary>
|
||||
/// 事件响应方法
|
||||
/// </summary>
|
||||
private readonly RoutedEventHandler? _routedEventHandler;
|
||||
/// <summary>
|
||||
/// 在特定「UIElement」上创建「WindowDrawer」蒙层,同时绑定特定路由事件
|
||||
@@ -149,6 +159,10 @@ namespace Deedy
|
||||
_border.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
|
||||
return finalSize;
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示抽屉并播放入场动画
|
||||
/// </summary>
|
||||
/// <param name="seconds">动画持续时间</param>
|
||||
public void ShowWithAnimation(double seconds = 1)
|
||||
{
|
||||
var doubleAnimation = new DoubleAnimation
|
||||
@@ -169,6 +183,10 @@ namespace Deedy
|
||||
};
|
||||
_border.BeginAnimation(MarginProperty, marginAnimation);
|
||||
}
|
||||
/// <summary>
|
||||
/// 关闭抽屉并播放出场动画;同时清理事件注册
|
||||
/// </summary>
|
||||
/// <param name="seconds">动画持续时间</param>
|
||||
public void HideWithAnimation(double seconds = 1)
|
||||
{
|
||||
var doubleAnimation = new DoubleAnimation
|
||||
|
||||
Reference in New Issue
Block a user