ensure the flyout is closed before opening a new one

This commit is contained in:
Pilzinsel64
2025-04-08 08:32:28 +02:00
parent b60f8541f2
commit 3292c09a5f
2 changed files with 24 additions and 3 deletions

View File

@@ -101,14 +101,23 @@ partial class RadFlyoutBase
titleToAssing = title; titleToAssing = title;
iconToAssign = icon; iconToAssign = icon;
ParentContext = controlToAssociate; ParentContext = controlToAssociate;
CloseFlyout(false); // Ensure it's closed!
RadFlyoutManager.Show(controlToAssociate, flyoutContentType); RadFlyoutManager.Show(controlToAssociate, flyoutContentType);
} }
protected static void CloseFlyout() protected static void CloseFlyout()
{ {
if (ParentContext == null) CloseFlyout(true);
}
protected static void CloseFlyout(bool throwOnError)
{
if (throwOnError && ParentContext is null)
throw new NullReferenceException(nameof(ParentContext)); throw new NullReferenceException(nameof(ParentContext));
ParentContext.BeginInvoke(RadFlyoutManager.Close); if (ParentContext is null)
RadFlyoutManager.Close();
else
ParentContext.BeginInvoke(RadFlyoutManager.Close);
} }
} }

View File

@@ -1,5 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Telerik.WinControls; using Telerik.WinControls;
using Telerik.WinControls.UI; using Telerik.WinControls.UI;
@@ -27,6 +26,8 @@ public partial class RadFlyoutBase : UserControl
[DefaultValue(true)] [DefaultValue(true)]
public bool RegisterDialogCancel { get; set; } = true; public bool RegisterDialogCancel { get; set; } = true;
public new Size PreferredSize { get; set; } = Size.Empty;
[DefaultValue(true)] [DefaultValue(true)]
public virtual bool ActionPanelVisible public virtual bool ActionPanelVisible
{ {
@@ -224,9 +225,20 @@ public partial class RadFlyoutBase : UserControl
frm.AutoSize = true; frm.AutoSize = true;
frm.AutoSizeMode = AutoSizeMode.GrowAndShrink; frm.AutoSizeMode = AutoSizeMode.GrowAndShrink;
} }
frm.Shown += Form_Shown;
} }
} }
private void Form_Shown(object? sender, EventArgs e)
{
if (FindForm() is not Form frm)
return;
if (!AutoSize)
frm.ClientSize = PreferredSize;
}
protected void Close(DialogResult result) protected void Close(DialogResult result)
{ {
Result = result; Result = result;