add ability to show DialogBaseForm with custom created content
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||||
|
|
||||||
namespace Pilz.UI.Telerik.Dialogs
|
namespace Pilz.UI.Telerik.Dialogs
|
||||||
{
|
{
|
||||||
@@ -23,18 +24,28 @@ namespace Pilz.UI.Telerik.Dialogs
|
|||||||
|
|
||||||
public static T ShowDialog<T>(IWin32Window? parent, string title, Icon icon, object? tag = null) where T : FlyoutDialogBase
|
public static T ShowDialog<T>(IWin32Window? parent, string title, Icon icon, object? tag = null) where T : FlyoutDialogBase
|
||||||
{
|
{
|
||||||
var dialogPanel = Activator.CreateInstance<T>();
|
T dialogPanel = Activator.CreateInstance<T>();
|
||||||
dialogPanel.Dock = DockStyle.Fill;
|
|
||||||
dialogPanel.Tag = tag;
|
dialogPanel.Tag = tag;
|
||||||
|
return ShowDialog(dialogPanel, parent, title, icon);
|
||||||
|
}
|
||||||
|
|
||||||
var dialog = new DialogBaseForm
|
public static T ShowDialog<T>(T dialogPanel, string title, Icon icon) where T : FlyoutDialogBase
|
||||||
|
{
|
||||||
|
return ShowDialog(dialogPanel, null, title, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T ShowDialog<T>(T dialogPanel, IWin32Window? parent, string title, Icon icon) where T: FlyoutDialogBase
|
||||||
|
{
|
||||||
|
dialogPanel.Dock = DockStyle.Fill;
|
||||||
|
|
||||||
|
var dialog = new DialogBaseForm(dialogPanel)
|
||||||
{
|
{
|
||||||
DialogPanel = dialogPanel,
|
|
||||||
Text = title,
|
Text = title,
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
||||||
ClientSize = dialogPanel.Size
|
ClientSize = dialogPanel.Size
|
||||||
};
|
};
|
||||||
|
|
||||||
dialog.Controls.Add(dialogPanel);
|
dialog.Controls.Add(dialogPanel);
|
||||||
dialog.ShowDialog(parent);
|
dialog.ShowDialog(parent);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ namespace Pilz.UI.Telerik.Dialogs
|
|||||||
FormClosed += DialogBaseForm_FormClosed;
|
FormClosed += DialogBaseForm_FormClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DialogBaseForm(FlyoutDialogBase? dialogPanel) : this()
|
||||||
|
{
|
||||||
|
DialogPanel = dialogPanel;
|
||||||
|
}
|
||||||
|
|
||||||
private void DialogBaseForm_Load(object? sender, EventArgs e)
|
private void DialogBaseForm_Load(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (DialogPanel is ILoadContent iLoadContent)
|
if (DialogPanel is ILoadContent iLoadContent)
|
||||||
|
|||||||
Reference in New Issue
Block a user