In this section, you will "test-drive" a C# application that enables you to draw on the screen using the mouse. You will run and interact with a working application. You will build a similar application in Chapter 13, Graphical User Interface Concepts: Part 1.
The Drawing application allows you to draw with different brush sizes and colors. The elements and functionality you see in this application are typical of what you will learn to program in this text. We use fonts to distinguish between IDE features (such as menu names and menu items) and other elements that appear in the IDE. Our convention is to emphasize IDE features (such as the File menu) in a bold sans-serif Helvetica font and to emphasize other elements, such as file names (e.g., Form1.cs), in a sans-serif Lucida font. The following steps show you how to test-drive the application.
1. |
Checking your setup. Confirm that you have installed Visual C# 2005 Express or Visual Studio 2005 as discussed in the Preface. |
2. |
Locating the application directory. Open Windows Explorer and navigate to the C:examplesCh01Drawing directory. |
3. |
Running the Drawing application. Now that you are in the correct directory, double click the file name Drawing.exe to run the application. Figure 1.3. Visual C# Drawing application. You can use existing controlswhich are objectsto get powerful applications running in C# much faster than if you had to write all of the code yourself. In this text, you will learn how to use many preexisting controls, as well as how to write your own program code to customize your applications. The brush's properties, selected in the RadioButtons (the small circles where you select an option by clicking the mouse) labeled Black and Small, are default settings, which are the initial settings you see when you first run the application. Programmers include default settings to provide reasonable choices that the application will use if the user chooses not to change the settings. You will now choose your own settings. |
4. |
Changing the brush color. Click the RadioButton labeled Red to change the color of the brush. Hold the mouse button down with the mouse pointer positioned anywhere on the Panel, then drag the mouse to draw with the brush. Draw flower petals as shown in Fig. 1.4. Then click the RadioButton labeled Green to change the color of the brush again. Figure 1.4. Drawing with a new brush color. |
5. |
Changing the brush size. Click the RadioButton labeled Large to change the size of the brush. Draw grass and a flower stem as shown in Fig. 1.5. Figure 1.5. Drawing with a new brush size. |
6. |
Finishing the drawing. Click the RadioButton labeled Blue. Then click the RadioButton labeled Medium. Draw raindrops as shown in Fig. 1.6 to complete the drawing. Figure 1.6. Finishing the drawing. (This item is displayed on page 18 in the print version) |
7. |
Closing the application. Click the close box, , to close your running application. |
Additional Applications Found in Visual C# 2005 How to Program, 2/e
Figure 1.7 lists a few of the hundreds of applications found in the examples and exercises in this text. These programs introduce some of the powerful and entertaining capabilities of C#. We encourage you to practice running some of them. The examples folder for Chapter 1 contains all of the files required to run each application listed in Fig. 1.7. Simply double click the file names for any application you would like to run. [Note: The Garage.exe application assumes that the user inputs a value from 0 to 24.]
Application name |
Chapter location |
File to execute |
---|---|---|
Parking Fees |
Chapter 7 |
Garage.exe |
Tic Tac Toe |
Chapter 9 |
TicTacToe.exe |
Drawing Stars |
Chapter 17 |
DrawStars.exe |
Drawing Shapes |
Chapter 17 |
DrawShapes.exe |
Drawing Polygons |
Chapter 17 |
DrawPolygons.exe |
Preface
Index
Introduction to Computers, the Internet and Visual C#
Introduction to the Visual C# 2005 Express Edition IDE
Introduction to C# Applications
Introduction to Classes and Objects
Control Statements: Part 1
Control Statements: Part 2
Methods: A Deeper Look
Arrays
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Polymorphism, Interfaces & Operator Overloading
Exception Handling
Graphical User Interface Concepts: Part 1
Graphical User Interface Concepts: Part 2
Multithreading
Strings, Characters and Regular Expressions
Graphics and Multimedia
Files and Streams
Extensible Markup Language (XML)
Database, SQL and ADO.NET
ASP.NET 2.0, Web Forms and Web Controls
Web Services
Networking: Streams-Based Sockets and Datagrams
Searching and Sorting
Data Structures
Generics
Collections
Appendix A. Operator Precedence Chart
Appendix B. Number Systems
Appendix C. Using the Visual Studio 2005 Debugger
Appendix D. ASCII Character Set
Appendix E. Unicode®
Appendix F. Introduction to XHTML: Part 1
Appendix G. Introduction to XHTML: Part 2
Appendix H. HTML/XHTML Special Characters
Appendix I. HTML/XHTML Colors
Appendix J. ATM Case Study Code
Appendix K. UML 2: Additional Diagram Types
Appendix L. Simple Types
Index