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
|
public partial class RadFlyoutBase : UserControl
|
||||||
{
|
{
|
||||||
private bool addedControlsToUi;
|
private bool addedControlsToUi;
|
||||||
|
private RunWorkerCompletedEventArgs loadDataEventArgs;
|
||||||
|
|
||||||
protected RadButton radButton_Cancel;
|
protected RadButton radButton_Cancel;
|
||||||
protected RadButton radButton_Confirm;
|
protected RadButton radButton_Confirm;
|
||||||
@@ -34,6 +35,9 @@ public partial class RadFlyoutBase : UserControl
|
|||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
public bool RegisterDialogCancel { get; set; } = true;
|
public bool RegisterDialogCancel { get; set; } = true;
|
||||||
|
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool EnsureHandleOnDataLoadComplete { get; set; } = true;
|
||||||
|
|
||||||
public new Size PreferredSize { get; set; } = Size.Empty;
|
public new Size PreferredSize { get; set; } = Size.Empty;
|
||||||
|
|
||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
@@ -113,7 +117,6 @@ public partial class RadFlyoutBase : UserControl
|
|||||||
protected RadFlyoutBase()
|
protected RadFlyoutBase()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ParentChanged += FlyoutDialogBase_ParentChanged;
|
|
||||||
bgWorker_LoadData.DoWork += BgWorker_LoadData_DoWork;
|
bgWorker_LoadData.DoWork += BgWorker_LoadData_DoWork;
|
||||||
bgWorker_LoadData.RunWorkerCompleted += BgWorker_LoadData_RunWorkerCompleted;
|
bgWorker_LoadData.RunWorkerCompleted += BgWorker_LoadData_RunWorkerCompleted;
|
||||||
}
|
}
|
||||||
@@ -124,12 +127,19 @@ public partial class RadFlyoutBase : UserControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void BgWorker_LoadData_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e)
|
protected virtual void BgWorker_LoadData_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
loadDataEventArgs = null;
|
||||||
|
|
||||||
|
if (!EnsureHandleOnDataLoadComplete || IsHandleCreated)
|
||||||
{
|
{
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
BeginInvoke(() => OnLoadDataCompleted(e));
|
BeginInvoke(() => OnLoadDataCompleted(e));
|
||||||
else
|
else
|
||||||
OnLoadDataCompleted(e);
|
OnLoadDataCompleted(e);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
loadDataEventArgs = e;
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void LoadData()
|
protected virtual void LoadData()
|
||||||
{
|
{
|
||||||
@@ -236,6 +246,19 @@ public partial class RadFlyoutBase : UserControl
|
|||||||
tableLayoutPanel_ActionPanel.ResumeLayout(false);
|
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)
|
protected override void OnLoad(EventArgs e)
|
||||||
{
|
{
|
||||||
if (!addedControlsToUi && !DesignMode)
|
if (!addedControlsToUi && !DesignMode)
|
||||||
@@ -253,7 +276,13 @@ public partial class RadFlyoutBase : UserControl
|
|||||||
base.OnLoad(e);
|
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();
|
var frm = FindForm();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user