enure handle created on load data complete
This commit is contained in:
@@ -8,6 +8,7 @@ namespace Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
public partial class RadFlyoutBase : UserControl
|
||||
{
|
||||
private bool addedControlsToUi;
|
||||
private RunWorkerCompletedEventArgs loadDataEventArgs;
|
||||
|
||||
protected RadButton radButton_Cancel;
|
||||
protected RadButton radButton_Confirm;
|
||||
@@ -34,6 +35,9 @@ public partial class RadFlyoutBase : UserControl
|
||||
[DefaultValue(true)]
|
||||
public bool RegisterDialogCancel { get; set; } = true;
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool EnsureHandleOnDataLoadComplete { get; set; } = true;
|
||||
|
||||
public new Size PreferredSize { get; set; } = Size.Empty;
|
||||
|
||||
[DefaultValue(true)]
|
||||
@@ -113,7 +117,6 @@ public partial class RadFlyoutBase : UserControl
|
||||
protected RadFlyoutBase()
|
||||
{
|
||||
InitializeComponent();
|
||||
ParentChanged += FlyoutDialogBase_ParentChanged;
|
||||
bgWorker_LoadData.DoWork += BgWorker_LoadData_DoWork;
|
||||
bgWorker_LoadData.RunWorkerCompleted += BgWorker_LoadData_RunWorkerCompleted;
|
||||
}
|
||||
@@ -125,10 +128,17 @@ public partial class RadFlyoutBase : UserControl
|
||||
|
||||
protected virtual void BgWorker_LoadData_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
BeginInvoke(() => OnLoadDataCompleted(e));
|
||||
loadDataEventArgs = null;
|
||||
|
||||
if (!EnsureHandleOnDataLoadComplete || IsHandleCreated)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
BeginInvoke(() => OnLoadDataCompleted(e));
|
||||
else
|
||||
OnLoadDataCompleted(e);
|
||||
}
|
||||
else
|
||||
OnLoadDataCompleted(e);
|
||||
loadDataEventArgs = e;
|
||||
}
|
||||
|
||||
protected virtual void LoadData()
|
||||
@@ -236,6 +246,19 @@ public partial class RadFlyoutBase : UserControl
|
||||
tableLayoutPanel_ActionPanel.ResumeLayout(false);
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
|
||||
if (EnsureHandleOnDataLoadComplete && loadDataEventArgs != null)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
BeginInvoke(() => OnLoadDataCompleted(loadDataEventArgs));
|
||||
else
|
||||
OnLoadDataCompleted(loadDataEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
if (!addedControlsToUi && !DesignMode)
|
||||
@@ -253,7 +276,13 @@ public partial class RadFlyoutBase : UserControl
|
||||
base.OnLoad(e);
|
||||
}
|
||||
|
||||
protected virtual void FlyoutDialogBase_ParentChanged(object? sender, EventArgs e)
|
||||
protected override void OnParentChanged(EventArgs e)
|
||||
{
|
||||
base.OnParentChanged(e);
|
||||
HandleOnParentChanged(e);
|
||||
}
|
||||
|
||||
protected virtual void HandleOnParentChanged(EventArgs e)
|
||||
{
|
||||
var frm = FindForm();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user