예제 #1
0
 private void fBooks_Load(object sender, EventArgs e)
 {
     BooksSettings.GetSettings();
     lblLeftBooks.Text = "You have " + Convert.ToString(BooksSettings.BooksLeftPerYear) + " books left to read this year";
     lblLeftBooks.Show();
     OpenBooks();
 }
예제 #2
0
 private void btnSaveNewAmountOfBooksPerYear_Click(object sender, EventArgs e)
 {
     BooksSettings.BooksLeftPerYear += Convert.ToInt32(tbBooksPerYear.Text) - BooksSettings.BooksPerYear;
     BooksSettings.BooksPerYear      = Convert.ToInt32(tbBooksPerYear.Text);
     BooksSettings.SaveSettings();
     this.Close();
 }
예제 #3
0
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            string s;

            s = "• " + tbNewBook.Text.ToString();
            lbBooks.Items.Add(s);
            StreamWriter file = File.AppendText("Books.rtf");

            file.WriteLine(s);
            file.Close();
            tbNewBook.Clear();
            BooksSettings.BooksLeftPerYear--;
            BooksSettings.SaveSettings();
            lblLeftBooks.Text = "You have " + Convert.ToString(BooksSettings.BooksLeftPerYear) + " books left to read this year";
            lblLeftBooks.Show();
        }
예제 #4
0
        private void btnDeleteBook_Click(object sender, EventArgs e)
        {
            if (lbBooks.SelectedItem != null)
            {
                lbBooks.Items.Remove(lbBooks.SelectedItem);
                BooksSettings.BooksLeftPerYear++;
                string s;
                File.WriteAllText("Books.rtf", "");
                StreamWriter file = File.AppendText("Books.rtf");
                for (int i = 0; i < lbBooks.Items.Count; i++)
                {
                    s = Convert.ToString(lbBooks.Items[i]);
                    file.WriteLine(s);
                }
                file.Close();

                BooksSettings.SaveSettings();
                lblLeftBooks.Text = "You have " + Convert.ToString(BooksSettings.BooksLeftPerYear) + " books left to read this year";
                lblLeftBooks.Show();
            }
        }