This lab will give you practice utilizing standard Font dialog, RichTextBox control, menus, building and using a DLL in your application. You should work in your groups (2 members). If your partner is not present in class each will need to complete the assignment on your own by the due date/time.
- Deitel’s book.
- This assignment grade sheet for this lab already printed out.
- USB Flash drive(s) or other storage media.
- Your laptop with Microsoft Visual Studio 2015.
Create an application whose form has a main menu, a rich text box, and a Font Dialog. The default font for the form and the rich text box should be 10-point Arial.
The File menu contains three commands: Clear, Font , and Exit. The Help menu has just one command: About The rich text box has the Dock property set to Fill.
The ShowEffects property of the font dialog object should be set to False. Implement the commands on the File menu for this simple application. The Clear command should remove all text from the rich text box. The Font command should display the font dialog, and use the resulting font to change the font of all text now appearing in the rich text box. Also change the default font for the rich text box. The Exit command should terminate the program. Run the program to verify it’s working before continuing.
Create one of your own. Save the icon in the project folder.
Use “Add existing item” to add the icon to the project.
Go to the properties for the project and change the icon for the project to the one you selected. Just type in the name of the ICO file. Don’t browse for it.
Compile and run. Is the icon for the EXE file the correct one?
Change the form icon to match.
Right-click on the Solution and add a new project to the solution called StdDialogs. This solution should be a “Class Library” and NOT a Windows application.
Delete the file called Class1.cs in the resulting project.
Add a new form to this project called “AboutBox.cs”. This will be used to display an About box for a variety of applications. The form should not be resizable.
The form should contain a picture box, three labels (one below the other, each the width of the window, with center justification for the text), and an OK button. The font size for the first label should be larger than the size of the other two. The Text property of the labels can be anything at all. Give a good name to each control on the form. The OK button merely closes the form.
The constructor should accept an Image and three strings. The image should be associated with the picture box. The size of the picture box should be changed to match the size of the Image passed in. The strings should become the text of the labels on the form.
Build your DLL project (don’t build the solution) but don’t try to execute. We just want to create a small DLL file.
Choose a small image file to display in the about box and save it in the application folder.
Add this logo to the project and change the Build Action property to “Embedded Resource”.
Add private class level data to the form: private Image appLogo;
Add code to the Form1 constructor to load the logo from your file into the Image object. The following code should work (if your main project is called Smith-Lab7 and your image file is logo.jpg):
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Notice that the hyphen in the project name is replaced with the underscore character in the call to GetManifestResourceStream.
In the main application, add a reference to the DLL. (Remember how? Right-click on References in Solution Explorer, and then) You’ll also want to add a “using” statement for the namespace.
For the About command, just display the About box found in the DLL. Pass in the logo image and three strings (maybe program name, copyright date, programmer name) Run the program and verify that everything is working.
A splash screen is visible for a few seconds when you first start an application. The format will be very similar to the about box, with these changes:
There is no OK button.
The form will have the following properties: TopMost=True, FormBorderStyle=None, StartPosition= CenterParent.
The form will have a Timer object.
The constructor will pass in the number of milliseconds that the splash screen should be visible, in addition to an image and three strings. Use 3000.
The constructor initializes the Interval property of the timer to the value passed in.
When the Tick event occurs, the form is closed.
When you have added the splash screen to the DLL, display the splash screen from the Load event of Form1. You can use splash.ShowDialog();
Run your application and make sure everything is working properly.
Each of your source files should contain a documentation header with description, author name, class information. Each function should have a documentation header with minimally function name, description, parameters, return value. Use proper program style at all times which means indentation, alignment, and whitespace. Utilize self-documenting code which means use mnemonic, i.e., meaningful variable/function/namespace/class names, etc.
Submit compressed (.zip) solution folder via Canvas. In your solution folder make sure that all necessary files to compile/link/execute your projects are provided. Here are some files that may be required
- All required C# source files (.cs)
- makefile (if the solution requires it)
- The entire Visual Studio 2015 solution folder (if the solution requires it)