public DialogResult ShowDialog(IWin32Window owner) { if (ServerConnection.ServerConnections.Count == 0) { NewSrcpServer newConnection = new NewSrcpServer(start); DialogResult result = newConnection.ShowDialog(owner); if (result == DialogResult.OK) { connection = newConnection.Connection; } return(result); } else { ModalDialog dialog = new ModalDialog(this); try { this.ModalDialogShouldBeClosed += new EventHandler(dialog.OkClick); dialog.OkPressed += new EventHandler(buttonOk_Click); return(dialog.ShowDialog(owner)); } finally { this.ModalDialogShouldBeClosed -= new EventHandler(dialog.OkClick); } } }
private void buttonEdit_Click(object sender, System.EventArgs e) { ServerConnection connection = (ServerConnection)comboBoxConnections.SelectedItem; string nameOld = connection.Name; NewSrcpServer newServer = new NewSrcpServer(connection, start); if (DialogResult.OK == newServer.ShowDialog(this)) { if (newServer.Connection.Name != nameOld) { comboBoxConnections.Items.Remove(connection); int index = comboBoxConnections.Items.Add(newServer.Connection); comboBoxConnections.SelectedIndex = index; } connection = newServer.Connection; } }
private void buttonNew_Click(object sender, System.EventArgs e) { NewSrcpServer newServer = new NewSrcpServer(start); if (DialogResult.OK == newServer.ShowDialog(this)) { connection = newServer.Connection; if (!comboBoxConnections.Items.Contains(connection)) { comboBoxConnections.Items.Add(connection); } comboBoxConnections.SelectedItem = connection; if (start) { OnModalDialogShouldBeClosed(EventArgs.Empty); } } }