Files
Pilz/Pilz.UI.Telerik/Dialogs/DialogBaseForm.Statics.cs

56 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
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
{
partial class DialogBaseForm
{
public delegate void DialogLoadingEventHandler(DialogLoadingEventArgs e);
public delegate void DialogClosedEventHandler(DialogClosedEventArgs e);
public static event DialogLoadingEventHandler? DialogLoading;
public static event DialogClosedEventHandler? DialogClosed;
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
{
T dialogPanel = Activator.CreateInstance<T>();
dialogPanel.Tag = tag;
return ShowDialog(dialogPanel, parent, title, icon);
}
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)
{
Text = title,
Icon = icon,
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
ClientSize = dialogPanel.Size
};
dialog.Controls.Add(dialogPanel);
dialog.ShowDialog(parent);
return dialogPanel;
}
}
}