private void AddNewBook() { Book newBook = null; string author = addBookWindow.AuthorTextBox.Text; string title = addBookWindow.TitleTextBox.Text; string year = addBookWindow.YeraTextBox.Text; int pages = 0; try { pages = int.Parse(addBookWindow.PagesTextBox.Text); } catch (Exception e) { pages = 0; } string readed = (string)addBookWindow.ReadedComboBox.SelectedItem; if (readed == "Yes") { Mark mark = SetMark(); newBook = new ReadedBook(author, title, year, pages, mark); } else { Priority priority = SetPriority(); newBook = new BookToRead(author, title, year, pages, priority); } BooksList.Add(newBook); SortBooks(); }
public int CompareTo(object otherBook) { BookToRead otherBookToRead = otherBook as BookToRead; if (otherBookToRead == null) { return(-1); } if (this.PriorityToRead > otherBookToRead.PriorityToRead) { return(1); } else if (this.PriorityToRead < otherBookToRead.PriorityToRead) { return(-1); } else { return(0); } }