feat: add TryGetXXManager to WindowXXManager.
This commit is contained in:
@@ -5,6 +5,7 @@ using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -69,6 +70,12 @@ public class WindowNotificationManager : WindowMessageManager, INotificationMana
|
||||
VerticalAlignmentProperty.OverrideDefaultValue<WindowNotificationManager>(VerticalAlignment.Stretch);
|
||||
}
|
||||
|
||||
public static bool TryGetNotificationManager(Visual? visual, out WindowNotificationManager? manager)
|
||||
{
|
||||
manager = visual?.FindDescendantOfType<WindowNotificationManager>();
|
||||
return manager is not null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Show(INotification content)
|
||||
{
|
||||
|
||||
@@ -84,6 +84,12 @@ public abstract class WindowMessageManager : TemplatedControl
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetMessageManager(Visual? visual, out WindowMessageManager? manager)
|
||||
{
|
||||
manager = visual?.FindDescendantOfType<WindowMessageManager>();
|
||||
return manager is not null;
|
||||
}
|
||||
|
||||
protected void TopLevelOnTemplateApplied(object? sender, TemplateAppliedEventArgs e)
|
||||
{
|
||||
if (Parent is AdornerLayer adornerLayer)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -33,6 +35,12 @@ public class WindowToastManager : WindowMessageManager, IToastManager
|
||||
{
|
||||
}
|
||||
|
||||
public static bool TryGetToastManager(Visual? visual, out WindowToastManager? manager)
|
||||
{
|
||||
manager = visual?.FindDescendantOfType<WindowToastManager>();
|
||||
return manager is not null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Show(IToast content)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user