1. Trang chủ
  2. » Giáo án - Bài giảng

Chapter 1 Introduction to the Visual Studio 2005

39 476 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Introduction to the Visual Studio 2005
Định dạng
Số trang 39
Dung lượng 493 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

2.12  Manipulate the properties of a form or control  Each control has its own set of properties  Properties can include size, color, text, or position  Right column is the property

Trang 1

Chapter 1

Visual Studio 2005

Trang 2

©

Slide 2

1 INTRODUCTION Visual Studio.NET

Visual Basic (VB.Net, VB 8.0)

C++

C# (C Sharp)

J++ (J Sharp)

.NET Framework

Trang 4

©

Slide 4

The NET Framework

The Common Language Runtime (CLR) is another central

part of the NET Frameworkit executes NET programs

.NET language (biet Net)

Trang 5

The Net Framework

Understanding the NET Framework Architecture

Trang 7

Programming Languages

Program specifies exact sequence

Event Driven

User controls sequence

Click event

Double Click event

Change event

Trang 8

©

Slide 8

Object Model

Object ==> Like a Noun in English

Form and Controls on forms ( Button, Text boxes …)

Property ==> Like Adjective,they describe object

Text, Name, BackColor, Font and Size

Method ==> Like Verb, They are actions that objects exhibit

Trang 9

2 INTRODUCTION C#.NET

Windows desktop and Internet environments We will

focus on the Windows desktop

graphical user interface or GUI for short

Trang 10

©

Slide 10

Visual Studio NET Integrated Development

Environment (IDE) Overview

Fig 2.1 Start Page in Visual Studio NET

Trang 11

Visual Studio NET Integrated

Development Environment (IDE)

Allows Visual Studio NET customization

– Keyboard preferences – Window layout preferences

Trang 12

©

Slide 12

Visual Studio NET Integrated Development

Environment (IDE) Overview

Fig 2.2 New Project dialog

Visual C#

projects folder

project name

project location description of

selected project

Visual C# Windows

Application (selected)

Trang 13

Visual Studio NET Integrated Development

Environment (IDE) Overview

Fig 2.3 Visual Studio NET environment after a new project has been created

Trang 15

Solution Explorer

Lists all files in the solution

Displays the contents or a new project or open file

The start up project is the project that runs when the program is executed

It appears in bold in the Solution Explorer

The plus and minus images expand and collapse the tree

Can also double click on the file name to expand/collapse

Solution Explorer toolbar

The Refresh icon reloads files in the solution

The Display icon shows all files, even the hidden ones

Icons change based on selected file

Trang 16

©

Slide 16

Solution Explorer

Fig 2.9 Solution Explorer window

Refresh Display all files

Startup project

Collapse tree

Expand tree

Properties window

Trang 17

Properties window

The Properties window (Fig 2.12)

Manipulate the properties of a form or control

Each control has its own set of properties

Properties can include size, color, text, or position

Right column is the property

Left column is the property value

Icons

The Alphabetic icon arranges the properties alphabetically

The Categorized icon arranges the properties by category

The Event icon allows reactions to user actions

Users alter controls visually without writing code

The component selection dropdown list shows what control is being

altered and what other controls can be altered

Trang 19

3 Simple Program:

Displaying Text and an Image

Fig 2.14 Simple program as it executes

Trang 20

©

Slide 20

Simple Program: Displaying Text and

an Image

Fig 2.17 Setting the form’s Text property

Name and type of object

Property value Selected property

Property description

Trang 21

Simple Program: Displaying Text and

an Image

Resize the form (Fig 2.18)

Click and drag one of the forms size handles

Enables handles are white

Disables handles are gray

The grid in the background will not appear in the solution

Change the form’s background color (Fig 2.19)

The BackColor determines the form’s background color

Dropdown arrow is used to set the color

Add a label control to the form (Fig 2.20)

Controls can be dragged to the form

Controls can be added to the form by double clicking

The forms background color is the default of added controls

Trang 23

Simple Program: Displaying Text and

an Image

Fig 2.19 Changing property BackColor

Down arrow Current color

Custom palette

Trang 24

©

Slide 24

Simple Program: Displaying Text and

an Image

Set the label’s text (Fig 2.21)

The Text property is used to set the text of a label

The label can be dragged to a desired location

used to position the label as in in this example

Set the label’s font size and align text (Fig 2.22)

The Font property changes the label’s text (Fig 2.23)

The TextAlign property to align the text (Fig 2.24)

Add a picture box to the form (Fig 2.25)

Picture boxes are used to display pictures

Drag the picture box onto the form

Trang 25

Simple Program: Displaying Text and

an Image

Insert an image

The Image property sets the image that appears (Fig 2.26)

Pictures should be of type gif, jpeg, or png (Fig 2.27)

The picture box is resizable to fit the entire image (Fig 2.28)

Save the project

Using Save All will save the source code and the project

Run the project (Fig 2.29)

In run mode several IDE features are disabled

Click Debug in the Start menu or press the F5 key

Trang 26

©

Slide 26

Simple Program: Displaying Text and

an Image

Click the close button (x in the top right corner)

Or click the End button in the toolbar

Trang 27

Forms with several output types

Contain Graphical User Interfaces (GUIs)

Trang 28

©

Slide 28

Simple Program: Printing a line of text

Comments

Comments can be created using //…

Multi-lines comments use /* … */

Comments are ignored by the compiler

Used only for human readers

Namespaces

Groups related C# features into a categories

Allows the easy reuse of code

Many namespaces are found in the NET framework library

Must be referenced in order to be used

White Space

Includes spaces, newline characters and tabs

Trang 29

Simple Program: Printing a line of text

Words that cannot be used as variable or class names or any other capacity

Have a specific unchangeable function within the language

Example: class

All keywords are lowercase

Class names can only be one word long (i.e no white space in class name )

Class names are capitalized, with each additional English word capitalized

as well (e.g., MyFirstProgram )

Each class name is an identifier

Can contain letters, digits, and underscores (_)

Cannot start with digits

Can start with the at symbol (@)

Trang 30

©

Slide 30

Simple Program: Printing a line of text

Class bodies start with a left brace ({)

Class bodies end with a right brace (})

Building blocks of programs

The Main method

Each console or windows application must have exactly one

All programs start by executing the Main method

Braces are used to start ({) and end (}) a method

Anything in quotes (“) is considered a string

Every statement must end in a semicolon (;)

Trang 31

Simple Program: Printing a line of text

Graphical User Interface

GUIs are used to make it easier to get data from the user as well as display data to the user

Message boxes

Within the System.Windows.Forms namespace

Used to prompt or display information to the user

Trang 33

Simple Program: Printing a Line of

Text

Fig 3.3 Execution of the Welcome1 program

Trang 35

Ex 3: Welcome3.cs

Welcome to

Trang 36

©

Slide 36

Simple Program: Printing a Line of

Text

Escape sequence Description

beginning of the next line

the next tab stop

Trang 37

// Printing multiple lines in a dialog Box.

Trang 38

©

Slide 38

Another Simple Program: Adding

Integers

Data types that are built into C#

String, Int, Double, Char, Long

15 primitive data types (chapter 4)

Each data type name is a C# keyword

Same type variables can be declared on separate lines or on one line

Used to get a value from the user input

Used to convert a string argument to an integer

Allows math to be preformed once the string is converted

Trang 39

Finish

Ngày đăng: 13/05/2014, 11:39

TỪ KHÓA LIÊN QUAN

w