تبلیغات
C# How to Program - Painter Test-Drive in Visual Studio Express 2012 forWindows Desktop

C# How to Program


Visual C# 2012 How to Program Deitel and Deitel

[Note: This test-drive can be performed on a computer running either Windows 7 or Windows 8. The steps shown here are for Windows 7.We discuss running an app on Windows 8 in Section 1.15.]
You’ll now use Visual Studio Express 2012 for Windows Desktop to “test-drive” an existing app that enables you to draw on the screen using the mouse. The Painter app—which you’ll build in a later chapter—allows you to choose among several brush sizes and colors. The elements and functionality you see in this app are typical of what you’ll learn to program in this text. The following steps walk you through test-driving the app.


Step 1: Checking Your Setup
Confirm that you’ve set up your computer and the software properly by reading the book’s Before You Begin section that follows the Preface.

Step 2: Locating the Painter App’s Directory
Open a Windows Explorer window and navigate to C:\examples\ch01\win7testdrive. (We assume you placed the examples in the C:\examples folder.) Double click the Painter folder to view its contents (Fig. 1.6), then double click the Painter.sln file to open the app’s solution in Visual Studio. An app’s solution contains all of the app’s code files, supporting files (such as images, videos, data files, etc.) and configuration information. We’ll discuss the contents of a solution in more detail in the next chapter.

Depending on your system configuration, Windows Explorer might not display file name extensions. To display them (like .sln in Fig. 1.6):

1. In Windows Explorer, type Alt + t to display the Tools menu, then select Folder options….
2. Select the View tab in the Folder Options dialog.
3. Locate the checkbox Hide extensions for known file types and ensure that it’s unchecked.
4. Click OK to dismiss the Folder Options dialog.

Step 3: Running the Painter App
To see the running Painter app, click the Start ( ) button (Fig. 1.7) or press the F5 key. Figure 1.8 shows the executing app. Figure 1.8 labels several of the app’s graphical elements—called controls. These include GroupBoxes, RadioButtons, Buttons and a Panel. These controls and many others are discussed throughout the text. The app allows you to draw with a Black, Red, Blue or Green brush of Small, Medium or Large size. As you drag the mouse on the white Panel, the app draws circles of the specified color and size at the mouse pointer’s current position.
The slower you drag the mouse, the closer the circles will be. Thus, dragging slowly draws a continuous line (as in Fig. 1.9) and dragging quickly draws individual circles with space in between. You can also Undo your previous operation or Clear the drawing to start from scratch by pressing the Buttons belowthe RadioButtons in the GUI. By using existing controls—which are objects—you can create powerful apps much faster than if you had to write all the code yourself. This is a key benefit of software reuse.
The brush’s properties, selected in the RadioButtons labeled Black and Medium, are default settings—the initial settings you see when you first run the app. Programmers include default settings to provide reasonable choices that the app will use if the user does not change the settings. Default settings also provide visual cues for users to choose their own settings. Now you’ll choose your own settings as a user of this app.

Step 4: Changing the Brush Color
Click the RadioButton labeled Red to change the brush color, then click the RadioButton labeled Small to change the brush size. Position the mouse over the white Panel, then drag the mouse to draw with the brush. Draw flower petals, as shown in Fig. 1.9.

Step 5: Changing the Brush Color and Size
Click the Green RadioButton to change the brush color. Then, click the Large RadioButton to change the brush size. Draw grass and a flower stem, as shown in Fig. 1.10.

Step 6: Finishing the Drawing
Click the Blue and Medium RadioButtons. Draw raindrops, as shown in Fig. 1.11, to complete the drawing.

Step 7: Stopping the App
When you run an app from Visual Studio, you can terminate it by clicking the stop button ( ) on the Visual Studio toolbar or by clicking the close box ( ) on the running app’s window.

Now that you’ve completed the test-drive, you’re ready to begin developing C# apps. In Chapter 2, Dive Into® Visual Studio, you’ll use Visual Studio to create your first C# program using visual programming techniques. As you’ll see, Visual Studio will generate for you the code that builds the app’s GUI. In Chapter 3, Introduction to C# Apps, you’ll begin writing C# programs containing conventional program code that you write.

Comments  
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر
نظرات پس از تایید نشان داده خواهند شد.

آمار وبلاگ

  • کل بازدید :
  • بازدید امروز :
  • بازدید دیروز :
  • بازدید این ماه :
  • بازدید ماه قبل :
  • تعداد نویسندگان :
  • تعداد کل پست ها :
  • آخرین بازدید :
  • آخرین بروز رسانی :