Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# ПІДРУЧНИКИ / c# / Manning - Windows.forms.programming.with.c#.pdf
Скачиваний:
108
Добавлен:
12.02.2016
Размер:
14.98 Mб
Скачать

bToolbox

Used to add new controls to a form

cLinks

These display various information and resources available. The Get Started link is shown.

dRecent projects

Quick access to recent projects

eDockable windows

One-click access (via the tabs) to various windows in the environment

b

c

d

f

e

fNew Project button

Click here to create a new project

gSolution Explorer

Displays the files and resources in your solution. Note that this area contains other dockable windows.

hDynamic Help

Instant help on topics related to your current activities.

g

h

Figure 2.1 Components of the initial Visual Studio .NET window that relate to the discussion in this chapter. The exact placement of some of these windows may vary.

As a way to structure our discussion, this chapter as well as subsequent chapters will use the Action-Result table format described in the introduction to present the steps required to create the sample code discussed in each chapter. These tables provide numbered instructions for the task, including the actions to perform and the result of these actions.

In this section we will create a Visual Studio project for our application, compile and run this application from within Visual Studio, and look at the source code generated by Visual Studio in contrast to the program we wrote in section 1.1.

2.1.1Creating a project

To begin, let’s create a Visual Studio project called “MyPhotos” for our new application. This application will duplicate the functionality presented in section 1.1. The

36

CHAPTER 2 GETTING STARTED WITH VISUAL STUDIO .NET

following table enumerates the steps required. We discuss the term project and other aspects of the application following this table.

 

 

CREATE THE MYPHOTOS PROJECT

 

 

 

 

Action

Result

 

 

 

1

Start Visual Studio. NET.

The Microsoft Development Environment displays with the Start

 

How-to

Page shown.

 

 

 

Locate the appropriate

Note: This window is illustrated in figure 2.1. You may want to

 

item in the Start menu.

consider closing the Dynamic Help window (by clicking the X

 

 

in the upper right corner of this window) while using this

 

 

book. While quite useful in that it provides help related to your

 

 

current activities, this window also uses quite a bit of CPU and

 

 

memory resources.

 

 

 

2

Click the New Project

The New Project dialog box appears.

 

button.

 

 

 

 

3

Under Project Types,

A list of C# Templates appears.

 

select Visual C# Projects.

 

 

 

 

4

Under Templates, select

 

 

Windows Application.

 

 

 

 

5

In the Name field, enter

Note: The Location entry may vary depending on which ver-

 

“MyPhotos”.

sion of Windows you are using. To avoid any confusion, this

 

 

book will use the directory “C:\Windows Forms\Projects.” In

 

 

your code, use the default setting provided by the environ-

 

 

ment.

 

 

 

PROGRAMMING WITH VISUAL STUDIO .NET

37

 

 

CREATE THE MYPHOTOS PROJECT (continued)

 

 

 

 

 

Action

 

Result

 

 

 

 

6

Click the OK button.

 

The new MyPhotos project is created. The Solution Explorer now

 

 

 

contains the files in this solution, and the main window displays a

 

 

 

blank form.

 

 

 

 

Visual Studio .NET has a lot of information and a ton of features. We will cover some features in this section, and others as we develop our application. On the right side of the Visual Studio window, you will see the Solution Explorer window. This window shows the contents of the current solution, namely the projects in the solution and files in these projects.

Visual Studio uses projects and solutions to manage application development. Conceptually, a project is a collection of files that produce a .NET application, such as a library (.dll) or executable (.exe). A solution is a collection of projects that are grouped together for development or deployment purposes. When a solution has only one project, the two words are somewhat equivalent.

The MyPhotos solution is stored on disk in a file called “MyPhotos.sln.” This solution holds a single project called MyPhotos, stored in the C# project file “MyPhotos.csproj.” The Solution Explorer window shows the MyPhotos solution containing the MyPhotos project. This project displays four items:

References—the list of assemblies referenced by the project. These are provided to the compiler using the /references switch we saw in chapter 1. You can expand this entry to see the default list of assemblies for the project, or wait until chapter 5 where we add an assembly to this list.

App.ico—the icon for the application. We will discuss icons in chapter 12.

38

CHAPTER 2 GETTING STARTED WITH VISUAL STUDIO .NET

Соседние файлы в папке c#