Merge branch 'master' into pr/75
This commit is contained in:
commit
9b0205a030
125 files changed
+5048
-832
No files matched your search
@@ -15,7 +15,7 @@ namespace HandyControl.Controls
|
||||
private bool _isLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// 故事版
|
||||
/// 故事板
|
||||
/// </summary>
|
||||
private Storyboard _storyboard;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
@@ -12,6 +14,8 @@ namespace HandyControl.Controls
|
||||
{
|
||||
private Adorner _container;
|
||||
|
||||
private static readonly Dictionary<string, System.Windows.Window> WindowDic = new Dictionary<string, System.Windows.Window>();
|
||||
|
||||
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
|
||||
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
@@ -21,21 +25,94 @@ namespace HandyControl.Controls
|
||||
internal set => SetValue(IsClosedProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TokenProperty = DependencyProperty.RegisterAttached(
|
||||
"Token", typeof(string), typeof(Dialog), new PropertyMetadata(default(string), OnTokenChanged));
|
||||
|
||||
private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is System.Windows.Window window)
|
||||
{
|
||||
if (e.NewValue == null)
|
||||
{
|
||||
Unregister(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
Register(e.NewValue.ToString(), window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetToken(DependencyObject element, string value)
|
||||
=> element.SetValue(TokenProperty, value);
|
||||
|
||||
public static string GetToken(DependencyObject element)
|
||||
=> (string) element.GetValue(TokenProperty);
|
||||
|
||||
public Dialog()
|
||||
{
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close()));
|
||||
}
|
||||
|
||||
public static Dialog Show<T>() where T : new() => Show(new T());
|
||||
public static void Register(string token, System.Windows.Window window)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token) || window == null) return;
|
||||
WindowDic[token] = window;
|
||||
}
|
||||
|
||||
public static Dialog Show(object content)
|
||||
public static void Unregister(string token, System.Windows.Window window)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token) || window == null) return;
|
||||
|
||||
if (WindowDic.ContainsKey(token))
|
||||
{
|
||||
if (ReferenceEquals(WindowDic[token], window))
|
||||
{
|
||||
WindowDic.Remove(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister(System.Windows.Window window)
|
||||
{
|
||||
if (window == null) return;
|
||||
var first = WindowDic.FirstOrDefault(item => ReferenceEquals(window, item.Value));
|
||||
if (!string.IsNullOrEmpty(first.Key))
|
||||
{
|
||||
WindowDic.Remove(first.Key);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token)) return;
|
||||
|
||||
if (WindowDic.ContainsKey(token))
|
||||
{
|
||||
WindowDic.Remove(token);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dialog Show<T>(string token = "") where T : new() => Show(new T(), token);
|
||||
|
||||
public static Dialog Show(object content, string token = "")
|
||||
{
|
||||
var dialog = new Dialog
|
||||
{
|
||||
Content = content
|
||||
};
|
||||
|
||||
var window = VisualHelper.GetActiveWindow();
|
||||
System.Windows.Window window;
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
window = VisualHelper.GetActiveWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowDic.TryGetValue(token, out window);
|
||||
}
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
var decorator = VisualHelper.GetChild<AdornerDecorator>(window);
|
||||
@@ -62,9 +139,23 @@ namespace HandyControl.Controls
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
public void Close(string token = "")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
if (WindowDic.TryGetValue(token, out var window))
|
||||
{
|
||||
Close(window);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Close(VisualHelper.GetActiveWindow());
|
||||
}
|
||||
}
|
||||
|
||||
private void Close(System.Windows.Window window)
|
||||
{
|
||||
var window = VisualHelper.GetActiveWindow();
|
||||
if (window != null)
|
||||
{
|
||||
var decorator = VisualHelper.GetChild<AdornerDecorator>(window);
|
||||
|
||||
@@ -98,6 +98,19 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token)) return;
|
||||
|
||||
if (PanelDic.ContainsKey(token))
|
||||
{
|
||||
var panel = PanelDic[token];
|
||||
PanelDic.Remove(token);
|
||||
panel.ContextMenu = null;
|
||||
panel.SetCurrentValue(PanelElement.FluidMoveBehaviorProperty, DependencyProperty.UnsetValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
|
||||
@@ -114,7 +114,8 @@ namespace HandyControl.Controls
|
||||
_isRunning = false;
|
||||
};
|
||||
_isRunning = true;
|
||||
BeginAnimation(CurrentVerticalOffsetProperty, animation);
|
||||
|
||||
BeginAnimation(CurrentVerticalOffsetProperty, animation, HandoffBehavior.Compose);
|
||||
}
|
||||
|
||||
internal void ScrollToHorizontalOffsetInternal(double offset, double milliseconds = 500)
|
||||
@@ -131,7 +132,8 @@ namespace HandyControl.Controls
|
||||
_isRunning = false;
|
||||
};
|
||||
_isRunning = true;
|
||||
BeginAnimation(CurrentHorizontalOffsetProperty, animation);
|
||||
|
||||
BeginAnimation(CurrentHorizontalOffsetProperty, animation, HandoffBehavior.Compose);
|
||||
}
|
||||
|
||||
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) =>
|
||||
@@ -150,7 +152,7 @@ namespace HandyControl.Controls
|
||||
|
||||
public static bool GetIsEnableInertia(DependencyObject element)
|
||||
{
|
||||
return (bool) element.GetValue(IsEnableInertiaProperty);
|
||||
return (bool)element.GetValue(IsEnableInertiaProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -158,7 +160,7 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
public bool IsEnableInertia
|
||||
{
|
||||
get => (bool)GetValue(IsEnableInertiaProperty);
|
||||
get => (bool) GetValue(IsEnableInertiaProperty);
|
||||
set => SetValue(IsEnableInertiaProperty, value);
|
||||
}
|
||||
|
||||
@@ -173,7 +175,7 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
public bool IsPenetrating
|
||||
{
|
||||
get => (bool)GetValue(IsPenetratingProperty);
|
||||
get => (bool) GetValue(IsPenetratingProperty);
|
||||
set => SetValue(IsPenetratingProperty, value);
|
||||
}
|
||||
|
||||
@@ -190,7 +192,7 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 当前垂直滚动偏移
|
||||
/// </summary>
|
||||
private static readonly DependencyProperty CurrentVerticalOffsetProperty = DependencyProperty.Register(
|
||||
internal static readonly DependencyProperty CurrentVerticalOffsetProperty = DependencyProperty.Register(
|
||||
"CurrentVerticalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(ValueBoxes.Double0Box, OnCurrentVerticalOffsetChanged));
|
||||
|
||||
private static void OnCurrentVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
@@ -204,7 +206,7 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 当前垂直滚动偏移
|
||||
/// </summary>
|
||||
private double CurrentVerticalOffset
|
||||
internal double CurrentVerticalOffset
|
||||
{
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
get => (double) GetValue(CurrentVerticalOffsetProperty);
|
||||
@@ -214,7 +216,7 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 当前水平滚动偏移
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CurrentHorizontalOffsetProperty = DependencyProperty.Register(
|
||||
internal static readonly DependencyProperty CurrentHorizontalOffsetProperty = DependencyProperty.Register(
|
||||
"CurrentHorizontalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(ValueBoxes.Double0Box, OnCurrentHorizontalOffsetChanged));
|
||||
|
||||
private static void OnCurrentHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
@@ -228,7 +230,7 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 当前水平滚动偏移
|
||||
/// </summary>
|
||||
public double CurrentHorizontalOffset
|
||||
internal double CurrentHorizontalOffset
|
||||
{
|
||||
get => (double) GetValue(CurrentHorizontalOffsetProperty);
|
||||
set => SetValue(CurrentHorizontalOffsetProperty, value);
|
||||
|
||||
Reference in new issue
Block a user