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.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace Pilz.UI.Telerik.Dialogs
|
||||
{
|
||||
@@ -19,26 +20,36 @@ namespace Pilz.UI.Telerik.Dialogs
|
||||
public static T ShowDialog<T>(string title, Icon icon, object? tag = null) where T : FlyoutDialogBase
|
||||
{
|
||||
return ShowDialog<T>(null, title, icon, tag);
|
||||
}
|
||||
}
|
||||
|
||||
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>();
|
||||
dialogPanel.Dock = DockStyle.Fill;
|
||||
dialogPanel.Tag = tag;
|
||||
T dialogPanel = Activator.CreateInstance<T>();
|
||||
dialogPanel.Tag = tag;
|
||||
return ShowDialog(dialogPanel, parent, title, icon);
|
||||
}
|
||||
|
||||
var dialog = new DialogBaseForm
|
||||
{
|
||||
DialogPanel = dialogPanel,
|
||||
Text = title,
|
||||
Icon = icon,
|
||||
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
||||
ClientSize = dialogPanel.Size
|
||||
};
|
||||
dialog.Controls.Add(dialogPanel);
|
||||
dialog.ShowDialog(parent);
|
||||
public static T ShowDialog<T>(T dialogPanel, string title, Icon icon) where T : FlyoutDialogBase
|
||||
{
|
||||
return ShowDialog(dialogPanel, null, title, icon);
|
||||
}
|
||||
|
||||
return dialogPanel;
|
||||
}
|
||||
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)
|
||||
{
|
||||
Text = title,
|
||||
Icon = icon,
|
||||
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
||||
ClientSize = dialogPanel.Size
|
||||
};
|
||||
|
||||
dialog.Controls.Add(dialogPanel);
|
||||
dialog.ShowDialog(parent);
|
||||
|
||||
return dialogPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace Pilz.UI.Telerik.Dialogs
|
||||
FormClosed += DialogBaseForm_FormClosed;
|
||||
}
|
||||
|
||||
public DialogBaseForm(FlyoutDialogBase? dialogPanel) : this()
|
||||
{
|
||||
DialogPanel = dialogPanel;
|
||||
}
|
||||
|
||||
private void DialogBaseForm_Load(object? sender, EventArgs e)
|
||||
{
|
||||
if (DialogPanel is ILoadContent iLoadContent)
|
||||
|
||||
Reference in New Issue
Block a user