Esempio n. 1
0
        private void buttonEditSelected_Click(object sender, EventArgs e)
        {
            int index = listBox1.SelectedIndex;

            if (index < 0 || index >= articles.Count)
            {
                MessageBox.Show("Choose 1 article!");
                return;
            }
            ArticleEditForm articleForm = new ArticleEditForm(articles[index], authors);

            var res = articleForm.ShowDialog();

            if (res == DialogResult.OK)
            {
                Article article = new Article(articles[index]);
                //hack to make articles notify listBox about state change
                articles.Add(article);
                articles.RemoveAt(index);
            }
            else if (res != DialogResult.Abort)
            {
                MessageBox.Show("Nothing changed");
            }
        }
Esempio n. 2
0
        private void addArticle_Click(object sender, EventArgs e)
        {
            Article         article     = new Article();
            ArticleEditForm articleForm = new ArticleEditForm(article, authors);

            var res = articleForm.ShowDialog();

            if (res == DialogResult.OK)
            {
                articles.Add(article);
            }
            else if (res != DialogResult.Abort)
            {
                MessageBox.Show("Nothing changed");
            }
        }