private void OnKeyDown(KeyEventArgs args) { if (args.Key == Keys.Enter) { // Only create a new dialog if one isn't show if (this.gui.GetModal() == null) { // Create and show dialog this.dialog = new UserDetailsDialog(this, this.gui); this.dialog.Close += new CloseHandler(OnDialogClosed); this.dialog.Show(true); } } }
private void OnDialogClosed(UIComponent sender) { if (sender == this.dialog) { if (this.dialog.DialogResult == DialogResult.OK) { MessageBox message = new MessageBox( this, this.gui, "Name: " + this.dialog.Name, "User Name", MessageBoxButtons.OK, MessageBoxType.Info ); message.Show(true); } // Remove event handler so garbage collector will pick it up this.dialog.Close -= OnDialogClosed; this.dialog = null; } }