Developing User Interfaces
CMSC 498B
Spring 2005
Prof. Ben Bederson
Project #1
Due February 24, 2005
The purpose of this program is to gain familiarity with C#, Visual Studio, the VS form designer, standard widgets, and basic event handling and layout.
You must create an application that performs the basic features of Windows Explorer, the standard file browser.
The requirements of the project are:
- There should be a menu bar with the following elements:
File->Open ... - Should bring up a file dialog box that lets you select a directory. After closing the dialog, the folder view should be opened to the selected directory, and the contents view should show the contents of that directory. This should be operable with the keyboard shortcut Ctrl-O, and the Alt-F should bring up the File menu.- File->Exit - should exit the application.
- View->Status Bar - should toggle display of the status bar on and off. The current status should be shown with a checkmark. Note that changing this should also update the interface within Folder Options. Alt-V should bring up the View menu.
- View->List - should change the contents view to List view. This should be shown with a radio-button style checkmark when checked. If this is checked, then View->Details should not be.
- View->Details - should change the contents view to Detail view. This should be shown with a radio-button style checkmark when checked. If this is checked, then View->List should not be.
- Tools->Folder Options ... - should bring up a modal dialog to configure the following properties of this application. Alt-T should bring up the Tools menu.
- User should be able to change font used throughout application
- Ability to turn on and off status bar. Note that changing this should also update the View->Status Bar menu checkmark.
- Help-About - should bring up a modal dialog that gives you credit for building this application. Alt-H should bring up the Help menu.
- There should be a horizontal row of buttons below the menu bar as follows:
- Up - Changes the current folder to the folder's parent. If the root folder is already selected, then this button should be disabled.
- ComboBox enabling user to select between List and Detail view. Note that changing this should update the checkmark in the View menu.
- The folder view on the left should be implemented with a TreeView control, and should be populated with a root of "C:\". The entire tree should not be pre-loaded. Rather, whenever a node is expanded, it's children should be loaded from disk. Whenever a node is collapsed, the children should be removed from the tree. This results in slightly slower interaction performance, but it loads fast and uses little resources. Whenever a folder is selected, the contents of that folder should be shown in the content view on the right.
- The content view on the right should be able to display either a List or Details view, depending on the above selection.
The layout of List view should be similar to Windows Explorer List view - but it should not show file type icons, and it should show file extensions. Specifically, it should be a horizontally scrollable (if necessary) multi-column list of items sorted alphabetically. Folders should be shown with a folder icon, but files should not show an icon. This should be implemented with the "List" View of the ListView control.
The Details view should be similar to the Windows Explorer Details view - but it should not show file type icons, and it should show file extensions. Specifically, it should be a vertically scrollable (if necessary) list of items sorted alphabetically. There should be one column each for filename, size, and date modified. Folders should be shown with a folder icon, but files should not show an icon. This should be implemented with the "Detail" View of the ListView control.
No action needs to be taken when interacting with items in the content view.- There should be a Splitter control that lets the user control how many space is allocated to the folder view on the left and contents view on the right.
- A status bar should be at the bottom (if shown), and it should show the number of items in the content view on the right.
- The application should respond to Form resizes nicely. In particular, all elements should maintain a fixed size on Form resize except for the contents view which should expand or contract to fill the available space.
This project will be graded 80% on correctness and 20% on style. Style includes:
- Each source code file that you write should contain your name and the fact that the code is part of project 1 for this class.
- Following naming and capitalization conventions of C#
- Well-structured code. For example, classes and methods must have well-defined purposes and clear, meaningful names. All forms and controls must have clear and meaningful names. There should not be duplicated code. Access to all fields should be through properties.
- Documentation for the purpose of each class, any non-obvious methods, any non-obvious fields, and any non-obvious implementation details.
1. Consider using System.Windows.Forms.FolderBrowserDialog to browse files.
2. // Necessary to make all controls use proper visual styles // Call this on every Form. And before Application.Run(), call: // Application.EnableVisualStyles(); // Application.DoEvents(); // Workaround for bug with icons in toolbars when visual styles are enabled static public void SetFlatStyleSystem(Control parent) { foreach (Control control in parent.Controls) { // Only these controls have a FlatStyle property ButtonBase button = control as ButtonBase; GroupBox group = control as GroupBox; Label label = control as Label; if (button != null) { button.FlatStyle = FlatStyle.System; } else if (group != null) { group.FlatStyle = FlatStyle.System; } else if (label != null) { label.FlatStyle = FlatStyle.System; } // Set contained controls FlatStyle, too SetFlatStyleSystem(control); } }
3. There is a bug in the TreeView control where a non-themed and incorrectly set up horizontal scrollbar appears sometimes. It turns out that this only happens if the contents of the TreeView is populated before the the control is activated. The workaround is to delay populating the control until the Form.Load event (rather than in the Form constructor).
Submit following the same rules as HW #0, but make the subject line of your email contain "DUI: Proj #1 submission". As before, any submissions after the deadline will be ignored. If multiple submissions are made, then only the last one before the deadline will be looked at.
The zip file you submit must contain all files within a directory named "proj1-<name>.zip" where you replace <name> with your last name.