private void downloadArticles() { NewsConnection connection = new NewsConnection(); try { connection.Connect(DEFAULT_HOST); NewsgroupCollection groups = connection.GetNewsgroups(new string[] { DEFAULT_GROUP }, null); if (groups.Count != 1) { MessageBox.Show("Could not find desired group" , "Error" , MessageBoxButtons.OK , MessageBoxIcon.Exclamation); } else { group = groups[0]; group.Articles = connection.GetArticleHeaders(group, DEFAULT_MAX_HEADERS); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Download" , MessageBoxButtons.OK , MessageBoxIcon.Information); } finally { connection.Disconnect(); } }
private void buttonOK_Click(object sender, EventArgs e) { if (validateData()) { try { connection = new NewsConnection(); connection.Connect(textBoxNewsServer.Text); // This will close the dialog. It will also allow the caller to // learn that the user didn't cancel the dialog. this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void openConnectionToolStripMenuItem_Click(object sender, EventArgs e) { ConnectionForm dlg = new ConnectionForm(); dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { connection = dlg.Connection; } dlg.Dispose(); refreshControls(); }