In this assignment, we're going to put together a standard GUI frontend for our book data. Create a new Windows Forms project and bring in your Assignment 8 binary search tree code to use (you can also use the Lab 9 binary tree code if you had trouble with Assignment 8).
Your app will have three tabs:
As before, please omit the bin
and obj
directories when you commit, but commit all other files. The repo is here:
https://cssvn.utrgv.edu/svn_etomai/201810_3328/assn09_bookapp/<username>
Create your main form and add a TabControl
to give you separate panes to work with. Create three tabs and name them File, Display and Add.
This app will work with a tree of Book
objects. When it starts up, the tree should be empty, until you either manually start adding Book
s, or load a saved tree from a file.
On this tab, display a TextBox
and two Button
s, labeled Load
and New
.
Load
, load the Book
s tree from that fileNew
, create a new Book
s treeLabel
on the formOnce a file is loaded (or a new tree made), the form should show a Label
with the loaded/new filename, and an overwrite Button
to save the current tree into that file. This button should only be active if new Book
s have been added to the tree since it was loaded.
We went over saving and loading files using BinaryFormatter
serialization in class.
On this tab, display all the books in a list, one book on each line. You can just use your ToString method to format the books so that the author name, title and year are all displayed. They should be sorted by title. There are a number of built-in controls that can show multi-line text with scrolling, so don't reinvent the wheel.
At the top of the tab, add two Button
s and a TextBox
.
The sorting and filtering is very easy using LINQ, so I'd recommend that route. You'll need your tree set up to implement the yield return
IEunmerable
. Pay attention to the methods available in the String
class to see how to do partial string matching.
Finally, this tab has textboxes to enter the author's name, title and year, and a button to add the new book. It should show an error (as a Label
on the form) if anything is left blank, or if the title is a duplicate to what is already in the tree.