You will create a small Windows GUI application to input details about people, manipulate them, and edit them. The project consists of several tasks, which you should tackle in order. Each task builds on the previous one.
Read through this entire document before you start coding, so you are aware of all the tasks and the overall structure of the program. Your solution should demonstrate your knowledge of C# and GUI development with Visual Studio.
Your application should look something like the screenshots shown below. It doesn't have to be identical but it should have the same buttons and controls.
The solution is shown working and discussed in the accompanying video. Please watch this to get a good idea of how your application should behave.
Figure: see image.
Task 1 - Person Class Definition
Create a Person class that stores a name and age. The name should be stored as a string, and the age as an integer. Implement a constructor that takes appropriate parameters and stores them in the object. Also implement the appropriate C# property getters and setters.
Task 2 - Form Layout
Use the Visual Studio layout designer to create a form similar to that shown above on the left. At this stage the application should be runnable. When it's run, the form window should be displayed without any build errors, although it will not do anything apart from terminate correctly when the user closes the window.
Task 3 - Adding People (Internal and Visual)
Use a relevant C# container class to store Person objects. Implement the code that runs when the user clicks the Add button. Your code should retrieve the text entered into the Name and Age boxes, convert them into a Person object, and store that object in the collection. You should also update the GUI so the added person appears in the large list area. Use the format shown above on the right (or very similar).
Task 4 - Removing People (Internal and Visual)
Implement the code that runs when the user clicks the Remove button. Your code should find out which item in the list is currently selected (represented by the blue background) and remove it.
Important: Make sure you remove the item from both the internal list and the visible display. Be sure to check the index of the removed item to prevent runtime out-of-bounds errors.
Task 5 - Updating Person Data
When the user clicks on an item in the visible list (or uses the keyboard to move up and down the list), the Name and Age text boxes should be updated to reflect the current selection.
Implement the code that runs when the user clicks the Update button. Your code should update the current selection with whatever text is currently in the Name and Age boxes. You should update both the internal data collection and the visible list.
Task 6 - Sorting by Name and Age
Implement comparison methods in the Person class called CompareByName() and CompareByAge(). Add the code that runs when the user clicks the Name Sort and Age Sort buttons. The internal data collection should be sorted accordingly, and the visible list should be updated (redrawn) to reflect the change.
Task 7 - General UX Improvements & Robustness
One of the biggest challenges is to make sure the blue highlight (current selection) stays visible when the list changes. For example, when the currently selected item is removed, you need to decide what should become the new current selection, then set the blue highlight accordingly. This is actually more complicated than it sounds. For this task, add any necessary code to ensure the blue highlight remains visible when there is data in the list.
You should also ensure there is consistency between the current selection and the values shown in the Name and Age boxes. Add validation code so that the application doesn't crash when the user clicks Update or Remove with an empty list, and any other checks that you deem necessary for a robust implementation.