Wrap-Up

Answers to Self Review Exercises

17.1

a) False. Size is a read-only property. b) True. c) True. d) True. e) False. It returns the size of the current Font in design units. f) False. The coordinate (0,0) corresponds to the upper-left corner of a GUI component on which drawing occurs. g) False. A Pen is used to draw lines, a HatchBrush fills a shape with a hatch pattern. h) False. A color is defined by its alpha, red, green and blue content. i) True. j) True.

 
17.2

a) Pen. b) LinearGradientBrush, PathGradientBrush. c) DrawLine. d) alpha, red, green, blue. e) points. f) TextureBrush. g) Windows Media Player h) GraphicsPath i) System.Drawing, System.Drawing.Drawing2D. j) FromFile.

Exercises

17.3

Write a program that draws eight concentric circles. The circles should be separated from one another by 10 pixels. Use the DrawArc method.

17.4

Write a program that draws 100 lines with random lengths, positions, thicknesses and colors.

17.5

Write a program that draws a tetrahedron (a pyramid). Use class GraphicsPath and method DrawPath.

17.6

Write a program that allows the user to draw "free-hand" images with the mouse in a PictureBox. Allow the user to change the drawing color and width of the pen. Provide a button that allows the user to clear the PictureBox.

17.7

Write a program that repeatedly flashes an image on the screen. Do this by interspersing the image with a plain background-color image.

17.8

(Eight Queens) A puzzler for chess buffs is the Eight Queens problem. Simply stated: Is it possible to place eight queens on an empty chessboard so that no queen is "attacking" any other (i.e., so that no two queens are in the same row, in the same column or along the same diagonal)?

Create a GUI that allows the user to drag-and-drop each queen on the board. Use the graphical features of Fig. 17.26. Provide eight queen images to the right of the board (Fig. 17.38) that the user can drag-and-drop on the board. When a queen is dropped on the board, its corresponding image to the right should not be visible. If a queen is in conflict with another queen when placed on the board, display a message box and remove that queen from the board.

Figure 17.38. GUI for the Eight Queens exercise.

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



    Visual C# How to Program
    Visual C# 2005 How to Program (2nd Edition)
    ISBN: 0131525239
    EAN: 2147483647
    Year: 2004
    Pages: 600

    Flylib.com © 2008-2020.
    If you may any questions please contact us: flylib@qtcs.net