1.Introducing Visual C# Express

… A Brief History of Visual C# Express………….. 1-1

… Let’s Get Started…………………………… 1-4

… Starting Visual C# Express…………………… 1-6

… Opening a Visual C# Express Project…………… 1-9

… Running a Visual C# Express Project………….. 1-14

… Stopping a Visual C# Express Project…………. 1-19

… Stopping Visual C# Express………………….. 1-20

… Summary…………………………………… 1-21

2.The Visual C# Express Design Environment

… Review and Preview………………………….. 2-1

… Parts of a Visual C# Express Project………….. 2-2

… Parts of the Visual C# Express Environment…….. 2-5

Starting a New Visual C# Express Project……. 2-6

Main Window……………………………… 2-7

Solution Explorer Window………………….. 2-8

Design Window……………………………. 2-9

Toolbox Window………………………….. 2-10

Properties Window……………………….. 2-11

Moving Around in Visual C# Express…………… 2-13

Solution Explorer Window…………………. 2-13

Properties Window……………………….. 2-15

Code Window…………………………….. 2-17

… Summary…………………………………… 2-20

3.Your First Visual C# Express Project

… Review and Preview………………………….. 3-1

… Steps in Building a Visual C# Express Project….. 3-2

… Placing Controls on the Form…………………. 3-4

Example…………………………………. 3-5

Setting Control Properties (Design Mode)………. 3-7

Naming Controls……………………………. 3-11

Setting Properties in Run Mode……………. 3-12

How Control Names are Used in Event Methods… 3-15

Writing Event Methods………………………. 3-17

Example………………………………… 3-19

Summary…………………………………… 3-27

4.Project Design, Forms, Buttons

… Review and Preview………………………….. 4-1

… Project Design……………………………… 4-2

… Saving a Visual C# Express Project……………. 4-4

… On-Line Help……………………………….. 4-6

… The Form Control…………………………… 4-12

Properties……………………………… 4-12

Example………………………………… 4-13

Events…………………………………. 4-14

Typical Use of Form Control………………. 4-15

… Button Control…………………………….. 4-16

Properties……………………………… 4-16

Example………………………………… 4-18

Events…………………………………. 4-21

Typical Use of Button Control…………….. 4-21

C# – The First Lesson………………………. 4-22

Event Method Structure…………………… 4-22

Some C# Programming Rules………………… 4-23

Assignment Statement…………………….. 4-25

Property Types………………………….. 4-26

Comments……………………………….. 4-29

… Project – Form Fun…………………………. 4-30

Project Design………………………….. 4-30

Place Controls on Form…………………… 4-30

Set Control Properties…………………… 4-31

Write Event Methods……………………… 4-34

Run the Project…………………………. 4-39

Other Things to Try……………………… 4-40

Summary…………………………………… 4-41

5.Labels, Text Boxes, Variables

… Review and Preview………………………….. 5-1

… Debugging a Visual C# Express Project…………. 5-2

Syntax Errors……………………………. 5-3

Run-Time Errors………………………….. 5-6

Logic Errors……………………………. 5-11

… Label Control……………………………… 5-12

Properties……………………………… 5-12

Example………………………………… 5-13

Events…………………………………. 5-15

Typical Use of Label Control……………… 5-16

… Text Box Control…………………………… 5-17

Properties……………………………… 5-17

Example………………………………… 5-18

Events…………………………………. 5-19

Typical Use of Text Box Control…………… 5-20

C# – The Second Lesson……………………… 5-21

Variables………………………………. 5-21

Variable Names………………………….. 5-22

Variable Types………………………….. 5-23

Declaring Variables……………………… 5-24

Type Casting……………………………. 5-28

Arithmetic Operators…………………….. 5-28

String/Number Conversion Methods………….. 5-32

String Concatenation…………………….. 5-36

… Project – Savings Account…………………… 5-37

Project Design………………………….. 5-37

Place Controls on Form…………………… 5-37

Set Control Properties…………………… 5-38

Write Event Methods……………………… 5-41

Run the Project…………………………. 5-44

Other Things to Try……………………… 5-45

Summary…………………………………… 5-48

6.UpDown Control, Decisions, Random Numbers

… Review and Preview………………………….. 6-1

… Numeric UpDown Control………………………. 6-2

Properties………………………………. 6-2

Example…………………………………. 6-4

Events………………………………….. 6-5

Typical Use of Numeric UpDown Control………. 6-5

C# – The Third Lesson……………………….. 6-6

Logical Expressions………………………. 6-6

Comparison Operators……………………… 6-8

Logical Operators……………………….. 6-11

Decisions – The If Statement……………… 6-16

Random Number Generator………………….. 6-22

… Project – Guess the Number Game……………… 6-25

Project Design………………………….. 6-25

Place Controls on Form…………………… 6-27

Set Control Properties…………………… 6-28

Write Event Methods……………………… 6-30

Run the Project…………………………. 6-36

Other Things to Try……………………… 6-37

Summary…………………………………… 6-39

7.Icons, Group Boxes, Check Boxes, Radio Buttons

… Review and Preview………………………….. 7-1

… Icons……………………………………… 7-2

Designing Your Own Icon with IconEdit………. 7-3

Assigning Icons to Forms………………….. 7-7

… Group Box Control…………………………… 7-8

Properties………………………………. 7-8

Placing Controls in a Group Box…………… 7-10

Example………………………………… 7-11

Typical Use of Group Box Control………….. 7-12

… Check Box Control………………………….. 7-13

Properties……………………………… 7-13

Example………………………………… 7-15

Events…………………………………. 7-15

Typical Use of Check Box Control………….. 7-16

… Radio Button Control……………………….. 7-17

Properties……………………………… 7-18

Example………………………………… 7-19

Events…………………………………. 7-20

Typical Use of Radio Button Control……….. 7-20

… C# – The Fourth Lesson……………………… 7-21

Decisions – Switch Structure…………….. 7-21

… Project – Sandwich Maker……………………. 7-24

Project Design………………………….. 7-24

Place Controls on Form…………………… 7-25

Set Control Properties…………………… 7-26

Write Event Methods……………………… 7-33

Run the Project…………………………. 7-43

Other Things to Try……………………… 7-44

Summary…………………………………… 7-46

8.Panels, Mouse Events, Colors

… Review and Preview………………………….. 8-1

… Panel Control………………………………. 8-2

Properties………………………………. 8-2

Typical Use of Panel Control………………. 8-3

Graphics Using the Panel Control……………… 8-4

Graphics Methods…………………………. 8-4

Graphics Objects…………………………. 8-5

Colors………………………………….. 8-7

Example………………………………… 8-10

Pen Objects…………………………….. 8-11

Graphics Coordinates…………………….. 8-13

DrawLine Method…………………………. 8-14

Graphics Review…………………………. 8-16

Example………………………………… 8-17

C# – The Fifth Lesson………………………. 8-22

Mouse Events……………………………. 8-22

MouseDown Event…………………………. 8-23

Example………………………………… 8-25

MouseUp Event…………………………… 8-28

Example………………………………… 8-28

MouseMove Event…………………………. 8-29

Example………………………………… 8-30

… Project – Blackboard Fun……………………. 8-31

Project Design………………………….. 8-31

Place Controls on Form…………………… 8-32

Set Control Properties…………………… 8-33

Write Event Methods……………………… 8-37

Run the Project…………………………. 8-44

Other Things to Try……………………… 8-46

Summary…………………………………… 8-50

9.Picture Boxes, Arrays

… Review and Preview………………………….. 9-1

… Picture Box Control…………………………. 9-2

Properties………………………………. 9-2

Image Property…………………………… 9-4

Example…………………………………. 9-6

SizeMode Property……………………….. 9-11

Example………………………………… 9-13

Events…………………………………. 9-16

Typical Use of Picture Box Control………… 9-17

C# – The Sixth Lesson………………………. 9-18

Variable Arrays…………………………. 9-18

C# for Loops……………………………. 9-21

Block Level Variables……………………. 9-26

Method Level Variables…………………… 9-27

Shuffle Routine…………………………. 9-28

… Project – Card Wars………………………… 9-34

Project Design………………………….. 9-34

Place Controls on Form…………………… 9-35

Set Control Properties…………………… 9-36

Write Event Methods……………………… 9-41

Run the Project…………………………. 9-50

Other Things to Try……………………… 9-51

Summary…………………………………… 9-52

  1. Timers, Animation, Keyboard Events

… Review and Preview…………………………. 10-1

… Timer Control……………………………… 10-2

Properties……………………………… 10-2

Events…………………………………. 10-3

Examples……………………………….. 10-3

Typical Use of Timer Control…………….. 10-11

C# – The Final Lesson……………………… 10-12

Animation – The DrawImage Method…………. 10-12

Image Disappearance…………………….. 10-17

Border Crossing………………………… 10-20

Image Erasure………………………….. 10-25

Collision Detection…………………….. 10-28

Keyboard Events………………………… 10-33

KeyDown Event………………………….. 10-34

KeyPress Event…………………………. 10-37

… Project – Beach Balls……………………… 10-42

Project Design…………………………. 10-42

Place Controls on Form………………….. 10-43

Set Control Properties………………….. 10-44

Write Event Methods…………………….. 10-48

Run the Project………………………… 10-58

Other Things to Try…………………….. 10-59

Summary………………………………….. 10-61


 

 

  1. Noah’s Ark Project

… Preview…………………………………… 11-1

… Noah’s Ark Program Preview………………….. 11-2

… Noah’s Ark Form Design……………………… 11-7

Code Design – Initial State (Instructions)…… 11-12

Code Design – Select Number of Turtles………. 11-14

Code Design – Initial to Stopped State………. 11-16

Code Design – Stop the Program……………… 11-19

Code Design – Selecting Turtles…………….. 11-20

Code Design – Stopped to Moving State……….. 11-23

Noah’s Ark Program Review………………….. 11-29

 

 

  1. Elijah and the Ravens Project

 

… Preview…………………………………… 12-1

… Elijah and the Ravens Program Preview………… 12-2

… Elijah and the Ravens Form Design……………. 12-7

Code Design – Initial State (Instructions)…… 12-13

Code Design – Select Difficulty…………….. 12-15

Code Design – Position Elijah………………. 12-17

Code Design – Position Raven and Bread………. 12-21

Code Design – Stop the Program……………… 12-25

Code Design – Dropping Bread……………….. 12-26

Code Design – Moving Elijah………………… 12-29

Code Design – Catching Bread……………….. 12-34

Code Design – Stop the Game………………… 12-38

Elijah and the Ravens Program Review………… 12-42

 

  1. Daniel and the Lions Project

… Preview…………………………………… 13-1

… Daniel and the Lions Program Preview…………. 13-2

… Daniel and the Lions Form Design……………. 13-10

Code Design – Initial State (Instructions)…… 13-20

Code Design – Select Difficulty…………….. 13-22

Code Design – Draw Grid……………………. 13-24

Code Design – Position Rocks……………….. 13-27

Code Design – Position Daniel and Lions……… 13-30

Code Design – Stop the Program……………… 13-34

Code Design – Moving Daniel………………… 13-35

Code Design – Moving Lions…………………. 13-45

Code Design – Shooting Prayers……………… 13-54

Code Design – Stop the Game………………… 13-62

Daniel and the Lions Program Review…………. 13-63

 

 

  1. Bonus Projects

… Preview……………………………………. B-1

… Project 1 – Stopwatch……………………….. B-2

Project Design…………………………… B-2

Place Controls on Form……………………. B-2

Set Control Properties……………………. B-3

Write Event Procedures……………………. B-5

Run the Project………………………….. B-7

Other Things to Try………………………. B-7

Project 2 – Times Tables…………………….. B-8

Project Design…………………………… B-8

Place Controls on Form……………………. B-8

Set Control Properties……………………. B-9

Write Event Procedures…………………… B-12

Run the Project…………………………. B-15

Other Things to Try……………………… B-15

Project 3 – Dice Rolling……………………. B-16

Project Design………………………….. B-16

Place Controls on Form…………………… B-16

Set Control Properties…………………… B-17

Write Event Procedures…………………… B-20

Run the Project…………………………. B-21

Other Things to Try……………………… B-22

Project 4 – State Capitals………………….. B-23

Project Design………………………….. B-23

Place Controls on Form…………………… B-24

Set Control Properties…………………… B-25

Write Event Procedures…………………… B-28

Run the Project…………………………. B-34

Other Things to Try……………………… B-35

Project 5 – Memory Game…………………….. B-36

Project Design………………………….. B-36

Place Controls on Form…………………… B-37

Set Control Properties…………………… B-38

Write Event Procedures…………………… B-45

Run the Project…………………………. B-52

Other Things to Try……………………… B-53

Project 6 – Units Conversion………………… B-54

Project Design………………………….. B-54

Place Controls on Form…………………… B-54

Set Control Properties…………………… B-55

Write Event Procedures…………………… B-58

Run the Project…………………………. B-63

Other Things to Try……………………… B-63

Project 7 – Decode…………………………. B-64

Project Design………………………….. B-64

Place Controls on Form…………………… B-64

Set Control Properties…………………… B-66

Write Event Procedures…………………… B-69

Run the Project…………………………. B-74

Other Things to Try……………………… B-75

Project 8 – Frown………………………….. B-76

Project Design………………………….. B-76

Place Controls on Form…………………… B-77

Set Control Properties…………………… B-78

Write Event Procedures…………………… B-85

Run the Project…………………………. B-93

Other Things to Try……………………… B-94

Project 9 – Loan Calculator…………………. B-95

Project Design………………………….. B-95

Place Controls on Form…………………… B-95

Set Control Properties…………………… B-96

Write Event Procedures…………………… B-99

Run the Project………………………… B-100

Other Things to Try…………………….. B-101

Project 10 – Checkbook Balancer…………….. B-102

Project Design…………………………. B-102

Place Controls on Form………………….. B-102

Set Control Properties………………….. B-103

Write Event Procedures………………….. B-108

Run the Project………………………… B-112

Other Things to Try…………………….. B-113

Project 11 – Portfolio Manager……………… B-114

Project Design…………………………. B-114

Place Controls on Form………………….. B-114

Set Control Properties………………….. B-115

Write Event Procedures………………….. B-121

Run the Project………………………… B-126

Other Things to Try…………………….. B-127

Project 12 – Bonus Pong Game……………….. B-128

  1. Classic Computer Games Enhanced using Visual C# Express

Preview  ……………………………………… C-1

Visual Basic Program Operation Instructions……….. C-2

Even Wins  ……………………………………. C-3

Mugwump  ……………………………………… C-5

Lunar Lander  …………………………………. C-6