programming with windows forms - springer978-1-4302-2986-5/1.pdf · a p p e n d i x a 1561...

172
A P P E N D I X A ■ ■ ■ 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the base class libraries have included a particular API named Windows Forms, represented primarily by the System.Windows.Forms.dll assembly. The Windows Forms toolkit provides the types necessary to build desktop graphical user interfaces (GUIs), create custom controls, manage resources (e.g., string tables and icons), and perform other desktop- centric programming tasks. In addition, a separate API named GDI+ (represented by the System.Drawing.dll assembly) provides additional types that allow programmers to generate 2D graphics, interact with networked printers, and manipulate image data. The Windows Forms (and GDI+) APIs remain alive and well within the .NET 4.0 platform, and they will exist within the base class library for quite some time (arguably forever). However, Microsoft has shipped a brand new GUI toolkit called Windows Presentation Foundation (WPF) since the release of .NET 3.0. As you saw in Chapters 27-31, WPF provides a massive amount of horsepower that you can use to build bleeding-edge user interfaces, and it has become the preferred desktop API for today’s .NET graphical user interfaces. The point of this appendix, however, is to provide a tour of the traditional Windows Forms API. One reason it is helpful to understand the original programming model: you can find many existing Windows Forms applications out there that will need to be maintained for some time to come. Also, many desktop GUIs simply might not require the horsepower offered by WPF. When you need to create more traditional business UIs that do not require an assortment of bells and whistles, the Windows Forms API can often fit the bill. In this appendix, you will learn the Windows Forms programming model, work with the integrated designers of Visual Studio 2010, experiment with numerous Windows Forms controls, and receive an overview of graphics programming using GDI+. You will also pull this information together in a cohesive whole by wrapping things up in a (semi-capable) painting application.

Upload: doancong

Post on 20-Sep-2018

236 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

A P P E N D I X A

■ ■ ■

1561

Programming with Windows Forms

Since the release of the .NET platform (circa 2001), the base class libraries have included a particular API named Windows Forms, represented primarily by the System.Windows.Forms.dll assembly. The Windows Forms toolkit provides the types necessary to build desktop graphical user interfaces (GUIs), create custom controls, manage resources (e.g., string tables and icons), and perform other desktop-centric programming tasks. In addition, a separate API named GDI+ (represented by the System.Drawing.dll assembly) provides additional types that allow programmers to generate 2D graphics, interact with networked printers, and manipulate image data.

The Windows Forms (and GDI+) APIs remain alive and well within the .NET 4.0 platform, and they will exist within the base class library for quite some time (arguably forever). However, Microsoft has shipped a brand new GUI toolkit called Windows Presentation Foundation (WPF) since the release of .NET 3.0. As you saw in Chapters 27-31, WPF provides a massive amount of horsepower that you can use to build bleeding-edge user interfaces, and it has become the preferred desktop API for today’s .NET graphical user interfaces.

The point of this appendix, however, is to provide a tour of the traditional Windows Forms API. One reason it is helpful to understand the original programming model: you can find many existing Windows Forms applications out there that will need to be maintained for some time to come. Also, many desktop GUIs simply might not require the horsepower offered by WPF. When you need to create more traditional business UIs that do not require an assortment of bells and whistles, the Windows Forms API can often fit the bill.

In this appendix, you will learn the Windows Forms programming model, work with the integrated designers of Visual Studio 2010, experiment with numerous Windows Forms controls, and receive an overview of graphics programming using GDI+. You will also pull this information together in a cohesive whole by wrapping things up in a (semi-capable) painting application.

Page 2: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1562

■ Note Here’s one proof that Windows Forms is not disappearing anytime soon: .NET 4.0 ships with a brand new Windows Forms assembly, System.Windows.Forms.DataVisualization.dll. You can use this library to incorporate charting functionality into your programs, complete with annotations; 3D rendering; and hit-testing support. This appendix will not cover this new .NET 4.0 Windows Forms API; however, you can look up the System.Windows.Forms.DataVisualization.Charting namespace if you want more information.

The Windows Forms Namespaces The Windows Forms API consists of hundreds of types (e.g., classes, interfaces, structures, enums, and delegates), most of which are organized within various namespaces of the System.Windows.Forms.dll assembly. Figure A-1 shows these namespaces displayed in the Visual Studio 2010 object browser.

Figure A-1. The namespaces of System.Windows.Forms.dll

Far and away the most important Windows Forms namespace is System.Windows.Forms. At a high level, you can group the types within this namespace into the following broad categories:

• Core infrastructure: These are types that represent the core operations of a Windows Forms program (e.g., Form and Application) and various types to facilitate interoperability with legacy ActiveX controls, as well as interoperability with new WPF custom controls.

• Controls: These are types used to create graphical UIs (e.g., Button, MenuStrip, ProgressBar, and DataGridView), all of which derive from the Control base class. Controls are configurable at design time and are visible (by default) at runtime.

Page 3: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1563

• Components: These are types that do not derive from the Control base class, but still may provide visual features to a Windows Forms program (e.g., ToolTip and ErrorProvider). Many components (e.g., the Timer and System.ComponentModel.BackgroundWorker) are not visible at runtime, but can be configured visually at design time.

• Common dialog boxes: Windows Forms provides several canned dialog boxes for common operations (e.g., OpenFileDialog, PrintDialog, and ColorDialog). As you would hope, you can certainly build your own custom dialog boxes if the standard dialog boxes do not suit your needs.

Given that the total number of types within System.Windows.Forms is well over 100 strong, it would be redundant (not to mention a terrible waste of paper) to list every member of the Windows Forms family. As you work through this appendix, however, you will gain a firm foundation that you can build on. In any case, be sure to check out the .NET Framework 4.0 SDK documentation for additional details.

Building a Simple Windows Forms Application As you might expect, modern .NET IDEs (e.g., Visual Studio 2010, VB 2010 Express, and SharpDevelop) provide numerous form designers, visual editors, and integrated code-generation tools (wizards) to facilitate the construction of Windows Forms applications. These tools are extremely useful, but they can also hinder the process of learning Windows Forms, because these same tools tend to generate a good deal of boilerplate code that can obscure the core object model. Given this, you will create your first Windows Forms example using a Console Application project as a starting point.

Begin by creating a Console Application named SimpleWinFormsApp. Next, use the Project ➤ Add Reference menu option to set a reference to the System.Windows.Forms.dll and System.Drawing.dll assemblies through the .NET tab of the resulting dialog box. Next, update your Module1 file with the following code:

' The minimum required windows forms namespaces. Imports System.Windows.Forms ' This is the application object. Module Module1 Sub Main() Application.Run(New MainWindow()) End Sub End Module ' This is the main window. Public Class MainWindow Inherits Form End Class

Page 4: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1564

■ Note When Visual Studio 2010 finds a class that extends System.Windows.Forms.Form, it attempts to open the related GUI designer (provided this class is the first class in the VB 2010 code file). Double-clicking the Module1.vb file from the Solution Explorer opens the designer, but don’t do that yet! You will work with the Windows Forms designer in the next example; for now, be sure you right-click on the VB 2010 file containing your code within the Solution Explorer and select the View Code option.

This code represents the absolute simplest Windows Forms application you can build. At a bare minimum, you need a class that extends the Form base class and a Main() method to call the Shared Application.Run() method (you can find more details on Form and Application later in this chapter). Running your application now reveals that you have a resizable, minimizable, maximizable, and closable topmost window (see Figure A-2).

Figure A-2. A simple Windows Forms application

■ Note When you run this program, you will notice a command prompt looming in the background of your topmost window. This is because, when you create a Console Application, the /target flag sent to the VB 2010 compiler defaults to /target:exe. You can change this to /target:winexe (preventing the display of the command prompt) by double-clicking the My Project item in the Solution Explorer and changing the Application Type setting to Windows Forms Application using the Application tab.

Page 5: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1565

Granted, the current application is not especially exciting, but it does illustrate how simple a Windows Forms application can be. To spruce things up a bit, you can add a custom constructor to your MainWindow class, which allows the caller to set various properties on the window to be displayed:

' This is the main window. Public Class MainWindow Inherits Form Public Sub New() End Sub Public Sub New(ByVal title As String, ByVal frmHeight As Integer, ByVal frmWidth As Integer) ' Set various properties from the parent classes. Text = title Width = frmWidth Height = frmHeight ' Inherited method to center the form on the screen. CenterToScreen() End Sub End Class

You can now update the call to Application.Run(), as follows:

Sub Main() Application.Run(New MainWindow("My Window", 200, 300)) End Sub

This is a step in the right direction, but any window worth its salt requires various user interface

elements (e.g., menu systems, status bars, and buttons) to allow for input. To understand how a Form-derived type can contain such elements, you must understand the role of the Controls property and the underlying controls collection.

Populating the Controls Collection The System.Windows.Forms.Control base class (which is the inheritance chain of the Form type) defines a property named Controls. This property wraps a custom collection nested in the Control class named ControlsCollection. This collection (as the name suggests) references each UI element maintained by the derived type. Like other containers, this type supports several methods for inserting, removing, and finding a given UI widget (see Table A-1).

Page 6: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1566

Table A-1. ControlCollection Members

Member Meaning in Life

Add() AddRange()

You use these members to insert a new Control-derived type (or array of types) in the collection.

Clear() This member removes all entries in the collection.

Count This member returns the number of items in the collection.

Remove() RemoveAt()

You use these members to remove a control from the collection.

When you wish to populate the UI of a Form-derived type, you typically follow a predictable series

of steps:

• Define a member variable of a given UI element within the Form-derived class.

• Configure the look and feel of the UI element.

• Add the UI element to the form’s ControlsCollection container using a call to Controls.Add().

Assume you wish to update your MainWindow class to support a File ➤ Exit menu system. Here are the relevant updates, with code analysis to follow:

Public Class MainWindow Inherits Form ' Members for a simple menu system. Private mnuMainMenu As New MenuStrip() Private mnuFile As New ToolStripMenuItem() Private mnuFileExit As New ToolStripMenuItem() Public Sub New(ByVal title As String, ByVal frmHeight As Integer, ByVal frmWidth As Integer) … ' Method to create the menu system. BuildMenuSystem() End Sub Private Sub BuildMenuSystem() ' Add the File menu item to the main menu. mnuFile.Text = "&File" mnuMainMenu.Items.Add(mnuFile)

Page 7: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1567

' Now add the Exit menu to the File menu. mnuFileExit.Text = "E&xit" mnuFile.DropDownItems.Add(mnuFileExit) AddHandler mnuFileExit.Click, Sub(o, s) Application.Exit() ' Finally, set the menu for this Form. Controls.Add(Me.mnuMainMenu) MainMenuStrip = Me.mnuMainMenu End Sub End Class

Notice that the MainWindow type now maintains three new member variables. The MenuStrip type

represents the entirety of the menu system, while a given ToolStripMenuItem represents any topmost menu item (e.g., File) or submenu item (e.g., Exit) supported by the host.

You configure the menu system within the BuildMenuSystem() helper function. Notice that the text of each ToolStripMenuItem is controlled through the Text property; each menu item has been assigned a string literal that contains an embedded ampersand symbol. As you might already know, this syntax sets the Alt key shortcut. Thus, selecting Alt+F activates the File menu, while selecting Alt+X activates the Exit menu. Also notice that the File ToolStripMenuItem object (mnuFile) adds subitems using the DropDownItems property. The MenuStrip object itself adds a topmost menu item using the Items property.

Once you establish the menu system, you can add it to the controls collection (through the Controls property). Next, you assign your MenuStrip object to the form’s MainMenuStrip property. This step might seem redundant, but having a specific property such as MainMenuStrip makes it possible to dynamically establish which menu system to show a user. You might change the menu displayed based on user preferences or security settings.

The only other point of interest is the fact that you handle the Click event of the File ➤ Exit menu; this helps you capture when the user selects this submenu. The Click event works in conjunction with a standard delegate type named System.EventHandler. This event can only call methods that take a System.Object as the first parameter and a System.EventArgs as the second. Here, you use a lambda expression to terminate the entire application with the Application.Exit() method.

Once you recompile and execute this application, you will find your simple window sports a custom menu system (see Figure A-3).

Figure A-3. A simple window, with a simple menu system

Page 8: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1568

The Role of System.EventArgs and System.EventHandler System.EventHandler is one of many delegate types used within the Windows Forms (and ASP.NET) APIs during the event-handling process. As you have seen, this delegate can only point to methods where the first argument is of type System.Object, which is a reference to the object that sent the event. For example, assume you want to update the implementation of the lambda expression, as follows:

AddHandler mnuFileExit.Click, Sub(o, s) MessageBox.Show(String.Format("{0} sent this event", o.ToString())) Application.Exit() End Sub

You can verify that the mnuFileExit type sent the event because the string is displayed within the

message box: "E&xit sent this event"

You might be wondering what purpose the second argument, System.EventArgs, serves. In reality, the System.EventArgs type brings little to the table because it simply extends Object and provides practically nothing by way of addition functionality:

Public Class EventArgs Public Shared ReadOnly Empty As EventArgs Shared Sub New() Public Sub New() End Class

However, this type is useful in the overall scheme of .NET event handling because it is the parent to

many (useful) derived types. For example, the MouseEventArgs type extends EventArgs to provide details regarding the current state of the mouse. KeyEventArgs also extends EventArgs to provide details of the state of the keyboard (such as which key was pressed); PaintEventArgs extends EventArgs to yield graphically relevant data; and so forth. You can also see numerous EventArgs descendents (and the delegates that make use of them) not only when working with Windows Forms, but when working with the WPF and ASP.NET APIs, as well.

While you could continue to build more functionality into your MainWindow (e.g., status bars and dialog boxes) using a simple text editor, you would eventually end up with hand cramps because you have to author all the grungy control configuration logic manually. Thankfully, Visual Studio 2010 provides numerous integrated designers that take care of these details on your behalf. As you use these tools during the remainder of this chapter, always remember that these tools authoring everyday VB 2010 code; there is nothing magical about them whatsoever.

■ Source Code You can find the SimpleWinFormsApp project under the Appendix A subdirectory.

Page 9: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1569

The Visual Studio Windows Forms Project Template When you wish to leverage the Windows Forms designer tools of Visual Studio 2010, your typically begin by selecting the Windows Forms Application project template using the File ➤ New Project menu option. To get comfortable with the core Windows Forms designer tools, create a new application named SimpleVSWinFormsApp (see Figure A-4).

Figure A-4. The Visual Studio Windows Forms Project Template

The Visual Designer Surface Before you begin to build more interesting Windows applications, you will re-create the previous example leveraging the designer tools. Once you create a new Windows Forms project, you will notice that Visual Studio 2010 presents a designer surface to which you can drag-and-drop any number of controls. You can use this same designer to configure the initial size of the window simply by resizing the form itself using the supplied grab handles (see Figure A-5).

Page 10: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1570

Figure A-5. The visual forms designer

When you wish to configure the look-and-feel of your window (as well as any control placed on a form designer), you do so using the Properties window. Similar to a Windows Presentation Foundation project, this window can be used to assign values to properties, as well as to establish event handlers for the currently selected item on the designer (you select a configuration using the drop-down list box mounted on the top of the Properties window).

Currently, your form is devoid of content, so you see only a listing for the initial Form, which has been given a default name of Form1, as shown in the read-only Name property of Figure A-6.

Figure A-6. The Properties window for setting properties and handling events

Page 11: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1571

■ Note You can configure the Properties window to display its content by category or alphabetically using the first two buttons mounted beneath the drop-down list box. I’d suggest that you sort the items alphabetically to find a given property or event quickly.

The next designer element to be aware of is the Solution Explorer window. All Visual Studio 2010 projects support this window, but it is especially helpful when building Windows Forms applications to be able to (1) change the name of the file and related class for any window quickly, and (2) view the file that contains the designer-maintained code (you’ll learn more information on this tidbit in just a moment). For now, right-click the Form1.vb icon and select the Rename option. Name this initial window to something more fitting: MainWindow.vb. The IDE will ask you if you wish to change the name of your initial class; it’s fine to do this.

Dissecting the Initial Form Each Form in a Visual Studio 2010 Windows Application project is composed of two related VB 2010 files, which can be verified using Solution Explorer (note that I renamed this initial class from Form1 to MainWindow). Be aware that the *.Designer.vb file is hidden until you click the Show All Files button in Solution Explorer.

Right-click the MainWindow.vb icon and select View Code. Here you will see a class type that will contain all of the form’s event handlers, custom constructors, member overrides, and any additional member you author yourself. Upon startup, the Form type is quite empty: Public Class MainWindow End Class

The first point of interest is it does not appear that the MainWindow class is extending the necessary Form base class. Rest assured this is the case; however, this detail has been established in the related *.Designer.vb file. If you open up the *.Designer.vb file, you will find that your MainWindow class is further defined via the Partial keyword. Recall this keyword allows a single type to be defined across multiple files. Visual Studio 2010 uses this technique to hide the designer-generated code, allowing you to keep focused on the core logic of your Form-derived type. Here is the initial definition of this Partial class:

Partial Class MainWindow Private components As System.ComponentModel.IContainer Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub

Page 12: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1572

Private Sub InitializeComponent() components = New System.ComponentModel.Container() Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.Text = "Form1" End Sub End Class

The IContainer member variable and Dispose() methods are little more than infrastructure used by

the Visual Studio designer tools. The InitializeComponent() method is invoked by a form’s constructor at runtime. Visual Studio also makes use of this same method at design time to render correctly the UI seen on the Forms designer. To see this in action, change the value assigned to the Text property of the window to "My Main Window". Once you activate the designer, the form’s caption will update accordingly.

When you use the visual design tools (e.g., the Properties window or the form designer), the IDE updates InitializeComponent() automatically. To illustrate this aspect of the Windows Forms designer tools, ensure that the Forms designer is the active window within the IDE and find the Opacity property listed in the Properties window. Change this value to 0.8 (80%); this gives your window a slightly transparent look-and-feel the next time you compile and run your program. Once you make this change, reexamine the implementation of InitializeComponent():

Private Sub InitializeComponent() … Me.Opacity = 0.8R End Sub

For all practical purposes, you should ignore the *.Designer.vb files and allow the IDE to maintain

them on your behalf when you build a Windows Forms application using Visual Studio. If you were to author syntactically (or logically) incorrect code within InitializeComponent(), you might break the designer. Also, Visual Studio often reformats this method at design time. Thus, if you were to add custom code to InitializeComponent(), the IDE might delete it! In any case, remember that each window of a Windows Forms application is composed using Partial classes.

Visually Building a Menu System To wrap up this look at the Windows Forms visual designer tools and move on to some more illustrative examples, activate the Forms designer window, locate the Toolbox window of Visual Studio 2010, and find the MenuStrip control within the Menus & Toolbars node (see Figure A-7).

Page 13: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1573

Figure A-7. Windows Forms controls you can add to your designer surface

Drag a MenuStrip control onto the top of your Forms designer. Notice that Visual Studio responds by activating the menu editor. If you look closely at this editor, you will notice a small triangle on the top-right of the control. Clicking this icon opens a context-sensitive inline editor that allows you to make numerous property settings at once (be aware that many Windows Forms controls have similar inline editors). For example, click the Insert Standard Items option, as shown in Figure A-8.

Figure A-8. The inline menu editor

Page 14: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1574

In this example, Visual Studio was kind enough to establish an entire menu system on your behalf. Now open your designer-maintained file (MainWindow.Designer.vb) and note the numerous lines of code added to InitializeComponent(), as well as several new member variables that represent your menu system (designer tools are good things!). Finally, flip back to the designer and undo the previous operation by clicking the Ctrl+Z keyboard combination. This brings you back to the initial menu editor and removes the generated code. Using the menu designer, type in a topmost File menu item, followed by an Exit submenu (see Figure A-9).

Figure A-9. Manually building our menu system

If you take a look at InitializeComponent(), you will find the same sort of code you authored by hand in the first example of this chapter. To complete this exercise, flip back to the Forms designer and click the lightning bolt button mounted on the Properties window. This shows you all of the events you can handle for the selected control. Make sure you select the Exit menu (named ExitToolStripMenuItem by default), then locate the Click event (see Figure A-10).

Page 15: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1575

Figure A-10. Establishing Events with the IDE

At this point, you can enter the name of the method to be called when the item is clicked; or, if you feel lazy at this point, you can double-click the event listed in the Properties window. This lets the IDE pick the name of the event handler on your behalf (which follows the pattern, NameOfControl_NameOfEvent()). In either case, the IDE will create stub code, and you can fill in the implementation details:

Public Class MainWindow Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub End Class

The System.EventHandler Delegate The ApplicationExit event works in conjunction with the System.EventHandler delegate. This delegate must point to subroutines that conform to the following signature: Sub MyEventHandler(ByVal sender As Object, ByVal args As EventArgs)

System.EventHandler is the most primitive delegate used to handle events within Windows Forms,

but many variations do exist for other events. As far as EventHandler is concerned, the first parameter of

Page 16: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1576

the assigned method is of type System.Object, which represents the object sending the event (the form itself in this case). The second EventArgs parameter contains any relevant information regarding the current event.

The Anatomy of a Form So far you have examined how to build simple Windows Forms applications with (and without) the aid of Visual Studio; now it’s time to examine the Form type in greater detail. In the world of Windows Forms, the Form type represents any window in the application, including the topmost main windows, child windows of a multiple document interface (MDI) application, as well as modal and modeless dialog boxes. As Figure A-11 shows, the Form type gathers a good deal of functionality from its parent classes and the numerous interfaces it implements.

Figure A-11. The inheritance chain of System.Windows.Forms.Form

Page 17: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1577

Table A-2 offers a high-level look at each parent class in the Form’s inheritance chain.

Table A-2. Base Classes in the Form Inheritance Chain

Parent Class Meaning in Life

System.Object Like any class in .NET, a Form is-a object.

System.MarshalByRefObject Types deriving from this class are accessed remotely through a reference to (not a local copy of) the remote type.

System.ComponentModel. Component

This class provides a default implementation of the IComponent interface. In the .NET universe, a component is a type that supports design-time editing, but it is not necessarily visible at runtime.

System.Windows.Forms.Control This class defines common UI members for all Windows Forms UI controls, including the Form type itself.

System.Windows.Forms. ScrollableControl

This class defines support for horizontal and vertical scrollbars, as well as members, which allow you to manage the viewport shown within the scrollable region.

System.Windows.Forms. ContainerControl

This class provides focus-management functionality for controls that can function as a container for other controls.

System.Windows.Forms.Form This class represents any custom form, MDI child, or dialog box.

Although the complete derivation of a Form type involves numerous base classes and interfaces, you

should keep in mind that you are not required to learn the role of each and every member of each and every parent class or implemented interface to be a proficient Windows Forms developer. In fact, you can easily set the majority of the members (specifically, properties and events) you use on a daily basis using the Visual Studio 2010 Properties window. That said, it is important that you understand the functionality provided by the Control and Form parent classes.

The Functionality of the Control Class The System.Windows.Forms.Control class establishes the common behaviors required by any GUI type. The core members of Control allow you to configure the size and position of a control, capture keyboard and mouse input, get or set the focus/visibility of a member, and so forth. Table A-3 defines some properties of interest, which are grouped by related functionality.

Page 18: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1578

Table A-3. Core Properties of the Control Type

Property Meaning in Life

BackColor ForeColor BackgroundImage Font Cursor

These properties define the core UI of the control (e.g., colors, font for text, and the mouse cursor to display when the mouse is over the widget).

Anchor Dock AutoSize

These properties control how the control should be positioned within the container.

Top Left Bottom Right Bounds ClientRectangle Height Width

These properties specify the current dimensions of the control.

Enabled Focused Visible

These properties encapsulate a Boolean that specifies the state of the current control.

ModifierKeys This Shared property checks the current state of the modifier keys (e.g., Shift, Ctrl, and Alt) and returns the state in a Keys type.

MouseButtons This Shared property checks the current state of the mouse buttons (left, right, and middle mouse buttons) and returns this state in a MouseButtons type.

TabIndex TabStop

You use these properties to configure the tab order of the control.

Opacity This property determines the opacity of the control (0.0 is completely transparent; 1.0 is completely opaque).

Text This property indicates the string data associated with this control.

Controls This property allows you to access a strongly typed collection (e.g., ControlsCollection) that contains any child controls within the current control.

Page 19: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1579

As you might guess, the Control class also defines a number of events that allow you to intercept mouse, keyboard, painting, and drag-and-drop activities, among other things. Table A-4 lists some events of interest, grouping them by related functionality.

Table A-4. Events of the Control Type

Event Meaning in Life

Click DoubleClick MouseEnter MouseLeave MouseDown MouseUp MouseMove MouseHover MouseWheel

These events that let you interact with the mouse.

KeyPress KeyUp KeyDown

These events let you interact with the keyboard.

DragDrop DragEnter DragLeave DragOver

You use these events to monitor drag-and-drop activity.

Paint This event lets you to interact with the graphical rendering services of GDI+.

Finally, the Control base class also defines a several methods that allow you to interact with any

Control-derived type. As you examine the methods of the Control type, notice that a many of them have an On prefix, followed by the name of a specific event (e.g., OnMouseMove, OnKeyUp, and OnPaint). Each of these On-prefixed Overridable methods is the default event handler for its respective event. If you override any of these Overridable members, you gain the ability to perform any necessary pre- or post-processing of the event before (or after) invoking the parent’s default implementation:

Public Class MainWindow Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) ' Add custom code for MouseDown event here. ' Call parent implementation when finished. MyBase.OnMouseDown(e) End Sub End Class

This can be helpful in some circumstances (especially if you want to build a custom control that

derives from a standard control), but you will often handle events using the standard VB 2010 event syntax (in fact, this is the default behavior of the Visual Studio designers). When you handle events in

Page 20: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1580

this manner, the framework calls your custom event handler once the parent’s implementation has completed. For example, this code lets you manually handle the MouseDown event:

Public Class MainWindow Private Sub MainWindow_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown ' Add code for MouseDown event. End Sub End Class

You should also be aware of a few other methods, in addition to the just described OnXXX() methods:

• Hide(): Hides the control and sets the Visible property to False.

• Show(): Shows the control and sets the Visible property to True.

• Invalidate(): Forces the control to redraw itself by sending a Paint event (you learn more about graphical rendering using GDI+ later in this chapter).

The Functionality of the Form Class The Form class is typically (but not necessarily) the direct base class for your custom Form types. In addition to the large set of members inherited from the Control, ScrollableControl, and ContainerControl classes, the Form type adds additional functionality in particular to main windows, MDI child windows, and dialog boxes. Let’s start with the core properties in Table A-5.

Table A-5. Properties of the Form Type

Property Meaning in Life

AcceptButton Gets or sets the button on the form that is clicked when the user presses the Enter key.

ActiveMdiChild IsMdiChild IsMdiContainer

Used within the context of an MDI application.

CancelButton Gets or sets the button control that will be clicked when the user presses the Esc key.

ControlBox Gets or sets a value that indicates whether the form has a control box (e.g., the minimize, maximize, and close icons in the upper right of a window).

FormBorderStyle Gets or sets the border style of the form. You use this in conjunction with the FormBorderStyle enumeration.

Page 21: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1581

Property Meaning in Life

Menu Gets or sets the menu to dock on the form.

MaximizeBox MinimizeBox

Used to determine whether this form will enable the maximize and minimize boxes.

ShowInTaskbar Determines whether this form will be seen on the Windows taskbar.

StartPosition Gets or sets the starting position of the form at runtime, as specified by the FormStartPosition enumeration.

WindowState Configures how the form is to be displayed on startup. You use this in conjunction with the FormWindowState enumeration.

In addition to numerous On-prefixed default event handlers, Table A-6 provides a list of some core

methods defined by the Form type.

Table A-6. Key Methods of the Form Type

Method Meaning in Life

Activate() Activates a given form and gives it focus.

Close() Closes the current form.

CenterToScreen() Places the form in the center of the screen

LayoutMdi() Arranges each child form (as specified by the MdiLayout enumeration) within the parent form.

Show() Displays a form as a modeless window.

ShowDialog() Displays a form as a modal dialog box.

Finally, the Form class defines a number of events, many of which fire during the form’s lifetime (see

Table A-7).

Page 22: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1582

Table A-7. Select Events of the Form Type

Event Meaning in Life

Activated This event occurs whenever the form is activated, which means that the form has been given the current focus on the desktop.

FormClosed FormClosing

You use these events to determine when the form is about to close or has closed.

Deactivate This event occurs whenever the form is deactivated, which means the form has lost the current focus on the desktop.

Load This event occurs after the form has been allocated into memory, but is not yet visible on the screen.

MdiChildActive This event is sent when a child window is activated.

The Life Cycle of a Form Type If you have programmed user interfaces using GUI toolkits such as Java Swing, Mac OS X Cocoa, or WPF, you know that window types have many events that fire during their lifetime. The same holds true for Windows Forms. Internally, the life of a form begins when the class constructor is called prior to being passed into the Application.Run() method.

Once the object has been allocated on the managed heap, the framework fires the Load event. Within a Load event handler, you are free to configure the look-and-feel of the Form, prepare any contained child controls (e.g., ListBoxes and TreeViews), or allocate resources used during the Form’s operation (e.g., database connections and proxies to remote objects).

Once the Load event fires, the next event to fire is Activated. This event fires when the form receives the focus as the active window on the desktop. The logical counterpart to the Activated event is (of course) Deactivate, which fires when the form loses the focus as the active window. As you can guess, the Activated and Deactivate events can fire numerous times over the life of a given Form object as the user navigates between active windows and applications.

Two events fire when the user chooses to close a given form: FormClosing and FormClosed. The FormClosing event is fired first and is an ideal place to prompt the end user with the much hated (but useful) message: “Are you sure you wish to close this application?” This step gives the user a chance to save any application-centric data before terminating the program.

The FormClosing event works in conjunction with the FormClosingEventHandler delegate. If you set the FormClosingEventArgs.Cancel property to True, you prevent the window from being destroyed and instruct it to return to normal operation. If you set FormClosingEventArgs.Cancel to False, the FormClosed event fires, and the Windows Forms application exits, which unloads the AppDomain and terminates the process.

To solidify the sequence of events that take place during a form’s lifetime, assume you have a new MainWindow.vb file that handles the Load, Activated, Deactivate, FormClosing, and FormClosed events (be sure to add an Imports directive for the System.ComponentModel namespace to obtain the definition of CancelEventArgs).

Page 23: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1583

Within the Load, FormClosed, Activated, and Deactivate event handlers, you must update the value of a new Form-level String member variable (named lifeTimeInfo) with a simple message that displays the name of the event that has just been intercepted. Begin by adding this member to your Form derived class:

Public Class MainWindow Private lifeTimeInfo As String = "" …. End Class

The next step is to implement the event handlers. Notice that you display the value of the

lifeTimeInfo string within a message box in the FormClosed event handler:

Private Sub MainWindow_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load lifeTimeInfo &= "Load event" & vbLf End Sub Private Sub MainWindow_Activated(ByVal sender As Object, ByVal e AsnEventArgs) Handles MyBase.Activated lifeTimeInfo = lifeTimeInfo & "Activate event" & vbLf End Sub Private Sub MainWindow_Deactivate(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Deactivate lifeTimeInfo = lifeTimeInfo & "Deactivate event" & vbLf End Sub Private Sub MainWindow_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs) Handles MyBase.FormClosed lifeTimeInfo = lifeTimeInfo & "FormClosed event" & vbLf MessageBox.Show(lifeTimeInfo) End Sub

Within the FormClosing event handler, you prompt the user to ensure that she wishes to terminate

the application using the incoming FormClosingEventArgs. In the following code, the MessageBox.Show() method returns a DialogResult type that contains a value representing which button has been selected by the end user. Here, you craft a message box that displays Yes and No buttons; therefore, you want to discover whether the return value from Show() is DialogResult.No:

Private Sub MainWindow_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing lifeTimeInfo = lifeTimeInfo & "FormClosing event" & vbLf ' Show a message box with Yes and No buttons. Dim dr As DialogResult = MessageBox.Show("Do you REALLY want to close this app?", "Closing event!", MessageBoxButtons.YesNo)

Page 24: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1584

' Which button was clicked? If dr = DialogResult.No Then e.Cancel = True Else e.Cancel = False End If End Sub

Let’s make one final adjustment. Currently, the File ➤ Exit menu destroys the entire application,

which is a bit aggressive. More often, the File ➤ Exit handler of a top-most window calls the inherited Close() method, which fires the close-centric events and then tears down the application: Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click ' Application.Exit() Close() End Sub

Now run your application and shift the form into and out of focus a few times (to trigger the Activated and Deactivate events). When you eventually shut down the application, you will see a message box that looks something like the message shown in Figure A-12.

Figure A-12. The life and times of a Form-derived type

■ Source Code You can find the SimpleVSWinFormsApp project under the Appendix A subdirectory.

Page 25: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1585

Responding to Mouse and Keyboard Activity You might recall that the Control parent class defines a set of events that allow you to monitor mouse and keyboard activity in a variety of manners. To check this out firsthand, create a new Windows Forms Application project named MouseAndKeyboardEventsApp, rename the initial form to MainWindow.vb (using the Solution Explorer), and handle the MouseMove event using the Properties window. These steps generate the following event handler: Public Class MainWindow ' Generated via the Properties window. Private Sub MainWindow_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove End Sub End Class

The MouseMove event works in conjunction with the System.Windows.Forms.MouseEventHandler

delegate. This delegate can only call methods where the first parameter is a System.Object, while the second is of type MouseEventArgs. This type contains various members that provide detailed information about the state of the event when mouse-centric events occur: Public Class MouseEventArgs Inherits EventArgs Public Sub New(ByVal button As MouseButtons, ByVal clicks As Integer, ByVal x As Integer, ByVal y As Integer, ByVal delta As Integer) End Sub Public ReadOnly Property Button() As MouseButtons Public ReadOnly Property Clicks() As Integer Public ReadOnly Property Delta() As Integer Public ReadOnly Property Location() As Point Public ReadOnly Property X() As Integer Public ReadOnly Property Y() As Integer End Class

Most of the Public properties are self-explanatory, but Table A-8 provides more specific details.

Table A-8. Properties of the MouseEventArgs Type

Property Meaning in Life

Button Gets which mouse button was pressed, as defined by the MouseButtons enumeration.

Clicks Gets the number of times the mouse button was pressed and released.

Page 26: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1586

Continued

Property Meaning in Life

Delta Gets a signed count of the number of detents (which represents a single notch of the mouse wheel) for the current mouse rotation.

Location Returns a Point that contains the current X and Y location of the mouse.

X Gets the x-coordinate of a mouse click.

Y Gets the y-coordinate of a mouse click.

Now it’s time to implement your MouseMove handler to display the current X- and Y-position of the

mouse on the Form’s caption; you do this using the Location property:

Private Sub MainWindow_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove Text = String.Format("Mouse Position: {0}", e.Location) End Sub

When you run the application and move the mouse over the window, you find the position

displayed on the title area of your MainWindow type (see Figure A-13).

Figure A-13. Intercepting mouse movements

Determining Which Mouse Button Was Clicked Another common mouse-centric detail to attend to is determining which button has been clicked when a MouseUp, MouseDown, MouseClick, or MouseDoubleClick event occurs. When you wish to determine exactly which button was clicked (whether left, right, or middle), you need to examine the Button property of the MouseEventArgs class. The value of the Button property is constrained by the related MouseButtons enumeration:

Page 27: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1587

Public Enum MouseButtons Left Middle None Right XButton1 XButton2 End Enum

■ Note The XButton1 and XButton2 values allow you to capture forward and backwards navigation buttons that are supported on many mouse-controller devices.

You can see this in action by handling the MouseDown event on your MainWindow type using the Properties window. The following MouseDown event handler displays which mouse button was clicked inside a message box:

Private Sub MainWindow_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown ' Which mouse button was clicked? If e.Button = MouseButtons.Left Then MessageBox.Show("Left click!") End If If e.Button = MouseButtons.Right Then MessageBox.Show("Right click!") End If If e.Button = MouseButtons.Middle Then MessageBox.Show("Middle click!") End If End Sub

Determining Which Key Was Pressed Windows applications typically define numerous input controls (e.g., the TextBox) where the user can enter information using the keyword. When you capture keyboard input in this manner, you do not need to handle keyboard events explicitly because you can extract the textual data from the control using various properties (e.g., the Text property of the TextBox type).

However, if you need to monitor keyboard input for more exotic purposes (e.g., filtering keystrokes on a control or capturing keypresses on the form itself), the base class libraries provide the KeyUp and KeyDown events. These events work in conjunction with the KeyEventHandler delegate, which can point to any method taking an object as the first parameter and KeyEventArgs as the second. You define this type like this:

Page 28: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1588

Public Class KeyEventArgs Public Sub New(ByVal keyData As Keys) Public Overridable ReadOnly Property Alt() As Boolean Public ReadOnly Property Control() As Boolean Public Property Handled() As Boolean Public ReadOnly Property KeyCode() As Keys Public ReadOnly Property KeyData() As Keys Public ReadOnly Property KeyValue() As Integer Public ReadOnly Property Modifiers() As Keys Public Overridable ReadOnly Property Shift() As Boolean Public Property SuppressKeyPress() As Boolean End Class

Table A-9 documents some of the more interesting properties supported by KeyEventArgs.

Table A-9. Properties of the KeyEventArgs Type

Property Meaning in Life

Alt Gets a value that indicates whether the Alt key was pressed.

Control Gets a value that indicates whether the Ctrl key was pressed.

Handled Gets or sets a value that indicates whether the event was fully handled in your handler.

KeyCode Gets the keyboard code for a KeyDown or KeyUp event.

Modifiers Indicates which modifier keys (e.g., Ctrl, Shift, and/or Alt) were pressed.

Shift Gets a value that indicates whether the Shift key was pressed.

You can see this in action by handling the KeyDown event as follows:

Private Sub MainWindow_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyDown Text = String.Format("Key Pressed: {0} Modifiers: {1}", e.KeyCode.ToString(), e.Modifiers.ToString()) End Sub

Now compile and run your program. You should be able to determine which mouse button was

clicked, as well as which keyboard key was pressed. For example, Figure A-14 shows the result of pressing the Ctrl and Shift keys simultaneously.

Page 29: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1589

Figure A-14. Intercepting keyboard activity

■ Source Code You can find the MouseAndKeyboardEventsApp project under the Appendix A subdirectory.

Designing Dialog Boxes Within a graphical user interface program, dialog boxes tend to be the primary way to capture user input for use within the application itself. Unlike other GUI APIs you might have used previously, there Windows Forms has no Dialog base class. Rather, dialog boxes under Windows Forms are simply types that derive from the Form class.

In addition, many dialog boxes are intended to be nonsizable; therefore, you typically want to set the FormBorderStyle property to FormBorderStyle.FixedDialog. Also, dialog boxes typically set the MinimizeBox and MaximizeBox properties to False. In this way, the dialog box is configured to be a fixed constant. Finally, if you set the ShowInTaskbar property to False, you will prevent the form from being visible in the Windows taskbar.

Let’s look at how to build and manipulate dialog boxes. Begin by creating a new Windows Forms Application project named CarOrderApp and rename the initial Form1.vb file to MainWindow.vb using Solution Explorer. Next, use the Forms designer to create a simple File ➤ Exit menu, as well as a Tool ➤ Order Automobile... menu item (remember: you create a menu by dragging a MenuStrip from the Toolbox and then configuring the menu items in the designer window). Once you do this, handle the Click event for the Exit and Order Automobile submenus using the Properties window.

You implement the File ➤ Exit menu handler so it terminates the application with a call to Close():

Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click Close() End Sub

Now use the Project menu of Visual Studio to select the Add Windows Forms menu option and

name your new form OrderAutoDialog.vb (see Figure A-15).

Page 30: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1590

For this example, design a dialog box that has the expected OK and Cancel buttons (named btnOK and btnCancel, respectively), as well as three TextBox controls named txtMake, txtColor, and txtPrice. Now use the Properties window to finalize the design of your dialog box, as follows:

• Set the FormBorderStyle property to FixedDialog.

• Set the MinimizeBox and MaximizeBox properties to False.

• Set the StartPosition property to CenterParent.

• Set the ShowInTaskbar property to False.

Figure A-15. Inserting new dialog boxes using Visual Studio

The DialogResult Property Finally, select the OK button and use the Properties window to set the DialogResult property to OK. Similarly, you can set the DialogResult property of the Cancel button to (you guessed it) Cancel. As you will see in a moment, the DialogResult property is quite useful because it enables the launching form to determine quickly which button the user has clicked; this enables you to take the appropriate action. You can set the DialogResult property to any value from the related DialogResult enumeration:

Page 31: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1591

Public Enum DialogResult Abort Cancel Ignore No None OK Retry Yes End Enum

Figure A-16 shows one possible design of your dialog box; it even adds in a few descriptive Label

controls.

Figure A-16. The OrderAutoDialog type

Configuring the Tab Order You have created a somewhat interesting dialog box; the next step is to formalize the tab order. As you might know, users expect to be able to shift focus using the Tab key when a form contains multiple GUI widgets. Configuring the tab order for your set of controls requires that you understand two key properties: TabStop and TabIndex.

You can set the TabStop property to True or False, based on whether or not you wish this GUI item to be reachable using the Tab key. Assuming that you set the TabStop property to True for a given control, you can use the TabOrder property to establish the order of activation in the tabbing sequence (which is zero-based), as in this example:

Page 32: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1592

' Configure tabbing properties. txtMake.TabIndex = 0 txtMake.TabStop = True

The Tab Order Wizard You can set the TabStop and TabIndex manually using the Properties window; however, the Visual Studio 2010 IDE supplies a Tab Order Wizard that you can access by choosing View ➤ Tab Order (be aware that you will not find this menu option unless the Forms designer is active). Once activated, your design-time form displays the current TabIndex value for each widget. To change these values, click each item in the order you prefer the controls to tab (see Figure A-17).

Figure A-17. The Tab Order Wizard

You can exit the Tab Order Wizard by pressing the Esc key.

Setting the Form’s Default Input Button Many user-input forms (especially dialog boxes) have a particular button that automatically responds to the user pressing the Enter key. Now assume that you want the Click event handler for btnOK invoked when the user presses the Enter key. Doing so is as simple as setting the form’s AcceptButton property in the form’s constructor (after the call to the InitializeComponent() method) as follows (you can establish this same setting using the Properties window):

Public Class OrderAutoDialog Public Sub New() InitializeComponent()

Page 33: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1593

' When the Enter key is pressed, it is as if ' the user clicked the btnOK button. Me.AcceptButton = btnOK End Sub End Class

■ Note Some forms require the ability to simulate clicking the form’s Cancel button when the user presses the Esc key. You can accomplish this by assigning the CancelButton property of the Form to the Button object that represents the clicking of the Cancel button.

Displaying Dialog Boxes When you wish to display a dialog box, you must first decide whether you wish to launch the dialog box in a modal or modeless fashion. As you might know, modal dialog boxes must be dismissed by the user before he can return to the window that launched the dialog box in the first place; for example, most About boxes are modal in nature. To show a modal dialog box, call ShowDialog() off your dialog box object. On the other hand, you can display a modeless dialog box by calling Show(), which allows the user to switch focus between the dialog box and the main window (e.g., a Find/Replace dialog box).

For this example, you want to update the Tools ➤ Order Automobile... menu handler of the MainWindow type to show the OrderAutoDialog object in a modal manner. Consider the following initial code:

Private Sub OrderAutomobileToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles OrderAutomobileToolStripMenuItem.Click ' Create your dialog object. Dim dlg As New OrderAutoDialog() ' Show as modal dialog box, and figure out which button ' was clicked using the DialogResult return value. If dlg.ShowDialog() = DialogResult.OK Then ' They clicked OK, so do something... End If End Sub

■ Note You can optionally call the ShowDialog() and Show() methods by specifying an object that represents the owner of the dialog box (which for the form loading the dialog box would be represented by this). Specifying the owner of a dialog box establishes the z-ordering of the form types and also ensures (in the case of a modeless dialog box) that all owned windows are also disposed of when the main window is destroyed.

Page 34: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1594

Be aware that when you create an instance of a Form-derived type (OrderAutoDialog in this case), the dialog box is not visible on the screen, but simply allocated into memory. It is not until you call Show() or ShowDialog() that the form becomes visible. Also, notice that ShowDialog() returns the DialogResult value that has been assigned to the button (the Show() method is a Sub and therefore has no return value).

Once ShowDialog() returns, the form is no longer visible on the screen, but is still in memory. This means you can extract the values in each TextBox as follows:

Private Sub OrderAutomobileToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles OrderAutomobileToolStripMenuItem.Click ' Create your dialog object. Dim dlg As New OrderAutoDialog() ' Show as modal dialog box, and figure out which button ' was clicked using the DialogResult return value. If dlg.ShowDialog() = DialogResult.OK Then ' Get values in each text box? Compiler errors! Dim orderInfo As String = String.Format("Make: {0}, Color: {1}, Cost: {2}", dlg.txtMake.Text.dlg.txtColor.Text, dlg.txtPrice.Text) MessageBox.Show(orderInfo, "Information about your order!") End If End Sub

The reason you can access the controls is because Visual Studio 2010 declares the controls you add

to the Forms designer as Friend member variables of the class. You can verify this fact by opening the OrderAutoDialog.Designer.vb file.At this point, you can compile and run your application. Once you launch your dialog box, you should be able to see the input data displayed within a message box (provided you click the OK button).

Understanding Form Inheritance So far, each one of your custom windows/dialog boxes in this chapter has derived directly from System.Windows.Forms.Form. However, one intriguing aspect of Windows Forms development is the fact that Form types can function as the base class to derived Forms. For example, assume you create a .NET code library that contains each of your company’s core dialog boxes. Later, you decide that your company’s About box is a bit on the bland side, and you wish to add a 3D image of your company logo. Rather than having to re-create the entire About box, you can extend the basic About box, thereby inheriting the core look-and-feel: ' ThreeDAboutBox "is-a" AboutBox Partial Public Class ThreeDAboutBox Inherits AboutBox ' Add code to render company logo... End Class

To see form inheritance in action, insert a new form into your project using the Project ➤ Add Windows Form menu option. This time, however, pick the Inherited Form icon, and name your new form ImageOrderAutoDialog.vb (see Figure A-18).

Page 35: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1595

Figure A-18. Adding a derived form to your project

This option brings up the Inheritance Picker dialog box, which shows you each of the forms in your current project. Notice that the Browse button allows you to pick a form in an external .NET assembly. Here, simply pick your OrderAutoDialog class.

■ Note You must compile your project at least one time to see the forms of your project in the Inheritance Picker dialog box because this tool reads from the assembly metadata to show you your options.

Once you click the OK button, the visual designer tools show each of the base controls on your parent controls; each control has a small arrow icon mounted on the upper-left of the control (symbolizing inheritance). To complete your derived dialog box, locate the PictureBox control from the Common Controls section of the Toolbox and add one to your derived form. Next, use the Image property to select an image file of your choosing. Figure A-19 shows one possible UI, using a (crude) hand drawing of a junker automobile (a lemon!).

Page 36: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1596

Figure A-19. The UI of the ImageOrderAutoDialog class

With this, you can now update the Tools ➤ Order Automobile... Click event handler to create an instance of your derived type, rather than the OrderAutoDialog base class:

Private Sub OrderAutomobileToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles OrderAutomobileToolStripMenuItem.Click ' Create the derived dialog object. Dim dlg As New ImageOrderAutoDialog() ... End Sub

■ Source Code You can find the CarOrderApp project under the Appendix A subdirectory.

Rendering Graphical Data Using GDI+ Many GUI applications require the ability to generate graphical data dynamically for display on the surface of a window. For example, perhaps you have selected a set of records from a relational database and wish to render a pie chart (or bar chart) that visually shows items in stock. Or, perhaps you want to re-create some old-school video game using the .NET platform. Regardless of your goal, GDI+ is the API to use when you need to render data graphically within a Windows Forms application. This technology is bundled within the System.Drawing.dll assembly, which defines a number of namespaces (see Figure A-20).

Page 37: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1597

Figure A-20. The namespaces of System.Drawing.dll

■ Note A friendly reminder: WPF has its own graphical rendering subsystem and API; you use GDI+ only within a Windows Forms application.

Table A-10 documents the role of the key GDI+ namespaces at a high level.

Page 38: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1598

Table A-10. Core GDI+ Namespaces

Namespace Meaning in Life

System.Drawing This is the core GDI+ namespace that defines numerous types for basic rendering (e.g., fonts, pens, and basic brushes), as well as the almighty Graphics type.

System.Drawing.Drawing2D This namespace provides types used for more advanced 2D/vector graphics functionality (e.g., gradient brushes, pen caps, and geometric transforms).

System.Drawing.Imaging This namespace defines types that allow you to manipulate graphical images (e.g., change the palette, extract image metadata, manipulate metafiles, etc.).

System.Drawing.Printing This namespace defines types that allow you to render images to the printed page, interact with the printer itself, and format the overall appearance of a given print job.

System.Drawing.Text This namespace allows you to manipulate collections of fonts.

The System.Drawing Namespace You can find the vast majority of the types you’ll use when programming GDI+ applications in the System.Drawing namespace. As you might expect, you can find classes that represent images, brushes, pens, and fonts. System.Drawing also defines a several related utility types, such as Color, Point, and Rectangle. Table A-11 lists some (but not all) of the core types.

Table A-11. Core Types of the System.Drawing Namespace

Type Meaning in Life

Bitmap This type encapsulates image data (*.bmp or otherwise).

Brush Brushes SolidBrush SystemBrushes TextureBrush

You use brush objects to fill the interiors of graphical shapes, such as rectangles, ellipses, and polygons.

BufferedGraphics This type provides a graphics buffer for double buffering, which you use to reduce or eliminate flicker caused by redrawing a display surface.

Page 39: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1599

Type Meaning in Life

Color SystemColors

The Color and SystemColors types define a number of Shared read-only properties you use to obtain specific colors for the construction of various pens/brushes.

Font FontFamily

The Font type encapsulates the characteristics of a given font (e.g., type name, bold, italic, and point size). FontFamily provides an abstraction for a group of fonts that have a similar design, but also certain variations in style.

Graphics This core class represents a valid drawing surface, as well as several methods to render text, images, and geometric patterns.

Icon SystemIcons

These classes represent custom icons, as well as the set of standard system-supplied icons.

Image ImageAnimator

Image is a MustInherit base class that provides functionality for the Bitmap, Icon, and Cursor types. ImageAnimator provides a way to iterate over a number of Image-derived types at some specified interval.

Pen Pens SystemPens

Pens are objects you use to draw lines and curves. The Pens type defines several Shared properties that return a new Pen of a given color.

Point PointF

These structures represent an (x, y) coordinate mapping to an underlying Integer or Single, respectively.

Rectangle RectangleF

These structures represent a rectangular dimension (again, these map to an underlying Integer or Single).

Size SizeF

These structures represent a given height/width (again, these map to an underlying Integer or Single).

StringFormat You use this type to encapsulate various features of textual layout (e.g., alignment and line spacing).

Region This type describes the interior of a geometric image composed of rectangles and paths.

The Role of the Graphics Type The System.Drawing.Graphics class serves as the gateway to GDI+ rendering functionality. This class not only represents the surface you wish to draw upon (such as a form’s surface, a control’s surface, or a region of memory), but also defines dozens of members that allow you to render text, images (e.g., icons and bitmaps), and numerous geometric patterns. Table A-12 gives a partial list of members.

Page 40: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1600

Table A-12. Select Members of the Graphics Class

Method Meaning in Life

FromHdc() FromHwnd() FromImage()

These Shared methods provide a way to obtain a valid Graphics object from a given image (e.g., icon and bitmap) or GUI control.

Clear() This method fills a Graphics object with a specified color, erasing the current drawing surface in the process.

DrawArc() DrawBeziers() DrawCurve() DrawEllipse() DrawIcon() DrawLine() DrawLines() DrawPie() DrawPath() DrawRectangle() DrawRectangles() DrawString()

You use these methods to render a given image or geometric pattern. All DrawXXX() methods require that you use GDI+ Pen objects.

FillEllipse() FillPie() FillPolygon() FillRectangle() FillPath()

You use these methods to fill the interior of a given geometric shape. All FillXXX() methods require that you use GDI+ Brush objects.

Note that you cannot create the Graphics class directly using the new keyword because there are no

publicly defined constructors. So, how do you obtain a valid Graphics object? I’m glad you asked!

Obtaining a Graphics Object with the Paint Event The most common way to obtain a Graphics object is to use the Visual Studio 2010 Properties window to handle the Paint event on the window you want to render upon. This event is defined in terms of the PaintEventHandler delegate, which can point to any method taking a System.Object as the first parameter and a PaintEventArgs as the second.

The PaintEventArgs parameter contains the Graphics object you need to render onto the Form’s surface. For example, create a new Windows Application project named PaintEventApp. Next, use Solution Explorer to rename your initial Form.vb file to MainWindow.vb, and then handle the Paint event using the Properties window. This creates the following stub code:

Page 41: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1601

Public Class MainWindow Private Sub MainWindow_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint ' Add your painting code here! End Sub End Class

Now that you have handled the Paint event, you might wonder when it will fire. The Paint event

fires whenever a window becomes dirty; a window is considered dirty whenever it is resized, uncovered by another window (partially or completely), or minimized and then restored. In all these cases, the .NET platform ensures that the Paint event handler is called automatically whenever your Form needs to be redrawn. Consider the following implementation of MainWindow_Paint():

Private Sub MainWindow_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint ' Get the graphics object for this Form. Dim g As Graphics = e.Graphics ' Draw a circle. g.FillEllipse(Brushes.Blue, 10, 20, 150, 80) ' Draw a string in a custom font. g.DrawString("Hello GDI+", New Font("Times New Roman", 30), Brushes.Red, 200, 200) ' Draw a line with a custom pen. Using p As New Pen(Color.YellowGreen, 10) g.DrawLine(p, 80, 4, 200, 200) End Using End Sub

Once you obtain the Graphics object from the incoming PaintEventArgs parameter, you call

FillEllipse(). Notice that this method (as well as any Fill-prefixed method) requires a Brush-derived type as the first parameter. While you could create any number of interesting brush objects from the System.Drawing.Drawing2D namespace (e.g., HatchBrush and LinearGradientBrush), the Brushes utility class provides handy access to a variety of solid-colored brush types.

Next, you make a call to DrawString(), which requires a String to render as its first parameter. Given this, GDI+ provides the Font type, which represents not only the name of the font to use when rendering the textual data, but also related characteristics, such as the point size (30, in this case). Also notice that DrawString() requires a Brush type; as far as GDI+ is concerned, “Hello GDI+” is nothing more than a collection of geometric patterns to fill on the screen. Finally, DrawLine() is called to render a line using a custom Pen type, 10 pixels wide. Figure A-21 shows the output of this rendering logic.

Page 42: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1602

Figure A-21. A simple GDI+ rendering operation

■ Note In the preceding code, you explicitly dispose of the Pen object. As a rule, when you directly create a GDI+ type that implements IDisposable, you call the Dispose() method as soon as you are done with the object. Doing this lets you release the underlying resources as soon as possible. If you do not do this, the resources will eventually be freed by the garbage collector in a nondeterministic manner.

Invalidating the Form’s Client Area During the flow of a Windows Forms application, you might need to fire the Paint event in your code explicitly, rather than waiting for the window to become naturally dirty by the actions of the end user. For example, you might be building a program that allows the user to select from a number of predefined images using a custom dialog box. Once the dialog box is dismissed, you need to draw the newly selected image onto the form’s client area. Obviously, if you were to wait for the window to become naturally dirty, the user would not see the change take place until the window was resized or uncovered by another window. To force a window to repaint itself programmatically, you call the inherited Invalidate() method:

Public Class MainForm … Private Sub MainForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint Dim g As Graphics = e.Graphics ' Render the correct image here. End Sub

Page 43: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1603

Private Sub GetImageFromDialog() ' Show dialog box and get new image. ' Repaint the entire client area. Invalidate() End Sub End Class

The Invalidate() method has been overloaded a number of times. This allows you to specify a

specific rectangular portion of the form to repaint, rather than having to repaint the entire client area (which is the default). If you wish to update only the extreme upper-left rectangle of the client area, you can write the following code:

' Repaint a given rectangular area of the Form. Private Sub UpdateUpperArea() Dim myRect As New Rectangle(0, 0, 75, 150) Invalidate(myRect) End Sub

■ Source Code You can find the PaintEventApp project under the Appendix A subdirectory.

Building a Complete Windows Forms Application Let’s conclude this introductory look at the Windows Forms and GDI+ APIs by building a complete GUI application that illustrates several of the techniques discussed in this chapter. The program you will create is a rudimentary painting program that allows users to select between two shape types (a circle or rectangle) using the color of their choice to render data to the form. You will also allow end users to save their pictures to a local file on their hard drive for later use with object serialization services.

Building the Main Menu System Begin by creating a new Windows Forms application named MyPaintProgram and rename your initial Form1.vb file to MainWindow.vb. Now design a menu system on this initial window that supports a topmost File menu that provides Save..., Load..., and Exit submenus (see Figure A-22).

Page 44: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1604

Figure A-22. The File menu system

■ Note If you specify a single dash (-) as a menu item, you can define separators within your menu system.

Next, create a second topmost Tools menu that provides options to select a shape and color to use for rendering, as well as an option to clear the form of all graphical data (see Figure A-23).

Page 45: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1605

Figure A-23. The Tools Menu System

Finally, handle the Click event for each one of these subitems. You will implement each handler as you progress through the example; however, you can finish up the File ➤ Exit menu handler by calling Close():

Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click Close() End Sub

Defining the ShapeData Type Recall that this application will allow end users to select from two predefined shapes in a given color. You will provide a way to allow users to save their graphical data to a file, so you want to define a custom class type that encapsulates each of these details; for the sake of simplicity, you do this using VB 2010 automatic properties (see Chapter 5 for more details on how to do this). Begin by adding a new class to your project named ShapeData.vb and implementing this type as follows:

<Serializable()> Public Class ShapeData ' The upper left of the shape to be drawn. Public Property UpperLeftPoint() As Point ' The current color of the shape to be drawn. Public Property Color() As Color

Page 46: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1606

' The type of shape. Public Property ShapeType() As SelectedShape End Class

Here, ShapeData uses three automatic properties that encapsulates various types of data, two of

which (Point and Color) are defined in the System.Drawing namespace. Also, notice that this type has been adorned with the <Serializable()> attribute. In an upcoming step, you will configure your MainWindow type to maintain a list of ShapeData types that you persist using object serialization services (see Chapter 20 for more details).

Defining the ShapePickerDialog Type You can allow the user to choose between the circle or rectangle image type by creating a simple custom dialog box named ShapePickerDialog (insert this new Form now). Beyond adding the obligatory OK and Cancel buttons (each of which you should assign fitting DialogResult values), this dialog box uses of a single GroupBox that maintains two RadioButton objects: radioButtonCircle and radioButtonRect. Figure A-24 shows one possible design.

Figure A-24. The ShapePickerDialog type

Now, open the code window for your dialog box by right-clicking the Forms designer and selecting the View Code menu option. At the top of the source code file, define an enumeration (named SelectedShape) that defines names for each possible shape:

Public Enum SelectedShape Circle Rectangle End Enum

Page 47: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1607

Next, update your current ShapePickerDialog class type:

• Add an automatic property of type SelectedShape. The caller can use this property to determine which shape to render.

• Handle the Click event for the OK button using the Properties window.

• Implement this event handler to determine whether the circle radio button has been selected (through the Checked property). If so, set your SelectedShape property to SelectedShape.Circle; otherwise, set this property to SelectedShape.Rectangle.

Here is the complete code:

Public Class ShapePickerDialog Public Property SelectedShape() As SelectedShape Private Sub btnOK_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOK.Click If radioButtonCircle.Checked Then SelectedShape = SelectedShape.Circle Else SelectedShape = SelectedShape.Rectangle End If End Sub End Class

That wraps up the infrastructure of your program. Now all you need to do is implement the Click

event handlers for the remaining menu items on the main window.

Adding Infrastructure to the MainWindow Type Returning to the construction of the main window, add three new member variables to this Form. These member variables allow you to keep track of the selected shape (through a SelectedShape enum member variable), the selected color (represented by a System.Drawing.Color member variable), and through each of the rendered images held in a generic List(Of T) (where T is of type ShapeData):

Public Class MainWindow ' Current shape / color to draw. Private currentShape As SelectedShape Private currentColor As Color = Color.DarkBlue ' This maintains each ShapeData. Private shapes As New List(Of ShapeData)() … End Class

Next, you handle the MouseDown and Paint events for this Form-derived type using the Properties

window. You will implement them in a later step; for the time being, however, you should find that the IDE has generated the following stub code:

Page 48: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1608

Private Sub MainWindow_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint End Sub Private Sub MainWindow_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown End Sub

Implementing the Tools Menu Functionality You can allow a user to set the currentShape member variable by implementing the Click handler for the Tools ➤ Pick Shape... menu option. You use this to launch your custom dialog box; based on a user’s selection, you assign this member variable accordingly:

Private Sub PickShapeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PickShapeToolStripMenuItem.Click ' Load our dialog box and set the correct shape type. Dim dlg As New ShapePickerDialog() If DialogResult.OK = dlg.ShowDialog() Then currentShape = dlg.SelectedShape End If End Sub

You can let a user set the currentColor member variable by implementing the Click event handler

for the Tools ➤ Pick Color... menu so it uses the System.Windows.Forms.ColorDialog type:

Private Sub PickColorToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PickColorToolStripMenuItem.Click Dim dlg As New ColorDialog() If dlg.ShowDialog() = DialogResult.OK Then currentColor = dlg.Color End If End Sub

If you were to run your program as it now stands and select the Tools ➤ Pick Color menu option,

you would get the dialog box shown in Figure A-25.

Page 49: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1609

Figure A-25. The stock ColorDialog type

Finally, you implement the Tools ➤ Clear Surface menu handler so it empties the contents of the List(Of T) member variable and programmatically fires the Paint event using a call to Invalidate():

Private Sub ClearSurfaceToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ClearSurfaceToolStripMenuItem.Click shapes.Clear() ' This will fire the paint event. Invalidate() End Sub

Capturing and Rendering the Graphical Output Given that a call to Invalidate() fires the Paint event, you need to author code within the Paint event handler. Your goal is to loop through each item in the (currently empty) List(Of T) member variable and render a circle or square at the current mouse location. The first step is to implement the MouseDown event handler and insert a new ShapeData type into the generic List(Of T) type, based on the user-selected color, shape type, and current location of the mouse:

Private Sub MainWindow_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown ' Make a ShapeData type based on current user ' selections. Dim sd As New ShapeData() sd.ShapeType = currentShape sd.Color = currentColor sd.UpperLeftPoint = New Point(e.X, e.Y)

Page 50: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1610

' Add to the List(Of T) and force the form to repaint itself. shapes.Add(sd) Invalidate() End Sub

At this point, you can implement your Paint event handler:

Private Sub MainWindow_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint ' Get the Graphics object for this window. Dim g As Graphics = e.Graphics ' Render each shape in the selected color. For Each s As ShapeData In shapes ' Render a rectangle or circle 20 x 20 pixels in size ' using the correct color. If s.ShapeType = SelectedShape.Rectangle Then g.FillRectangle(New SolidBrush(s.Color), s.UpperLeftPoint.X, s.UpperLeftPoint.Y, 20, 20) Else g.FillEllipse(New SolidBrush(s.Color), s.UpperLeftPoint.X, s.UpperLeftPoint.Y, 20, 20) End If Next End Sub

If you run your application at this point, you should be able to render any number of shapes in a

variety of colors (see Figure A-26).

Figure A-26. MyPaintProgram in action

Page 51: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1611

Implementing the Serialization Logic The final aspect of this project involves implementing Click event handlers for the File ➤ Save... and File ➤ Load... menu items. Given that ShapeData has been marked with the <Serializable()> attribute (and given that List(Of T) itself is serializable), you can quickly save out the current graphical data using the Windows Forms SaveFileDialog type. Begin by updating your Imports directives to specify you are using the System.Runtime.Serialization.Formatters.Binary and System.IO namespaces: ' For the binary formatter. Imports System.Runtime.Serialization.Formatters.Binary Imports System.IO

Now update your File ➤ Save... handler, as follows:

Private Sub SaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveToolStripMenuItem.Click Using saveDlg As New SaveFileDialog() ' Configure the look and feel of the save dialog box. saveDlg.InitialDirectory = "." saveDlg.Filter = "Shape files (*.shapes)|*.shapes" saveDlg.RestoreDirectory = True saveDlg.FileName = "MyShapes" ' If they click the OK button, open the new ' file and serialize the List(Of T). If saveDlg.ShowDialog() = DialogResult.OK Then Dim myStream As Stream = saveDlg.OpenFile() If (myStream IsNot Nothing) Then ' Save the shapes! Dim myBinaryFormat As New BinaryFormatter() myBinaryFormat.Serialize(myStream, shapes) myStream.Close() End If End If End Using End Sub

The File ➤ Load event handler opens the selected file and deserializes the data back into the List(Of

T) member variable with the help of the Windows Forms OpenFileDialog type:

Private Sub LoadToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LoadToolStripMenuItem.Click Using openDlg As New OpenFileDialog() openDlg.InitialDirectory = "." openDlg.Filter = "Shape files (*.shapes)|*.shapes" openDlg.RestoreDirectory = True openDlg.FileName = "MyShapes"

Page 52: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1612

If openDlg.ShowDialog() = DialogResult.OK Then Dim myStream As Stream = openDlg.OpenFile() If (myStream IsNot Nothing) Then ' Get the shapes! Dim myBinaryFormat As New BinaryFormatter() shapes = CType(myBinaryFormat.Deserialize(myStream), List(Of ShapeData)) myStream.Close() Invalidate() End If End If End Using End Sub

After Chapter 20, the overall serialization logic here should look familiar. It is worth pointing out

that the SaveFileDialog and OpenFileDialog types both support a Filter property that is assigned a rather cryptic string value. This filter controls a number of settings for the save/open dialog boxes, such as the file extension (*.shapes). You use the FileName property to control what the default name of the file you want to create—MyShapes, in this example.

At this point, your painting application is complete. You should now be able to save and load your current graphical data to any number of *.shapes files. If you want to enhance this Windows Forms program, you might wish to account for additional shapes, or even to allow the user to control the size of the shape to draw or perhaps select the format used to save the data (e.g., binary, XML, or SOAP; see Chapter 20).

Summary This chapter examined the process of building traditional desktop applications using the Windows Forms and GDI+ APIs, which have been part of the .NET Framework since version 1.0. At minimum, a Windows Forms application consists of a type-extending Form and a Main() method that interacts with the Application type.

When you want to populate your forms with UI elements (e.g., menu systems and GUI input controls), you do so by inserting new objects into the inherited Controls collection. This chapter also showed you how to capture mouse, keyboard, and rendering events. Along the way, you learned about the Graphics type and many ways to generate graphical data at runtime.

As mentioned in this chapter’s overview, the Windows Forms API has been (in some ways) superseded by the WPF API introduced with the release of .NET 3.0 (which you learned about in some detail in Part 6 of this book). While it is true that WPF is the choice for supercharged UI front ends, the Windows Forms API remains the simplest (and in many cases, most direct) way to author standard business applications, in-house applications, and simple configuration utilities. For these reasons, Windows Forms will be part of the .NET base class libraries for years to come.

Page 53: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

A P P E N D I X B

■ ■ ■

1613

Platform-Independent .NET Development with Mono

This appendix introduces you to the topic of cross-platform VB and .NET development using an open source implementation of .NET named Mono (in case you are wondering about the name, mono is a Spanish word for monkey, which is a reference to the various monkey-mascots used by the initial creators of the Mono platform, Ximian Corporation). In this appendix, you will learn about the role of the Common Language Infrastructure (CLI), the overall scope of Mono, and various Mono development tools. At the conclusion of this appendix-and given your work over the course of this book—you will be in a perfect position to dig further into Mono development as you see fit.

■ Note If you require a detailed explanation of cross-platform .NET development, I recommend picking up a copy of Cross-Platform .NET Development: Using Mono, Portable .NET, and Microsoft .NET by Mark Easton and Jason King (Apress, 2004).

The Platform-Independent Nature of .NET Historically speaking, when programmers used a Microsoft development language (e.g., VB6) or Microsoft programming framework (e.g., MFC, COM, or ATL), they had to resign themselves to building software that (by-and-large) executed only on the Windows family of operating systems. Many .NET developers, accustomed to previous Microsoft development options, are frequently surprised when they learn that .NET is platform-independent. But it’s true. You can create, compile, and execute .NET assemblies on operating systems other than Microsoft Windows.

Using open source .NET implementations such as Mono, your .NET applications can find happy homes on numerous operating systems, including Mac OS X, Solaris, AIX, and numerous flavors of Unix/Linux. Mono also provides an installation package for (surprise, surprise) Microsoft Windows. Thus, it is possible to build and run .NET assemblies on the Windows operating system, without ever installing the Microsoft .NET Framework 4.0 SDK or the Visual Studio 2010 IDE.

Page 54: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1614

■ Note Be aware that the Microsoft .NET Framework 4.0 SDK and Visual Studio 2010 are your best options for building .NET software for the Windows family of operating systems.

Even after developers learn about .NET code’s cross-platform capabilities, they often assume that the scope of platform-independent .NET development is limited to little more than Hello World console applications. The reality is that you can build production-ready assemblies that use ADO.NET, Windows Forms (in addition to alternative GUI toolkits such as GTK# and Cocoa#), ASP.NET, LINQ, and XML web services by taking advantage of many of the core namespaces and language features you have seen featured throughout this book.

The Role of the CLI .NET’s cross-platform capabilities are implemented differently than the approach taken by Sun Microsystems and its handling of the Java programming platform. Unlike Java, Microsoft itself does not provide .NET installers for Mac, Linux, and so on. Rather, Microsoft has released a set of formalized specifications that other entities can use as a road map for building .NET distributions for their platform(s) of choice. Collectively, these specifications are termed the Common Language Infrastructure (CLI).

As briefly mentioned in Chapter 1, Microsoft submitted two formal specifications to ECMA (European Computer Manufacturers Association) when it released C# and the .NET platform to the world at large. Once approved, Microsoft submitted these same specifications to the International Organization for Standardization (ISO), and these specifications were ratified shortly thereafter.

So, why should you care? These two ECMA specifications provide a road map for other companies, developers, universities, and other organizations to build their own custom distributions of the C# programming language and the .NET platform. The two ECMA specifications in question are:

• ECMA-334: Defines the syntax and semantics of the C# programming language.

• ECMA-335: Defines many details of the .NET platform, collectively called the Common Language Infrastructure.

ECMA-334 tackles the lexical grammar of C# in an extremely rigorous and scientific manner (as you might guess, this level of detail is quite important to those who want to implement a C# compiler). However, ECMA-335 is the meatier of the two specifications, so much so that it has been broken down into six partitions (see Table B-1).

Page 55: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1615

Table B-1. ECMA-335 Specification Partitions

ECMA-335 Partition Meaning in Life

Partition I: Concepts and Architecture

Describes the overall architecture of the CLI, including the rules of the Common Type System, the Common Language Specification, and the mechanics of the .NET runtime engine.

Partition II: Metadata Definition and Semantics

Describes the details of the .NET metadata format.

Partition III: CIL Instruction Set

Describes the syntax and semantics of the common intermediate language (CIL) programming language.

Partition IV: Profiles and Libraries

Provides a high-level overview of the minimal and complete class libraries that must be supported by a CLI-compatible .NET distribution.

Partition V: Debug Interchange Formats

Provides details of the portable debug interchange format (CILDB). Portable CILDB files provide a standard way to exchange debugging information between CLI producers and consumers.

Partition VI: Annexes Represents a collection of odds and ends; it clarifies topics such as class library design guidelines and the implementation details of a CIL compiler.

The point of this appendix is not to dive into the details of the ECMA-334 and ECMA-335

specifications—nor must you know the ins-and-outs of these documents to understand how to build platform-independent .NET assemblies. However, if you are interested, you can download both of these specifications for free from the ECMA website (www.ecma-international.org/publications/standards).

The Mainstream CLI Distributions To date, you can find two mainstream implementations of the CLI beyond Microsoft’s CLR, Microsoft Silverlight, and the Microsoft NET Compact Framework (see Table B-2).

Page 56: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1616

Table B-2. Mainstream .NET CLI Distributions

CLI Distribution Supporting Website Meaning in Life

Mono www.mono-project.com Mono is an open source and commercially supported distribution of .NET sponsored by Novell Corporation._Mono is targeted to run on many popular flavors of Unix/Linux, Mac OS X, Solaris, and Windows.

Portable .NET www.gnu.org/software/dotgnu/ Portable .NET is distributed under the GNU General Public License._As the name implies, Portable .NET intends to function on as many operation systems and architectures as possible, including esoteric platforms such as BeOS, Microsoft Xbox, and Sony PlayStation (no, I’m not kidding about the last two!).

Each of the CLI implementations shown in Table B-2 provide a fully function Visual Basic .NET

compiler, numerous command-line development tools, a global assembly cache (GAC) implementation, sample code, useful documentation, and dozens of assemblies that constitute the base class libraries.

Beyond implementing the core libraries defined by Partition IV of ECMA-335, Mono and Portable .NET provide Microsoft-compatible implementations of mscorlib.dll, System.Core.dll, System.Data.dll, System.Web.dll, System.Drawing.dll, and System.Windows.Forms.dll (among many others).

The Mono and Portable .NET distributions also ship with a handful of assemblies specifically targeted at Unix/Linux and Mac OS X operating systems. For example, Cocoa# is a .NET wrapper around the preferred Mac OX GUI toolkit, Cocoa. In this appendix, I will not dig into these OS-specific binaries; instead, I’ll focus on using the OS-agonistic programming stacks.

■ Note This appendix will not examine Portable .NET; however, it is important to know that Mono is not the only platform-independent distribution of the .NET platform available today. I recommend you take some time to play around with Portable .NET in addition to the Mono platform.

The Scope of Mono Given that Mono is an API built on existing ECMA specifications that originated from Microsoft, you would be correct in assuming that Mono is playing a constant game of catch up as newer versions of Microsoft’s .NET platform are released. This means you can build ASP.NET websites, Windows Forms applications, database-centric applications using ADO.NET, and (of course) simple console applications.

Page 57: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1617

Currently, Mono is not completely compatible with the new features of VB 2010 or with all aspects of .NET 3.0-4.0. This means that Mono applications are currently unable (again, at the time of this writing) to use the following Microsoft .NET APIs:

• Windows Presentation Foundation (WPF)

• Windows Communication Foundation (WCF)

• Windows Workflow Foundation (WF)

• LINQ to Entities (however, LINQ to Objects and LINQ to XML are supported)

• Any VB 2010 specific language features

Some of these APIs might eventually become part of the standard Mono distribution stacks. For example, according to the Mono website, future versions of the platform (2.8-3.0) will provide support for Visual Basic .NET language features and .NET 3.5-4.0 platform features.

In addition to keeping-step with Microsoft’s core .NET APIs and VB .NET language features, Mono also provides an open source distribution of the Silverlight API named Moonlight. This enables browsers that run under Linux based operating systems to host and use Silverlight / Moonlight web applications. As you might already know, Microsoft’s Silverlight already includes support for Mac OS X; and given the Moonlight API, this technology has truly become cross-platform.

Mono also supports some .NET based technologies that do not have a direct Microsoft equivalent. For example, Mono ships with GTK#, a .NET wrapper around a popular Linux-centric GUI framework named GTK. One compelling Mono-centric API is MonoTouch, which allows you to build applications for Apple iPhone and iTouch devices using the VB .NET programming language.

■ Note The Mono website includes a page that describes the overall road map of Mono’s functionality and the project’s plans for future releases (www.mono-project.com/plans).

A final point of interest regarding the Mono feature set: Much like Microsoft’s .NET Framework 4.0 SDK, the Mono SDK supports several .NET programming languages. While this appendix focuses on VB .NET Mono also provides support for a C# compiler, as well as support for many other .NET-aware programming languages.

Obtaining and Installing Mono Now that you have a better idea what you can do with the Mono platform, let’s turn our attention to obtaining and installing Mono itself. Navigate to the Mono website (www.mono-project.com) and locate the Download tab to navigate to the downloads page. Here you can download a variety of installers (see Figure B-1).

Page 58: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1618

Figure B-1. The Mono Download Page

This appendix assumes that you are installing the Windows distribution of Mono (note that installing Mono will not interfere whatsoever with any existing installation of Microsoft .NET or Visual Studio IDEs). Begin by downloading the current, stable Mono installation package for Microsoft Windows and saving the setup program to your local hard drive.

When you run the setup program, you are given a chance to install a variety of Mono development tools beyond the expected base class libraries and the VB .NET programming tools. Specifically, the installer will ask you whether you wish to include GTK# (the open source .NET GUI API based on the Linux-centric GTK toolkit) and XSP (a stand-alone web server, similar to Microsoft’s ASP.NET development web server [webdev.webserver.exe]). This appendix also assumes you have opted for a Full Installation, which selects each option in the setup script (see Figure B-2).

Page 59: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1619

Figure B-2. Select All Options for Your Mono Installation

Examining Mono’s Directory Structure By default, Mono installs under C:\Program Files\Mono-<version> (at the time of this writing, the latest version of Mono is 2.6.7; however, your version number will almost certainly be different). Beneath that root, you can find several subdirectories (see Figure B-3).

Page 60: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1620

Figure B-3. The Mono Directory Structure

For this appendix, you need to concern yourself only with the following subdirectories:

• bin: Contains a majority of the Mono development tools, including the VB .NET command-line compilers.

• lib\mono\gac: Points to the location of Mono’s global assembly cache.

Given that you run the vast majority of Mono’s development tools from the command line, you will want to use the Mono command prompt, which automatically recognizes each of the command-line development tools. You can activate the command prompt (which is functionally equivalent to the Visual Studio 2010 command prompt) by selecting Start ä All Programs ä Mono <version> For Windows menu option. To test your installation, enter the following command and press the Enter key:

mono --version

Page 61: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1621

If all is well, you should see various details regarding the Mono runtime environment. Here is the output on my Mono development machine:

Mono JIT compiler version 2.6.7 (tarball) Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC: Included Boehm (with typed GC and Parallel Mark)

SIGSEGV: normal Notification: Thread + polling Architecture: x86

Disabled: none

The Mono Development Languages Similar to the Microsoft’s CLR distribution, Mono ships with a number of managed compilers:

• vbnc: The Mono Visual Basic compiler

• mcs: The Mono C# compiler

• booc: The Mono Boo language compiler

• ilasm: The Mono CIL compilers

The Visual Basic .NET support in Mono is relatively new . Having a native compiler for Visual Basic .NET allows developers to write applications in a Mono-supported platform. It also lets applications that depend on the CodeDOM (ASP.NET, for example) to be developed using Visual Basic .NET, which was not possible before the availability of the VB .NET compiler. The intended goal is to bring the world of human-readable keywords (e.g., Inherits, MustOverride, and Implements) to the world of Unix/Linux and Mac OS X (see www.mono-project.com/Visual_Basic for more details).

Boo is an object-oriented, statically typed programming language for the CLI that sports a Python-based syntax. Check out http://boo.codehaus.org for more details on the Boo programming language. Finally, as you might have guessed, ilasm is the Mono CIL compiler.

Working with the VB 2010 Compiler The VB .NET compiler for the Mono project was vbnc, and it’s fully compatible with VB 2010. Like the Microsoft VB 2010 command-line compiler (vbc.exe), mono’s vbnc supports response files, a /target: flag (to define the assembly type), an /out: flag (to define the name of the compiled assembly), and a /reference: flag (to update the manifest of the current assembly with external dependencies). You can view all the options of vbnc using the following command:

vbnc -?

Page 62: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1622

Building Mono Applications using MonoDevelop When you install Mono, you will not be provided with a graphical IDE. However, this does not mean you must build all of your Mono applications at the command prompt! In addition to the core framework, you can also download the free MonoDevelop IDE. As its name suggests, MonoDevelop was built using the core code base of SharpDevelop (see Chapter 2).

You can download the MonoDevelop IDE from the Mono website, and it supports installation packages for Mac OS X, various Linux distributions, and (surprise!) Microsoft Windows! Once installed, you might be pleased to find an integrated debugger, IntelliSense capabilities, numerous project templates (e.g., ASP.NET and Moonlight). You can get a taste of what the MonoDevelop IDE brings to the table by perusing Figure B-4.

Figure B-4. The MonoDevelop IDE

Microsoft-Compatible Mono Development Tools In addition to the managed compilers, Mono ships with various development tools that are functionally equivalent to tools found in the Microsoft .NET SDK (some of which are identically named). Table B-3 enumerates the mappings between some of the commonly used Mono/Microsoft .NET utilities.

Page 63: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1623

Table B-3. Mono Command-Line Tools and Their Microsoft .NET Counterparts

Mono Utility Microsoft .NET Utility Meaning in Life

al al.exe Manipulates assembly manifests and builds multifile assemblies (among other things).

gacutil gacutil.exe Interacts with the GAC.

mono when run with the -aot option as a startup parameter to the executing assembly

ngen.exe Performs a precompilation of an assembly’s CIL code.

wsdl wsdl.exe Generates client-side proxy code for XML web services.

disco disco.exe Discovers the URLs of XML web services located on a web server.

xsd xsd.exe Generates type definitions from an XSD schema file.

sn sn.exe Generates key data for a strongly named assembly.

monodis ildasm.exe The CIL disassembler

ilasm ilasm.exe The CIL assembler

xsp2 webdev.webserver.exe A testing and development ASP.NET web server

Mono-Specific Development Tools Mono also ships with development tools for which no direct Microsoft .NET Framework 3.5 SDK equivalents exist (see Table B-4).

Page 64: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1624

Table B-4. Mono Tools That Have No Direct Microsoft .NET SDK Equivalent

Mono-Specific Development Tool Meaning in Life

monop The monop (mono print) utility displays the definition of a specified type using VB .NET syntax (see the next section for a quick example).

SQL# The Mono Project ships with a graphical front end (SQL#) that allows you to interact with relational databases using a variety of ADO.NET data providers.

Glade 3 This tool is a visual development IDE for building GTK# graphical applications.

■ Note You can load SQL# and Glade by using the Windows Start button and navigating to the Applications folder within the Mono installation. Be sure to do this because this illustrates definitively how rich the Mono platform has become.

Using monop You can use the monop utility (short for mono print) to display the definition of a given type within a specified assembly. As you might suspect, this tool can be quite helpful when you wish to view a method signature quickly, rather than digging through the formal documentation. As a quick test, try entering the following command at a Mono command prompt:

monop System.Object

You should see the definition of your good friend, System.Object:

[Serializable] public class Object { public Object (); public static bool Equals (object objA, object objB); public static bool ReferenceEquals (object objA, object objB); public virtual bool Equals (object obj); protected override void Finalize (); public virtual int GetHashCode (); public Type GetType (); protected object MemberwiseClone (); public virtual string ToString (); }

Page 65: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1625

■ Note The command “monop System.Object” will always show the definition in C# syntax. There is no way to get it displayed in VB .NET format.

Building .NET Applications with Mono Now let’s look at Mono in action. You begin by building a code library named CoreLibDumper.dll. This assembly contains a single class type named CoreLibDumper that supports a Shared method named DumpTypeToFile(). The method takes a String parameter that represents the fully qualified name of any type within mscorlib.dll and obtains the related type information through the reflection API (see Chapter 15), dumping the class member signatures to a local file on the hard drive.

Building a Mono Code Library Create a new folder on your C: drive named MonoCode. Within this new folder, create a subfolder named CorLibDumper that contains the following VB .NET file (named CorLibDumper.vb): ' CorLibDumper.vb Imports System.Reflection Imports System.IO ' Define assembly version. <Assembly:AssemblyVersion("1.0.0.0")> Namespace CorLibDumper Public Class TypeDumper Public Shared Function DumpTypeToFile(ByVal typeToDisplay As String) As Boolean ' Attempt to load type into memory. Dim theType As Type = Nothing Try ' Second parameter to GetType() controls if an ' exception should be thrown if the type is not found. theType = Type.GetType(typeToDisplay, True) Catch Return False End Try ' Create local *.txt file. Using sw As StreamWriter = File.CreateText(String.Format("{0}.txt", theType.FullName)) ' Now dump type to file. sw.WriteLine("Type Name: {0}", theType.FullName) sw.WriteLine("Members:") For Each mi As MemberInfo In theType.GetMembers() sw.WriteLine(vbTab & "-> {0}", mi.ToString()) Next

Page 66: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1626

End Using Return True End Function End Class End Namespace

Like the Microsoft VB 2010 compiler, Mono’s VB .NET compilers support the use of response files

(see Chapter 2). While you could compile this file by specifying each required argument manually at the command line, you can instead create a new file named LibraryBuild.rsp (in the same location as CorLibDumper.vb) that contains the following command set:

/target:library /out:CorLibDumper.dll CorLibDumper.vb

You can now compile your library at the command line, as follows:

vbnc @LibraryBuild.rsp

This approach is functionally equivalent to the following (more verbose) command set:

vbnc /target:library /out:CorLibDumper.dll CorLibDumper.vb

Assigning CoreLibDumper.dll a Strong Name Mono supports the notion of deploying strongly named assemblies (see Chapter 15) to the Mono GAC. To generate the necessary public/private key data, Mono provides the sn command-line utility, which functions more or less identically to Microsoft’s tool of the same name. For example, the following command generates a new *.snk file (specify the -? option to view all possible commands):

sn -k myTestKeyPair.snk

You can tell the VB .NET compiler to use this key data to assign a strong name to CorLibDumper.dll

by updating your LibraryBuild.rsp file with the following additional command:

/target:library /out:CorLibDumper.dll /keyfile:myTestKeyPair.snk CorLibDumper.vb

Now recompile your assembly:

vbnc @LibraryBuild.rsp

Viewing the Updated Manifest with monodis Before you deploy the assembly to the Mono GAC, you should familiarize yourself with the monodis command-line tool, which is the functional equivalent of Microsoft’s ildasm.exe (without the GUI front end). Using monodis, you can view the CIL code, manifest, and type metadata for a specified assembly. In

Page 67: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1627

this case, you want to view the core details of your (now strongly named) assembly using the --assembly flag. Figure B-5 shows the result of the following command set:

monodis --assembly CorLibDumper.dll

Figure B-5. Viewing the CIL Code, Metadata, and Manifest of an Assembly with monodis

The assembly’s manifest now exposes the public key value defined in myTestKeyPair.snk.

Installing Assemblies into the Mono GAC So far you have provided CorLibDumper.dll with a strong name; you can install it into the Mono GAC using gacutil. Like Microsoft’s tool of the same name, Mono’s gacutil supports options to install, uninstall, and list the current assemblies installed under C:\Program Files\Mono-<version>\lib\mono\gac. The following command deploys CorLibDumper.dll to the GAC and sets it up as a shared assembly on the machine:

gacutil -i CorLibDumper.dll

■ Note Be sure to use a Mono command prompt to install this binary to the Mono GAC! If you use the Microsoft gacutil.exe program, you’ll install CorLibDumper.dll into the Microsoft GAC!

Page 68: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1628

After you run the command, opening the \gac directory should reveal a new folder named CorLibDumper (see Figure B-6). This folder defines a subdirectory that follows the same naming conventions as Microsoft’s GAC (versionOfAssembly__publicKeyToken).

Figure B-6. Deploying Your Code Library to the Mono GAC

■ Note Supplying the -l option to gacutil lists out each assembly in the Mono GAC.

Building a Console Application in Mono Your first Mono client will be a simple, console-based application named ConsoleClientApp.exe. Create a new file in your C:\MonoCode\CorLibDumper folder, ConsoleClientApp.vb, that contains the following Module1 definition:

' This client app makes use of the CorLibDumper.dll ' to dump type information to a file. Imports CorLibDumper Namespace ConsoleClientApp Module Module1 Sub Main() Console.WriteLine("***** The Type Dumper App *****" & vbLf) ' Ask user for name of type. Dim typeName As String = "" Console.Write("Please enter type name: ") typeName = Console.ReadLine()

Page 69: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1629

' Now send it to the helper library. If TypeDumper.DumpTypeToFile(typeName) Then Console.WriteLine("Data saved into {0}.txt", typeName) Else Console.WriteLine("Error! Can't find that type...") End If End Sub End Module End Namespace

Notice that the Main() method prompts the user for a fully qualified type name. The

TypeDumper.DumpTypeToFile() method uses the user-entered name to dump the type’s members to a local file. Next, create a ClientBuild.rsp file for this client application and reference CorLibDumper.dll:

/target:exe /out:ConsoleClientApp.exe /reference:CorLibDumper.dll ConsoleClientApp.vb

Now, use a Mono command prompt to compile the executable using vbnc, as shown here:

vbnc @ClientBuild.rsp

Loading Your Client Application in the Mono Runtime At this point, you can load ConsoleClientApp.exe into the Mono runtime engine by specifying the name of the executable (with the *.exe file extension) as an argument to Mono:

mono ConsoleClientApp.exe

As a test, enter System.Threading.Thread at the prompt and press the Enter key. You will now find a

new file named System.Threading.Thread.txt containing the type’s metadata definition (see Figure B-7).

■ Note The method signatures are shown in C# syntax. There is no way to get it displayed in VB .NET format.

Page 70: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1630

Figure B-7. The Results of Running Your Client Application

Before moving on to a Windows Forms–based client, try the following experiment. Use Windows Explorer to rename the CorLibDumper.dll assembly from the folder containing the client application to DontUseCorLibDumper.dll. You should still be able to run the client application successfully because the only reason you needed access to this assembly when building the client was to update the client manifest. At runtime, the Mono runtime will load the version of CorLibDumper.dll you deployed to the Mono GAC.

However, if you open Windows Explorer and attempt to run your client application by double-clicking ConsoleClientApp.exe, you might be surprised to find a FileNotFoundException is thrown. At first glance, you might assume this is due to the fact that you renamed CorLibDumper.dll from the location of the client application. However, the true reason for the error is that you just loaded ConsoleClientApp.exe into the Microsoft CLR!

To run an application under Mono, you must pass it into the Mono runtime through Mono. If you do not, you will be loading your assembly into the Microsoft CLR, which assumes all shared assemblies are installed into the Microsoft GAC located in the <%windir%>\Assembly directory.

■ Note If you double-click your executable using Windows Explorer, you will load your assembly into the Microsoft CLR, not the Mono runtime!

Executing Your Windows Forms Application Under Linux So far, this appendix has shown you how to create a few assemblies that you could also have compiled using the Microsoft .NET Framework 4.0 SDK. However, the importance of Mono becomes clear when you view Figure B-8, which shows the same exact Windows Forms application running under SuSe Linux. Notice how the Windows Forms application has taken on the correct look and feel of my current desktop theme.

Page 71: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1631

Figure B-8. Executing the Windows Forms Application Under SuSe Linux

■ Source Code You can find the CorLibDumper project under the Appendix B subdirectory.

The preceding examples shows how you can compile and execute the same exact VB 2010 code shown during this appendix on Linux (or any OS supported by Mono) using the same Mono development tools. In fact, you can deploy or recompile any of the assemblies created in this text that do not use .NET 4.0 programming constructs to a new Mono-aware OS and run them directly using the Mono runtime utility. Because all assemblies contain platform-agonistic CIL code, you do not need to recompile the applications whatsoever.

Who is Using Mono? In this short appendix, I’ve tried to capture the promise of the Mono platform in a few simple examples. Granted, if you intend only to build .NET programs for the Windows family of operating systems, you might not have encountered companies or individuals who actively use Mono. Regardless, Mono is alive and well in the programming community for Mac OS X, Linux, and Windows.

For example, navigate to the /Software section of the Mono website:

http://mono-project.com/Software At this location, you can find a long-running list of commercial products built using Mono,

including development tools, server products, video games (including games for the Nintendo Wii and iPhone), and medical point-of-care systems.

If you take a few moments to click the provided links, you will quickly find that Mono is completely equipped to build enterprise-level, real-world .NET software that is truly cross-platform.

Suggestions for Further Study If you have followed along with the materials presented in this book, you already know a great deal about Mono, given that it is an ECMA-compatible implementation of the CLI. If you want to learn more about Mono’s particulars, the best place to begin is with the official Mono website (www.mono-project.com). Specifically, you should examine the page at www.mono-project.com/Use, which serves an entry point to a number of important topics, including database access using ADO.NET, web development using ASP.NET, and so on.

Page 72: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1632

I have also authored some Mono-centric articles for the DevX website (www.devx.com) that you might find interesting:

• “Mono IDEs: Going Beyond the Command Line”: This article examines many Mono-aware IDEs.

• “Building Robust UIs in Mono with Gtk#”: This article examines building desktop applications using the GTK# toolkit as an alternative to Windows Forms.

Finally, you should familiarize yourself with Mono’s documentation website (www.go-mono.com/docs). Here you will find documentation on the Mono base class libraries, development tools, and other topics (see Figure B-9).

Figure B-9. The Online Mono Documentation

■ Note The website with Mono’s online documentation is community supported; therefore, don’t be too surprised if you find some incomplete documentation links! Given that Mono is an ECMA-compatible distribution of Microsoft .NET, you might prefer to use the feature-rich MSDN online documentation when exploring Mono.

Page 73: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1633

Summary The point of this appendix was to provide an introduction to the cross-platform nature of the VB

.NET programming language and the .NET platform when using the Mono framework. You have seen how Mono ships with a number of command-line tools that allow you to build a wide variety of .NET assemblies, including strongly named assemblies deployed to the GAC, Windows Forms applications, and .NET code libraries.

You’ve also learned that Mono is not fully compatible with the .NET 3.5 or .NET 4.0 programming APIs (WPF, WCF, WF, or LINQ) or the VB 2010 language features. Efforts are underway (through the Olive project) to bring these aspects of the Microsoft .NET platform to Mono. In any case, if you need to build .NET applications that can execute under a variety of operating systems, the Mono project is a wonderful choice for doing so.

Page 74: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

1635

Index

■Special Characters & (ampersand) suffix, 715

* (wildcard character), 47

. (dot) prefix, 689

■A ABCs (addresses, bindings, and contracts)

addresses, 1079–1080

bindings

HTTP-based, 1077–1078

MSMQ-based, 1078

TCP-based, 1078

contracts, 1075

establishing within App.config files, 1084–1085

specifying in code, 1112–1113

AboutToBlow event, 449–450

AboutToBlowEventHandler delegate, 441

abstract classes, 250–251

abstract FileSystemInfo base class, 819–820

abstract stream class, FileStreams class, 835–836

AcceptButton property, 1592

access modifiers, 197–198

accessors and mutators, using for encapsulation of classes, 199–202

Action(Of T) delegate, 804, 806–807

Active Template Library (ATL), 3

activities, WF 4.0

collection, 1142

connecting in flowchart workflow, 1143–1144

control flow, 1138

error handling, 1142

flowchart, 1139

messaging, 1140

primitives, 1141

runtime, 1141

transaction, 1141

Activity1.xaml file, 1153

Add another item button, 1280

Add class menu item, 199

Add Content Page menu option, 1497, 1504

Add Existing Item menu option, 235, 289, 337, 358, 1033, 1035, 1056, 1292, 1497

Add Function Import. menu option, 1029

Add Keyframe button, 1413

Add New Diagram menu option, 891

Page 75: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1636

Add New Item dialog box, 1349

Add New Item menu option, 232, 337, 986, 1159, 1474, 1494, 1496, 1515, 1529

Add Project Data Source link, 975

Add Reference dialog box, 562–563, 568, 570, 591, 751, 753, 851, 870, 1155, 1184, 1352, 1457

Add Reference menu option, 570, 1463, 1563

Add References dialog box, 51, 575

Add State button, 1418

Add State Group button, 1418

Add Sticky Note button, 1284

Add This Car button, 1542

Add Transition button, 1419

Add UserControl menu option, 1383

Add Windows Form menu option, 1594

AddParams parameter, 787

Add/Remove WizardSteps link, 1504

AddressOf keyword, 444

AddWithThreads project, 788

Administrative Tools folder, 1550

ADO.NET

abstracting data providers using interfaces, 881–884

additional namespaces, 875–876

building reusable data access library, 907–916

adding connection logic, 908–909

adding deletion logic, 910

adding insertion logic, 909–910

adding selection logic, 911–912

adding update logic, 911

executing stored procedure, 914–916

parameterized command objects, 912–914

connected layer of, 899–903

command objects, 903

connection objects, 900–902

ConnectionStringBuilder objects, 902

creating AutoLot database

authoring GetPetName( ) stored procedure, 888

creating customers and orders tables, 889

creating inventory table, 885–887

visually creating table relationships, 891–892

creating console UI-based front end, 916–922

DeleteCar( ) method, 919

InsertNewCar( ) method, 920

ListInventory( ) method, 918–919

LookUpPetName( ) method, 921–922

Main( ) method, 917

ShowInstructions( ) method, 918

UpdateCarPetName( ) method, 921

data provider factory model, 892–898

complete data provider factory example, 893–897

<connectionStrings> element, 897–898

potential drawback with provide factory model, 897

data providers, 871–875

Page 76: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1637

Microsoft-supplied, 873–875

System.Data.OracleClient.dll, 875

third-party, obtaining, 875

data readers, 904–907

database transactions, 923–929

adding CreditRisks table to AutoLot database, 925–926

adding transaction method to InventoryDAL, 926–928

key members of transaction object, 924–925

testing, 928–929

high-level definition of, 869–871

System.Data namespace, types of, 876–881

IDataReader and IDataRecord interfaces, 880–881

IDbCommand interface, 878–879

IDbConnection interface, 878

IDbDataAdapter and IDataAdapter interfaces, 880

IDbDataParameter and IDataParameter interfaces, 879–880

IDbTransaction interface, 878

AdoNetTransaction project, 929

AdornerDecorator, 1394

AdRotator control, 1492, 1496–1497

AdRotator widget, 1496–1497

Advanced Compile Options button, 113

Advanced Properties button, 1352

Advanced Property options, 1286

AdvertisementFile property, 1496–1497

Age property, 402

airvehicles.dll file, 573–574

al.exe tool, 600

aliasesresolving name clashes with, 548–549

AlternationCount property, 1293

ampersand (&) suffix, 715

and opcode, 692, 738

AndAlso operator, 525

Angle property, 1358

animated styles, WPF, 1369–1370

animation, defining with Expression Blend, 1410–1414

Animation class types, 1355–1356

animation services, WPF, 1354–1360

Animation class types, 1355–1356

authoring animation in VB 2010 code, 1357–1358

authoring animation in XAML, 1360–1363

discrete key frames, 1362–1363

event triggers, 1362

storyboards, 1361

looping animation, 1359–1360

pacing of animation, controlling, 1358–1359

From property, 1356

By property, 1356

From property, 1356To property

reversing animation, 1359–1360

Timeline Base class, 1356

annotations, WPF, 1282–1284

Page 77: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1638

AnnotationService class, 1283

anonymous types, 498–505-511

containing anonymous types, 504–505

equality for, 502–504

internal representation of, 500–501

ToString( ) and GetHashCode, 502

AnonymousMethods project, 450

AnonymousTypes project, 505

API features

1.0-1.1, 1440–1441

2.0, 1441–1442

3.5 (and .NET 3.5 SP1), 1442–1443

4.0, 1443

App_Code folder, 1462–1463, 1535

App_Data folder, 1488, 1552, 1556–1557

App_Theme folder, 1515, 1518

app.config files, 980, 1084–1085

AppConfigReaderApp application, 604

AppDomain.CurrentDomain property, 671

AppDomains (application domains)

creating

loading assemblies into custom application domains, 677

programmatically unloading AppDomains, 678–680

default, interacting with, 671–674

System.AppDomain class, 668–670

AppendText( ) method, FileInfo class, 831–832

AppIDs (application identifiers), 3

application cache

data caching, 1539–1541

modifying *.aspx file, 1541–1543

Application class, 1176–1178

Application.Windows collection, enumerating, 1178

constructing, 1177–1178

application data, modifying, 1536–1537

application domains, 317, 653, 668, 670, 674, 677, 680–681, 684–685, 730, 766–767

application error code, VB 2010 programming, 78–80

application identifiers (AppIDs), 3

Application property, 1535

application resourcesembedding, 1340–1341

application rootsand object lifetime, 308–309

application shutdown, handling, 1538

application state

handling web application shutdown, 1538

maintaining application-level state data, 1534–1536

modifying application data, 1536–1537

Application tab, 75, 543, 547, 565, 588, 595, 967, 1185, 1192, 1564

Application Type setting, 1564

ApplicationCommands object, 1254

ApplicationCommands.Help command, 1253

Application-derived class, 1178, 1186, 1201

ApplicationExit event, 1575

application-level exceptions (System.ApplicationException), 288

Page 78: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1639

application-level resources, 1347–1348

application-level state data, maintaining, 1534–1536

applications

building

adding infrastructure to MainWindow type, 1607

capturing and rendering graphical output, 1609–1610

implementing serialization logic, 1611–1612

implementing Tools menu functionality, 1608–1609

main menu system, 1603–1605

populating controls collection, 1565–1567

ShapeData type, 1605–1606

ShapePickerDialog type, 1606–1607

System.EventArgs and System.EventHandler, 1568

client, building, 1094–1099

Applications tab, 1033

Application.Windows collection, enumerating, 1178

Application.Windows property, 1186

Application.xaml file, 1364

Apply Resource. menu option, 1348

App.xaml file, 1348, 1354, 1374

arbitrary actions, connecting WPF commands to, 1252–1253

Args property, 1188

ArgumentException, 369–370, 372, 390, 474, 660–661, 664, 845

arguments

array as, 143–144

optional, 183–184

workflow

defining, 1155–1156

defining using workflow designer, 1134–1136

passing to workflows using WorkflowInvoker class, 1134

retrieving output, 1162–1164

Arguments button, 1144

Array class, 539

Array type, 360, 514, 519, 532

arrays

as arguments, 143–144

generating documents from, 1053–1054

initialization syntax, 139

of interface types, 348–349

multidimensional, 141–142

of objects, 140–141

primitive, applying LINQ queries to, 514–522

as return values, 143–144

System.Array class, 144–146

As clauses, 412

As integer, 508

as keyword, 321

ASP.NET Development web server, 1436

ASP.NET master pages, 1490–1497

ASP.NET session state server, 1549

ASP.NET state management techniques, 1523–1559

Page 79: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1640

application cache, 1538–1543

data caching, 1539–1541

modifying *.aspx file, 1541–1543

application/session distinction

handling web application shutdown, 1538

maintaining application-level state data, 1534–1536

modifying application data, 1536–1537

cookies

creating, 1547–1548

reading incoming data, 1549

Global.asax file

global last-chance exception event handler, 1531

HttpApplication base class, 1532

Profile API

accessing profile data programmatically, 1554–1556

ASPNETDB.mdf database, 1552–1553

defining user profiles within Web.config, 1553–1554

grouping profile data and persisting custom objects, 1557–1559

role of <sessionState> elements

storing session data in ASP.NET session state servers, 1549–1551

storing session data in dedicated databases, 1551

view state

adding custom data, 1528–1529

demonstrating, 1527–1528

ASP.NET themes

*.skin files, 1515–1517

applying at page level, 1518

applying sitewide, 1517–1518

assigning programmatically, 1519–1521

SkinID property, 1518

ASP.NET web controls, 1477–1479

AutoPostBack property, 1479

categories of, 1486–1489

documentation, 1489

System.Web.UI.HtmlControls, 1488–1489

control and WebControl base classes, 1480–1486

dynamically adding and removing controls, 1484

enumerating contained controls, 1480–1483

interacting with dynamically created controls, 1484–1485

WebControl base class, 1485–1486

server-side event handling, 1478

ASP.NET Web pages, building, 1427–1476

API features, 1440–1443

1.0-1.1, 1440–1441

2.0, 1441–1442

3.5 (and .NET 3.5 SP1), 1442–1443

4.0, 1443

client-side scripting, 1505–1507??

HTML

building forms, 1435–1436

document structure, 1431–1432

Page 80: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1641

forms, 1432

Visual Studio 2010 designer tools, 1433–1435

HTTP

request/response cycle, 1428

stateless protocols, 1428

incoming HTTP requests

access to incoming form data, 1467–1468

IsPostBack property, 1468

obtaining brower statistics, 1467

inheritance chain of Page type, 1464

life cycle of, 1471–1474

outgoing HTTP response

emitting HTML content, 1470

redirecting users, 1470–1471

posting back to Web servers, 1439

single file Web pages

adding data access logic, 1446–1449

ASP.NET control declarations, 1452–1453

ASP.NET directives, 1450–1451

compilation cycle for single-file pages, 1453–1454

designing UI, 1445–1446

referencing AutoLotDAL.dll, 1445

"script" block, 1451–1452

using code files, 1454–1459

compilation cycle for multifile pages, 1458

debugging and tracing ASP.NET pages, 1458–1459

referencing AutoLotDAL.dll assembly, 1457

updating code file, 1457–1458

Web applications and servers, 1429–1430

ASP.NET development web server, 1430

IIS virtual directories, 1429–1430

Web site directory structure, 1461–1463

App_Code folder, 1463

referencing assemblies, 1462–1463

Web sites and Web applications, 1460–1461

Web.config files, 1474–1476

aspnet_regsql.exe, 1552

aspnet_state.exe, 1549–1551

aspnet_wp.exe, 1549

AspNetCarsSite website, 1506

ASPNETDB.mdf database, 1552–1553, 1558

.aspx files, 1541–1543

assemblies, 12. See also .NET assemblies

assembly manifest, 17–18

and Common Intermediate Language (CIL), 12–15

documenting

defining assembly, 609

referenced assemblies, 609

dynamically loading, 621–623

exploring using ildasm.exe

viewing assembly metadata, 34–35

viewing CIL code, 33

viewing type metadata, 34

Page 81: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1642

exploring using Reflector, 35–36

loaded, 672–674

loading into custom application domains, 677

metadata, 15–16

referencing, 1462–1463

referencing external, 31

with vbc.exe, 45–46

with Visual Studio 2010, 55

resource-only, defining, 1350–1352

shared, 625–626

single-file, 12

workflow, importing, 1155

assemblies, WPF

Application class, 1176–1178

Window class

System.Windows.Controls.ContentControl, 1179–1180

System.Windows.Controls.Control, 1181

System.Windows.DependencyObject, 1183

System.Windows.FrameworkElement, 1181

System.Windows.Media.Visual, 1183

System.Windows.Threading.DispatcherObject, 1183–1184

System.Windows.UIElement, 1182

Assembly Information button, 1033

assembly manifest, 17–18

assembly metadata, exploring assemblies using ildasm.exe, 34–35

Assembly table, 609

Assembly Version number, 595

AssemblyBuilder type, 730, 732

AssemblyInfo.vb file, 565–566, 585–587, 639, 692

assembly-level (and module-level) attributes, 638–639

AssemblyLoadEventHandler delegate, 674

AssemblyName type, 625

AssemblyRef #n tokens, 609

Assets Library, 1261–1262, 1266, 1271, 1278, 1371–1372, 1408

Assign activity, 1157

Associations folder, 1032

AsyncCallback delegate, role of, 774–776

AsyncCallback object, 774

AsyncCallbackDelegate project, 778, 786

AsyncDelegate project, 774

AsyncDelegate property, 777

asynchronous delegates, 773, 777, 787, 803, 806

AsyncResult class, role of, 776–777

AsyncState property, 777

ATL (Active Template Library), 3

attached properties, XAML, 1210–1211

Attribute token, 634

AttributedCarLibrary assembly, 637, 640–641

attributes

assembly-level (and module-level), 638–639

CIL, role of, 689

custom, 635–638

applying, 636

Page 82: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1643

named property syntax, 636

restricting usage, 637–638

.NET

applying in VB 2010, 632–633

attribute consumers, 631–632

obsolete attribute in action, 634–635

specifying constructor parameters for, 634

VB 2010 attribute shorthand notation, 634

using early binding, 640–641

using late binding, 641–642

using to customize serialization, 866

XAML, 1210–1211

authoring animations, 1355, 1358

Auto Format option, 1448

autocompletion, 49, 513

autogenerated data adapter object, 980

autoincrementing column, 937

autoincrementing fields, 937–938

AutoLot database

adding CreditRisks table to, 925–926

creating

authoring GetPetName( ) stored procedure, 888

creating customers and orders tables, 889

creating inventory table, 885–887

visually creating table relationships, 891–892

AutoLotConnectedLayer namespace, 928, 1446, 1542

AutoLotCUIClient application, 923, 928

AutoLotDAL namespace, 1033, 1292

AutoLotDAL project, 916, 928, 964, 1028, 1033, 1035

AutoLotDAL Version 4.0

invoking stored procedure, 1034–1035

mapping stored procedure, 1029–1030

navigation properties, using within LINQ to Entity queries, 1033–1034

AutoLotDAL.dll assembly

adding disconnection functionality to

configuring data adapters using SqlCommandBuilder class, 965–966

defining initial class types, 964

GetAllInventory( ) method, 966

setting version numbers, 967

testing disconnected functionality, 967–968

UpdateInventory( ) method, 966

referencing, 1457

AutoLotDAL.sln file, 986

AutoLotDataReader project, 907

AutoLot.dll assembly, 1033, 1155

autoLotDS object, 971

AutoLotEDM_GUI project, 1292

AutoLotEntities class, 1007, 1019–1020

automatic properties, 213–217

and default values, 215–217

interacting with, 214–215

automatic property syntax, 213, 215, 235, 560

AutoPostBack property, 1479

AutoProps project, 217

Page 83: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1644

AutoResetEvent class, 787–788

AutoResetEvent object, 1136

AutoReverse checkbox, 1411

AutoReverse property, 1359

■B Background and Content value, 1403

Background color property, 1343

background garbage collection, 311

Background property, 1209, 1211, 1344, 1348, 1352, 1403

background threads, 788–789

BAML, transforming markup into .NET assembly, 1200–1201

base addresses, specifying, 1086–1087

base classes

casting rules

Is keyword, 262–263

TryCast keyword, 262

controlling creation of with base keyword, 237–239

libraries, role of in .NET, 6

multiple, 230

BasedOn property, 1366

BasicConsoleIO project, 88

BasicDataTypes project, 100

BasicInheritance project, 234

BasicMath class, 413

bear_paper.design file, 1326

BeginTime property, 1359

BenefitPackage class, 242

BigFontButton skin, 1518

BigInteger class, 99

BigInteger data type, 92, 98, 100

BigInteger variable, 92, 99

Bin folder, 1462–1463

binary CIL opcodes, 690

binary format, serializing DataTable/DataSet objects in, 948–949

binary operator overloading, 468–470

binary resources, WPF, 1336–1341

embedding application resources, 1340–1341

loose resources

configuring, 1337–1338

including files in project, 1337

programmatically loading images, 1339–1340

BinaryCars.bin file, 949

BinaryFormatter class, 549, 632

BinaryFormatter type, 853–855

BinaryOp delegate, 416–417, 421–423, 768, 770–771, 775–777

BinaryOp variable, 776

BinaryReaders class, 842–843

BinaryWriter class, 842

BinaryWriters class, 842–843

binding

DataTable objects to Windows Forms GUIs, 949–959

DataView type, 958–959

deleting rows from DataTable, 953–955

Page 84: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1645

hydrating DataTable from generic List(Of T), 951–953

selecting rows based on filter criteria, 955–957

updating rows within DataTable, 958

early, attributes using, 640–641

late

attributes using, 641–642

invoking methods with no parameters, 628–629

invoking methods with parameters, 629–630

System.Activator class, 627–628

Binding keyword, 1288

BindingFlags enumeration, 616

bindings

changing settings for, 1102–1103

exposing single services using multiple, 1101–1102

HTTP-based, 1077–1078

MSMQ-based, 1078

selecting, 1105–1107

TCP-based, 1078

binebug folder, 571, 582, 596, 628, 677, 749, 759, 838, 854, 947, 949, 1042, 1056, 1164, 1197, 1285, 1337

Bitmap class, 30

black box programming, 199

Blend brush editor, 1319

Blend code editor, 1271

Blend Designer, 1259

Blend editor, 1278

Blend Properties editor, 1258

Blend Properties window, 1266, 1270, 1409

Blend Resources window, 1373

Blend transformation editor, 1320

Blend window, 1260–1261

Blend XAML editor, 1259

block elements, WPF, 1277

Blocks (Collection) property, 1279–1280

Blocks editor, 1280

boolArray type, 139

Boolean data type, 96, 164–165

Boolean expression, 121, 1157

Boolean keyword, 91

Boolean parameter, 312, 613, 641, 928

Boolean property, 1285

Boolean variable, 91–92, 775, 787, 1145, 1358

Border control, 1270

Border menu option, 1269

BorderBrush color, 1408

br opcodes, 721

bread crumbs, establishing with SiteMapPath type, 1496

brower statistics, obtaining, 1467

Browse For Types. menu option, 1156–1157

Browse tab, 55, 563, 568, 591

Browser property, 1467

brush editors, 1308, 1319–1321

brush object, 1298–1299, 1323, 1348, 1598, 1601

Brush type, 1319

Page 85: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1646

brushes

configuring in code, 1310–1311

configuring using Visual Studio 2010, 1309–1310

Brushes area, 1319

Brushes editor, 1272, 1319, 1408

btnCancelTask, 807

btnProcessImages, 804–805, 807

btnShowLogicalTree object, 1393

btnSpinner object, 1358

bubbling events, 1389–1390

bugs, 273–274

Build Action property, 1337, 1340, 1342

Build-a-Car, designing content page, 1504–1506

BuildCar.aspx content page, 1504

business process, defining, 1128

Button class, 1187

Button Click event handler, 1479

Button element, 1208, 1389

Button object, implementing Click event, 1223–1224

Button property, 1586

Button skin, 1518

Button template, 1417

Button type, 1195, 1221, 1446, 1457, 1470, 1518–1519

Button.HeightProperty, 1356

buttons, determining which was clicked, 1586–1587

By property, Animation class types, 1356

ByRef argument, 418

ByRef modifier, 128

ByRef parameters, 305, 418

ByVal keyword, 127, 161

ByVal parameter modifier, 126–127

■C C command, 1308

C#, building client application, 570–571

C# compiler, 1614, 1617, 1621

C++ COM developers, 275

C++/CLI, 8, 21–22, 27, 275, 907

C++/MFC (Microsoft Foundation Classes), 2

Cache object, 1538–1539

Cache property, 1538

CacheDependency object, 1541

CacheItemRemovedCallback delegate, 1540, 1543

Cache.NoSlidingExpiration parameter, 1541

Calc class, 12, 16

Calc.vb code file, 14, 17

Calendar control, 1504

Calendar type, 1516

call opcode, 691

callback functions, 7, 415

callbacks, 415–416

calling tier, 911, 931–932

callvirt opcode, 729

Cancel button, 807–808, 1343, 1345, 1347, 1590, 1593, 1606

Cancel property, 1189

Page 86: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1647

cancelation request, 807–808

CancelButton property, 1593

CancelEventHandler delegate, 1189

cancellation tokens, 807

CancellationToken property, 808

CanExecute attribute, 1255

CanExecute event, 1253, 1255

CanExecute property, 1255

Canvas panels, 1235–1237

Canvas type, 1237

Caption property, 937

capturing graphical output, 1609–1610

Car type, 607

Car.CarEngineHandler object, 430

CarDelegate project, 430–431

CarDelegateMethodGroupConversion project, 432

CaretIndex property, 1249

CarEvents example, retrofitting using lambda expressions, 457–459

CarID column, 886, 936–937, 943, 963, 995

CarID field, 891

CarID key, 891

CarIsDeadException class, 290

CarIsDeadException type, 290–291

CarIsDeadException.vb file, 293

CarLibrary assembly, 585

CarLibrary icon, 590

CarLibrary namespace, 568, 628

CarLibrary project, 562, 568, 587, 594

CarLibrary.dll assembly, 553, 567–568, 576, 586, 592–593, 599, 606

CarLibrary.EngineState enumeration, 607

CarLibrary.EngineState.engineAlive, 607

CarLocator class, 496–498

CarNickname property, 1018, 1020

CarOrderApp project, 1596

Cars property, 1003, 1008, 1020, 1023

cars web site, building

defining default content pages, 1497–1498

designing Build-a-Car content page, 1504–1506

designing Inventory content pages, 1499–1500

master pages

AdRotator widget, 1496–1497

bread crumbs, establishing with SiteMapPath type, 1496

TreeView control site, 1493–1496

carsDataSet.xml file, 947

Car.vb file, 1021

casting operations, 259, 263, 389, 756, 760, 996

Catch activity, 1142

Catch block, 281–282, 289, 293–296, 301, 666, 729

Catch keyword, 111, 262, 302

catching exceptions, 281–282

CDATA scope, 1195

CDATA section, 1046, 1438

CGI applications, 1525

Change Layout Type menu option, 1260

Char array, 101

Char keyword, 96

Page 87: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1648

Char variable, 92

character data, 97, 100, 103, 105–107, 128, 269, 831–833, 839–841

Chart control, 1443, 1487

Check button, 1245, 1247

CheckBox control, 1285

Checked property, 1607

Choose Data Source drop-down box, 975, 1500

CIL (common intermediate language)

and assemblies, 12–15

attributes, role of, 689

building .NET assembly with, 721–726

building CILCarClient.exe, 724–726

building CILCars.dll, 721–724

code, 556–557

compiling CILTypes.il file, 709–711

defining

class types in, 705–706

current assembly in, 704

enums in, 708

field data in, 712–713

generics in, 709

and implementing interfaces in, 707–708

member parameters, 714–715

namespaces in, 705

properties in, 713

structures in, 708

type members in, 712–715

directivesrole of, 689

.NET base class library, VB, and CIL data type mappings, 711

opcodes

declaring local variables in CIL, 718–719

hidden Me reference, 720

mapping parameters to local variables in CIL, 719

.maxstack directive, 718

representing iteration constructs in CIL, 720–721

role of, 689

reasons for learning grammar of, 687–688

round-trip engineering

authoring CIL code using SharpDevelop, 701–703

compiling CIL code using ilasm.exe, 697–701

interacting with CIL, 696–697

role of CIL code labels, 695

role of peverify.exe, 703

specifying externally referenced assemblies in, 703

stack-based nature of, 690–692

viewing code, exploring assemblies using ildasm.exe, 33

CILCar argument, 724

CILCar parameter, 723

CILCars namespace, 722–723

CILCars.dll assembly, 724

CILTypes assembly, 704

CILTypes.dll assembly, 710

CILTypes.il file, compiling, 709–711

Page 88: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1649

Circle class, 256, 545, 547, 550

circleOption RadioButton, 1301

Class attribute, 1154, 1195, 1198, 1204, 1407

class constructor, 216, 222, 238–239, 280, 291, 683, 713, 735, 1333, 1582

Class Designer Toolbox, 64–66

Class Details window, 64–66, 234

Class Diagram icon, 232

Class Diagram viewer, 64

class hierarchy, of system data types, 169

class hierarchyof system data types, 93–95

Class icon, 169

Class keyword, 18, 169, 1206

class libraries, isolating strongly typed database code into, 986–992

deleting data with generated codes, 991

inserting data with generated codes, 990–991

invoking stored procedures using generated codes, 992

selecting data with generated codes, 989–990

viewing generated codes, 988–989

Class Library project, 492, 543, 559, 569, 635, 645–646, 749, 908, 986, 988, 1133, 1153

class types

access modifiers, 197–198

automatic properties, 213–217

and default values, 215–217

interacting with, 214–215

Common Type System (CTS), 18

constant field data

constants, 221–223

read-only fields, 222–223

shared read-only fields, 223

constructors, 173–176

conversions, 478

defining in CIL, 705–706

encapsulation services

internal representation of properties, 207

read-only and write-only properties, 210–211

shared properties, 211–212

using .NET properties, 202–205

using properties within class definition, 206

using traditional accessors and mutators, 199–202

visibility levels of properties, 210

Me keyword

chaining constructor calls using, 178–181

and constructor flow, 181–183

New keyword, 172–173

object initializer syntax, 217–221

calling custom constructors with, 218–219

inner types, 220–221

and optional arguments, 183–184

partial types, 224

Shared keyword, 184–193

classes, 193

constructors, 188–190

Page 89: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1650

field data, 185–188

methods, 184–185

Class View utility, Visual Studio 2010, 57

Class View window, 1019

Class1.vb, 749

classes

abstract, 250–251

generic

creating, 406–410

specifying type parameters for, 387–388

classical inheritance, 2–3, 7, 227–228, 236, 245, 434, 478, 482, 489

Clear Surface menu handler, 1609

CLI (Common Language Infrastructure), 38

mainstream distributions, 1615–1616

role of, 1614–1615

Click event, implementing for Button object, 1223–1224

Click handlers, 1301, 1336, 1339

ClickOnce technology, 1169

client applications, building

configuring TCP-based binding, 1097–1099

generating proxy code using svcutil.exe, 1094–1095

generating proxy code using Visual Studio 2010, 1095–1097

client area, invalidating, 1602–1603

Client Assembly, 873

client proxyrefreshing, 1105–1107

client tier, 931–932, 968

ClientBuild.rsp file, 1629

client-side scripting, 1436–1438

clientsinvoking services asynchronously from, 1117–1118

ClipToBounds property, 1315

cloneable objects, building, 361–367

CloneablePoint project, 367

Closed event, implementing, 1224

Closing event, 1190, 1583

CLR (Common Language Runtime), 1, 24–25, 39, 746

file header, 555–556

property wrappers, 1382–1383

thread pool, 800–802

clr-namespace token, 1131, 1207

CLS (Common Language Specification), 1, 22–24, 39, 631

CLS-compliant constructs, 632

cnStr value, 894, 903

Code activity, 1159–1161

Code Definition window, 634

code expansions, Visual Studio 2010, 61

code files

building Web pages using, 1454–1459

updating, 1457–1458

code reuse, 193, 195, 227, 241, 551, 907

CodeActivityContext, 1159–1160

<codeBase> element, 600–603

CodeBaseClient project, 601

code-behind files, WPF applications

MainWindow class, 1213–1214

MyApp class, 1214–1215

Page 90: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1651

processing files with msbuild.exe, 1215

code-behind model, 1215, 1427, 1454, 1458

CodeFile attribute, 1456

codes

deleting data with, 991

inserting data with, 990–991

invoking using stored procedures, 992

selecting data with, 989–990

viewing, 988–989

coding

keyword color, 53

against ServiceHost type, 1085–1086

collection activities, WF 4.0, 1142

collection objects, applying LINQ queries to, 524–527

accessing contained subobjects, 525–526

applying LINQ queries to nongeneric collections, 526–527

filtering data using OfType(Of T)( ), 527

collection/object initialization syntax, 509

collections

nongeneric, applying LINQ queries to, 526–527

of objects, serializing, 859–860

colon operator, 232

Color class, 1311

color coding, 703

Color object, 1274, 1310–1311

Color property, 1308

color selector, 1309

Colors enumeration, 1311

Column Properties editor, 886

Columns collection, 936, 946, 990, 992

Columns indexer, 982

Columns property, 936, 938

COM (Component Object Model)

programming language comparison, 3–4

simplifying using dynamic data, 751–756

common COM interop pain points, 755–756

embedding interop metadata, 754–755

role of PIAs, 753

using VB 2010 language features, 756–763

without VB 2010 language features, 760–763

COM+/Enterprise Services, 1063

Combine menu, 1318–1319

ComboBox control, WPF, 1274–1275

ComboBoxItem objects, 1269

comma-delimited list, 46, 130–131, 324, 633

command builder type, 965

command line, generating strong names at, 585–587

Command object, 872, 879, 965, 1252

Command property, connecting WPF commands to, 1251–1252

CommandBinding objects, 1253

CommandBindings collection, 1254

CommandCollection property, 985

Page 91: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1652

command-line arguments, VB 2010 programming, 80–81

command-line compiler, 43, 49, 55, 558, 572, 575, 1216, 1621

command-line parameters, 78

CommandText property, 903, 912, 915

CommandType Enum, 903

CommandType property, 903, 915

COMMIT statement, 924

Common Controls section, 1595

common intermediate language, 102, 566, 1615

Common Language Infrastructure, 38, 1613

Common Language Infrastructure (CLI), 38

Common Language Runtime (CLR), 1, 39, 746

Common Language Specification (CLS), 1, 39, 631

Common Object Runtime Execution Engine, 24

Common Properties area, 1263, 1267, 1269, 1286

Common Properties section, 1266, 1269

Common Type System, 1, 5, 18, 39, 1615

CommonSnappableTypes assembly, 645

CommonSnappableTypes namespace, 647

CommonSnappableTypes.dll, 645assembly

CommonSnappableTypes.dll assembly, 647–648

Company property, 212

companyName field, 212

comparable objects, building

custom properties, custom sort types, 373

specifying multiple sort orders (IComparer), 371–372

ComparableCar project, 373

CompareValidator widget, 1510–1511

comparison operator overloading, 473

Competed event, 1141

compilation cycle

for multifile pages, 1458

for single-file pages, 1453–1454

Compile tab, 112–113, 691, 740

Completed event, 1357–1359

Completed property, 1137

Component Object Model, 3

component tray, 979

concatenation, of string data, 102–103

conceptual model, 1001, 1006, 1014–1016, 1018, 1020, 1022, 1029–1031, 1040

concurrency, 790–798

concurrent garbage collection, 311

Condition editor, 1157

Condition property, 1146

configuration files, altering using SvcConfigEditor.exe, 1109–1110

ConfigurationManager.AppSettings indexer, 894, 897

ConfigurationManager.ConnectionStrings indexer, 897

configuring

tab order, 1591

TCP-based binding, 1097–1099

Page 92: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1653

connected layer, of ADO.NET

command objects, 903

connection objects, 900–902

ConnectionStringBuilder objects, 902

Connection property, 899, 903, 925

connection string builder objects, 902

ConnectionState enumeration, 901

ConnectionState values, 902

connectionString attributes, 898

ConnectionString property, 894, 900, 902, 1500

ConnectionStringBuilder objects, 902

<connectionStrings> element, 897–898

Console class, 27, 77, 84–85, 1145

Console project, 750

Console type, 85, 794

console user interface (CUI), 84

Console window, 589

ConsoleColor enumeration, 84

ConsoleColor variables, 134

constant field data

constants, 221–223

read-only fields, 222–223

shared read-only fields, 223

ConstData project, 224

ConstructorBuilder type, 728, 735

constructors

chaining calls using this, 178–181

for classes, 173–176

emitting, 735–736

flow of, and Me keyword, 181–183

shared, 188–190

contained controls, enumerating, 1480–1483

ContainerControl class, 1580

containers, generating documents from, 1053–1054

containment, programming for, 241–245

containment/delegation model, 195, 227, 241

content display area, 1404

content pages

default, 1497–1498

designing, 1504–1506

Content property, 1179–1180, 1186–1187, 1195, 1230, 1234, 1267, 1269, 1286, 1288, 1363, 1384, 1403–1404

ContentPlaceHolderID value, 1498

ContentPresenter class, 1402, 1404

Context property, 1539–1540

context.Inventories, 1038–1039, 1292–1293

contracts

data, 1119–1125

operationalservice types as, 1083

contravariance, 7–8, 434

Control class, 334, 1365, 1453, 1565, 1577–1580

control declarations, ASP.NET, 1452–1453

control flow activities, WF 4.0, 1138

Control Flow area, 1154

Control Library section, 1233

Control Panel, 1429, 1550

Page 93: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1654

control templates, WPF

custom, building with Visual Studio 2010, 1399–1406

ContentPresenter, 1404

incorporating templates into styles, 1405–1406

incorporating visual cues using triggers, 1401–1402

markup extension, 1402–1403

templates as resources, 1400–1401

default, 1392–1398

Control Type, 1181, 1578–1579

control-agnostic events, 1250, 1294

ControlCollection object, 1480

controls. See also ASP.NET web controls

collection, populating, 1565–1566

contained, enumerating, 1480–1483

created dynamically, 1484–1485

dynamically adding and removing, 1484

dynamically created, 1484–1485

for validation

CompareValidator widget, 1510–1511

creating summaries, 1511–1512

defining groups, 1512–1514

RangeValidator widget, 1510

RegularExpressionValidator widget, 1509

RequiredFieldValidator widget, 1509

WebControl base class, 1485–1486

Controls node, 1278

Controls property, 1480, 1565, 1567

ControlTemplate class, 1395

ControlToValidate property, 1510

conversion routines, custom, 484

conversions, numerical, 477

Convert to New Resource option, 1352

Convert to Path menu option, 1318

Convert type, 114

Cookie collection, 1548

cookies, 1547–1549

creating, 1547–1548

reading incoming data, 1549

Copy Local property, 592

Copy to Output Directory property, 1056, 1337

core assemblies, of WCF, 1070

CoreLibDumper.dll, assigning strong name to, 1626

cores, 802

CorLibDumper project, 1631

CorLibDumper.dll assembly, 1630

covariance, 7–8, 434

CrazyOrange theme, 1518

CrazyOrange.skin file, 1516

CREATE PROCEDURE statement, 888

CreateSalesMemoActivity.vb, 1159

CreateText( ) method, FileInfo class, 828

CreditRisks table, adding to AutoLot database, 925–926

cross-language inheritance, 571–572

CSE (corrupted state exceptions), 300

CSharpCarClient project, 572

CssStyle property, 1514

Page 94: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1655

ctor token, 713, 727

CTS (Common Type System), 18–22

class types, 18

data types, 21–22

delegate types, 21

enumeration types, 20

interface types, 19

structure types, 19

type members, 21

CType keyword, 110

CType operator, 468, 478

CUI (console user interface), 84

currBalance field, 186

Current value, 942

CurrentNumber property, 1384–1385, 1387

currInterestRate field, 188

currInterestRate variable, 189

currSpeed field, 173, 228, 723–724

Cursor property, 1247

CustID field, 891

custID parameter, 928

CustID value, 890, 1034

custom attributes

applying, 636

named property syntax, 636

restricting usage, 637–638

custom classes, 209, 316, 333–334, 462, 467, 476, 527, 1188, 1544

custom conversion routines, internal representation of, 484

custom event arguments, creating, 445–446

custom exceptions, building, 289

custom interfaces, defining, 337–339

custom layout manager, rendering to, 1330–1332

custom metadata viewer

displaying various odds and ends, 616

fields and properties, 615

generic types, 619

implemented interfaces, 616

implementing Main( ) method, 617–618

method parameters and return values, 619–621

methods, 614–615

custom namespaces, defining

creating nested namespaces, 550–551

resolving name clashes with aliases, 548–549

resolving name clashes with fully qualified names, 547–548

custom objects, persisting, 1557–1559

custom type conversions

among related class types, 478

anonymous types

containing anonymous types, 504–505

equality for, 502–504

internal representation of, 500–501

ToString( ) and GetHashCode( ), 502

creating routines, 479–481

explicit conversions for square types, 482

Page 95: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1656

extension methods

extending interface types with, 494–495

extension libraries, 492–494

importing types that define, 490–491

IntelliSense mechanism, 491–492

invoking on instance level, 487–488

invoking statically, 489

scope of, 489–490

implicit conversion routines, 482–483

internal representation of custom conversion routines, 484

numerical, 477

partial methods, 496–498

custom view state data, adding, 1528–1529

CustomAttribute tokens, 611

CustomConversions project, 484

CustomDepPropApp project, 1388

CustomEnumerator project, 361

Customers table, creating in AutoLot database, 889

CustomException project, 293

CustomGenericMethods project, 406

CustomInterface project, 349

customizing Soap/Binary serialization processes, 861–867

using attributes, 866

using ISerializable, 862–865

CustomNamespaces namespace, 547

CustomNamespaces project, 551

CustomNamespaces.exe assembly, 545

CustomSerialization project, 867

CustomVisualFrameworkElement class, 1333

Cut command, 1250

cut operation, 1252

C/Windows API, programming language comparison, 1–2

■D daemon threads, 789

data

deleting with generated codes, 991

inserting with generated codes, 990–991

selecting with generated codes, 989–990

data access library, ADO.NET, reusing, 907–916

adding connection logic, 908–909

adding deletion logic, 910

adding insertion logic, 909–910

adding selection logic, 911–912

adding update logic, 911

executing stored procedure, 914–916

parameterized command objects, 912–914

data access logic, adding, 1446–1449

data adapters

configuring using SqlCommandBuilder class, 965–966

mapping database names to friendly names, 963

prepping, 969–970

simple data adapter example, 961–962

strongly typed, 984–985

Page 96: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1657

data binding

entities, to Windows Forms GUIs, 1035–1039

WPF

Data Binding tab, 1286

DataContext property, 1289

DataGrid tab, 1292–1294

establishing data bindings, 1286–1292

IValueConverter interface, data conversion using, 1290–1291

Data Binding tab, WPF, 1286

data caching, 1539–1541

Data Connections node, 885

data contracts, designing

examining Web.config files, 1123

implementing service contracts, 1122–1123

role of *.svc files, 1123

testing services, 1124–1125

using Web-Centric service project templates, 1120–1121

data parallelism, 804–807

data points, 18, 91, 138, 173, 194, 206, 499, 865, 1531

Data property, 285–288

data provider factory model, ADO.NET

connectionStrings element, 897–898

complete data provider factory example, 893–897

potential drawback with provide factory model, 897

data providers, ADO.NET, abstracting using interfaces, 881–884

data readers, ADO.NET, 904–907

data relationships andmultitabled DataSet objects

building table relationships, 971

navigating between related tables, 972–974

prepping data adapters, 969–970

updating database tables, 971

Data Source Configuration Wizard, 976, 979, 981, 984

data type conversions, 108–114

narrowing data conversions, 111

Option Strict, 112–113

overflow checking, 113–114

System.Convert, 114

data type variable, 93, 109

data validation logic, 217, 1386

Database Diagrams node, 891

Database Explorer window, 885

database management systems (DBMSs), 871

database names, mapping to friendly names, 963

database tables, updating, 971

database transactions, ADO.NET, 923–929

adding CreditRisks table to AutoLot database, 925–926

adding transaction method to InventoryDAL class, 926–928

key members of transaction object, 924–925

testing, 928–929

DatabaseReader class, 166, 193

Page 97: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1658

data-binding operation, 1035, 1285, 1287–1290, 1292

DataColumn class, 933, 936

DataColumn types

adding objects to DataTable types, 938

building, 937

enabling autoincrementing fields, 937–938

DataContext property, 1289

DataGrid control, 1292

DataGrid objects, 1285

DataGrid tab, WPF, 1292–1294

dataGridCars, 756–757

DataGridView control, 975–980

DataGridView widget, 968

DataGridView wizard, 988

DataGridViewDataDesigner project, 986

DataParallelismWithForEach project, 808

DataProviderFactory project, 898

DataProviderFactory.exe assembly, 893

DataRow class, 982–983, 988

DataRow type

DataRowVersion property, 942

RowState property, 940–941

System.Data namespace, 891

DataRowExtensions.Field(Of T)( ) Extension method, 996

DataRows, strongly typed, 983

DataRowState enumeration, 940

DataRowVersion enumeration, 942

DataSet class, 932, 974, 982, 986, 1000

DataSet container, 999

DataSet extensions library, 994

DataSet objects, 512, 910, 931–932, 945, 980, 993–994, 999

DataSet types, 932–935, 992–997

building, 935

key methods of, 934

key properties of, 933

programming to with LINQ

DataSet extensions library, 994

obtaining LINQ-compatible datatables, 994–995

populating new DataTables from LINQ queries, 996–997

role of DataRowExtensions.Field(Of T)( ) Extension method, 996

DataSets, 869, 872, 880, 932, 935, 944–945, 947–948, 960, 990, 1000, 1041, 1529

inserting DataTables into, 944

obtaining data in, 944–945

strongly typed, 980–982

DataSource property, 953, 959, 968

DataSourceID property, 1495–1496, 1499–1500

DataTable objects, binding to Windows Forms GUIs

DataView type, 958–959

deleting rows from DataTable, 953–955

hydrating DataTable from generic List(Of T), 951–953

selecting rows based on filter criteria, 955–957

updating rows within DataTable, 958

DataTable type

inserting into DataSets, 944

Page 98: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1659

obtaining data in DataSets, 944–945

processing data using DataTableReader objects, 945–947

serializing DataTable/DataSet objects

in binary format, 948–949

as XML, 947

DataTable/DataSet objects

serializing as XML, 947

serializing in binary format, 948–949

DataTableReader objects, using to processing data, 945–947

DataTables

hydrating from generic List(Of T), 951–953

populating from LINQ queries, 996–997

strongly typed, 982

DataView class, 959

DataView type, 958–959, 997

DatePicker control, 1398

DateTime.Now.AddSeconds(15) parameter, 1541

DbCommand type, 903

DbDataAdapter class, 932

DBMSs (database management systems), 871

DbParameter type, specifying parameters using, 912–914

Deactivate event, 1582–1584

Debug folder, 79, 569, 1019, 1200

Debug tab, 81, 83, 1189

debugging ASP.NET pages, 1458–1459

dedicated databases, storing session data in, 1551

deep copy, 160, 362–363, 366

default application domain, 668, 670–672, 674–675, 677, 679

default content pages, 1497–1498

Default edit area, 1157

default endpoints, 1099–1101

default input button, setting, 1592

Default property, 1156

Default value, 783, 903, 1381

Default1.aspx file, 1447

DefaultAppDomainApp project, 674

Default.aspx file, 1458, 1498, 1518–1519, 1554

DefaultDrawingAttributes property, 1274

defining

groups, 1512–1514

user profiles within Web.config, 1553–1554

definitions on interface types, 467

Delegate class, 429

Delegate keyword, 20, 416–417, 419–420, 459, 770

delegate variable, 431

DelegateCovariance project, 435

delegate/event model, 7

delegates

asynchronous nature of

BeginInvoke( ) and EndInvoke( ) methods, 770

System.IAsyncResult interface, 771

defining delegate type in VB, 416–418

delegate covariance, 432–434

Page 99: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1660

generic, 435–437

method group conversion syntax, 431–432

.NET delegate type, 415–416

sending object state notifications using

enabling multicasting, 428–429

removing targets from delegate's invocation list, 429–430

simplest possible delegate example, 421–424

System.MulticastDelegate and System.Delegate base classes, 419–420

delegationprogramming for, 241–245

DELETE command, 961

Delete request, 907

Delete statement, 907, 1499

Delete Sticky Note button, 1284

DeleteCar( ) method, 919

deleting records, 1023

demonstrating view state, 1527–1528

dependency properties, WPF, 1377–1383

building custom

adding data validation routine, 1386

responding to property change, 1386–1387

CLR property wrappers, 1382–1383

examining existing, 1379–1382

DependencyObject parameter, 1387

DependencyProperty object, 1380, 1382, 1387

derived class, casting rules

Is keyword, 262–263

TryCast keyword, 262

Descending operator, 533–534

Description property, 636–637, 641–642

deserialization, 861–862, 867

deserializing objects, 855

desktop applications, WPF and XAML, 1169–1171

desktop markup, 1167

development web server, ASP.NET, 1430

dialog boxes

designing

configuring tab order, 1591

DialogResult property, 1590–1591

displaying dialog boxes, 1593–1594

setting form's default input button, 1592

Tab Order Wizard, 1592

understanding form inheritance, 1594–1596

WPF, 1232

DialogResult enumeration, 1590

DialogResult property, 1590

DialogResult type, 1583

DialogResult values, 1606

diamond button, 1344

dictionaries, merged resource, 1349–1350

Dictionary object, 1138, 1155, 1164

DictionaryEntry type, 286

digital signature, 584

Dim keyword, 118, 499, 508, 519, 523

dimensions, multiple, indexers with, 466

direct event, 1389

Page 100: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1661

Direct Selection button, 1262

Direction property, 888, 916

directives

ASP.NET, 1450–1451

CIL, role of, 689

Directory type, 824

DirectoryApp project, 825

DirectoryInfo class, 820

DirectoryInfo types

abstract FileSystemInfo base class, 819–820

creating subdirectories with DirectoryInfo type, 823–824

enumerating files with DirectoryInfo type, 822–823

DirectX layer, 1168

Disassembler window, 36

disconnected functionality, testing, 967–968

disconnected layer, of ADO.NET, 931–997

adding disconnection functionality to AutoLotDAL.dll

configuring data adapters using SqlCommandBuilder class, 965–966

defining initial class types, 964

GetAllInventory( ) method, 966

setting version numbers, 967

testing disconnected functionality, 967–968

UpdateInventory( ) method, 966

binding DataTable objects to Windows Forms GUIs

DataView type, 958–959

deleting rows from DataTable, 953–955

hydrating DataTable from generic List(Of T), 951–953

selecting rows based on filter criteria, 955–957

updating rows within DataTable, 958

data adapters

mapping database names to friendly names, 963

simple data adapter example, 961–962

DataColumn types

adding objects to DataTable types, 938

building, 937

enabling autoincrementing fields, 937–938

DataRow type

DataRowVersion property, 942

RowState property, 940–941

DataSet types, 932–935

building, 935

key methods of, 934

key properties of, 933

DataTable type

inserting into DataSets, 944

obtaining data in DataSets, 944–945

processing data using DataTableReader objects, 945–947

serializing DataTable/DataSet objects as XML, 947

Page 101: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1662

serializing DataTable/DataSet objects in binary format, 948–949

isolating strongly typed database code into class libraries

deleting data with generated codes, 991

inserting data with generated codes, 990–991

invoking stored procedure using generated codes, 992

selecting data with generated codes, 989–990

viewing generated codes, 988–989

multitabled DataSet objects and data relationships

building table relationships, 971

navigating between related tables, 972–974

prepping data adapters, 969–970

updating database tables, 971

programming with LINQ to DataSet types

DataSet extensions library, 994

obtaining LINQ-compatible datatables, 994–995

populating new DataTables from LINQ queries, 996–997

role of DataRowExtensions.Field(Of T)( ) Extension method, 996

Windows Forms database designer tools

app.config files, 980

completing Windows Forms applications, 985–986

DataGridView control, 975–980

strongly typed data adapters, 984–985

strongly typed DataRows, 983

strongly typed DataSets, 980–982

strongly typed DataTables, 982

disconnection functionality, adding to AutoLotDAL.dll

configuring data adapters using SqlCommandBuilder class, 965–966

defining initial class types, 964

GetAllInventory( ) method, 966

setting version numbers, 967

testing disconnected functionality, 967–968

UpdateInventory( ) method, 966

discrete key frames, authoring animation in XAML, 1362–1363

DiscreteStringKeyFrame elements, 1363

Display property, 1511

DisplayBaseClass(Of T) method, 405–406

displaying dialog boxes, 1593–1594

DisplayName property, 1143–1144, 1154

disposable objects, 320–323

distributed computing APIs, 1061–1067

COM+/Enterprise Services, 1063

Distributed Component Object Model (DCOM), 1062–1063

Microsoft Message Queuing (MSMQ), 1063–1064

named pipes, sockets, and P2P, 1067

.NET remoting, 1064

XML web services, 1064–1067

Page 102: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1663

DLL hell, 4, 602

DLR (dynamic types and Dynamic Language Runtime), 739–763

COM interoperability

simplifying using dynamic data, 751–756

using VB 2010 language features, 756–763

without VB 2010 language features, 760–763

Dynamic objects

limitations of, 745

practical uses of, 746

role of Microsoft.VisualBasic.dll assembly, 743–744

simplifying late bound calls using dynamic types, 749–751

DNS (Domain Name Service), 1428

Dock property, 1378

DockPanel panels, 1242–1243

DockPanel types, 1243

document annotations, 1168

document controls, WPF, 1232

document layout managers, WPF, 1277–1278

Document Object Model (DOM), 1043, 1436

Document property, 1279

document structure, HTML, 1431–1432

documentation

defining assembly, 609

referenced assemblies, 609

string literals, 610

documents, generating from arrays and containers, 1053–1054

Documents API, WPF, 1276–1278

block elements, 1277

document layout managers, 1277–1278

inline elements, 1277

Documents tab, WPF

annotations, enabling, 1282–1284

populating FlowDocument

using Blend, 1279–1281

using code, 1281–1282

saving and loading FlowDocument, 1284–1285

sticky notes, enabling, 1282–1284

DOM (Document Object Model), 1043, 1436

DOM models vs. XML APIs, 1043–1044

domain first programming, 1010

Domain Name Service (DNS), 1428

dot (.) prefix, 689

dot operator, 101, 152, 197, 304, 316, 352, 354, 491, 519, 539, 628, 742, 1044, 1532

dotNetFx40_Full_x86.exe setup program, 37

DotNetLanguages.net, 9

Double arguments, 131

Double data type, 130

Double value, 1312

Do/While loop, 119–121, 917

download cache, 558, 601, 603

DownloadStringCompleted event, 809

Drawing class, 1321

Page 103: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1664

DrawingAttributes object, 1274

DrawingBrush class

building using geometries, 1322–1323

painting with, 1323–1324

DrawingImage, containing drawing types in, 1324–1325

drawings and geometries, rendering graphical data using

building DrawingBrush using geometries, 1322–1323

containing drawing types in DrawingImage, 1324–1325

painting with DrawingBrush, 1323–1324

DrawingVisual class, 1329

dreamCar object, 572

DriveInfo class type, 825–827

DriveInfoApp project, 827

DriveNames variable, 1148–1149

DropDownItems property, 1567

Dump menu option, 693

Duration object, 1359

Duration property, 1359

dynamic assemblies

emitting

assembly and module set, 732–733

constructors, 735–736

HelloClass type and String Member variable, 734–735

SayHello( ) method, 736

ModuleBuilder type, role of, 733

System.Reflection.Emit namespace, 727–728

System.Reflection.Emit.ILGenerator, role of, 728–729

using dynamically generated assembly, 736

dynamic data, 741–746, 748, 756, 758, 760, 762–763

dynamic keyword, 4, 8

dynamic loading, 605, 621, 630, 641, 643–644, 651

dynamic typing, 117, 739–742, 745–746, 748–749, 751–752, 756, 762

dynamic variable, 742

DynamicAsmBuilder project, 737

DynamicCtrls website, 1485

markup extension, 1346–1347

DynamicType project, 746

■E early binding, attributes using, 640–641

ECMA (European Computer Manufacturers Association), 1614

Edit menu, 1245

EditingMode property, 1272

EDM (entity data model), building and analyzing, 1010–1022

enhancing generated source code, 1021–1022

generating *.edmx file, 1010–1014

reshaping Entity Data, 1014–1016

viewing generated *.edmx file data, 1017–1019

viewing generated source code, 1019–1020

viewing mappings, 1016

Page 104: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1665

.edmx file

generating, 1010–1014

viewing generated data, 1017–1019

edmxResourcesToEmbed subdirectory, 1019

EF (Entity Framework)

*.edmx file, role of, 1006

AutoLotDAL Version 4.0

invoking stored procedure, 1034–1035

mapping stored procedure, 1029–1030

navigation properties, 1031–1034

building and analyzing entity data model (EDM)

enhancing generated source code, 1010–1022

generating *.edmx file, 1010–1014

reshaping Entity Data, 1014–1016

viewing generated *.edmx file data, 1017–1019

viewing generated source code, 1019–1020

viewing mappings, 1016

building blocks of, 1003–1004

data binding entities to Windows Forms GUIs, 1035–1039

entities, role of, 1001–1003

entity client, role of, 1005–1006

object services, role of, 1004

ObjectContext and ObjectSet(Of T) classes, role of, 1006–1008

programming against conceptual model

deleting records, 1023

Entity Client Data Reader Object, 1027

querying with Entity SQL, 1026–1027

querying with LINQ to Entities, 1024–1026

updating records, 1024

Element Property tab, 1287

ElementName value, 1288

elementsXAML, 1208–1209

Ellipse area, 1402

Ellipse types, 1389

ellipses

adding to canvas, 1299–1302

removing from canvas, 1302–1303

Else branch, 1160–1161

Else statement, 121–122

Embed Interop Types property, 754, 756, 758

embedding interop metadata, 754–755

emitting HTML content, 1470

empBenefits object, 242

empName field, 201–202

Empty Web Site project, 1455, 1508, 1523, 1535, 1544

EmpType enumeration, 146, 150

Enable Editing check box, 1503

EnabledStateGroup, 1417

enabling

autoincrementing fields, 937–938

Page 105: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1666

in-place editing, 1503

metadata exchange, 1090–1093

sorting and paging, 1502

encapsulation

of classes

internal representation of properties, 207–209

read-only and write-only properties, 210–211

shared properties, 211–212

using .NET properties, 202–205

using properties within class definition, 206

using traditional accessors and mutators, 199–202

visibility levels of properties, 210

pillar of OOP, 193–194

endpoints, default, 1099–1101

EngineState enumerationviewing type metadata for, 606–607

EntiryDataReader, 1009

entities, 1001–1003

entity classes, 1001, 1006, 1021–1022, 1024, 1027, 1040, 1442

entity client, 999, 1004–1006, 1009, 1026–1027

Entity Client Data Reader Object, 1027

entity data model, 1006

Entity Model Data Wizard, 1011

Entity Set Name field, 1016

Entity Set value, 1016

Entity SQL, querying with, 822–823, 1026–1027

Entity Types folder, 1014

EntityDataReader class, 1006

EntityKey object, 1023–1024

Enum keyword, 20, 148, 688

enum type

declaring variables, 147–148

discovering name/value pairs of, 149–151

System.Enum type, 148–149

underlying storage for, 147

Enum variable, 148–149

Enumerable class, 532–534, 536–537, 540

enumerable types, building, 358

EnumerateMachineInfoWF project, 1153

enumerating

contained controls, 1480–1483

files with DirectoryInfo type, 822–823

enumeration types, Common Type System (CTS), 20

enums, defining in CIL, 708

Environment class, 82

ephemeral generations, 310–311

equality, operator overloading, 472–473

Erase mode, 1273

Error event, 1472–1474, 1531

error handling activities, WF 4.0, 1142

escape characters, 103–104, 1222

European Computer Manufacturers Association (ECMA), 1614

event handling, server-side, 1478

Event keyword, 415, 425, 437, 439–440, 442, 459

Page 106: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1667

event triggers, authoring animation in XAML, 1362

EventArgs parameter, 1576

EventHandlerT delegategeneric, 446–447

EventHandler(Of T) type, 446

events

anonymous methods, 447–450

creating custom event arguments, 445–446

event keyword, 439–440

generic EventHandlerT delegate, 446–447

incoming, listening to, 442–443

registrating, simplifying event using Visual Studio 2010, 444–445

Events tab, 1220, 1229, 1409, 1421

Exception class, 276, 283

Exception code snippet template, 293

exception event handler, 1531

Exception property, 1147

Executed events, 1255

Executed handlers, 1255

Existing Item menu option, 1337

Exit event, 1177, 1184–1185, 1195

Exit handler, 1178, 1246, 1584

Exit menu, 1566–1567, 1574, 1584, 1589, 1605

ExitEventHandler delegate, 1185

Expander control, 1247

Expander widget, 1244

ExpenseIt WPF sample program, 1172

explicit conversions, for square types, 482

Exploded event, 439–440, 446, 449

ExplodedEventHandler delegate, 442

Export All button, 1326

Export dialog box, 1326

Export menu option, 1326

ExportDataToOfficeApp project, 762

exporting design document to XAML, 1326–1327

exposing single services using multiple bindings, 1101–1102

Expression Blend

building user interface with

key aspects of, 1256–1262

TabControl control, 1262–1264

establishing data bindings using, 1286–1289

extracting resources in, 1352–1354

generating WPF styles with, 1371–1375

populating FlowDocument, 1279–1281

UserControls, building custom, 1406–1414

animation, defining, 1410–1412

initial VB 2010 code, 1409

programmatically starting storyboard, 1413–1414

renaming initial, 1407–1408

SpinControl, 1408

working with shapes using

brush and transformation editors, 1319–1321

combining shapes, 1318–1319

converting shapes to paths, 1318

Page 107: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1668

selecting shape to render from tool palette, 1316–1317

expression trees, 747

extendable applications

CommonSnappableTypes.dll, 645

extendable Windows Forms application, 646–651

VB 2010 Snap-In, 645–646

Windows Forms, 646–651

ExtendableApp folder, 651

ExtendedProperties property, 933

extending interface types, 494–495

extends attribute, 706, 708

extends clause, 707

extension libraries, 492–494

extension methods

extending interface types with, 494–495

extension libraries, 492–494

importing types that define, 490–491

IntelliSense mechanism, 491–492

invoking

on instance level, 487–488

statically, 489

scope of, 489–490

ExtensionMethods project, 492

external assemblies, referencing, 31

external attribute, 703

external code libraries, 317, 552, 653, 1133, 1450

external XAML files, 1132

extracting resources

changing after, 1346

in Expression Blend, 1352–1354

■F Field #n token, 607

field data

defining in CIL, 712–713

shared, 185–188

FieldBuilder type, 735

FieldCount property, 905

FieldInfo array, 612, 615

FieldModifier keyword, 1207

fields, custom metadata viewer, 615

FIFO (first-in, first-out) list, 392

File class, 819

File menu, 1254, 1431, 1444, 1566–1567, 1574, 1603–1604

File Open dialog box, 648

File Transfer Protocol (FTP), 1429

file types, 832–834

file-centric methods, 833–834

FileInfo class

AppendText( ) method, 831–832

Create( ) method, 828

CreateText( ) method, 831–832

Open( ) method, 829–830

OpenRead( ) method, 830

OpenText( ) method, 831

OpenWrite( ) method, 830

File(Info) types, 819–820

Page 108: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1669

FileMode enumeration, 829

FileName property, 1612

FileNotFoundException class, 677

files

enumerating with DirectoryInfo type, 822–823

watching programmatically, 844–846

FileStream class, 835

FileStreamApp project, 836

FileStreams class, 835–836

FileSystemInfo abstract base class, 819–820

FileSystemWatcher class, 844

Fill property, 1300, 1309–1310, 1323, 1402–1403, 1415, 1419

FillDataSetUsingSqlDataAdapter project, 964

filter criteria, selecting rows based on, 955–957

Filter property, 844, 1612

filtering data, using OfType(Of T)( ), 527

finalizable objects, 316–320

FinalizableDisposableClass project, 327

finalization queue, 319–320

finalization reachable table, 320

Finally blocks, 297–298

Finally clause, 796

Find/Replace dialog box, 1593

Finish button, 978, 1014, 1037, 1505

FinishButtonClick event, 1505

first-in, first-out (FIFO) list, 392

firstName variable, 102

flags, 16, 44, 48, 81, 89, 555–556, 608, 697

flow chart model, 1139

Flow Control area, 1157

flow documents, 1168

flowchart activities, WF 4.0, 1139

flowchart workflows

connecting activities in, 1143–1144

defining workflow wide variables, 1145

FlowDecision activity, 1145–1146

ForEachT activity, 1148

ForEachT activity, 1150

InvokeMethod activity, 1144–1145

TerminateWorkflow activity, 1146–1147

FlowDecision activity, 1143, 1145–1146, 1148

FlowDocument

loading, 1284–1285

populating

using Blend, 1279–1281

using code, 1281–1282

saving, 1284–1285

FlowDocumentReader control, 1278–1279

FlowSwitch<T> activity, 1146

FocusedStateGroup, 1417

Font type, 1599, 1601

FontSize attribute, 1378

For Each construct, 360

For Each loop, 119–120

For keyword, 119

For loop, 80–81, 119, 515, 720–721, 1053

For statement, 119

Page 109: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1670

forcing garbage collection, 313–316

foreach construct, 515

for-each enumeration, 1149

foreach style, 376

ForEach<T> activity, 1148–1150

ForEach<T> mini designer, 1150

foreach-style iteration, 391

ForEachT activity, 1150

Foreground color, 1402

foreground threads, 788–789

Form class, 1580–1581, 1589

form data, accessing, 1467–1468

form inheritance, 1594–1596

form statement, 1465

Form type

Control class, 1577–1580

Form class, 1580–1581

life cycle, 1582–1584

Form1.vb file, 950, 967, 1055, 1589, 1603

Format drop-down list, 1326

FormattedResponse argument, 1157

FormattedResponse variable, 1158

FormattedText object, 1329–1330

formatters

for serialization

IFormatter and IRemotingFormatter interfaces, 851–852

type fidelity among formatters, 852–853

type fidelity among, 852–853

FormBorderStyle enumeration, 1580

FormBorderStyle property, 1589–1590

FormClosed event, 1582–1583

FormClosing event, 1582–1583

FormClosingEventArgs.Cancel property, 1582

FormClosingEventHandler delegate, 1582

forms. See also Windows Forms

client area, invalidating, 1602–1603

HTML, 1432

Forms designer, 51, 965, 1564, 1569, 1572–1574, 1589, 1592, 1594, 1606

Forms-based authentication model, 1556

Form.vb file, 1600

FormWindowState enumeration, 1581

FrameworkElement class, 1328, 1379, 1381

FrameworkPropertyMetadata object, 1381, 1386

FrameworkPropertyMetadataOptions enum, 1381

Friend keyword, 197, 568

Friend modifier, 198

friendly names, mapping database names to, 963

From operator, 529

From propertyAnimation class types, 1356

FTP (File Transfer Protocol), 1429

Func(Of T) delegate, 510, 537–540, 542, 804

Function Imports folder, 1029

Function keyword, 452

Function statement, 453

FunWithEnums project, 151

FunWithGenericCollections project, 402

Page 110: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1671

FunWithLinqExpressions project, 537

FunWithModules project, 76

FunWithPageMembers website, 1471

FunWithStrings project, 108

FunWithStructures project, 155

■G GAC (Global Assembly Cache), 588–289

GainFocusStar, 1417

garbage collection

background (.NET 4.0), 311

concurrent (.NET 1.0 - 3.5), 311

forcing, 313–316

GC class, 184, 303, 331

GCCollectionMode enumeration, 312, 314

GDI+, rendering graphical data using, 1596–1603

general catch statements, 295–296

general exceptions, throwing, 280

generating proxy code

using svcutil.exe, 1094–1095

using Visual Studio 2010, 1095–1097

generation 0 objects, 310–311, 314

generation 1 objects, 311

generational value, 311

generic List(Of T), hydrating DataTables from, 951–953

generic members, 7, 21, 389, 402

generic types, 7–8, 21, 116, 375, 387, 402, 412–414, 463, 526, 619, 1356

GenericDelegate project, 437

GenericPoint project, 409

generics

constraining type parameters

examples using where keyword, 411–412

lack of operator constraints, 412–414

creating custom generic methods, 402–406

creating custom generic structures and classes

default keyword in generic code, 407–409

generic base classes, 409–410

defining in CIL, 709

generic type parameters, 386–391

non-generic collections, issues with

performance, 377–381

type safety, 381–385

System.Collections.Generic namespace

collection initialization syntax, 392–393

List(Of T) class, 394–396

Queue(Of T) class, 398–400

SortedSet(Of T) class, 400–402

Stack(Of T) class, 397–398

GetAllInventory( ) method, 966

Get/End Get scope, 203

GetObjectData( ) method, 502

GetPetName( ) method, 502, 888

Global Application Class icon, 1529

global application object, 1177, 1188

global last-chance exception event handler, 1531

Page 111: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1672

Global.asax file

global last-chance exception event handler, 1531

HttpApplication base class, 1532

Global.asax script, 1532

globally unique identifier (GUID), 935

GoToStateAction, 1417

gradient brush button, 1309

gradient offset, 1309

gradient stop, 1309–1310, 1319, 1346

gradient strip, 1309

Gradient Tool icon, 1319

GradientStop objects, 1311

graphical data, rendering using GDI+

Graphics type, 1599–1600

invalidating form's client area, 1602–1603

obtaining Graphics object with Paint event, 1600–1601

System.Drawing namespace, 1598

Graphics class, obtaining with Paint event, 1600–1601

Graphics type, 1598–1600, 1612

Grid panels, 1240–1242

gridInventory, 1035, 1038, 1292–1293

GridSplitter types, 1241–1242

GridView control, 1445, 1448, 1490, 1499–1500, 1502–1503, 1521

GridView widget, 1445, 1500

GridWithSplitter.xaml file, 1242

grouping profile data, 1557–1559

GroupName property, 1269

groups, defining, 1512–1514

GrowLabelFont.xaml file, 1361

Grunt value, 148

GUID (globally unique identifier), 935

GZIP standard, 1443

■H Handled property, 1391

has-a relationship, 3, 848

HasErrors property, 939

hash code, 269, 376, 584–585, 1453

HashSet(Of T) class, 392

HasValue property, 165

Header property, 1263

Header values, 1246

HeaderText property, 1511

heap-allocated object, 305, 321, 378, 380

Height property, 1355–1356, 1379, 1382–1383, 1386

Height value, 1242, 1370

HeightProperty field, 1381

HelloClass type, emitting, 734–735

HelloProgram.il file, 698

HelloWorld class, 729–730, 732, 734, 736–737

helloWorldClass variable, 736

Help cursor, 1365

Help Library Manager, 68

Help page, 69

Helper class, rigging up UI to, 1058–1059

HelpLink property, 284–286

Page 112: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1673

Hexagon class, 194, 545

Hexagon type, 254, 337, 341–342

hit test operations, responding to, 1333–1334

HitTestResult object, 1303

HitTestResultCallback delegate, 1333

hosting

services within Windows services

creating Windows service installer, 1114–1115

enabling MEX, 1113

installing Windows service, 1116

specifying ABCs in code, 1112–1113

Windows Communication Foundation (WCF) services

system.serviceModel element, 1089–1090

coding against ServiceHost type, 1085–1086

enabling metadata exchange, 1090–1093

establishing ABCs within App.config files, 1084–1085

ServiceHost type, 1087–1089

specifying base addresses, 1086–1087

HTML (Hypertext Markup Language)

building forms, 1435–1436

document structure, 1431–1432

forms, 1432

Visual Studio 2010 designer tools, 1433–1435

HTTP (Hypertext Transfer Protocol)

request/response cycle, 1428

requests, incoming, 1465–1468

response, outgoing, 1468–1471

stateless protocols, 1428

HttpApplication base class, 1532

HttpApplicationState class, 1534

HTTP-based bindings, 1077–1078

HttpCookie.Expires property, 1548

HttpRequest class, 1466

HttpRequest.Browser property, 1437

HttpRequest.Cookies property, 1548–1549

HttpServerUtility object, 1465, 1532

HttpSessionState class, 1533, 1546–1547

HyperLink widget, 1481

Hypertext Markup Language, 1430

Hypertext Transfer Protocol, 1427

■I i command, 589

i parameter, 454

IAppFunctionality interface, 645–646

IAsyncResult interface, 418, 771, 773–774, 815

IAsyncResult parameter, 776–777

IAsyncResult-compatible object, 771

ICloneable interface, building, 361–367

ICloneableExample project, 336

ICollection interface, 393

ICommand interface, 1250, 1254

Page 113: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1674

IComparable interface

building

custom properties, custom sort types, 373

specifying multiple sort orders (IComparer), 371–372

IComparer interface, 144, 371–373

IComparer(Of T) interface, 400

IComponent interface, 1577

IComponentConnector interface, 1199

IContextProperty interface, 683

ICustomFormatter interface, 88

ID attribute, 1042, 1445, 1516

IDataAdapter interface, 880

IDataParameter interface, 879–880

IDataReader interface, 880–881

IDataRecord interface, 880–881

IDbCommand interface, 878–879

IDbConnection interface, 334, 340, 878

IDbConnection parameter, 882

IDbDataAdapter interface, 880

IDbDataAdapterinterface, 880

IDbDataParameter interface, 879–880

IDbTransaction interface, 878, 924–925

IDisposable interface, 303, 317, 320–322, 331

IDraw3D interface, 346–347

IDrawable interface, 412

IDynamicObject interface, 748

IEnumerable interface, 120, 358–359, 383, 462, 518, 526

IEnumerable type, 523

IEnumerable(Of Integer) interface, 517

IEnumerable(Of String), 515, 517, 522–523

IEnumerable(Of T) interface, 518–519, 542

IEnumerator interface, 358, 376

IEnumerator(Of T) interface, 391

If activity, 1157–1158, 1160

If operator, nullable types, 166–167

If scope, 263

If statement, 122, 515

if statement, 1369

If Then/Else branches, 1154

if/else/then statement, 1157

IFormatter interface, 851–852

If/Then/Else statement, 121–122

IIS (Internet Information Services), 1429

IIS virtual directories, 1429–1430

.il file, modifying, 696–697

ilasm.exe, compiling CIL code using, 697–701

ildasm.exe, exploring assemblies using

viewing assembly metadata, 34–35

viewing Common Intermediate Language (CIL) code, 33

viewing type metadata, 34

ILGenerator class, 735–736

Image control, 1322, 1325, 1329–1330, 1336, 1339, 1408–1411

ImageOrderAutoDialog class, 1596

images, programmatically loading, 1339–1340

ImageSource object, 1308

immediate-mode graphical systems, 1295

Page 114: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1675

implementing

interfaces, custom metadata viewer, 616

serialization logic, 1611–1612

service contracts, 1122–1123

Tools menu functionality, 1608–1609

implements attribute, 689, 707–708

implements clause, 707

Implements keyword, 339–340, 351

implicit conversion routines, 461, 482–483

implicit load, 576

implicit type variables, 531

implicitly typed arrays, 139–140

implicitly typed variables

restrictions on, 116

as strongly typed data, 117

usefulness of, 118

importing Inventory.xml files, 1056

importing types, that define, 490–491

Imports keyword, 30–31, 46, 490, 546–549, 570, 627–628, 1155, 1446

Imports statements, 395, 639, 916

In operator, 529

Include attribute, 1197

incoming

cookie data, reading, 1549

HTTP requests

access to incoming form data, 1467–1468

IsPostBack property, 1468

obtaining brower statistics, 1467

indexer methods

definitions on interface types, 467

multiple dimensions, 466

overloading, 465–466

string values, 464–465

infrastructure, adding to MainWindow type, 1607

inheritance. See also polymorphism

base class/derived class casting rules

Is keyword, 262–263

TryCast keyword, 262

basic mechanics of

multiple base classes, 230

NotInheritable keyword, 230–232

specifying parent class of existing class, 228–229

chain of Page type, 1464

cross-language, 571–572

details of

adding NotInheritable class, 240–241

controlling base class creation with base keyword, 237–239

protected keyword, 239–240

multiple, with interface types, 356–358

pillar of OOP, 194–195

programming for containment/delegation, 241–245

revising Visual Studio class diagrams, 232–234

System.Object class

overriding System.Object.Equals( ), 268–269

Page 115: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1676

overriding System.Object.GetHashCode( ), 269–270

overriding System.Object.ToString( ), 267–268

shared members of, 271–272

testing modified person class, 270–271

Inheritance Picker dialog box, 1595

Inherited Form icon, 1594

Inherited property, 571

Inherits attribute, 1457

init attribute, 719

Init event, 1526

Initial Catalog name, 900

initial class types, 964

InitialValue property, 1509

Ink API tab, WPF, 1265–1276

ComboBox control, 1274–1275

InkCanvas control, 1271–1276

RadioButton control, 1269–1271

ToolBar, 1266–1269

Ink controls, WPF, 1231–1232

Ink mode, 1272–1273

InkCanvas control, WPF, 1271–1273

InkCanvasEditingMode enumeration, 1272

inkToolbar node, 1266

inline elements, WPF, 1277

inline menu editor, 1573

in-memory data allocation, 186

in-memory representation, 7, 904, 932, 997

inner exceptions, 296–297

innerEllipse object, 1389

InnerException property, 297

in/out parameter, 916

in-place editing, enabling, 1503

input button, setting default, 1592

input parameter, 18, 81, 416, 418, 451, 599, 916, 1035

Insert Snippet option, 293

Insert Standard Items option, 1573

INSERT statement, 1003

Insert/Delete logic, 928

InsertNewCar( ) method, 920

installing

Mono, 1617–1621

strongly named assemblies to GAC, 588–589

Windows service, 1116

instance level, invoking extension methods on, 487–488

intArray declaration, 139

Integer data type, 169, 199

Integer parameters, 109

Integer variable, 110

IntelliSense mechanism, 491–492

Interface keyword, 19, 338, 374

interface types

Common Type System (CTS), 19

definitions on, 467

extending, 494–495

InterfaceExtension project, 495

InterfaceNameClash project, 354

Page 116: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1677

interfaces

building cloneable objects, 361–367

building comparable objects

custom properties, custom sort types, 373

specifying multiple sort orders (IComparer), 371–372

building enumerable types, 358

custom, defining, 337–339

defining and implementing in CIL, 707–708

designing hierarchies, 354–358

explicit implementation of, resolving name clashes via, 351–354

generic, specifying type parameters for, 389–391

implementing, 339–341

invoking interface members at object level, 342

obtaining references, 343–344

as parameters, 345–347

as return values, 348

types

arrays of, 348–349

interface types vs. abstract base classes, 335–337

Interlocked class, 797

Intermediate Language Disassembler utility, 32

internal reference counter, 306

internal representation

of anonymous types, 500–501

of overloaded operators, 474–475

InternalsVisibleToAttribute class, 568

International Organization for Standardization (ISO), 1614

Internet Information Services (IIS), 1429

interoperability assemblies, 692, 752, 762

interoperability data, 754

intrinsic control command objects, WPF, 1250

invalidating form's client area, 1602–1603

InvalidCastException exception, 379

InvalidOperationException, 397, 399, 666–667, 857

Inventory database, 1014, 1017, 1022, 1039

Inventory entity, 1015, 1037

Inventory objects, 1034, 1038

Inventory property, 980, 982

Inventory schema, 1002

inventory table, AutoLot database, 885–887

Inventory table icon, 887

Inventory variable, 1157

Inventory.aspx file, 1499

InventoryDAL class, adding transaction method to, 926–928

InventoryDAL type, 909, 912, 915, 919, 964, 1542

InventoryDALDisconnectedGUI project, 968

InventoryDALDisLayer class, 964, 967, 1156

InventoryDataSet.xsd file, 981

InventoryDataTable class, 982

InventoryEDM.edmx file, 1017

Page 117: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1678

Inventory.xml files, importing, 1056

InvokeMethod activity, 1144–1145, 1147–1148

invoking

extension methods, 487–488

services asynchronously from clients, 1117–1118

statically, 489

I/O and object serialization, 817–867

abstract stream class, 836

BinaryWriters and BinaryReaders classes, 842–843

configuring objects for serialization

public fields, private fields, and public properties, 850–851

serializable types, 849–850

customizing Soap/Binary serialization processes, 861–867

using attributes, 866

using ISerializable interface, 862–865

Directory type, 824

Directory(Info) and File(Info) types, 819–820

DirectoryInfo type

creating subdirectories with, 823–824

enumerating files with, 822–823

DriveInfo class type, 825–827

file type, 832–834

FileInfo class

AppendText( ) method, 831–832

Create( ) method, 828

CreateText( ) method, 831–832

Open( ) method, 829–830

OpenRead( ) method, 830

OpenText( ) method, 831

OpenWrite( ) method, 830

files, watching programmatically, 844–846

MustInherit stream class, 834–835

object serialization, 846–849

serialization formatters, 851–853

serializing objects

collections of, 859–860

using BinaryFormatter type, 853–855

using SoapFormatter type, 855–856

using XmlSerializer type, 857–859

StreamWriters and StreamReaders classes

directly creating types, 840

reading from text files, 839

writing to text files, 838

StringWriters and StringReaders classes, 840–841

System.IO namespace, 817–818

IPointy interface, 338, 340–342, 350

IRemotingFormatter interface, 851–852

Is keyword, 262–263, 343–344

is-a relationships, 2

IsBackground property, 789

IsChecked property, 1269

IsCompleted property, 773–774

ISerializable interface, 276, 862–867

Page 118: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1679

IShape interface, 356

IsMouseOver property, 1370

IsNot operator, 165

ISO (International Organization for Standardization), 1614

IsolationLevel enumeration, 925

IsolationLevel property, 925

IsPostBack property, 1468

Item keyword, 462–463

ItemHeight value, 1238

Items (Collection) property, 1266, 1269

Items property, 1504, 1527, 1567

ItemsSource collection, 1293

ItemsSource property, 1212

iteration constructs

Do/While loop, 120–121

For Each loop, 119–120

For loop, 119

representing in CIL, 720–721

While loop, 120–121

IterationsAndDecisions project, 123

IValueConverter interfacedata conversion using, 1290–1291

■J Jackpot Deluxe WPF application

extracting UserControl from drawing geometry, 1415–1417

finalizing, 1421–1426

.NET 4.0 visual states

changing using VisualStateManager class, 1421

for StarButton control, 1418–1419

state transition timings, 1419–1420

viewing generated XAML, 1420

jagged arrays, 142

Java, programming language comparison, 3

JavaScript function, 1438, 1511

JIT (just-in-time) compiler, 39, 556

just-in-time (JIT) compiler, 39, 556

■K k flag, 585

kaxaml editor, 1203–1204, 1304, 1327

key frame animations, 1355

keyboard activity, 1585–1588

keyboard events, intercepting, 1191–1192

KeyDown event, 1191–1192, 1587–1588

KeyEventHandler delegate, 1587

keyframes, 1355, 1410

KeyNotFoundException exception, 392

keys, determining which was pressed, 1587–1588

KeyUp event, 1588

keywords, XAML, 1204–1207

■L l option, 1628

Label class, 1292

Label control, 1290, 1384, 1387, 1452, 1482, 1484, 1499, 1545

Label widget, 1470, 1481, 1524

lambda expressions, 450–459, 509–510

Page 119: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1680

building query expressions using enumerable type and, 538–540

with multiple (or zero) parameters, 456–457

parts of, 454

processing arguments within multiple statements, 454–455

retrofitting CarEvents example using, 457–459

language attribute, 1450

Language Integrated Query, 7, 507

LastAccessTime, 820

LastChildFill attribute, 1243

late binding

attributes using, 641–642

invoking methods with no parameters, 628–629

invoking methods with parameters, 629–630

System.Activator class, 627–628

late bound calls, simplifying using dynamic types, 748–751

LateBindingApp project, 630

LateBindingWithDynamic project, 749–750

Layout section, 1266

LayoutRoot icon, 1260

LayoutTransform property, 1313, 1315

lazy objects, 327–331

ldarg opcode, 717

ldflda opcode, 724

ldnull opcode, 307

ldstr opcode, 106

Length property, 80

lexical scope, 729

libraries

consuming workflow, 1162–1164

of extension, 492–494

isolating workflows into

arguments, defining, 1155–1156

assemblies, importing, 1155

Assign activity, 1157

Code activity, 1159–1161

defining project, 1153–1154

If activity, 1157–1158

namespaces, importing, 1155

Switch activity, 1157–1158

variables, defining, 1156–1157

LibraryBuild.rsp file, 1626

Lightning Bolt button, 1270

lightweight class type, 19

lightweight events, 498

line geometry, 1312

Line object, 1300, 1302

Line type, 1304

linear gradient, 1308, 1342

linear interpolation animations, 1355

lines, removing from canvas, 1302–1303

LinkedListNode(Of T) type, 392

LINQ (Language Integrated Query)

to Entities, querying with, 1024–1026

to Entity queries, using navigation properties within, 1033–1034

Page 120: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1681

programming to DataSet types with, 992–997

DataSet extensions library, 994

obtaining LINQ-compatible datatables, 994–995

populating new DataTables from LINQ queries, 996–997

role of DataRowExtensions.Field(Of T)( ) Extension method, 996

queries, populating new DataTables from, 996–997

LINQ to Objects

applying LINQ queries to collection objects

accessing contained subobjects, 525–526

applying LINQ queries to nongeneric collections, 526–527

filtering data using OfType(Of T)( ), 527

applying LINQ queries to primitive arrays

extension methods, 519

implicitly typed local variables, 517–519

result set, 516

role of deferred execution, 520–521

role of immediate execution, 521–522

internal representation of LINQ query statements

building query expressions using enumerable type and anonymous methods, 540–541

building query expressions using enumerable type and lambda expressions, 538–540

building query expressions using enumerable type and raw delegates, 541–542

building query expressions with query operators, 538

LINQ specific programming constructs

anonymous types, 511

extension methods, 510–511

implicit typing of local variables, 508

lambda expressions, 509–510

object and collection initialization syntax, 509

returning result of LINQ query, 522–524

role of LINQ, 511–514

VB 2010 LINQ query operators, 527–529

VB LINQ query operators

aggregation operations, 536

basic selection syntax, 529–530

LINQ as better Venn diagramming tool, 534–535

obtaining counts using enumerable, 532

obtaining subsets of data, 530

projecting new data types, 531–532

removing duplicates, 536

reversing result sets, 533

sorting expressions, 533–534

LINQ to XML

System.Xml.Linq namespaces

LINQ to XML axis methods, 1048–1049

Page 121: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1682

XName (and XNamespace) class, 1049–1050

XElement and XDocument objects, 1050–1054

XML APIs, 1041

XML documents

building UI of LINQ to XML App, 1055–1056

defining LINQ to XML Helper class, 1057

importing Inventory.xml files, 1056

rigging up UI to Helper class, 1058–1059

LINQ-compatible datatables, obtaining, 994–995

LinqOverArray project, 522

LinqOverCollections project, 527

LinqOverDataSet example, 997

LinqRetValues project, 524

Linux operating system, executing Windows Forms application under, 1630–1631

ListBox control, 1212, 1274, 1370, 1479, 1504

ListControl type, 1479

ListDictionary type, 464

ListInventory( ) method, 918–919

List(Of T) class, 386, 389, 394–396, 509

List(Of T) variable, 709

literal attributes, 712

literal floating point data, 99

Load event, 757, 985, 1038, 1468, 1471–1473, 1528, 1542–1543, 1546, 1555, 1582, 1611

loaded assemblies

enumerating, 672–673

receiving assembly load notifications, 674

Loaded event, 1222, 1329, 1339, 1409

LoadedAssembly property, 674

loading

assemblies, into custom application domains, 677

images programmatically, 1339–1340

InkCanvas data, 1276

XML content, 1054

local variables

accessing, VB, 449–450

declaring in CIL, 718–719

mapping parameters to in CIL, 719

localized assemblies, 625

Location property, 1586

lock token, 793–794

logging support, 1128

logical model, 1006

logical resources, 1335

logical trees, WPF, 1392–1398

logical view, 1392

Login controls, 1488

LookUpPetName( ) method, 921–922

looping animation, 1359–1360

loops. See iteration constructs

Page 122: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1683

loose resources, WPF

configuring, 1337–1338

including files in project, 1337

LoseFocusStar, 1417

■M M command, 1308

machine.config file, 1552

magic numbers, 147

main menu system, 1603–1605

Main Window class, 1273

MainControl.xaml file, 1407

MainForm class, 951–952, 1038

MainMenuStrip property, 1567

MainWindow class, 1213–1214

MainWindow type, adding infrastructure to, 1607

MainWindow.g.vb file, 1198, 1214

MainWindow.xaml file, 1199–1200, 1214, 1416

Manage Help Settings tool, 68

ManagedThreadId property, 769

Manager class, 236–238

MANIFEST data, 564

MANIFEST icon, 563, 609

mapping database names to friendly names, 963

Mapping Details window, 1016–1018

mappings, viewing, 1016

markup extensions, XAML, 1211–1213

markup tags, 1488

massive numerical value, 99

master constructor, 180–182, 206

master pages

AdRotator widget, 1496–1497

bread crumbs, establishing with SiteMapPath type, 1496

TreeView control site navigation logic, 1493–1496

Master property, 1499

MasterPageFile attribute, 1498

MasterPage.master file, 1491

MathExtensions class, 495

MathLibrary project, 749

MathLibrary.dll assembly, 749

MathMessage delegate, 457

MAX_IMAGES constant, 1339

MaximumValue property, 1510

.maxstack directive, 718

MaxValue property, 96

MDI (multiple document interface) application, 1576

Me keyword

chaining constructor calls using, 178–181

and constructor flow, 181–183

hidden reference, 720

Me reference, 720

MediaPlayer type, 1322

member parameters, defining in CIL, 714–715

member shadowing, 257–259

members, specifying type parameters for, 389

Menu class, 1245

Page 123: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1684

Menu control, 1495

menu systems

building window frame using nested panels, 1245–1246

visually building, 1572–1575

MenuItem objects, 1245

Menus & Toolbars node, 1572

MenuStrip component, 647

MenuStrip control, 1572–1573

MenuStrip object, 1567

MenuStrip type, 1567

merged resource dictionaries, defining, 1349–1350

Message property, 280, 283, 289–292, 299

MessageBox class, 562, 1185

messaging activities, WF 4.0, 1140

metadata. See also type metadata

of assemblies, 15–16

interop, embedding, 754–755

viewer. See custom metadata viewer

MetaInfo window, 611

method attribute, 1465

method implementation, 11, 136, 306, 510, 718, 952

method overriding, 246, 257

method parameters and return values, custom metadata viewer, 615, 619–621

method scope, 77, 128–130, 177, 189, 304, 310, 449, 709, 714

method signatures, 1629

MethodBase object, 277, 283

MethodBase.DeclaringType property, 283

MethodInfo class, 749

MethodInfo.Name property, 615

MethodName property, 1145, 1147

methods

anonymous, VB, 447, 450

ByRef modifier, 128

custom generic, creating, 402–406

custom metadata viewer, 614–615

default parameter-passing behavior, 126–127

invoking asynchronously

passing and receiving custom state data, 777–778

role of AsyncCallback delegate, 774–776

role of AsyncResult class, 776–777

synchronizing calling thread, 772–774

invoking using named parameters, 133–135

with no parameters, invoking, 628–629

optional parameters, 132–133

<out( )> attribute, 129–130

overloading of, 135–137

ParamArry modifier, 130–131

with parameters, invoking, 629–630

shared, 184–185

MEX (metadata exchange), 1104–1105

MFC (Microsoft Foundation Classes), 2

MI (multiple inheritance)

finally blocks, 297–298

general catch statements, 295–296

Page 124: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1685

inner exceptions, 296–297

with interface types, 356–358

rethrowing, 296

Microsoft Expression Blend, 1165, 1167, 1194, 1294, 1355

Microsoft Foundation Classes (MFC), 2

Microsoft GAC, 1627, 1630

Microsoft SQL Server, 869, 874–876, 883, 885, 900, 912, 958, 1003–1004, 1551

Microsoft.Office.Interop.Excel.dll assembly, 760

Microsoft-supplied data providers, 873–875

Microsoft.VisualBasic namespace, 103

Microsoft.VisualBasic.CompilerServices class, 744

Microsoft.VisualBasic.dll assembly, role of, 743–744

Microsoft.Win32 namespace, 1232, 1255

Microsoft.WinFX.targets file, 1197

MIInterfaceHierarchy project, 358

Miscellaneous category, 1279

mnuFileExit type, 1568

Model Browser window, 1014–1015, 1032

modifiers, for methods

ByRef, 128

<out( )> attribute, 129–130

ParamArray, 130–131

Module class, 192

Module keyword, 71, 190

Module Module1, 305, 548, 1022

module option, 572

module set of process, 663–664

Module1.vb file, 76, 526, 750, 1133, 1162, 1564

ModuleBuilder type, role of, 733

module-level manifest, 12, 558, 573

modules

members of, 75–76

multiple, 73–74

not creatable, 74–75

renaming, 75

modulo statement, 455

Monitor class, 796

Mono

building .NET applications with

building console application in Mono, 1628–1630

building Mono code library, 1625–1628

building Windows Forms Client program, 1631

development languages, 1621–1622

development tools, Microsoft-compatible, 1622–1624

directory structure of, 1619–1621

further study of, 1631–1633

obtaining and installing, 1617–1621

scope of, 1616–1617

who uses, 1631

Mono GAC, installing assemblies into, 1627–1628

MonoDevelop IDE, 1622

monodis tool, viewing updated manifest with, 1626–1627

monop utility, 1624

Page 125: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1686

MonoTouch API, 38

Motorcycle class, 176, 179–181, 633

mouse activity, 1585–1588

mouse operation, 1331

MouseAndKeyboardEventsApp project, 1589

MouseButtonEventArgs, 1298, 1301–1302, 1333, 1389, 1391, 1421, 1424

MouseButtons enumeration, 1585–1586

MouseDoubleClick event, 1586

MouseDown event, 1298, 1327, 1333, 1389–1390, 1422, 1424, 1579–1580, 1587, 1609

MouseDownStar state, 1417, 1419

MouseEnter event, 1220, 1357

MouseEnterStar state, 1417, 1419

MouseEventArgs class, 1586

MouseExit event, 1245–1246

MouseExitStar state, 1419

MouseLeave event, 1421

MouseLeftButtonDown event, 1300–1301

MouseMove event, 1190–1191, 1478, 1585

MouseRightButtonDown event, 1302

MouseStateGroup, 1417–1420

MSBuild, 43, 1196

msbuild.exe, processing files with

building WPF applications using code-behind files, 1215

building WPF applications with XAML, 1196–1198

mscorlib.dll assembly, 26, 231, 300, 543

multicasting, 21, 415, 428

multicore processors, 766

multidimensional arrays, 141–143

multifile assemblies, 557–559

multifile NET assemblies, building and consuming

airvehicles.dll file, 573–574

consuming multifile assembly, 574–575

ufo.netmodule file, 573

multifile pages, compilation cycle for, 1458

multi-language, programming languages, 10

Multiline property, 1055

multiple (or zero) parameters, 456–457

multiple base classes, 230

multiple bindings, exposing single services using, 1101–1102

multiple conditions, 1369

multiple dimensions, indexers with, 466

multiple document interface (MDI) application, 1576

multiple inheritance, 230, 335

multiple sort orders, specifying, 371–372

multiple statements, processing arguments within, 454–455

multitabled DataSet objects and data relationships

building table relationships, 971

navigating between related tables, 972–974

prepping data adapters, 969–970

updating database tables, 971

MultitabledDataSetApp project, 974

Page 126: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1687

multithreaded and parallel programming

asynchronous nature of delegates, 770–771

brief review of .NET delegate, 767–769

CLR thread pool, 800–802

concurrency, 790–798

invoking methods asynchronously

passing and receiving custom state data, 777–778

role of AsyncCallback delegate, 774–776

role of AsyncResult class, 776–777

synchronizing calling thread, 772–774

parallel LINQ queries (PLINQ), 812–815

parallel programming under .NET platform

handling cancelation request, 807–808

role of Parallel class, 804

Task class, 806–807

task parallel library API, 802–804

task parallelism, 808–812

understanding data parallelism, 804–807

process/appdomain/context/thread relationship, 765–767

programmatically creating secondary threads

AutoResetEvent class, 787–788

foreground and background threads, 788–789

ParameterizedThreadStart delegate, 786

ThreadStart delegate, 784–785

programming with timer callbacks, 798–800

synchronization

using <Synchronization> attribute, 798

using System.Threading.Interlocked type, 797–798

using System.Threading.Monitor type, 796

using VB SyncLock keyword, 793–794

System.Threading namespace, 778

System.Threading.Thread class, 779–783

Name property, 782

obtaining statistics about current thread, 781

Priority property, 783

multithreading, 123, 417, 437, 653, 655, 770, 803

MultiThreadSharedData program, 796

MusicMedia enum, 630

MustInherit class, 19, 251, 253, 256, 335, 611, 613, 818, 1296

MustInherit keyword, 192, 251–252

MustInherit stream class, 834–835

MustOverride keyword, 252

MustOverride method, 195, 252–253, 255–256, 350, 409–410, 560

mutator methods, 202, 205, 207, 209

My Project dialog box, 75, 112

My Project icon, 81, 543, 587

My3DShapes namespace, 550–551

Page 127: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1688

MyApp class, adding code file for, 1214

MyApp.g.vb file, 1201, 1214

MyApp.xaml file, 1215

MyBase keyword, 238–239, 247, 268, 688, 1532

myBrush key, 1347

MyBrushesLibrary project, 1351

MyBrushes.xaml file, 1349–1351

myCar object, 305, 500–501

myCars list, 525

MyConnectionFactory project, 885

MyConnectionFactory.exe application, 884

MyCustomControl namespace, 1415

MyCustomControl project, 1415

MyEBookReader project, 812

MyEnum enumeration, 712

MyExtendableApp project, 651

MyExtensionMethods namespace, 491

MyExtensionsLibraryClient project, 494

MyExtensionsLibrary.dll assembly, 493

MyGenericDelegate(Of T), 435

MyResourceWrapper class, 320

myShapes array, 257

MyShapes namespace, 547

MyTypeViewer project, 621

MyTypeViewer.exe, 617

MyWordPad project, 1256

MyXamlPad project, 1225

■N name clashes, resolving via explicit

interface implementation of, 351–354

Name edit area, 1262

name parameter, 177

Name values, 530, 620

named arguments, 133–135, 183–184, 756, 758, 763, 1138

named parametersinvoking methods using, 133–135

named pipes, 1067

named properties, 1002, 1533

Namespace keyword, 544–545

namespaces

accessing programmatically, 29–31

custom, defining, 545

defining in CIL, 705

Microsoft root namespace, 29

nested, creating, 550–551

referencing external assemblies, 31

workflow, importing, 1155

narrowing conversion, 109, 111–112

narrowing operation, 71, 109–110

Navigate to Event Handler menu option, 1255

navigating between related tables, 972–974

Navigation node, 1488

Navigation Properties section, 1031

navigation properties, using within LINQ to Entity queries, 1033–1034

Navigation tab, 1496

Page 128: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1689

navigation-based applications, WPF and XAML, 1172

navigation-based desktop program, 1172

nested namespaces, creating, 550–551

nested panels, building window frame using

finalizing UI design, 1247–1248

menu system, 1245–1246

MouseEnter event handler, implementing, 1248–1249

MouseLeave event handler, implementing, 1248–1249

spell checking logic, implementing, 1249

StatusBar, 1247

ToolBar, 1247

nested type definitions, 243–245

.NET 4.0 visual states, 1417–1421

changing using VisualStateManager class, 1421

for StarButton control, 1418–1419

state transition timings, 1419–1420

viewing generated XAML, 1420

.NET assemblies

building with CIL, 721–726

building CILCarClient.exe, 724–726

building CILCars.dll, 721–724

<codeBase> element, 600–603

defining custom namespaces

creating nested namespaces, 550–551

resolving name clashes with aliases, 548–549

resolving name clashes with fully qualified names, 547–548

format of

CIL code, type metadata, and assembly manifest, 556–557

CLR file header, 555–556

optional assembly resources, 557

single-file and multifile assemblies, 557–559

Windows file header, 553–555

multifile, building and consuming

airvehicles.dll file, 573–574

consuming multifile assembly, 574–575

ufo.netmodule file, 573

private

configuration files and Visual Studio 2010, 579–581

configuring private assemblies, 577–579

identity of private assembly, 576

probing process, 576

publisher policy assemblies, 599–600

role of, 551–552

shared

configuring, 593–599

generating strong names at command line, 585–587

generating strong names using Visual Studio 2010, 587–588

installing strongly named assemblies to GAC, 588–589

strong names, 583–585

Page 129: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1690

viewing .NET 4.0 GAC using Windows Explorer, 589–590

single-file assembly, building and consuming

building C# client application, 570–571

building VB 2010 client application, 568–569

CIL (common intermediate language), 566–567

cross-language inheritance in action, 571–572

manifest, 563–566

type metadata, 567–568

System.Configuration namespace, 603

transforming markup into

BAML, 1200–1201

mapping application data to VB 2010 code, 1201–1202

mapping window data to VB 2010 code, 1198–1200

XAML-to-assembly process, 1202

.NET attributes

applying in VB 2010, 632–633

attribute consumers, 631–632

obsolete attribute, 634–635

specifying constructor parameters for, 634

VB 2010 attribute shorthand notation, 634

.NET exception handling, 274–277

.NET Framework 4.0 SDK (Software Development Kit)

documentation for, in Visual Studio 2010, 68–70

Visual Studio 2010 Command Prompt, 42–43

.NET platform

parallel programming under

data parallelism, 804–807

handling cancelation request, 807–808

role of Parallel class, 804

Task class, 806–807

task parallel library API, 802–804

task parallelism, 808–812

.NET properties, using for encapsulation of classes, 202–205

.NET remoting, 1064

.NET-aware programming languages, 8–10

New Connection button, 977, 1012

New Folder menu option, 1337

New keyword, and object lifetime, 306–307

New operator, and system data types, 92–93

New Project button, 1256

New Project menu, 1350, 1407, 1569

New Solution menu option, 701

NewCar class, 909

NewCarDialog.resx file, 758

newobj instruction, 306–307

newobj opcode, 726

newVersion attribute, 598

Next button, 976, 978, 1011, 1013

next object pointer, 306, 309

ngen.exe command-line tool, 15

nonabstract, 1193, 1195

Page 130: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1691

None radio button, 1030

non-ephemeral generation, 311

non-generic collections

applying LINQ queries to, 526–527

issues with

performance, 377–381

type safety, 381–385

nonnullable variable, 165

non-optional parameters, 133

nonShared class data, 185

nonshared members, 192

Notepad++ application, building Visual Studio 2010 applications with, 49–50

Nothing keyword, 408

Nothing reference, 262, 307, 343, 965

Nothing value, 165, 307, 343, 426, 801, 913

NotInheritable class, 231, 240–241, 416–418, 510, 767

NotInheritable keyword, 230–232, 241, 708

NotInheritable type, 231

NotOverridable members, 250

notserialized token, 633

null, setting object references to, 307–308

null reference exception, 215

null values, 936

nullable types, 164

?? operator, 167

If operator, 166–167

working with, 165–166

Nullable(Of T) type, 165

NullReferenceException, 288, 426

numerical conversions, 477

numerical data types, 94–95, 127, 155, 165, 432

■O obj variable, 628, 749

object (logical) resources, WPF

application-level resources, 1347–1348

changing after extraction, 1346

markup extension, 1346–1347

extracting in Expression Blend, 1352–1354

merged resource dictionaries, defining, 1349–1350

resource-only assembly, defining, 1350–1352

Resources property, 1343

markup extension, 1345

window-wide resources, defining, 1343–1345

Object Browser utility, Visual Studio 2010, 58

Object class, 263, 272

object context boundaries

context-agile and context-bound types, 681

defining context-bound object, 681–682

inspecting object's context, 682–684

object generations, 310–311

object graphs, 308, 848–849, 852

object initializer syntax

calling custom constructors with, 218–219

inner types, 220–221

Page 131: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1692

Object keyword, 263, 746, 749

object lifetime

and application roots, 308–309

classes, defined, 303–304

disposable

and finalizable blended technique, 324–327

objects, 320–323

finalizable

and disposable blended technique, 324–327

objects, 316–320

garbage collection

background (.NET 4.0), 311

concurrent (.NET 1.0 - 3.5), 311

forcing, 313–316

lazy objects, 327–331

and New keyword, 306–307

objects

defined, 303–304

generations, 310–311

references, setting to null, 307–308

references, defined, 303–304

System.GC type, 312–316

Object option, 1036

object parameters, 308, 403

object resources, 1291, 1302, 1335–1336, 1342–1343, 1347, 1349–1350, 1363, 1375

object serialization, 846–849. See also I/O and object serialization

object services, 999, 1004–1006, 1009

Object type, 855

Object variable, 260–261, 378

ObjectContext class, 1006–1008, 1019

ObjectContextApp project, 684

ObjectOverrides namespace, 266

ObjectOverrides project, 272

ObjectParameter object, 1035

ObjectQuery(Of T) object, 1025

ObjectResourcesApp project, 1351–1352, 1354

objects

adding to DataTable types, 938

arrays of, 140–141

Objects and Timeline editor, 1260, 1262, 1264, 1266, 1271, 1279, 1286, 1410–1411, 1415

Objects and Timeline window, 1260, 1278, 1320

ObjectSet(Of Car) data member, 1020

ObjectSet(Of Car) field, 1023

ObjectSet(Of Car) variable, 1008

ObjectSet(Of Car>) collection, 1026

ObjectSet(Of T) class, 1006–1008

ObtainVehicleDelegate delegate, 434

ODBC data provider, 874

OfType(Of T)( ) method, filtering data using, 527

oldVersion attribute, 598–599

OLE DB data provider, 874

On prefix, 498, 1579

OnClick attribute, 1446, 1457

OO wrapper, 625

Page 132: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1693

OOP (object-oriented programming), pillars of

encapsulation, 193–194

inheritance, 194–195

polymorphism, 195–196

Opacity property, 1358, 1572

opcodes

CIL, role of, 689

declaring local variables in CIL, 718–719

hidden Me reference, 720

mapping parameters to local variables in CIL, 719

.maxstack directive, 718

representing iteration constructs in CIL, 720–721

OpCodes class, 735

Open command, WPF, 1254–1255

OpenFileDialog type, 1611–1612

OpenRead( ) method, FileInfo class, 830

OpenText( ) method, FileInfo class, 831

OpenWrite( ) method, FileInfo class, 830–831

operation codes, 689

operational contracts, service types as, 1083

OperationCanceledException error, 808

<OperationContract( )> attributes, 1082–1083

Operator keyword, 469, 471, 480, 688

operator overloading

+= and -+, 470

binary, 468–470

comparison, 473

equality, 472–473

internal representation of, 474–475

unary, 471

Operator property, 1510

Option Strict, 109–110, 112–113, 116–117, 122, 140, 261, 739–740, 743

optional arguments, 132–133, 135, 183, 755–756, 758, 763

optional parameters, for methods, 132–133

optional/named parameters, 760

Or operator, 122

Order By operator, 533

OrderAutoDialog class, 1595

OrderAutoDialog.Designer.vb file, 1594

OrderedEnumerable type, 539

OrderID values, 890

Orders column, 1037

Orders table, 889–891, 968, 973, 988, 1007, 1033, 1128

Orientation property, 1235, 1238–1239, 1313

Other Windows menu option, 885, 1014

<out( )> attribute, 129–130

outer variables, 449, 459

outerEllipse control, 1389

outgoing HTTP response, 1468–1471

output parameters, 126, 129–130, 167, 888

Output Type setting, 1192

output variables, 129

overflow checking, 113–114

OverloadedOps project, 477

Page 133: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1694

overloading

indexer methods, 465–466

operators, 467–476

+= and -+, 470

binary, 468–470

comparison, 473

equality, 472–473

internal representation of, 474–475

unary, 471

Overridable keyword, 246–248, 254

Overridable members, 249, 270, 289, 1167, 1356, 1579

Overridable methods, 155, 247, 249–250, 255, 498, 1579

override keyword, 246–248

■P P2P (peer-to-peer) services, 1067

pacing of animation, controlling, 1358–1359

Padding property, 1244

Page class, 1468

page level themes, applying, 1518

Page objects, 1172–1173, 1203, 1477

Page type, inheritance chain of, 1464

Page_PreInit event, 1519

paging, enabling, 1502

Paint event, obtaining Graphics object with, 1600–1601

PaintEventApp project, 1603

PaintEventHandler delegate, 1600

Panel class, 1480

Panel widget, 1484

panels, WPF

enabling scrolling for, 1243–1244

nested, building window frame using

finalizing UI design, 1247–1248

menu system, 1245–1246

MouseEnter/MouseLeave event handlers, implementing, 1248–1249

spell checking logic, implementing, 1249

StatusBar, 1247

ToolBar, 1247

positioning content within

Canvas panels, 1235–1237

DockPanel panels, 1242–1243

Grid panels, 1240–1242

StackPanel panels, 1239–1240

WrapPanel panels, 1237–1239

Paragraph block, 1281

Paragraph element, 1281

Paragraph sub-block, 1280

Parallel class, role of, 804

Parallel LINQ, 507, 513, 765, 812

parallel programming. See multithreaded and parallel programming

ParallelEnumerable class, 812

ParallelOptions object, 807–808

ParamArray keyword, 125, 130, 714

ParamArray modifier, for methods, 130–131

parameter arrays, 7, 130, 167

Page 134: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1695

parameter modifier, 126, 162

parameter values, 133

parameterized command objects, 912–914

parameterized object construction, 2

parameterized queries, 879, 912, 914, 965, 1500

ParameterizedThreadStart delegate, 779, 784, 786, 789

ParameterName property, 914

parameters. See also type parameters

interfaces as, 345–347

for methods

default passing behavior, 126–127

named, 133–135

optional, 132–133

specifying using DbParameter type, 912–914

Parameters property, 879

parent class, of existing class, 228–229

parent/child relationships, 195, 933, 971

parsing XML content, 1054

Partial class, 1457–1458, 1460–1461, 1571–1572

partial class types, 224

Partial keyword, 224–225, 496–497, 1021, 1571

partial methods, 496–498

partial rollback, 925

PartialMethods project, 498

Path class, 1304, 1307, 1321

Path definition, 1317

Path settings, 1323

Path token, 1288

PATH variable, 42

Path= aspect, 1289

path-based animations, 1355

paths, converting shapes to, 1318

Patient Details button, 1170

payload, 747, 762

Pen button, 1415

Pen class, 1312

Pen tool, 1317

Pen type, 1601

Pencil control, 1415

Pencil tool, 1317, 1415

pens, configuring, 1312

PeopleCollection class, 462, 464

performance issues, non-generic collections, 377–381

persistence support, 1128

persistent cookie, 1547–1548

persisting custom objects, 1557–1559

Person class, 160, 267–269, 399

person only collection, 382

Person type, 162, 266, 850, 853

PersonCollection class, 383

PetName column, 937, 957, 963

petName field, 724

PetName property, 253, 259, 572, 1015

PetNameComparer class, 373

peverify.exe file, 703

pg41example, 41

PHP applications, 1525

Page 135: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1696

physical model, 1006, 1010, 1014, 1017–1018

PIAs (Primary Interop Assemblies), 753

Pick activity, 1139

Pick Color menu option, 1608

Pick Your Color link, 1504

PictureBox control, 1595

PID (Process Identifier), 654

PInvoke (Platform Invocation Services), 317

Place code in separate file checkbox, 1455

placeholders, 7, 62, 86, 136, 387, 391, 408, 414, 913, 1442, 1492, 1521

Platform Invocation Services (PInvoke), 317

platform-independent nature of .NET, 37–39

mainstream CLI distributions, 1615–1616

role of CLI, 1614–1615

PLINQ (parallel LINQ queries)

canceling, 814–815

opting in to, 813

PLINQDataProcessingWithCancellation project, 815

Point class, 362–364, 393, 468, 472

Point structure, 154, 157, 406–407, 470

Point type, 153, 156, 218–220, 363, 469, 472–473, 1191

Point variables, 154, 468

PointRef class, 157

Points property, 340, 342, 1304

PolyLine class, 1312

polylines and polygons, 1304

polymorphism. See also inheritance

abstract classes, 250–251

member shadowing, 257–259

NotOverridable members, 250

Overridable keyword, 246–248

pillar of OOP, 195–196

polymorphic interface, 252–257

populating

controls collection, 1565–1567

new DataTables from LINQ queries, 996–997

Portable.NET, 39

positional parameters, 134

posting back to Web servers, 1439

Predicate(Of T) delegate, 452, 509

PreInit event, 1520

PresentationCore.dll assembly, 1205

PresentationFramework.dll assembly, 1195, 1228, 1232, 1297

Preview suffix, 1390

PreviewKeyDown event, 1391

PrimAndProperCarEvents project, 446, 457

Primary Interop Assemblies (PIAs), 753

primary module, 12, 558–559, 572–573, 575

primary namespace, 1206

PrimaryKey property, 943

primitive arrays, applying LINQ queries to

extension methods, 519

implicitly typed local variables, 517–519

result set, 516

Page 136: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1697

role of deferred execution, 520–521

role of immediate execution, 521–522

primitives activities, WF 4.0, 1141

Primitives section, 1130

Printer class, 784, 790, 798

Priority property, System.Threading.Thread class, 783

private assembly, 575–576, 582, 591–592, 613, 1462

Private data, 153, 199, 217, 850–851, 864, 866

private fields, 850–851

private keys, 583

Private keyword, 192, 197, 200, 244

Private method, 758, 1281, 1283

private .NET assemblies

configuration files and Visual Studio 2010, 579–581

configuring private assemblies, 577–579

identity of private assembly, 576

probing process, 576

privatePath attribute, 579

Process Identifier (PID), 654

Process type, 661, 685

process/AppDomain/context relationship, 680

processes

interacting with under .NET platform, 656–667

controlling process startup using ProcessStartInfo class, 666–667

enumerating running processes, 658–659

investigating process's module set, 663–664

investigating process's thread set, 660–663

investigating specific process, 660

starting and stopping processes programmatically, 666

role of Windows process, 655–685

ProcessEvent event, 679

ProcessManipulator project, 668

Process.Modules property, 663

ProcessStartInfo classcontrolling process startup using, 666–667

ProcessThread Type, 663

ProcessThreadCollection collection, 660

production-ready assemblies, 1614

Profile API

accessing profile data programmatically, 1554–1556

ASPNETDB.mdf database, 1552–1553

defining user profiles within Web.config, 1553–1554

grouping profile data and persisting custom objects, 1557–1559

profile data

accessing programmatically, 1554–1556

grouping, 1557–1559

Profile property, 1553, 1555, 1558

Program class, 13, 33, 83, 260, 266, 336, 395, 405, 1185

programming languages

comparison of

C++/Microsoft Foundation Classes (MFC), 2

Page 137: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1698

Component Object Model (COM), 3–4

C/Windows application programming interface (API), 1–2

Java, 3

.NET, 4–5

Visual Basic 6.0, 2

.NET-aware, 8–10

Project menu, 53, 1349, 1589

Project node, 234, 565, 585

Project Properties, viewing with Solution Explorer Utility, 56–57

project templates, 1071–1073

Project window, 1372

Projects menu option, 1257

Projects tab, 1257, 1407

Project/Solution. menu option, 964, 986, 1292

properties

automatic

and default values, 215–217

interacting with, 214–215

custom, 373

defining in CIL, 713

and encapsulation of classes

within class definition, 206

internal representation of, 207–209

.NET, 202–205

read-only and write-only, 210–211

shared, 211–212

visibility levels of, 210

metadata viewer, custom, 615

Properties editor, 565–566, 588, 989, 1260, 1263, 1267, 1286, 1400, 1411

Properties icon, 565, 595, 1189, 1192

Properties list box, 1287

Properties page, 587

Properties tab, 1257

property editor, 1262, 1269

Property keyword, 203

Property suffix, 1292

PropertyChangedCallback delegate, 1381

PropertyCollection object, 933

property-element syntax, XAML, 1210

property-element syntaxXAML, 1209–1210

property/value pairs, 1363–1364

Proposed value, 942

Protected Friend keyword, 198

Protected Friend modifiers, 197

Protected keyword, 210

protected keyword, 239–240

Protected modifier, 197

protocols, stateless, 1428

provider value, 883, 894

proxy class, 1462

proxy code, generating

using svcutil.exe, 1094–1095

using Visual Studio 2010, 1095–1097

PTSalesPerson class, 241, 250

Public access modifier, 170

public attribute, 689

Public Button type, 1208

public fields, 850–851

Page 138: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1699

public key token, 592, 598, 625, 696, 852

public key value, 552, 584, 592, 1627

public keys, 583

Public keyword, 152, 245, 493, 568

Public member, 95, 170, 197, 229–230, 242, 351, 446, 490, 616, 638, 641, 742–745, 793

Public methods, 201, 240, 463

public point of data, 204

public properties, 850–851

publicKeyToken attribute, 602

publicKeyToken values, 602

public/private key data, 584–585, 1626

publisher policy assemblies, 599–600

■Q Q command, 922

query expressions, 118, 507, 511–514, 519–520, 524, 536–538, 542, 727, 993, 1041, 1043

query operators, 510, 512–513, 515, 526–527, 536–538, 540, 542

querying

with Entity SQL, 1026–1027

with LINQ to Entities, 1024–1026

QueryString property, 1468

Queue(Of T) class, 398–400

■R radial gradient brush, 1310

RadialGradientBrush object, 1345

RadioButton control, WPF, 1269–1271

RadioButtons, 1267, 1300, 1303

Radio.vb file, 289, 358

RaiseEvent keyword, 439, 459

Random member variable, 185

RangeValidator widget, 1510

RCW (Runtime Callable Wrapper), 752

reading

incoming cookie data, 1549

from text files, 839

read-only fields, constant field data, 222–223, 1549

ReadOnly keyword, 210

Reason property, 1147

Recent tab, 55, 563

Record Keyframe button, 1410

records

deleting, 1023

updating, 1024

Rectangle class, 220, 393, 1306

Rectangle type, 158, 356, 481, 483, 1300

Rectangle variable, 159

rectangular array, 141

redirecting users, 1470–1471

ref arguments, 8

refactoring code, Visual Studio 2010, 59–61

reference, passing reference types by, 162–163

reference count, 307–308, 752

Reference folder, 592

reference types

passing by reference, 162–163

passing by value, 160–162

Page 139: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1700

vs. value types, 156–158, 163–164

value types containing, 158–160

reference variable, 157, 272, 304, 361, 377

referencing

assemblies, 1462–1463

AutoLotDAL.dll, 1445–1457

reflection

obtaining Type reference using System.Object.GetType( ), 613

obtaining Type reference using System.Type.GetType( ), 613–614

System.Type class, 612

Reflector, exploring assemblies using, 35–36

refreshing client proxy, 1105–1107

RefTypeValTypeParams project, 163

registrating events, simplifying using Visual Studio 2010, 444–445

RegularExpressionValidator widget, 1509

Relations property, 933

relaxed delegates, 434

remoting layer, 683, 852, 943

RemotingFormat property, 948

RemoveHandler, 442–443

removing controls, dynamically, 1484

Rename option, 1571

RenamedEventHandler delegate type, 844

rendering

graphical data using GDI+

Graphics type, 1599–1600

invalidating form's client area, 1602–1603

obtaining Graphics object with Paint event, 1600–1601

System.Drawing namespace, 1598

graphical output, 1609–1610

RenderingWithShapes project, 1313, 1316

RenderingWithVisuals project, 1334

RenderTargetBitmap object, 1330

RenderTransform property, 1298, 1313, 1358

RepeatBehavior property, 1359

RepeatBehavior.Forever, 1360

RequestedColor argument, 1157

request/response cycle, 1428

RequiredFieldValidator widget, 1509

Reset Current Workspace menu option, 1261

resource system, WPF

binary resources

embedding application resources, 1340–1341

loose resources, 1337–1338

programmatically loading images, 1339–1340

object (logical) resources

application-level resources, 1347–1348

changing after extraction, 1346

markup extension, 1346–1347

extracting in Expression Blend, 1352–1354

merged resource dictionaries, defining, 1349–1350

resource-only assembly, defining, 1350–1352

Page 140: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1701

Resources property, 1343

markup extension, 1345

window-wide resources, defining, 1343–1345

ResourceDictionary object, 1343

resource-only assembly, defining, 1350–1352

Resources indexer, 1346

Resources link, 9

Resources property, 1343–1344, 1346

Resources tab, 1354

Resources view, 1373

response files, for vbc.exe, 47–49

Response property, 1468

Response.Cookies property, 1547

Result property, 1145, 1148

Results View option, 521

ret opcode, 691

retained-mode graphics, 1295–1296

rethrowing exceptions, 296

Return keyword, 77

return values

array as, 143–144

interfaces as, 348

ReturnType property, 619

reversing animation, 1359–1360

RichTextBox, 1228, 1277–1278, 1281, 1284

right-click operation, 1252

root namespace, 29

RotateTransform object, 1313, 1315, 1358

RoundButtonStyle, 1405–1406

RoundButtonTemplate, 1400–1405

round-trip engineering, 687, 692, 738

routed events, WPF

bubbling events, 1389–1390

tunneling events, 1390–1391

RoutedEventHandler delegate, 1187, 1388

routines

custom conversion, 479–481

implicit conversion, 482–483

routing strategies, 1389

row filtering, 955

RowError property, 939

rows

deleting from DataTables, 953–955

selecting based on filter criteria, 955–957

updating within DataTables, 958

RowState enumeration, 939

RowState property, 940–942

Run objects, 1281

runat="server" attribute, 1451–1452, 1516, 1527

running processes, enumerating, 658–659

runtime, deploying .NET, 37

runtime activities, WF 4.0, 1141

Runtime Callable Wrapper (RCW), 752

runtime engine, WF 4.0

hosting workflows

using WorkflowApplication class, 1136–1137

using WorkflowInvoker class, 1133–1136

Page 141: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1702

runtime exceptions, 274, 942, 996, 1142

runtime type discovery, 28, 611

rw2 object, 327

■S SAFEARRAY data type, 4

SalesPerson class, 236–237, 247, 250

Samples menu selection, 1326

sane subset, 2

satellite assemblies, 557

Save commandWPF, 1254–1255

save points, 925

SaveFileDialog type, 1611

SayHello( ) method, 736

scope, 489–490

scope ambiguity, 176–177

ScrollBar object, 1287–1288

ScrollBar value, 1290

ScrollBars property, 1055

scrolling enabling for panels, 1243–1244

ScrollViewer class, 1243

ScrollViewer.xaml file, 1243

SDK (Software Development Kit), 8, 41

Search edit box, 69

search editor, 1280

secondary threads, creating programmatically, 783–789

AutoResetEvent class, 787–788

foreground and background threads, 788–789

ParameterizedThreadStart delegate, 786

ThreadStart delegate, 784–785

SEH (structured exception handling)

application-level exceptions (System.ApplicationException), 288–289

configuring state of

Data property, 285–288

HelpLink property, 284–285

StackTrace property, 284

TargetSite property, 283

corrupted state exceptions (CSE), 300

example of

catching exceptions, 281–282

throwing general exceptions, 280

multiple exceptions

finally blocks, 297–298

general catch statements, 295–296

inner exceptions, 296–297

rethrowing, 296

.NET, 274–277

system-level exceptions (System.SystemException), 288

throws, identifying, 298

unhandled exceptions, result of, 298

Visual Studio debugger, 299–300

SELECT command, 961

Select items, 1262

Select mode, 1272–1273

Select Object editor, 1268

Select operator, 529

Select statements, 907

Select/Case statement, 123–124

Page 142: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1703

SelectCommand property, 961–962

SelectedIndex property, 1274

SelectedNodeChanged event, 1496

SelectedShape property, 1607

SelectedShape value, 1301

Selection button, 1262

selection method, 911

Selection tool, 1271, 1278

SelectionChanged event, 1271, 1371

Separator control, 1268

Sequence activity, 1143, 1156–1157

serializable token, 633

serializable types, 849–850

serialization. See also I/O and object serialization

collections of objects, 859–860

configuring objects for

public fields, private fields, and public properties, 850–851

serializable types, 849–850

DataTable/DataSet objects

in binary format, 948–949

as XML, 947

formatters

IFormatter and IRemotingFormatter interfaces, 851–852

type fidelity among formatters, 852–853

logic, implementing, 1611–1612

objects

using BinaryFormatter type, 853–855

using SoapFormatter type, 855–856

using XmlSerializer type, 857–859

server controls, 1477–1478, 1489

Server name text box, 885

Server property, 1470, 1473, 1531

servers, 1429–1430

server-side event handling, 1478

service contracts, implementing, 1122–1123

Service Library project templates

altering configuration files using SvcConfigEditor.exe, 1109–1110

building simple math services, 1107–1108

testing with WcfTestClient.exe, 1108–1109

service types, as operational contracts, 1083

Service Website project templates, 1073

<ServiceContract( )> attributes, 1081–1082

ServiceHost type, 1087–1089

services

exposing using multiple bindings, 1101–1102

invoking asynchronously from clients, 1117–1118

testing, 1124–1125

session cookie, 1547

session data

maintaining, 1543–1547

storing in ASP.NET session state servers, 1549–1551

storing in dedicated databases, 1551

Page 143: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1704

session ID, 1533, 1544–1546

session information, 1545

Session property, 1525, 1543

session state

handling web application shutdown, 1538

maintaining application-level state data, 1534–1536

modifying application data, 1536–1537

session variable, 1428, 1464, 1519–1520, 1525

<sessionState> element, role of, 1549–1551

Set block, 204, 210, 1381–1383

Set button, 1524

set method, 200, 202, 208–209, 608

set scope, 213

set_ prefix, 207, 714

setter method, 7

Setter objects, 1363–1364

Setters collection, 1364

settings, changing for bindings, 1102–1103

shadowing members, 257–259

Shadows keyword, 258–259

shallow copy, 160, 361–363, 366

Shape array, 257, 346–347

Shape class, 196, 255–256, 1297, 1312

Shape references, 257

Shape types, 343, 1321

ShapeData type, 1605–1606, 1609

ShapePickerDialog type, 1606–1607

shapes

adding rectangles, ellipses, and lines to canvas, 1299–1302

paths, 1304–1308

polylines and polygons, 1304

removing rectangles, ellipses, and lines from canvas, 1302–1303

working with using Expression Blend

brush and transformation editors, 1319–1321

combining shapes, 1318–1319

converting shapes to paths, 1318

selecting shape to render from tool palette, 1316–1317

Shapes project, 259

shared assemblies, 543, 582, 593, 604, 621, 625–626, 1630

Shared constructor, 189–190, 212, 713, 1378, 1380, 1386

shared data, 188, 790, 793

Shared keyword, 184–193

classes, 193

constructors, 190

field data, 185–188

methods, 184–185

Shared methods, 97, 185, 187, 212, 420–421, 469, 489, 611, 804, 1057, 1540, 1600

shared .NET assemblies

consuming, 591–592

generating strong names at command line, 585–587

generating strong names using Visual Studio 2010, 587–588

Page 144: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1705

installing strongly named assemblies to GAC, 588–589

strong names, 583–585

viewing .NET 4.0 GAC using Windows Explorer, 589–590

SharedAsmReflector project, 626

SharedCarLibClient, exploring manifest of, 592

SharedCarLibClient.exe.config file, 598

SharedData project, 193

SharpDevelop IDE, authoring CIL code using, 701–703

Shift+Click operation, 1269

ShoppingCart class, 1552

Short variables, 109

Show All Files button, 749, 1019, 1571

Show button, 1438

Show Errors check box, 1432

ShowInstructions( ) method, 918

ShowInTaskbar property, 1589–1590

ShowMessageBox property, 1512

ShowNumberControl.xaml, 1383

ShowSummary property, 1512

Signing tab, 587

Silverlight, WPF and, 1174

Silverlight plug-ins, 1174

simple data adapters, 961–962

simple math services, building, 1107–1108, 1443–1454

Simple Object Access Protocol (SOAP), 855

Simple Styles.xaml file, 1374

SimpleButton icon, 1373

SimpleCanvas.xaml file, 1236

SimpleClassExample project, 184

SimpleDataSet project, 937, 948

SimpleDelegate project, 424

SimpleDispose project, 324

SimpleDockPanel.xaml file, 1242

SimpleException project, 288

SimpleFileIO project, 834

SimpleFinalize project, 319

SimpleGC project, 316

SimpleGrid.xaml file, 1240

SimpleIndexer project, 464

SimpleInventory.xml file, 1055

SimpleMath class, 422–423

SimpleMath.vb, 749

SimpleMultiThreadApp project, 786

SimpleStackPanel.xaml file, 1239

SimpleVBApp project, 84

SimpleVSWinFormsApp project, 1584

SimpleWinFormsApp project, 1568

SimpleWrapPanel.xaml file, 1237

SimpleXamlApp.vbproj file, 1197

single constructor definition, 183

single file Web pages, building, 1443–1454

adding data access logic, 1446–1449

ASP.NET

control declarations, 1452–1453

directives, 1450–1451

compilation cycle for single-file pages, 1453–1454

designing UI, 1445–1446

Page 145: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1706

referencing AutoLotDAL.dll, 1445

"script" block, 1451–1452

single logical parameter, 130

single services, exposing using multiple bindings, 1101–1102

Single variable, 90

single-file assemblies

building and consuming, 559–572

building C# client application, 570–571

building VB 2010 client application, 568–569

CIL (common intermediate language), 566–567

cross-language inheritance, 571–572

manifest, 563–566

type metadata, 567–568

single-file pages, compilation cycle for, 1453–1454

single-threaded process, 655

SiteMap icon, 1496

SiteMapDataSource component, 1495–1496, 1521

SiteMapDataSource instance, 1495

SiteMapPath type, establishing bread crumbs with, 1496

sitewide themes, applying, 1517–1518

.skin files, 1515–1517

SkinID property, 1518

slider bar, 1280

SMEs (subject matter experts), 1128

Snap In Module menu, 648

sn.exe utility, 584–585

SOA (service-oriented architecture), 1068–1069

SOAP (Simple Object Access Protocol), 855

Soap/Binary serialization processes, customizing

using attributes, 866

using ISerializable interface, 862–865

SoapFormatter type, 851, 855–856, 860

SocialSecurityNumber property, 210, 238

sockets, 1067

Software Development Kit (SDK), 8, 41

Solution Explorer UtilityVisual Studio 2010, 54, 57

sort types, custom, 373

SortedSet(Of T) class, 400–402

source files, compiling multiple with vbc.exe, 46–47

Source property, 1325, 1330, 1336, 1339, 1408

Source value, 1329

Space key, 444, 1205

spaghetti code, 2

specialname attribute, 713

specifying base addresses, 1086–1087

Speed property, 229, 525

spell checking logic, 1249

Spelling Hints menu item, 1246

SpellingError object, 1249

SpinControl class, 1407–1408

SpinImageStoryboard, 1410–1411, 1413–1414

splitters, 1241–1242

Page 146: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1707

SqlCommandBuilder class, using to configure data adapters, 965–966

sqlConnectionString attribute, 1551

SqlDataSource class, 1499

SqlProfileProvider, 1553

SqlTransaction object, 925, 928

Square class, 482, 546, 548, 550–551

Square types, explicit conversions for, 482

stack-allocated integer, 380

stack-based data, 380–381

Stack(Of T) class, 397–398, 690

StackPanel control, 1239, 1392

StackPanel layout manager, 1343

StackPanel panels, 1239–1240

stackTemplatePanel, 1396

StackTrace documents, 284

star shaped button, 1392

StarButton control, .NET 4.0 visual states for, 1418–1419

Start icon, 1143

StartPosition property, 1590

Startup event, 1184–1186, 1188

StartupEventHandler delegate, 1185

StartupUri property, 1201

state data, maintaining application-level, 1534–1536

state management techniques. See ASP.NET state management techniques

state of exceptions, configuring

Data property, 285–288

HelpLink property, 284–285

StackTrace property, 284

TargetSite property, 283

State property, 864, 901

StateBag type, 1528

stateConnectionString attribute, 1551

stateless protocols, 1428

Statement (Sub or Function) block, 448

States tab, 1418–1419

static assemblies, 727

static attribute, 712

markup extension, 1345

StatusBar, building window frame using nested panels, 1247

sticky notes, 1282–1284

stloc.0 opcode, 307, 691

storage, for enum type, 147

Stored Procedure Name dropdown box, 1030

stored procedures, invoking using generated codes, 992

Stored Procedures node, 888

storing session data

in ASP.NET session state servers, 1549–1551

in dedicated databases, 1551

storyboards, 1417

authoring animation in XAML, 1361

programmatically starting, 1413–1414

Storyboard.TargetProperty value, 1363

stream wrappers, 835

Stream-derived type, 817, 834, 836, 842–843, 848, 854–855, 867, 947, 1223

Page 147: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1708

StreamingContext type, 864

streamlined syntax, 217

StreamReaders class, 837–840

directly creating types, 840

reading from text files, 839

writing to text files, 838

StreamWriterReaderApp project, 840

StreamWriters class

directly creating types, 840

reading from text files, 839

writing to text files, 838

String argument, 132–133, 735

String array, 81, 101, 138, 514, 538–539, 806, 809–810, 1148

String class, 106, 231, 269

String data

basic manipulation, 101–102

concatenation, 102–103

escape characters, 103–104

parsing values from, 97

strings and equality, 104–105

strings are immutable, 105–106

System.Text.StringBuilder type, 106–107

String keyword, 69

string literals, documenting, 610

String Member variable, emitting, 734–735

String objects, 100, 104–106, 269, 467, 532, 810, 864, 1054, 1148, 1534

string parameter, 238, 585, 613

String type, 105–106, 134, 435, 467, 724, 818, 835, 909, 911, 972, 1149, 1525

String values, 464–465, 819

String variable, 101–102, 128, 269, 291, 734, 809, 964, 1145, 1393, 1523–1524

StringAnimationUsingKeyFrames class, 1363

StringAnimation.xaml file, 1362

stringArray variable, 139

StringIndexer project, 465

String.Length property, 122

StringReaders class, 840–841

StringWriters class, 840–841

Stroke property, 1323, 1415

StrokeCollection object, 1272

Strokes property, 1272

StrokeThickness property, 1419

strong names

generating at command line, 585–587

generating using Visual Studio 2010, 587–588

installing strongly named assemblies to GAC, 588–589

strongly typed data

adapters, 984–985

implicitly typed local variables as, 117

strongly typed database code

DataRows, 983

DataSets, 980–982

DataTables, 982

deleting data with generated codes, 991

inserting data with generated codes, 990–991

invoking stored procedure using generated codes, 992

Page 148: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1709

selecting data with generated codes, 989–990

viewing generated codes, 988–989

StronglyTypedDataSetConsoleClient project, 992

Structure keyword, 19, 152

structure types

Common Type System (CTS), 19

creating variables, 153–154

structured exception handling, 111, 262, 273–275, 277, 300, 302, 342, 909, 1473

structures

defining in CIL, 708

generic, specifying type parameters for, 387–388

stub code, 1607

Style class, 1364

style inheritance, 1364

Style object, 1364, 1368

Style property, 1364–1365, 1367–1368, 1406

Style resource, 1367

style sheets, 1514

styles, WPF

animated, 1369–1370

applying, 1364–1365

assigning programmatically, 1370–1371

defining

with multiple triggers, 1369

with triggers, 1368

generating with Expression Blend, 1371–1375

incorporating control templates into styles, 1405–1406

overriding settings, 1365

subclassing existing, 1366–1367

unnamed, 1367–1368

sub opcode, 718

subdirectories, creating with DirectoryInfo type, 823–824

subject matter experts (SMEs), 1128

Submit button, 1465, 1511

subset variable, 517

Suggestions property, 1249

summaries, creating, 1511–1512

summary pane, 1511

Summary window, 231

Sun Microsystems, 1614

SuSe Linux, 1630–1631

.svc files, 1123

SvcConfigEditor.exe utility, altering configuration files using, 1109–1110

svcutil.exe file, generating proxy code using, 1094–1095

Swap Panes button, 1218

Switch activity, 1157

Switch editor, 1158

Switch<T> activity, 1157

SyncDelegateReview project, 770

synchronization

thread synchronization, role of, 767

using <Synchronization> attribute, 798

using System.Threading.Interlocked type, 797–798

Page 149: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1710

using System.Threading.Monitor type, 796

using VB SyncLock keyword, 793–794

<Synchronization> attribute, synchronization using, 798

synchronous blocking manner, 1133

SyncLock keyword, synchronization using, 793–794

SyncLock scope, 794, 796

SyncLock statement, 796–797

syntax folding, 49

system data types

class hierarchy, 93–95

enum type

declaring variables, 147–148

discovering name/value pairs of, 149–151

System.Enum type, 148–149

underlying storage for, 147

and new operator, 92–93

nullable types

?? operator, 167

If operator, 166–167

working with, 165–166

numerical data types, 95

parsing values from string data, 97

reference types

passing by reference, 162–163

passing by value, 160–162

structure type, 152–154

System.Boolean, 96

System.Char, 96–97

System.DateTime, 98

System.Enum type, 148–149

System.Numerics, 98–100

System.Text.StringBuilder, 106–107

System.TimeSpan, 98

value types

containing reference types, 158–160

vs. references types, 156–158, 163–164

variable declaration, 91

system exceptions, 288

System namespace, 22, 27, 29, 71, 77, 89–90, 98, 114, 124, 150, 164, 184, 231, 288, 329, 335, 537, 668, 771, 1212, 1450

System. Web.UI.TemplateControl class, 1464

System.Action(Of T) delegate, 804

System.Activator class, 627–628

System.Activities namespace, 1133

System.Activities.dll assembly, 1138

System.Activities.Statements namespace, 1138

System.AppDomain class, 668–670

System.ApplicationException class, 289

System.Array, System.Data.SqlClient.SqlConnection, 335

System.Array class, 80, 125, 144, 369, 375, 519

System.AsyncCallback delegate, 774

System.Boolean structure, 91

System.Boolean type, 96, 1212

System.Char type, 96–97

Page 150: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1711

System.Collections namespace, 269, 285–286, 359, 371–372, 375, 377, 382, 413, 526

System.Collections.Generic namespace

collection initialization syntax, 392–393

List(Of T) class, 394–396

Queue(Of T) class, 398–400

SortedSet(Of T) class, 400–402

Stack(Of T) class, 397–398

System.Collections.Hashtable class, 269

System.Collections.Specialized class, 377

SystemColors type, 1599

System.ComponentModel namespace, 1582

System.Configuration namespace, 543, 603, 883–884, 894, 970

System.Configuration.AppSettingsReader type, 603

System.Configuration.dll assembly, 894

System.Console class

basic input and output with, 85–86

formatting numerical data, 86–88

formatting output, 86

System.Console type, 45, 837

System.Convert class, 114

System.Core.dll assembly, 516, 747

System.Data namespace, types

IDataReader and IDataRecord interfaces, 880–881

IDbCommand interface, 878–879

IDbConnection interface, 878

IDbDataAdapter and IDataAdapter interfaces, 880

IDbDataParameter and IDataParameter interfaces, 879–880

IDbTransaction interface, 878

System.Data.Common namespace, 871, 892–894, 897, 963

System.Data.DataSetExtensions.dll assembly, 994

System.Data.DataTable object, 912

System.Data.EntityClient namespace, 1005, 1027

System.Data.Entity.dll assembly, 1003–1004

System.Data.Objects namespace, 1006, 1035

System.Data.Odbc namespace, 875

System.Data.OleDb namespace, 874

System.Data.OleDb types, 896

System.Data.OracleClient.dll library, 875

System.Data.SqlClient namespace, 874, 898–899, 962, 964, 969

System.DateTime type, 98

System.Diagnostics namespace, 656, 658

System.Diagnostics.Process class, 656, 666

System.Diagnostics.Process.ExitCode property, 78

System.Diagnostics.ProcessStartInfo type, 666

System.dll assembly, 817

System.Drawing namespace, 30, 1598, 1606

System.Drawing.Bitmap class, 31

System.Drawing.dll assembly, 1561, 1596

System.Drawing.Drawing2D namespace, 1601

Page 151: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1712

System.Drawing.Graphics class, 1599

System.Dynamic namespace, 747

System.Enum class, 148–149

System.Enum type, 609

System.Environment class, 82–83, 1147, 1212

System.EventArgs class, 1568

System.EventHandler class, 1568

System.EventHandler delegate, 1189, 1446, 1472, 1575–1576

System.Exception base class, 276–277

System.Exception class, 280

System.Exception.Message property, 284, 291

System.Exception.StackTrace property, 284

System.Exception.TargetSite property, 283

System.GC type, 312–316

System.IAsyncResult interface, 771

System.IComparable interface, 367

System.IO namespace, 296–297, 543, 677, 817–818, 821, 825, 836, 846, 867, 1611

System.IO.FileStream class, 322

system-level exceptions (System.SystemException), 288

System.Linq namespace, 513

System.Linq.Enumerable class, 519, 528

System.Net.Sockets namespace, 836

System.Numerics assembly, 99

System.Numerics type, 98–100

System.Numerics.dll assembly, 99

System.Object argument, 445

System.Object class

overriding System.Object.Equals( ), 268–269

overriding System.Object.GetHashCode( ), 269–270

overriding System.Object.ToString( ), 267–268

shared members of, 271–272

testing modified person class, 270–271

System.Object collections, 8

System.Object parameter, 436, 786

System.Object reference, 261, 628, 742

System.Object types, 382, 628, 1343, 1529, 1535

System.Object variables, 381, 760

System.Object.Equals( ) method, 268–269

System.Object.Finalize( )( ) method, 317–319

System.Object.GetHashCode( ) method, 269–270

System.Object.GetType( ) method, 613

System.Object.ToString( ) method, 267–268

System.OperatingSystem, System.String, 335

System.Random member variable, 185

System.Reflection namespace, 69, 485, 512, 605, 611–612, 614, 621, 625–627, 651, 672, 732, 748, 750

System.Reflection object model, 620

System.Reflection.Assembly class, 576

System.Reflection.Emit namespace, 485, 687–688, 727–728, 738

Page 152: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1713

System.Reflection.Emit.OpCodes class, 729

System.Reflection.MethodBase object, 283

System.Reflection.MethodInfo objects, 614

System.Reflection.TypeAttributes enum, 733

System.Runtime.CompilerServices namespace, 485–486, 510

System.Runtime.ExceptionServices namespace, 301

System.Runtime.InteropServices namespace, 129, 756

System.Runtime.InteropServices.Marshal type, 317

System.Runtime.Remoting.Contexts namespace., 798

System.Runtime.Remoting.Contexts.Context object, 766

System.Runtime.Serialization namespace, 861, 864, 866

<system.serviceModel> element, 1089–1090

System.String class, 107

System.Structure class, 155

System.Text namespace, 106, 809, 835

System.Text.StringBuilder class, 71, 106–107

System.Threading namespace, 416, 663, 765–767, 770, 778–779, 784, 786, 788, 793, 797, 800, 802, 806, 815, 1136, 1537

System.Threading.Interlocked typesynchronization using, 797–798

System.Threading.Monitor class, 779–783, 796

System.Threading.Tasks namespace, 803, 806, 812, 815

System.Threading.Thread class

Name property, 782

obtaining statistics about current thread, 781

Priority property, 783

System.Threading.ThreadPriority enumeration, 783

System.TimeSpan type, 98

System.Type class, 611–613, 621, 651

System.Type parameter, 614, 649

System.Type.GetType( ) method, 613–614

System.Types, 616

System.Web namespace, 32

System.Web.Caching.Cache class, 1539

System.Web.UI.HtmlControls, 1488–1489

System.Web.UI.Page class, 1464

System.Web.UI.Page type, 1532

System.Web.UI.Page.Request property, 1466

System.Web.UI.StateBag type, 1528–1529

System.Web.UI.WebControls namespace, 1452, 1477–1478, 1488

System.Windows namespace, 28, 1176, 1186, 1392

System.Windows.Annotations namespace, 1282

System.Windows.Application class, 1176, 1185

System.Windows.Controls namespace, 1228, 1232, 1234

System.Windows.Controls.ContentControl, 1179–1180

Page 153: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1714

System.Windows.Controls.Control, 1181

System.Windows.Data namespace, 1290

System.Windows.DependencyObject, 1183, 1382

System.Windows.Documents namespace, 1232, 1276

System.Windows.Forms namespace, 46, 334, 595, 784, 1057

System.Windows.Forms.ColorDialog type, 1608

System.Windows.Forms.Control class, 1577

System.Windows.Forms.DataVisualization.Charting namespace, 1562

System.Windows.Forms.dll assembly, 46, 562, 625, 696, 784, 1561–1562

System.Windows.Forms.MessageBox class, 46, 609

System.Windows.Forms.MouseEventHandler delegate, 1585

System.Windows.FrameworkElement, 1181

System.Windows.Ink namespace, 1232, 1276

System.Windows.Input.KeyEventHandler delegate, 1191

System.Windows.Input.MouseEventHandler delegate, 1190

System.Windows.Markup namespace, 1199, 1206, 1221, 1284, 1397

System.Windows.Media namespace, 1302, 1331

System.Windows.Media.Animation namespace, 1355, 1357, 1414

System.Windows.Media.Brush, 1308

System.Windows.Media.ColorConverter class, 1310

System.Windows.Media.Drawing class, 1321

System.Windows.Media.Imaging namespace, 1330, 1339

System.Windows.Media.Stretch enumeration, 1298

System.Windows.Media.Visual, 1183

System.Windows.Media.Visual class, 1183, 1327

System.Windows.Shapes namespace, 1296–1297, 1321

System.Windows.Style class, 1363

System.Windows.Threading.DispatcherObject, 1183–1184

System.Windows.UIElement, 1182

System.Windows.Window class, 1178, 1195

System.Xml DOM model, 1043

System.Xml namespaces, 512

System.Xml.dll assembly, 857, 1041

System.Xml.Linq namespaces

LINQ to XML axis methods, 1048–1049

XName (and XNamespace) class, 1049–1050

System.Xml.Serialization namespace, 851, 857–859

■T t variable, 742

tab order, configuring, 1591

Tab Order Wizard, 1592

TabControl control, 1262–1264

TabIndex value, 1592

Page 154: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1715

tabInk object, 1271

TabItem controls, 1263

table relationships

in AutoLot database, visually creating, 891–892

building, 971

TableMappings property, 880, 963

TableName property, 962

tables, navigating between related, 972–974

Tables collection, 944, 981–982

Tables node, 886–887

Tables property, 933, 980

TabOrder property, 1591

TabStop property, 1591

tag prefix, 1195, 1206–1207, 1282, 1445, 1452

Tag property, 1275

Target property, 423

TargetProperty property, 1361

TargetType attribute, applying WPF styles automatically, 1365–1366

TargetType property, 1144, 1147, 1367

Task class, 806–808

Task Parallel Library (TPL), 765, 767, 774

task parallelism, 808–812

TaskFactory object, 807

TCP-based bindings, 1078

Teenager class, 185

tempdb database, 1551

Template property, 1395, 1399–1400

markup extension, 1402–1403

templates, 1120–1121

templating services, 1181

temporary cookie, 1547–1548

TerminateWorkflow activity, 1146–1147

TestApp application, 45

TestApp class, 47

testing

ADO.NET database transactions, 928–929

modified person class, 270–271

services, 1124–1125

text files

reading to, 839

writing to, 838

Text property, 1135, 1144, 1468, 1484, 1587

TextBlock controls, 1422

TextBox control, 809, 1055, 1057–1058, 1247, 1367–1368, 1479, 1484, 1504, 1508, 1556, 1590

TextBox objects, 1368

TextBox scope, 1477

TextBox style, 1368

TextBox type, 1223, 1587

TextBoxLineDrawingVisual, 1394

TextChanged event, 1479

themes

*.skin files, 1515–1517

applying at page level, 1518

applying sitewide, 1517–1518

ASP.NET. See ASP.NET themes

assigning programmatically, 1519–1521

SkinID property, 1518

Page 155: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1716

Then area, If activity, 1157

Thickness objects, 1356

third-party data providers, obtaining, 875

Thread Local Storage (TLS), 655

Thread objects, 801

thread scheduler, 766–767, 783, 790, 793

thread set of process, 660–663

thread synchronization, role of, 767

Thread.CurrentContext property, 683, 766

Thread.CurrentThread property, 766, 781

threading primitives, 767, 1537

ThreadPool class, 800

ThreadPoolApp project, 802

ThreadPriority property, 783

ThreadStart delegate, 784–786

ThreadStats project, 783

thread-volatile operations, 767

three-letter abbreviation (TLA), 24

Throw keyword, 280, 296, 302

throwing general exceptions, 280

throws, identifying, 298

time slice, 655

Timeline area, 1260, 1265

Timeline Base class, 1356

timer callbacksprogramming with, 798–800

Timer class, 778

Timer constructor, 799

Timer types, 779

TimerApp project, 800

TimerCallback delegate, 799

TimeSpan object, 1359–1360

Title property, 1389

TLA (three-letter abbreviation), 24

TLS (Thread Local Storage), 655

To edit box, 1157

To property, 1356

token set, 689, 694

tool support, 1132

ToolBar

building window frame using nested panels, 1247

Ink API tab, WPF, 1266–1269

toolbar buttons, 1245, 1247, 1250

ToolBar class, 1247

ToolBar control, 1247, 1266, 1278

ToolBar element, 1247

ToolBar objects, 1247

ToolBar type, 1247

tools, Visual Studio 2010, 1433–1435

Tools area, 1261, 1264

Tools editor, 1260–1261

Tools menu functionality, implementing, 1608–1609

Tools window, 1261–1262, 1271

ToolStripMenuItem object, 1567

TPL (Task Parallel Library), 765, 767, 774

Trace attribute, 1459

Trace property, 1459

TraceContext object, 1465

tracing ASP.NET pages, 1458–1459

transaction activities, WF 4.0, 1141

Page 156: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1717

transaction object, 872, 877–878, 884, 924–925, 928–929

Transaction property, 928

Transform editor, 1411

Transform objects, 1312

Transform pane, 1320

transformation editors, 1319–1321

TreesAndTemplatesApp project, 1398

TreeView control site, 1493–1496

Trigger objects, 1368

triggers

defining WPF styles with, 136–139

incorporating visual cues in WPF control templates using, 1401–1402

Triggers collection, 1368

Triggers editor, 1414

Try block, 281, 293, 318, 796

TryCast keyword, 262, 343

Try/Catch block, 281, 744, 1224

Try/Finally block, 323

tunneling event, 1389–1390

txtRequiredField text box, 1509

TypDefName token, 607

Type attribute, 1510

type boundary, 552

Type class, 613

type constructors, defining in CIL, 713

type converters, XAML, 1208–1209

type fidelity among formatters, 852–853

type indexer, 380–381, 905, 939, 944, 995, 1163, 1188, 1546

type members

Common Type System (CTS), 21

defining in CIL, 712–715

type metadata

documenting referenced assemblies, 609

documenting string literals, 610

documenting the defining assembly, 609

TypeRef, 609

viewing

for Car type, 607

for EngineState enumeration, 606–607

Type Name edit area, 1145

Type object, 265, 613, 627

type parameters

constraining

examples using where keyword, 411–412

lack of operator constraints, 412–414

inference of, 405–406

specifying

for generic classes/structures, 387–388

for generic interfaces, 389–391

for generic members, 389

type safety, non-generic collections, 381–385

type system, 4, 140, 146, 737, 870, 1377

TypeAttributes enumeration, 733

TypeBuilder class, 727, 735

TypeConversions project, 115

Page 157: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1718

TypeDef #n token, 606

TypeRef, 609

TypeRef block, 609

types, directly creating, 840

■U UAC (User Access Control) settings, 589

Ufo class, 572–573

ufo.netmodule file, 573

ufo.vb file, 572

UI (user interface)

of LINQ to XML App, building, 1055–1056

rigging up to Helper class, 1058–1059

UIPropertyMetadata object, 1386

unary operator overloading, 471

unboxing operations, 378, 381

unhandled exceptions, result, 298

unloading AppDomains, programmatically, 678–680

unmanaged code, 8, 28, 276, 657, 713

unmanaged resources, 303, 312, 316–321, 324–326, 331

unnamed styles, WPF, 1367–1368

UpdateCarPetName( ) method, 921

updating

code file, 1457–1458

records, 1024

upward cast, 109

urgency level, 312

UriKind value, 1341

User Access Control (UAC) settings, 589

User Control library, 1351

user profiles, defining within Web.config, 1553–1554

UserControl class, 1374, 1377, 1379, 1426

UserControl1.xaml file, 1351

UserControls

custom, building with Blend

animation, defining, 1410–1412

programmatically starting storyboard, 1413–1414

renaming initial, 1407

SpinControl, 1408

extracting from drawing geometry, 1415–1417

user-defined collection, 120

UserName field, 76

UserShoppingCart class, 1544

UserShoppingCart type, 1545

Using scope, 323, 828–829

using statement, 570, 1457

utility classes, 184

■V Validate attribute, 1466

Validation area, 1487

validation controls

CompareValidator widget, 1510–1511

creating summaries, 1511–1512

defining groups, 1512–1514

RangeValidator widget, 1510

RegularExpressionValidator widget, 1509

Page 158: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1719

RequiredFieldValidator widget, 1509

ValidationExpression property, 1509

ValidationGroup property, 1513

ValidationSummary control, 1512

ValidatorCtrls website, 1514

value, passing reference types by, 160–162

Value property, 165, 330, 1157, 1287, 1489

value types

containing reference types, 158–160

vs. reference types, 156–158, 163–164

ValueAndReferenceTypes project, 160

ValueChanged event, 1286

Values property, 1149

ValueType class, 265

Variable Type drop down list, 1148

variables

declaration of, 91

for enum type, 147–148

local

declaring in CIL, 718–719

mapping parameters to in CIL, 719

VB, 449–450

for structure type, 153–154

workflow

defining, 1156–1157

workflow wide, 1145

XAML, declarations, 1207–1208

Variables aspect, 1145

Variables button, 1145, 1148, 1156

Variant data types, 756

VB

anonymous methods, 447–450

events

creating custom event arguments, 445–446

event keyword, 439–440

generic EventHandlerT delegate, 446–447

incoming, listening to, 442–443

registrating, simplifying using Visual Studio 2010, 444–445

LINQ query operators

aggregation operations, 536

basic selection syntax, 529–530

LINQ as better Venn diagramming tool, 534–535

obtaining counts using enumerable, 532

obtaining subsets of data, 530

projecting new data types, 531–532

removing duplicates, 536

reversing result sets, 533

sorting expressions, 533–534

literal syntax, 1044

VB 2010 compiler, 1621

VB 2010 language features

COM interoperability using, 756–763

COM interoperability without, 760–763

custom type conversions

among related class types, 478

anonymous types, 498–505

creating routines, 479–481

Page 159: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1720

explicit conversions for square types, 482

extension methods, 485–495

implicit conversion routines, 482–483

internal representation of custom conversion routines, 484

numerical, 477

partial methods, 496–498

indexer methods

definitions on interface types, 467

multiple dimensions, 466

overloading, 465–466

string values, 464–465

operator overloading

+= and +, 470

binary, 468–470

comparison, 473

equality, 472–473

internal representation of, 474–475

unary, 471

VB 2010 programming constructs

application error code, 78, 80

arrays

as arguments, 143–144

implicitly typed local, 139–140

initialization syntax, 139

multidimensional, 141–142

of objects, 140–141

as return values, 143–144

System.Array class, 144, 146

command-line arguments, 80–81

data type conversions

narrowing data conversions, 111

Option Strict, 112–113

overflow checking, 113–114

System.Convert, 114

enum type

declaring variables, 147–148

discovering name/value pairs of, 149, 151

System.Enum type, 148–149

underlying storage for, 147

If/Then/Else statement, 121–122

implicitly typed local variables, 115, 118

restrictions on, 116

as strongly typed data, 117

usefulness of, 118

iteration constructs

Do/While loop, 120–121

For Each loop, 119–120

For loop, 119

While loop, 120–121

methods

ByRef modifier, 128

default parameter-passing behavior, 126–127

invoking using named parameters, 133, 135

optional parameters, 132–133

<out( )> attribute, 129–130

overloading of, 135, 137

ParamArry modifier, 130–131

Page 160: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1721

modules

members of, 75–76

multiple, 73–74

not creatable, 74–75

renaming, 75

nullable types

?? operator, 167

If operator, 166–167

working with, 165–166

reference types

passing by reference, 162–163

passing by value, 160, 162

Select/Case statement, 123–124

string data

basic manipulation, 101–102

concatenation, 102–103

escape characters, 103–104

strings and equality, 104–105

strings are immutable, 105–106

System.Text.StringBuilder type, 106–107

structure type, 152, 154

system data types

class hierarchy, 93, 95

and new operator, 92–93

numerical data types, 95

parsing values from string data, 97

System.Boolean, 96

System.Char, 96–97

System.DateTime, 98

System.Numerics, 98, 100

System.TimeSpan, 98

variable declaration, 91

System.Console class

basic input and output with, 85–86

formatting numerical data, 86, 88

formatting output, 86

System.Environment class, 82–83

value types

containing reference types, 158, 160

vs. reference types, 156, 158, 163–164

variations on Main( ) method, 77–78

VB 2010 Snap-In, 645–646

VB Imports keyword, 30

VB Object keyword, 744

vbc.exe, building Visual Studio 2010 applications with

command line flags, 44

compiling multiple source files, 46–47

referencing external assemblies, 45–46

referencing multiple external assemblies, 46

response files, 47–49

VbCrLfconstant character, 104

VbSnapIn project, 646

vector graphics, generating using expression design, 1325

VehicleDescriptionAttribute class, 641

VehicleDescriptionAttributeReaderLateBinding project, 643

Venn diagramming, 534–535, 1319

version numbers, setting, 967

Page 161: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1722

Version type, 732

Vertical split button, 1218

VeryDynamicClass, 744–745

View Class Diagram button, 63, 234, 980

View Code menu option, 1154, 1606

View Code option, 981, 1564

View Detail link, 300

View in Browser option, 1436

View Inventory menu item, 1501

View menu, 54, 57–58, 65, 231, 545, 592, 634, 885, 988, 1217, 1499

View Source, 1527

view state

adding custom data, 1528–1529

demonstrating, 1527–1528

View Xaml button, 1236

ViewState property, 1535

virtual directories, IIS, 1429–1430

virtual execution stack, 307, 691, 716–717, 719–720

visibility trait, 21

Visible property, 1580

visual base class and derived child classes, 1327–1328

visual base class, and derived child classes, 1327–1328

Visual Basic 2010 Express, building Visual Studio 2010 applications with, 50–52

Visual class, 53, 1183

Visual Class Designer, Visual Studio 2010, 62–67

visual designer surface, 1569–1571

visual layer, rendering graphical data using

DrawingVisual class, 1328–1330

rendering to custom layout manager, 1330–1332

responding to hit test operations, 1333–1334

visual base class and derived child classes, 1327–1328

Visual Studio 2010

class diagrams, revising, 232–234

Class View utility, 57

code expansions, 61

configuration files and, 579–581

configuring brushes using, 1309–1310

generating proxy code using, 1095–1097

generating strong names using, 587–588

implementing interfaces using, 350

integrated .NET Framework 4.0 documentation, 68–70

New Project dialog box, 53–54

Object Browser utility, 58

overriding Overridable members using, 249

refactoring code, 59–61

Solution Explorer Utility, 54–57

unique features of, 53

Visual Class Designer, 62–67

WPF applications, building using, 1216–1226

Button Click event, implementing, 1223–1224

Closed event, implementing, 1224

Page 162: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1723

designer tools, 1217–1220

GUI, designing, 1221–1222

Loaded event, implementing, 1222

project templates, 1216–1217

testing, 1225–1226

WPF control templates, building custom

ContentPresenter class, 1404

incorporating into styles, 1405–1406

incorporating visual cues using triggers, 1401–1402

as resources, 1400–1401

markup extension, 1402–1403

WPF controls, 1229–1231

Visual Studio 2010 applications, 70

building with Notepad++, 49–50

building with vbc.exe

command line flags, 44

compiling multiple source files, 46–47

referencing external assemblies, 45–46

referencing multiple external assemblies, 46

response files, 47–49

building with Visual Basic 2010 Express, 50–52

building with Visual Studio 2010

Class View utility, 57

code expansions, 61

integrated .NET Framework 4.0 documentation, 68–70

New Project dialog box, 53–54

Object Browser utility, 58

refactoring code, 59–61

Solution Explorer Utility, 54–57

unique features of, 53

Visual Class Designer, 62–67

and .NET Framework 4.0 Software Development Kit (SDK), 41–43

Visual Studio debugger, 299–300

Visual Studio Windows Forms project template

initial Form, 1572

System.EventHandler delegate, 1575–1576

visual designer surface, 1569–1571

visually building menu systems, 1572–1575

visual trees, WPF, 1392–1398

Visual type, 1183, 1327–1328

Visual Web Developer 2010 Express, 50

VisualBasicCarClient project, 569

VisualBrush class, 1308

VisualChildrenCount property, 1332

VisualCollection container, 1333

VisualHit property, 1303

VisualStateGroup, 1418, 1420

VisualStateManager class, .NET 4.0 visual states, 1421

VisualTreeHelper class, 1394

void keyword, 713

Page 163: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1724

■W WaitCallback delegate, 801

WCF (Windows Communication Foundation)

addresses, bindings, and contracts (ABCs)

addresses, 1079–1080

bindings, 1076–1078

contracts, 1075

building client applications

configuring TCP-based binding, 1097–1099

generating proxy code using svcutil.exe, 1094–1095

generating proxy code using Visual Studio 2010, 1095–1097

building services

<OperationContract( )< attributes, 1082–1083

service types as operational contracts, 1083

<ServiceContract( )> attributes, 1081–1082

composition of applications, 1073–1075

core assemblies of, 1070

designing data contracts, 1119–1125

examining Web.config files, 1123

implementing service contracts, 1122–1123

role of *.svc files, 1123

testing services, 1124–1125

using Web-Centric service project templates, 1120–1121

distributed computing APIs, 1061–1067

COM+/Enterprise Services, 1063

Distributed Component Object Model (DCOM), 1062–1063

Microsoft Message Queuing (MSMQ), 1063–1064

named pipes, sockets, and P2P, 1067

.NET remoting, 1064

XML web services, 1064–1067

features, 1068

hosting services

coding against ServiceHost type, 1085–1086

enabling metadata exchange, 1090–1093

establishing ABCs within App.config files, 1084–1085

ServiceHost type, 1087–1089

specifying base addresses, 1086–1087

<system.serviceModel> element, 1089–1090

hosting services within Windows services

creating Windows service installer, 1114–1115

enabling MEX, 1113

installing Windows service, 1116

specifying ABCs in code, 1112–1113

invoking services asynchronously from clients, 1117–1118

service-oriented architecture (SOA), 1068–1069

simplifying configuration settings with WCF 4.0

Page 164: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1725

changing settings for bindings, 1102–1103

default endpoints in, 1099–1101

default MEX behavior configuration, 1104–1105

exposing single services using multiple bindings, 1101–1102

refreshing client proxy and selecting bindings, 1105–1107

using Service Library project templates

altering configuration files using SvcConfigEditor.exe, 1109–1110

building simple math services, 1107–1108

testing with WcfTestClient.exe, 1108–1109

Visual Studio project templates, 1071–1073

Web Application model, 1461

web application shutdown, handling, 1538

Web applications, 1460–1461

web controls, ASP.NET. See ASP.NET web controls

Web Form, 1444, 1455–1456, 1464, 1477–1478, 1486, 1506, 1508, 1510, 1523, 1527, 1535, 1539, 1548

Web pages

building single file

adding data access logic, 1446–1449

ASP.NET control declarations, 1452–1453

ASP.NET directives, 1450–1451

compilation cycle for single-file pages, 1453–1454

designing UI, 1445–1446

referencing AutoLotDAL.dll, 1445

"script" block, 1451–1452

building using code files, 1454–1459

Web servers, posting back to, 1439

Web site directory structure, 1461–1463

Web sites applications, 1460–1461

Web-Centric service project templates, 1120–1121

WebClient class, 809

Web.config files, 1123, 1474–1476

WebControl base class, 1485–1486

website administration utility, ASP.NET, 1475–1476

Web.sitemap file, 1494–1495

weightOfCurrentPassengers field, 633

Where clause, 530

where keyword, constraining type parameters using, 411–412

Where operator, 530

WhereSelectEnumerableIterator`2, 516–517

While loop, 119–121, 774

Widening keyword, 480, 483–484

widening operation, 71

Width property, 1242, 1269

Width value, 1237–1238

wildcard character (*), 47

wildcard token, 586

Window class

System.Windows.Controls.ContentControl, 1179–1180

System.Windows.Controls.Control, 1181

Page 165: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1726

System.Windows.DependencyObject, 1183

System.Windows.FrameworkElement, 1181

System.Windows.Media.Visual, 1183

System.Windows.Threading.DispatcherObject, 1183–1184

System.Windows.UIElement, 1182

Window construction, 1186

Window type, 1178, 1183–1184, 1186, 1194, 1221, 1224, 1245

WindowCollection type, 1177

Window-derived class, 1185, 1194

windows

closing, building WPF applications without XAML, 1189–1190

mapping data to VB 2010 code, 1198–1200

strongly typed, building WPF applications without XAML, 1186

Windows Communication Foundation, 16, 28, 605, 632, 653, 668, 817, 1041, 1617

Windows Explorer, viewing .NET 4.0 GAC using, 589–590

Windows file header, 553–555

Windows Forms

applications

completing, 985–986

executing under Linux, 1630–1631

extendable, 646–651

building applications

adding infrastructure to MainWindow type, 1563–1568

capturing and rendering graphical output, 1609–1610

implementing serialization logic, 1611–1612

implementing Tools menu functionality, 1608–1609

main menu system, 1603–1605

populating controls collection, 1565–1567

ShapeData type, 1605–1606

ShapePickerDialog type, 1606–1607

System.EventArgs and System.EventHandler, 1568

database designer tools

app.config files, 980

completing Windows Forms applications, 985–986

DataGridView control, 975–980

strongly typed data adapters, 984–985

strongly typed DataRows, 983

strongly typed DataSets, 980–982

strongly typed DataTables, 982

designing dialog boxes

configuring tab order, 1591

DialogResult property, 1590–1591

displaying dialog boxes, 1593–1594

setting form's default input button, 1592

Tab Order Wizard, 1592

understanding form inheritance, 1594–1596

Page 166: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1727

Form type

Control class, 1577–1580

Form class, 1580–1581

life cycle, 1582–1584

GUIs, binding DataTable objects to

DataView type, 958–959

deleting rows from DataTables, 953–955

hydrating DataTables from generic List(Of T), 951–953

selecting rows based on filter criteria, 955–957

updating rows within DataTables, 958

mouse and keyboard activity, 1585–1588

namespaces, 1562–1563

rendering graphical data using GDI+

Graphics type, 1599–1600

invalidating form's client area, 1602–1603

obtaining Graphics object with Paint event, 1600–1601

System.Drawing namespace, 1598

Visual Studio Windows Forms project template

initial Form, 1572

System.EventHandler delegate, 1575–1576

visual designer surface, 1569–1571

visually building menu systems, 1572–1575

Windows header information, 553

Windows services

creating installer, 1114–1115

hosting services within

creating Windows service installer, 1114–1115

enabling MEX, 1113

installing Windows service, 1116

specifying ABCs in code, 1112–1113

installing, 1116

Windows Task Manager utility, 653

Windows Workflow Foundation 4.0

activities

collection, 1142

control flow, 1138

error handling, 1142

flowchart, 1179

messaging, 1139

primitives, 1141

runtime, 1141

transaction, 1141

business process, defining, 1128

runtime engine

WorkflowApplication class, hosting workflows using, 1136–1137

WorkflowInvoker class, hosting workflows using, 1133–1136

workflows

consuming libraries, 1162–1164

flowchart, 1142–1153

isolating into dedicated libraries, 1153–1161

simple, 1129–1133

Page 167: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1728

WindowsFormsDataBinding project, 960

WindowsStartupLocation attribute, 1195

window-wide resources, defining, 1343–1345

Wizard control, 1490, 1504, 1506

Workflow Activity Library project, 1133

Workflow Console Application project, 1129, 1133

workflow designer, defining arguments using, 1134–1136

Workflow node, 1153

WorkflowApplication class, hosting workflows using, 1136–1137

WorkflowApplication.Completed event, 1141

workflow-enabled applications, 1127

WorkflowInvoker class, hosting workflows using, 1133–1136

WorkflowRuntime class, 1136

workflows

consuming libraries, 1162–1164

flowchart

activities, connecting in, 1143–1144

FlowDecision activity, 1145–1148

ForEach<T> activity, 1148, 1150

InvokeMethod activity, 1144–1145

TerminateWorkflow activity, 1146–1147

variables, workflow wide, 1145

hosting using WorkflowApplication class, 1136–1137

hosting using WorkflowInvoker class

defining arguments using workflow designer, 1134–1136

passing arguments to workflows, 1134

isolating into dedicated libraries, 1153–1161

arguments, defining, 1155–1156

assemblies, importing, 1155

Assign activity, 1157

Code activity, 1159–1161

defining project, 1153–1154

If activity, 1157–1158

namespaces, importing, 1155

Switch activity, 1157–1158

variables, defining, 1156–1157

simple, 1129–1133

WPF (Windows Presentation Foundation)

animation

Animation class types, 1355–1356

authoring in VB 2010 code, 1357–1358

authoring in XAML, 1360–1363

looping, 1359–1360

pacing of, controlling, 1358–1359

To property, 1356

By property, 1356

From property, 1356

reversing, 1359–1360

Timeline Base class, 1356

applying graphical transformations, 1312–1316

assemblies

Application class, 1176–1178

Window class, 1178–1184

Page 168: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1729

brushes

configuring in code, 1310–1311

configuring using Visual Studio 2010, 1309–1310

building using code-behind files, 1213–1215

building using only XAML

application object, defining, 1195

MainWindow class, defining, 1194–1195

processing files with msbuild.exe, 1196–1198

building using Visual Studio 2010

Button Click event, implementing, 1223–1224

Closed event, implementing, 1224

designer tools, 1217–1220

GUI, designing, 1221–1222

Loaded event, implementing, 1222

project templates, 1216–1217

testing, 1225–1226

building without XAML

application level data, interacting with, 1188–1189

closing window, 1189–1190

keyboard events, intercepting, 1191–1192

mouse events, intercepting, 1190–1191

strongly typed window, 1186

user interface, 1186–1187

commands, 1250–1255

connecting to arbitrary actions, 1252–1253

connecting to Command property, 1251–1252

intrinsic control command objects, 1250

Open command, 1254–1255

Save command, 1254–1255

control templates

custom, building with Visual Studio 2010, 1399–1406

default, 1392–1398

core controls, 1227–1229

data-binding model,1285-1294

Data Binding tab, 1286

DataContext property, 1289

DataGrid tab, 1292–1294

establishing data bindings, 1286–1292

IValueConverter interface, data conversion using, 1290–1291

dependency properties

building custom, 1383–1387

CLR property wrappers, 1382–1383

examining existing, 1379–1382

dialog boxes, 1232

document controls, 1232

Documents API

block elements, 1277

document layout managers, 1277–1278

inline elements, 1277

Documents tab, building

annotations, enabling, 1282–1284

loading FlowDocument, 1284–1285

Page 169: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1730

populating FlowDocument, 1279–1282

saving FlowDocument, 1284–1285

sticky notes, enabling, 1282–1284

Expression Blend, building user interface with

key aspects of, 1256–1262

TabControl control, 1262–1264

flavors of, 1169–1174

desktop applications, 1169–1171

navigation-based applications, 1172

WPF/Silverlight relationship, 1174

XBAP applications, 1172–1173

generating complex vector graphics using expression design, 1325–1327

Ink API tab, building

ComboBox control, 1274–1275

InkCanvas control, 1271–1276

RadioButton control, 1269–1271

ToolBar, 1266–1269

ink controls, 1231–1232

Jackpot Deluxe WPF application

extracting UserControl from drawing geometry, 1415–1417

finalizing, 1421–1426

.NET 4.0 visual states, 1417–1421

logical trees, 1392–1398

motivation behind, 1165–1169

optimized rendering model, 1168

separation of concerns via XAML, 1167

simplifying UI programming, 1168–1169

unifying APIs, 1166–1167

panels

enabling scrolling for, 1243–1244

nested, building window frame using, 1244–1249

positioning content within, 1235–1243

pens, configuring, 1312

rendering graphical data using drawings and geometries

building DrawingBrush using geometries, 1322–1323

containing drawing types in DrawingImage, 1324–1325

painting with DrawingBrush, 1323–1324

rendering graphical data using visual layer

DrawingVisual class, 1328–1330

rendering to custom layout manager, 1330–1332

responding to hit test operations, 1333–1334

visual base class and derived child classes, 1327–1328

resource system

binary resources, 1336–1341

object (logical) resources, 1342–1354

routed events, 1388–1391

shapes

adding rectangles, ellipses, and lines to canvas, 1299–1302

paths, 1304–1308

Page 170: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1731

polylines and polygons, 1304

removing rectangles, ellipses, and lines from canvas, 1302–1303

working with using Expression Blend, 1316–1321

styles

animated, 1369–1370

assigning programmatically, 1370–1371

automatically applying with TargetType, 1365–1366

defining and applying, 1364–1365

defining with multiple triggers, 1369

defining with triggers, 1368

generating with Expression Blend, 1371–1375

overriding settings, 1365

subclassing existing, 1366–1367

unnamed, 1367–1368

syntax of, 1203–1213

attached properties, 1210–1211

class and member variable declarations, controlling, 1207–1208

kaxaml, 1203–1204

kaxamlXAML XML namespaces and XAML, 1204–1207

markup extensions, 1211–1213

property-element syntax, 1209–1210

XAML elements, XAML attributes and type converters, 1208–1209

transforming markup into .NET assembly, 1198–1202

BAML, 1200–1201

mapping application data to VB 2010 code, 1201–1202

mapping window data to VB 2010 code, 1198–1200

XAML-to-assembly process, 1202

UserControls, building custom with Blend

animation, defining, 1410–1412

initial VB 2010 code, 1409

programmatically starting storyboard, 1413–1414

renaming initial, 1407

SpinControl, 1408

using Visual Studio 2010, 1229–1231

visual trees, 1392–1398

WpfAppAllCode project, 1192

WpfAppAllXaml project, 1202

WpfAppCodeFiles project, 1215

WpfControlsAndAPIs project, 1294

WPFRoutedEvents project, 1391

WpfStyles project, 1371

WrapPanel panels, 1237–1239

WriteLine activity, 1131, 1134–1135, 1142–1144, 1146–1148, 1150

WriteOnly keyword, 210

writing, to text files, 838

■X XAML (Extensible Application Markup

Language)

authoring animation in

discrete key frames, 1362–1363

event triggers, 1362

Page 171: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1732

storyboards, 1361

exporting design document to, 1326–1327

.NET 4.0 visual states, 1420

separation of concerns via, 1167

for simple workflows, 1131–1133

transforming markup into .NET assembly, 1202

WPF, syntax of, 1203, 1213

attached properties, 1210–1211

class and member variable declarations, controlling, 1207–1208

kaxaml tool, 1203–1204

markup extensions, 1211, 1213

property-element syntax, 1209–1210

type converters, 1208–1209

XAML XML namespaces, 1204, 1207

WPF applications, building using

application object, defining, 1195

MainWindow class, defining, 1194–1195

processing files with msbuild.exe, 1196, 1198

WPF applications, building without

application level data, interacting with, 1188–1189

closing window, 1189–1190

keyboard events, intercepting, 1191–1192

mouse events, intercepting, 1190–1191

strongly typed window, 1186

user interface, 1186–1187

XAML attribute, 1200, 1209, 1211, 1225

XamlAnimations folder, 1360

XamlSpecificStuff, 1206

XamlWriter class, 1226, 1284

XamlWriter type, 1221

XBAP applications (XAML browser applications), 1172–1173

XButton2 value, 1587

XContainer class, 1048

x-coordinate, 1586

Xcopy deployment, 575

XDocument objects

generating documents from arrays and containers, 1053–1054

loading and parsing XML content, 1054

XElement objects

generating documents from arrays and containers, 1053–1054

loading and parsing XML content, 1054

XML

APIs

vs. DOM models, 1043–1044

Visual Basic (VB) literal syntax, 1044

content, loading and parsing, 1054

data, 858–859

documents

building UI of LINQ to XML App, 1055–1056

defining LINQ to XML Helper class, 1057

importing Inventory.xml files, 1056

rigging up UI to Helper class, 1058–1059

Page 172: Programming with Windows Forms - Springer978-1-4302-2986-5/1.pdf · A P P E N D I X A 1561 Programming with Windows Forms Since the release of the .NET platform (circa 2001), the

■ INDEX

1733

namespaces, XAML, 1204–1207

serializing DataTable/DataSet objects as, 947

web services, 1064–1067

XML Paper Specification (XPS), 1168, 1175, 1232, 1276

XML-based grammar, 1041, 1127, 1129, 1138, 1165, 1192–1193, 1206

XmlElement class, 1043

xmlns (XML namespace) attribute, 1432

XmlSerializer type, serializing objects using, 857–859

XmlWriter class, 1041

XName class, 1049–1050

XName object, 1049

XNamespace class, 1049–1050

XPS (XML Paper Specification), 1168, 1175, 1232, 1276

■Y y-coordinate, 1586

YesOrNo variable, 1146

YourXaml.xaml file, 1223–1224

■Z zero second mark, 1410

zero-code model, 1501

zooming, 1232, 1277

z-ordering, 1313, 1593