using System; using System.Drawing; using System.Windows.Forms; namespace Core.Common.Controls.Dialogs { /// /// Base class for dialogs which should be derived in order to get a consistent look and feel. /// The base class ensures: /// /// /// the dialog is shown in the center of the parent form ( is set to ); /// /// /// no task bar icon is shown ( is set to false); /// /// /// no minimize control box item is shown ( is set to false); /// /// /// no maximize control box item is shown ( is set to false); /// /// /// the parent form is automatically obtained using . /// /// /// public abstract partial class DialogBase : Form { /// /// Constructs a new . /// /// The icon to show in the control box. protected DialogBase(Icon icon) { InitializeComponent(); Icon = icon; } /// /// This method provides a new implementation of . /// In this new implementation the dialog is shown with an owner, /// which is automatically derived via . /// /// A . public new DialogResult ShowDialog() { return base.ShowDialog(ModalHelper.MainWindow); } protected override void OnShown(EventArgs e) { // Initialize the cancel button (as this cannot be done during creation time) CancelButton = GetCancelButton(); base.OnShown(e); } /// /// Gets the cancel button of the . /// /// The cancel button. /// By forcing derivatives to provide a cancel button, dialogs can be closed by hitting the ESC key on the keyboard. protected abstract Button GetCancelButton(); } }