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