programming with windows forms - springer link978-1-4302-2550-8/1.pdf · programming with windows...

202
A P P E N D I X A ■ ■ ■ 1511 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. 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.

Upload: phungdien

Post on 16-Apr-2018

249 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

A P P E N D I X A

■ ■ ■

1511

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.

■ 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.

Page 2: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1512

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.

• 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

Page 3: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1513

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, C# 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 Program.cs file with the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; // The minimum required windows forms namespaces. using System.Windows.Forms; namespace SimpleWinFormsApp { // This is the application object. class Program { static void Main(string[] args) { Application.Run(new MainWindow()); } } // This is the main window. class MainWindow : Form {} }

■ 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 C# code file). Double-clicking the Program.cs 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 C# file containing your code within the Solution Explorer and select the View Code option.

Page 4: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1514

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 static 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 C# compiler defaults to /target:exe. You can change this to /target:winexe (preventing the display of the command prompt) by double-clicking the Properties icon in the Solution Explorer and changing the Output Type setting to Windows Application using the Application tab.

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. class MainWindow : Form { public MainWindow() {} public MainWindow(string title, int height, int width) { // Set various properties from the parent classes. Text = title; Width = width; Height = height;

Page 5: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1515

// Inherited method to center the form on the screen. CenterToScreen(); } }

You can now update the call to Application.Run(), as follows: static void Main(string[] args) { Application.Run(new MainWindow("My Window", 200, 300)); }

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).

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().

Page 6: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1516

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: class MainWindow : Form { // Members for a simple menu system. private MenuStrip mnuMainMenu = new MenuStrip(); private ToolStripMenuItem mnuFile = new ToolStripMenuItem(); private ToolStripMenuItem mnuFileExit = new ToolStripMenuItem(); public MainWindow(string title, int height, int width) { ... // Method to create the menu system. BuildMenuSystem(); } private void BuildMenuSystem() { // Add the File menu item to the main menu. mnuFile.Text = "&File"; mnuMainMenu.Items.Add(mnuFile); // Now add the Exit menu to the File menu. mnuFileExit.Text = "E&xit"; mnuFile.DropDownItems.Add(mnuFileExit); mnuFileExit.Click += (o, s) => Application.Exit(); // Finally, set the menu for this Form. Controls.Add(this.mnuMainMenu); MainMenuStrip = this.mnuMainMenu; } }

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

Page 7: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1517

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 static 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

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: mnuFileExit.Click += (o, s) => { MessageBox.Show(string.Format("{0} sent this event", o.ToString())); Application.Exit(); };

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 static readonly EventArgs Empty; static EventArgs(); public EventArgs(); }

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

Page 8: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1518

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 C# code; there is nothing magical about them whatsoever.

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

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

Page 9: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1519

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).

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 10: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1520

■ 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.cs icon and select the Rename option. Name this initial window to something more fitting: MainWindow.cs. 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 Before you build your menu system, you need to examine exactly what Visual Studio 2010 has created by default. Right-click the MainWindow.cs icon from the Solution Explorer window and select View Code. Notice that the form has been defined as a partial type, which allows a single type to be defined within multiple code files (see Chapter 5 for more information about this). Also, note that the form’s constructor makes a call to a method named InitializeComponent() and your type is-a Form: namespace SimpleVSWinFormsApp { public partial class MainWindow : Form { public MainWindow() { InitializeComponent(); } } }

As you might be expecting, InitializeComponent() is defined in a separate file that completes the

partial class definition. As a naming convention, this file always ends in .Designer.cs, preceded by the name of the related C# file containing the Form-derived type. Using the Solution Explorer window, open your MainWindow.Designer.cs file. Now, ponder the following code (this snippet strips out the code comments for simplicity; your code might differ slightly, based on the configurations you did in the Properties window): partial class MainWindow { private System.ComponentModel.IContainer components = null; protected override void Dispose(bool disposing) { if (disposing && (components != null)) {

Page 11: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1521

components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { this.SuspendLayout(); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(422, 114); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } }

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

the Visual Studio designer tools. However, notice that the InitializeComponent() is present and accounted for. Not only is this method invoked by a form’s constructor at runtime, Visual Studio 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 void InitializeComponent() { ... this.Opacity = 0.8; }

For all practical purposes, you should ignore the *.Designer.cs 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.

Dissecting the Program Class Beyond providing implementation code for an initial Form-derived type, the Windows Application project types also provide a static class (named Program) that defines your program’s entry point, Main(): static class Program {

Page 12: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1522

[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainWindow()); } }

The Main() method invokes Application.Run() and a few other calls on the Application type to

establish some basic rendering options. Last but not least, note that the Main() method has been adorned with the [STAThread] attribute. This informs the runtime that if this thread happens to create any classic COM objects (including legacy ActiveX UI controls) during its lifetime, the runtime must place these objects in a COM-maintained area termed the single-threaded apartment. In a nutshell, this ensures that the COM objects are thread-safe, even if the author of a given COM object did not explicitly include code to ensure this is the case.

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).

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.

Page 13: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1523

Figure A-8. The inline menu editor

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.cs) 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 14: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1524

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 partial class MainWindow : Form { public MainWindow() { InitializeComponent(); CenterToScreen(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } }

If you so desire, you can take a quick peek at InitializeComponent(), where the necessary event riggings have also been accounted for: this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);

At this point, you probably feel more comfortable moving around the IDE when building Windows

Forms applications. While there are obviously many additional shortcuts, editors, and integrated code wizards, this information is more than enough for you to press onward.

Page 15: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1525

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

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.

Page 16: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1526

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

Parent Class Meaning in Life

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.

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.

Page 17: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1527

Table A-3. Core Properties of the Control Type (continued)

Property Meaning in Life

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 static 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 static 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.

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.

Page 18: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1528

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 virtual methods is the default event handler for its respective event. If you override any of these virtual 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 partial class MainWindow : Form { protected override void OnMouseDown(MouseEventArgs e) { // Add custom code for MouseDown event here. // Call parent implementation when finished. base.OnMouseDown(e); } }

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 C# event syntax (in fact, this is the default behavior of the Visual Studio designers). When you handle events in 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:

Page 19: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1529

public partial class MainWindow : Form { public MainWindow() { ... MouseDown += new MouseEventHandler(MainWindow_MouseDown); } private void MainWindow_MouseDown(object sender, MouseEventArgs e) { // Add code for MouseDown event. } }

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 20: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1530

Table A-5. Properties of the Form Type (continued)

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 21: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1531

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. As you have seen, 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.

This snippet updates your form’s constructor and handles the Load, Activated, Deactivate, FormClosing, and FormClosed events (you might recall from Chapter 11 that the IDE will autogenerate the correct delegate and event handler when you press the Tab key twice after typing +=): public MainWindow() {

Page 22: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1532

InitializeComponent(); // Handle various lifetime events. FormClosing += new FormClosingEventHandler(MainWindow_Closing); Load += new EventHandler(MainWindow_Load); FormClosed += new FormClosedEventHandler(MainWindow_Closed); Activated += new EventHandler(MainWindow_Activated); Deactivate += new EventHandler(MainWindow_Deactivate); }

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 partial class MainWindow : Form { private string lifeTimeInfo = ""; ... }

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 void MainWindow_Load(object sender, System.EventArgs e) { lifeTimeInfo += "Load event\n"; } private void MainWindow_Activated(object sender, System.EventArgs e) { lifeTimeInfo += "Activate event\n"; } private void MainWindow_Deactivate(object sender, System.EventArgs e) { lifeTimeInfo += "Deactivate event\n"; } private void MainWindow_Closed(object sender, FormClosedEventArgs e) { lifeTimeInfo += "FormClosed event\n"; MessageBox.Show(lifeTimeInfo); }

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 void MainWindow_Closing(object sender, FormClosingEventArgs e) {

Page 23: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1533

lifeTimeInfo += "FormClosing event\n"; // Show a message box with Yes and No buttons. DialogResult dr = MessageBox.Show("Do you REALLY want to close this app?", "Closing event!", MessageBoxButtons.YesNo); // Which button was clicked? if (dr == DialogResult.No) e.Cancel = true; else e.Cancel = false; }

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 void exitToolStripMenuItem_Click(object sender, EventArgs e) { // Application.Exit(); Close(); }

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 24: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1534

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.cs (using the Solution Explorer), and handle the MouseMove event using the Properties window. These steps generate the following event handler: public partial class MainWindow : Form { public MainWindow() { InitializeComponent(); } // Generated via the Properties window. private void MainWindow_MouseMove(object sender, MouseEventArgs e) { } }

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 : EventArgs { public MouseEventArgs(MouseButtons button, int clicks, int x, int y, int delta); public MouseButtons Button { get; } public int Clicks { get; } public int Delta { get; } public Point Location { get; } public int X { get; } public int Y { get; } }

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 25: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1535

Table A-8. Properties of the MouseEventArgs Type (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 void MainWindow_MouseMove(object sender, MouseEventArgs e) { Text = string.Format("Mouse Position: {0}", e.Location); }

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: public enum MouseButtons { Left,

Page 26: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1536

Middle, None, Right, XButton1, XButton2 }

■ 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 void MainWindow_MouseDown (object sender, MouseEventArgs e) { // Which mouse button was clicked? if(e.Button == MouseButtons.Left) MessageBox.Show("Left click!"); if(e.Button == MouseButtons.Right) MessageBox.Show("Right click!"); if (e.Button == MouseButtons.Middle) MessageBox.Show("Middle click!"); }

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: public class KeyEventArgs : EventArgs { public KeyEventArgs(Keys keyData); public virtual bool Alt { get; } public bool Control { get; } public bool Handled { get; set; } public Keys KeyCode { get; } public Keys KeyData { get; }

Page 27: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1537

public int KeyValue { get; } public Keys Modifiers { get; } public virtual bool Shift { get; } public bool SuppressKeyPress { get; set; } }

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 void MainWindow_KeyDown(object sender, KeyEventArgs e) { Text = string.Format("Key Pressed: {0} Modifiers: {1}", e.KeyCode.ToString(), e.Modifiers.ToString()); }

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.

Figure A-14. Intercepting keyboard activity

Page 28: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1538

■ 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.cs file to MainWindow.cs 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 void exitToolStripMenuItem_Click(object sender, EventArgs e) { Close(); }

Now use the Project menu of Visual Studio to select the Add Windows Forms menu option and name your new form OrderAutoDialog.cs (see Figure A-15).

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.

Page 29: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1539

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: public enum DialogResult { Abort, Cancel, Ignore, No, None, OK, Retry, Yes }

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

controls.

Page 30: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1540

Figure A-16. The OrderAutoDialog type

Configuring the Tab Order You have created a somewhat interesting dialog box; the next step is 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: // 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).

Page 31: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1541

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 as follows (you can establish this same setting using the Properties window): public partial class OrderAutoDialog : Form { public OrderAutoDialog() { InitializeComponent(); // When the Enter key is pressed, it is as if // the user clicked the btnOK button. this.AcceptButton = btnOK; } }

■ 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.

Page 32: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1542

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 void orderAutomobileToolStripMenuItem_Click(object sender, EventArgs e) { // Create your dialog object. OrderAutoDialog dlg = new OrderAutoDialog(); // Show as modal dialog box, and figure out which button // was clicked using the DialogResult return value. if (dlg.ShowDialog() == DialogResult.OK) { // They clicked OK, so do something... } }

■ 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.

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 simply returns void).

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. However, you will receive compiler errors if you attempt to compile the following code: private void orderAutomobileToolStripMenuItem_Click(object sender, EventArgs e) { // Create your dialog object. OrderAutoDialog dlg = new OrderAutoDialog(); // Show as modal dialog box, and figure out which button

Page 33: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1543

// was clicked using the DialogResult return value. if (dlg.ShowDialog() == DialogResult.OK) { // Get values in each text box? Compiler errors! string orderInfo = string.Format("Make: {0}, Color: {1}, Cost: {2}", dlg.txtMake.Text, dlg.txtColor.Text, dlg.txtPrice.Text); MessageBox.Show(orderInfo, "Information about your order!"); } }

The reason you get compiler errors is that Visual Studio 2010 declares the controls you add to the

Forms designer as private member variables of the class! You can verify this fact by opening the OrderAutoDialog.Designer.cs file.

While a prim-and-proper dialog box might preserve encapsulation by adding public properties to get and set the values within these text boxes, you can take a shortcut and redefine them by using the public keyword. To do so, select each TextBox on the designer, and then set the Modifiers property of the control to Public using the Properties window. This changes the underlying designer code: partial class OrderAutoDialog { ... // Form member variables are defined within the designer-maintained file. public System.Windows.Forms.TextBox txtMake; public System.Windows.Forms.TextBox txtColor; public System.Windows.Forms.TextBox txtPrice; }

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 public partial class ThreeDAboutBox : AboutBox { // Add code to render company logo... }

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.cs (see Figure A-18).

Page 34: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1544

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 35: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1545

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 void orderAutomobileToolStripMenuItem_Click(object sender, EventArgs e) { // Create the derived dialog object. ImageOrderAutoDialog dlg = new ImageOrderAutoDialog(); ... }

■ 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 36: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1546

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.

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.

Page 37: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1547

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.

Color SystemColors

The Color and SystemColors types define a number of static 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 an abstract 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 static 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 float, respectively.

Page 38: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1548

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

Type Meaning in Life

Rectangle RectangleF

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

Size SizeF

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

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.

Table A-12. Select Members of the Graphics Class

Method Meaning in Life

FromHdc() FromHwnd() FromImage()

These static 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.

Page 39: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1549

Table A-12. Select Members of the Graphics Class (continued)

Method Meaning in Life

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.cs file to MainWindow.cs, and then handle the Paint event using the Properties window. This creates the following stub code: public partial class MainWindow : Form { public MainWindow() { InitializeComponent(); } private void MainWindow_Paint(object sender, PaintEventArgs e) { // Add your painting code here! } }

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 void MainWindow_Paint(object sender, PaintEventArgs e) { // Get the graphics object for this Form. Graphics g = e.Graphics; // Draw a circle. g.FillEllipse(Brushes.Blue, 10, 20, 150, 80);

Page 40: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1550

// 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 (Pen p = new Pen(Color.YellowGreen, 10)) { g.DrawLine(p, 80, 4, 200, 200); } }

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.

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.

Page 41: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1551

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 partial class MainForm: Form { ... private void MainForm_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; // Render the correct image here. } private void GetImageFromDialog() { // Show dialog box and get new image. // Repaint the entire client area. Invalidate(); } }

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 void UpdateUpperArea() { Rectangle myRect = new Rectangle(0, 0, 75, 150); Invalidate(myRect); }

■ 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

Page 42: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1552

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.cs file to MainWindow.cs. 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).

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).

Figure A-23. The Tools Menu System

Page 43: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1553

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 void exitToolStripMenuItem_Click(object sender, EventArgs e) { Close(); }

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 C# automatic properties (see Chapter 5 for more details on how to do this). Begin by adding a new class to your project named ShapeData.cs and implementing this type as follows: [Serializable] class ShapeData { // The upper left of the shape to be drawn. public Point UpperLeftPoint { get; set; } // The current color of the shape to be drawn. public Color Color { get; set; } // The type of shape. public SelectedShape ShapeType { get; set; } }

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, so be sure to import this namespace into your code file. 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.

Page 44: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1554

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. Within the MyPaintProgram namespace, define an enumeration (named SelectedShape) that defines names for each possible shape: public enum SelectedShape { Circle, Rectangle }

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 partial class ShapePickerDialog : Form { public SelectedShape SelectedShape { get; set; } public ShapePickerDialog() { InitializeComponent(); } private void btnOK_Click(object sender, EventArgs e) { if (radioButtonCircle.Checked) SelectedShape = SelectedShape.Circle; else

Page 45: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1555

SelectedShape = SelectedShape.Rectangle; } }

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<T> (where T is of type ShapeData): public partial class MainWindow : Form { // Current shape / color to draw. private SelectedShape currentShape; private Color currentColor = Color.DarkBlue; // This maintains each ShapeData. private List<ShapeData> shapes = new List<ShapeData>(); ... }

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: private void MainWindow_Paint(object sender, PaintEventArgs e) { } private void MainWindow_MouseDown(object sender, MouseEventArgs e) { }

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 void pickShapeToolStripMenuItem_Click(object sender, EventArgs e) { // Load our dialog box and set the correct shape type. ShapePickerDialog dlg = new ShapePickerDialog(); if (DialogResult.OK == dlg.ShowDialog()) {

Page 46: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1556

currentShape = dlg.SelectedShape; } }

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 void pickColorToolStripMenuItem_Click(object sender, EventArgs e) { ColorDialog dlg = new ColorDialog(); if (dlg.ShowDialog() == DialogResult.OK) { currentColor = dlg.Color; } }

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.

Figure A-25. The stock ColorDialog type

Finally, you implement the Tools ➤ Clear Surface menu handler so it empties the contents of the List<T> member variable and programmatically fires the Paint event using a call to Invalidate(): private void clearSurfaceToolStripMenuItem_Click(object sender, EventArgs e) { shapes.Clear(); // This will fire the paint event. Invalidate(); }

Page 47: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1557

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<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<T> type, based on the user-selected color, shape type, and current location of the mouse: private void MainWindow_MouseDown(object sender, MouseEventArgs e) { // Make a ShapeData type based on current user // selections. ShapeData sd = new ShapeData(); sd.ShapeType = currentShape; sd.Color = currentColor; sd.UpperLeftPoint = new Point(e.X, e.Y); // Add to the List<T> and force the form to repaint itself. shapes.Add(sd); Invalidate(); }

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

private void MainWindow_Paint(object sender, PaintEventArgs e) { // Get the Graphics object for this window. Graphics g = e.Graphics; // Render each shape in the selected color. foreach (ShapeData s in shapes) { // Render a rectangle or circle 20 x 20 pixels in size // using the correct color. if (s.ShapeType == SelectedShape.Rectangle) 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); } }

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).

Page 48: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1558

Figure A-26. MyPaintProgram in action

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<T> itself is serializable), you can quickly save out the current graphical data using the Windows Forms SaveFileDialog type. Begin by updating your using directives to specify you are using the System.Runtime.Serialization.Formatters.Binary and System.IO namespaces: // For the binary formatter. using System.Runtime.Serialization.Formatters.Binary; using System.IO;

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

private void saveToolStripMenuItem_Click(object sender, EventArgs e) { using (SaveFileDialog saveDlg = 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<T>. if (saveDlg.ShowDialog() == DialogResult.OK) { Stream myStream = saveDlg.OpenFile(); if ((myStream != null)) { // Save the shapes!

Page 49: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1559

BinaryFormatter myBinaryFormat = new BinaryFormatter(); myBinaryFormat.Serialize(myStream, shapes); myStream.Close(); } } } }

The File ➤ Load event handler opens the selected file and deserializes the data back into the List<T>

member variable with the help of the Windows Forms OpenFileDialog type: private void loadToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog openDlg = new OpenFileDialog()) { openDlg.InitialDirectory = "."; openDlg.Filter = "Shape files (*.shapes)|*.shapes"; openDlg.RestoreDirectory = true; openDlg.FileName = "MyShapes"; if (openDlg.ShowDialog() == DialogResult.OK) { Stream myStream = openDlg.OpenFile(); if ((myStream != null)) { // Get the shapes! BinaryFormatter myBinaryFormat = new BinaryFormatter(); shapes = (List<ShapeData>)myBinaryFormat.Deserialize(myStream); myStream.Close(); Invalidate(); } } } }

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).

Page 50: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX A ■ PROGRAMMING WITH WINDOWS FORMS

1560

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 51: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

A P P E N D I X B

■ ■ ■

1561

Platform-Independent .NET

Development with Mono

This appendix introduces you to the topic of cross-platform C# 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 52: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1562

■ 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 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 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 53: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1563

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 (http://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 54: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1564

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.dotgnu.org 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 C# 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. At the time of this writing, Mono is compatible with C# 2008 (work on the new C# 2010 language features are in development as I type) and .NET 2.0. This means you can build ASP.NET websites, Windows Forms applications, database-centric applications using ADO.NET, and (of course) simple console applications.

Page 55: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1565

Currently, Mono is not completely compatible with the new features of C# 2010 (e.g., optional arguments and the dynamic keyword) 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 C# 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 C# 2010 language features and .NET 3.5-4.0 platform features.

In addition to keeping-step with Microsoft’s core .NET APIs and C# 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 C# 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 C#, Mono also provides support for a Visual Basic 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 56: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1566

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 C# 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 57: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1567

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.4.2.3; however, your version number will almost certainly be different). Beneath that root, you can find several subdirectories (see Figure B-3).

Page 58: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1568

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 C# 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

If all is well, you should see various details regarding the Mono runtime environment. Here is the

output on my Mono development machine:

Page 59: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1569

Mono JIT compiler version 2.4.2.3 (tarball) Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC: Included Boehm (with typed GC) 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:

• mcs: The Mono C# compiler

• vbnc: The Mono Visual Basic .NET compiler

• booc: The Mono Boo language compiler

• ilasm: The Mono CIL compilers

While this appendix focuses only on the C# compilers, you should keep in mind that the Mono project does ship with a Visual Basic compiler. While this tool is currently under development, 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 C# Compiler The C# compiler for the Mono project was mcs, and it’s fully compatible with C# 2008. Like the Microsoft C# command-line compiler (csc.exe), mcs 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 mcs using the following command:

mcs -?

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).

Page 60: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1570

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.

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.

Page 61: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1571

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

Mono Utility Microsoft .NET Utility Meaning in Life

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).

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 C# 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.

Page 62: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1572

■ 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 C# 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 (); }

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 static 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 C# file (named CorLibDumper.cs):

Page 63: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1573

// CorLibDumper.cs using System; using System.Reflection; using System.IO; // Define assembly version. [assembly:AssemblyVersion("1.0.0.0")] namespace CorLibDumper { public class TypeDumper { public static bool DumpTypeToFile(string typeToDisplay) { // Attempt to load type into memory. Type theType = null; 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; } // Create local *.txt file. using(StreamWriter sw = File.CreateText(string.Format("{0}.txt", theType.FullName))) { // Now dump type to file. sw.WriteLine("Type Name: {0}", theType.FullName); sw.WriteLine("Members:"); foreach(MemberInfo mi in theType.GetMembers()) sw.WriteLine("\t-> {0}", mi.ToString()); } return true; } } }

Like the Microsoft C# compiler, Mono’s C# 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.cs) that contains the following command set:

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

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

mcs @LibraryBuild.rsp

Page 64: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1574

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

mcs /target:library /out:CorLibDumper.dll CorLibDumper.cs

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 C# 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.cs

Now recompile your assembly:

mcs @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 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

Page 65: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1575

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!

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).

Page 66: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1576

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.cs, that contains the following Program class definition:

// This client app makes use of the CorLibDumper.dll // to dump type information to a file. using System; using CorLibDumper; namespace ConsoleClientApp { public class Program { public static void Main(string[] args) { Console.WriteLine("***** The Type Dumper App *****\n"); // Ask user for name of type. string typeName = ""; Console.Write("Please enter type name: "); typeName = Console.ReadLine(); // Now send it to the helper library. if(TypeDumper.DumpTypeToFile(typeName))

Page 67: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1577

Console.WriteLine("Data saved into {0}.txt", typeName); else Console.WriteLine("Error! Can't find that type..."); } } }

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.cs

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

mcs @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).

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

Page 68: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1578

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!

Building a Windows Forms Client Program Before continuing, be sure to rename DontUseCorLibDumper.dll back to CorLibDumper.dll, so you can compile the next example. Next, create a new C# file named WinFormsClientApp.cs and save it in the same location as your current project files. This file defines two class types:

using System; using System.Windows.Forms; using CorLibDumper; using System.Drawing; namespace WinFormsClientApp { // Application object. public static class Program { public static void Main(string[] args) { Application.Run(new MainWindow()); } } // Our simple Window. public class MainWindow : Form { private Button btnDumpToFile = new Button(); private TextBox txtTypeName = new TextBox();

Page 69: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1579

public MainWindow() { // Config the UI. ConfigControls(); } private void ConfigControls() { // Configure the Form. Text = "My Mono Win Forms App!"; ClientSize = new System.Drawing.Size(366, 90); StartPosition = FormStartPosition.CenterScreen; AcceptButton = btnDumpToFile; // Configure the Button. btnDumpToFile.Text = "Dump"; btnDumpToFile.Location = new System.Drawing.Point(13, 40); // Handle click event anonymously. btnDumpToFile.Click += delegate { if(TypeDumper.DumpTypeToFile(txtTypeName.Text)) MessageBox.Show(string.Format( "Data saved into {0}.txt", txtTypeName.Text)); else MessageBox.Show("Error! Can't find that type..."); }; Controls.Add(btnDumpToFile); // Configure the TextBox. txtTypeName.Location = new System.Drawing.Point(13, 13); txtTypeName.Size = new System.Drawing.Size(341, 20); Controls.Add(txtTypeName); } } }

To compile this Windows Forms application using a response file, create a file named WinFormsClientApp.rsp, and add the following commands:

/target:winexe /out:WinFormsClientApp.exe /r:CorLibDumper.dll /r:System.Windows.Forms.dll /r:System.Drawing.dll WinFormsClientApp.cs

Now make sure this file is saved in the same folder as your example code, and supply this response

file as an argument to mcs (using the @ token):

Page 70: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1580

msc @WinFormsClientApp.rsp Finally, run your Windows Forms application using Mono:

mono WinFormsClientApp.exe Figure B-8 shows a possible test run.

Figure B-8. A Windows Forms Application Built Using Mono

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-9, 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.

Figure B-9. 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 C# 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.

Page 71: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1581

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.

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-10).

Page 72: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

APPENDIX B ■ PLATFORM-INDEPENDENT .NET DEVELOPMENT WITH MONO

1582

Figure B-10. 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.

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

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 C# 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 73: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

■ ■ ■

1583

Index

■SPECIAL CHARACTERS AND NUMERICS - (dash) symbol, 44 - operator, 445, 452 -- operator

CIL representation, 452 overloadability, 445 overloading, 449

-? option, 663 - pointer-centric operator, 479 -- pointer-centric operator, 479 - unary operator, 445 ! operator, 121 != operator, 102, 120, 163, 445, 450, 452 != pointer-centric operator, 479 # character, 47 % operator, 431, 445 <%@Assembly%> directives, 1398, 1402,

1403 %= operator, 445 %ERRORLEVEL% variable, 76 %FlowDocument> element, 1228 & (ampersand) suffix, 23, 677 & operator, 445, 482 & pointer-centric operator, 479 & symbol, 1094 && operator, 121, 506 &= operator, 445 * operator, 482

CIL representation, 452

overloadability, 445 overloading, 453

* pointer-centric operator, 479 *= operator, 445 . (dot) prefix, 655 "." notation, 779 /? flag, 565 / operator, 445 /= operator, 445 /addmodule flag, 551 /checked flag, 110, 111 /clrheader flag, 535 /connectionstring: option, 962 /debug flag, 663 /dll flag, 663 /exe flag, 664 /FalseString property, 93 /GODMODE value, 1139 /headers flag, 534 /i option, 565 /key flag, 664 /keyf option, 575 /keyfile option, 562 /l option, 565 /language: option, 962 /ldl option, 576 /main option, 74 /mode:FullGeneration option, 961 /noconfig option, 48 /nostdlib option, 45 /out flag, 44, 575, 1569 /out option, C# compiler, 44, 551

Page 74: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1584

/output flag, 664 /out:TestApp.exe flag, 48 /pluralize option, 962 /project: option, 961 /r flag, 45, 46, 48 /r option, 49 /reference flag, 45, 48, 1569 /reference option, 57 /t flag, 44 /target flag, 44, 550, 1514, 1569 /target:exe option, 44, 1514 /target:library option, C# compiler, 44 /target:module option, C# compiler, 44 /target:winexe option, 44, 1149, 1514 /t:exe flag, 44 /t:library option, 551 /u option, 565 /unsafe flag, 480 ? operator, 137 ?? operator, nullable types, 164—165 ? suffix, 162, 163 ? token, 115 [ ] (index operator), accessing items from

arrays, 439 \" escape character, 100 \\ escape character, 100 \" escape character, 101 \\ escape character, 101 \a escape character, 100 \gac directory, 1575 \Images folder, 1287 \n escape character, 101 \r escape character, 101 \SQLEXPRESS token, 854 \t escape character, 101 ^ operator, 445 ^= operator, 445 __VIEWSTATE field, 1392, 1476, 1477,

1478, 1479 __?VIEWSTATE form field, 1478 _contentLoaded member variable, 1150,

1151 _Default class, 1409, 1410 _Exception interface, 262 { and } tokens, 210

| operator, 445 || operator, 121 |= operator, 445 ~ (tilde symbol), 303 ~ operator, 445 ~/ prefix, 1446 + (plus) operator, 23, 99, 100, 1094 + (plus token), 589 + binary operator, 445, 447 + operator, 452 + pointer-centric operator, 479 + symbol, 99 + unary operator, 445 ++ operator

CIL representation, 452 overloadability, 445 overloading, 449

++ pointer-centric operator, 479 += and -+ operator overloading, 448 += operator, 408, 409

CIL representation, 452 overloadability, 445

+= syntax, 423, 428 < operator, 120, 452 < pointer-centric operator, 479 <%@Page%> directive, 1401, 1402, 1403,

1409, 1411, 1424, 1443, 1449, 1469, 1477

<<= operator, 445 << operator, 445 <= operator, 120, 445, 452 <= pointer-centric operator, 479 < operator, 445 -= operator, 422, 445, 452 =< operator, 437 == operator, 120

CIL representation, 452 overloadability, 445 overloading, 450

== operetor, 102 == pointer-centric operator, 479 => pointer-centric operator, 479 >, 445 -> operator, 484 >= operator, 120, 452

Page 75: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1585

>> operator, 445 >>= operator, 445 > operator, 120 > pointer-centric operator, 479 -> pointer-centric operator, 479 0 (integer), 1335 0x prefix, 675 0X58 opcode, 656 0X59 opcode, 656 0X73 opcode, 656 2D arrays, 443 2D geometric objects, 1246 2D graphical data, 1119, 1254 2D graphics, 1120 2D vector images, 1254, 1271 3D animation, 1118 3D functionality, 1118 3D graphical data, 1119 3D graphics, 1120 100% C# code, 1139 100% code approach, 1078 100% XAML free, 1144, 1145

■A ABCs. See addresses, bindings, and

contracts Abort( ) method, 742 About boxes, 1542, 1543 AboutToBlow event, 420, 428, 429, 430 aboutToBlowCounter integer, 429 abstract attribute, 669 abstract classes, 240, 244 abstract FileSystemInfo base class, 777—

778 abstract keyword, 188, 240, 241, 244 abstract members, 191, 241, 321, 695 abstract methods, 244 abstract stream class, 792—794 abstraction, 837 Accelerate( ) method, 265, 266, 267, 274,

277, 405, 406, 420, 425 AccelerationRatio property, Timeline class,

1305

AcceptAllChanges( ) method, 959 AcceptButton property, 1529, 1541 AcceptChanges( ) method, 888, 889, 893,

895, 896 access modifiers, 303

default, 193 and nested types, 194 overview, 192

accessing profile data programmatically, 1505—1507

accessor method, 194, 195, 196, 198, 200, 206

Accessories menu option, 43 accessors and mutators, for encapsulation

of classes, 195—197 Account property, 1065 ACID (Atomic, Consistent, Isolated,

Durable), 878 action attribute, 1384, 1390, 1417 Action<> delegate, 771 Action<T> delegate, 763, 765, 766 Activate( ) method, 1530 Activated event, 1531, 1532, 1533 Activator.CreateInstance( ) method, 601,

602, 710 Active Server Pages (ASP).NET Web

Application, 1412, 1413, 1414 Active Server Pages (ASP).NET Web page,

1412, 1414 Active Server Pages (ASP).NET Web Site,

1412, 1413 Active Template Library (ATL), 6 ActiveMDIChild property, 1529 ActiveX Data Objects (ADO), 1394, 1420 ActiveX UI controls, 1522 activities, WF 4.0, 1088—1093

collection, 1092—1093 connecting in flowchart workflow, 1094 control flow, 1089 error handling, 1092—1093 flowchart, 1089—1090 messaging, 1090—1091 primitives, 1091 runtime, 1091 transaction, 1091—1092

Page 76: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1586

Activity Library project, 1103 <Activity> element, 1082, 1104 <Activity> node, 1081 Activity1.xaml file, 1103 ActualHeight property,

FrameworkElement type, 1133 ActualWidth property, FrameworkElement

type, 1133 <Ad> element, 1448 adaptive rendering, 1389 Add another item area, 1218 Add another item button, 1217, 1230 Add another item dropdown list, 1218 Add button, 224, 226, 719 Add class menu item, 195 Add Content Page menu option, 1448,

1455 Add Existing Item menu option, 226, 273,

325, 343, 984, 986, 1242, 1448 Add Existing Item option, 277, 1358 Add Function Import menu option, 980 Add Installer option, 1064 Add Keyframe button, 1362 add mnemonic, 656 Add New Case link, 1108 Add New Diagram menu option, 846 Add New Item dialog box, 1298 Add New Item menu option, 224, 325, 531,

938, 962, 1037, 1109, 1240, 1445, 1448

Add New Item menu selection, 1442 Add New Stored Procedure option, 843 Add New Table option, 841 add opcode, 678 Add Project Data Source link, 927 Add Reference dialog box, 57, 492, 541,

546, 547, 567, 714, 715, 716, 1105 Add Reference menu option, 57, 96, 541,

547, 1072, 1364, 1513 Add References dialog box, 53, 552, 716 Add Service Reference dialog box, 1067,

1075 Add Service Reference menu option, 1043,

1047 Add State button, 1367, 1368

Add State Group button, 1367 Add Sticky Note button, 1234 Add TabItem option, 1213 Add This Car button, 1492 Add Transition button, 1369 Add UserControl menu option, 1331 Add Web Reference option, 1018 Add Windows Form menu option, 1543 Add Windows Forms menu option, 1538 add_ prefix, 421 add_AboutToBlow( ) method, 421 add_Exploded( ) method, 421 <add> elements, 578 AddChild( ) method, 1138 AddComplete( ) method, 736, 737, 738, 739 AddDefaultEndpoints( ) method, 1040,

1063 AddInventoryRow( ) method, 934 AddMemoryPressure( ) method,

System.GC class, 298 AddObject( ) method, 959, 974 .addon directive, 421 AddOne( ) method, 757 AddParams parameter, 747 AddPerson( ) method, 368 AddRange( ) method, 1515 AddRecord( ) method, 943 AddRecords( ) method, 951 AddRef( ) method, 292 Add/Remove WizardSteps link, 1455 address attribute, 1039 address element, 1037 Address group, 1507 addresses, bindings, and contracts (ABCs)

addresses, 1031—1032 bindings

HTTP-based, 1029—1030 MSMQ-based, 1031 overview, 1028 TCP-based, 1030

contracts, 1027 establishing within App.config files,

1037 specifying in code, 1062—1063

Page 77: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1587

AddServiceEndpoint( ) method, 1040, 1051, 1063

AddToCollection<T> activity, WF 4.0, 1092 AddWithThreads application, 747 AddWithThreads project, 749 Administrative Tools folder, 1066, 1500 ADO (ActiveX Data Objects), 1394, 1420 ADO.NET

abstracting data providers using interfaces, 837—840

additional namespaces, 831—832 building reusable data access library

adding connection logic, 863 adding deletion logic, 865 adding insertion logic, 863—864 adding selection logic, 866 adding update logic, 865 executing stored procedure, 869—

871 overview, 861 parameterized command objects,

867—869 connected layer of

command objects, 858 connection objects, 854—856 ConnectionStringBuilder objects,

856—857 overview, 853

creating AutoLot database authoring GetPetName( ) stored

procedure, 843 creating customers and orders

tables, 844 creating inventory table, 840—842 visually creating table relationships,

846—847 creating console UI-based front end

DeleteCar( ) method, 875 InsertNewCar( ) method, 875—876 ListInventory( ) method, 874 LookUpPetName( ) method, 876 Main( ) method, 872 overview, 871 ShowInstructions( ) method, 873 UpdateCarPetName( ) method, 876

data provider factory model <connectionStrings> element, 852—

853 complete data provider factory

example, 848—851 overview, 847 potential drawback with provide

factory model, 851—852 data providers

Microsoft-supplied, 829—830 overview, 827 system.Data.OracleClient.dll, 830—

831 third-party, obtaining, 831

data readers, 859—861 database transactions

adding CreditRisks table to AutoLot database, 879—880

adding transaction method to InventoryDAL, 880—882

key members of transaction object, 878—879

overview, 877 testing, 882—883

high-level definition of, 825—827 overview, 825 System.Data namespace, types of

IDataReader and IDataRecord interfaces, 836

IDbCommand interface, 834 IDbConnection interface, 833 IDbDataAdapter and IDataAdapter

interfaces, 835 IDbDataParameter and

IDataParameter interfaces, 834—835

IDbTransaction interface, 834 overview, 832

AdoNetTransaction application, 882 AdoNetTransaction project, 883 AdornerDecorator, 1344 adornments, 22 AdRotator control, 1439, 1444, 1447, 1448,

1449 AdRotator widget, 1447—1448

Page 78: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1588

Ads.xml file, 1447, 1448 Advanced button, 110, 1067 Advanced Properties button, 1301 Advanced properties square, 1297 Advanced Property options, 1236 AdvertisementFile property, 1447, 1448 Age property, 200, 379, 384 Aggregate<T>( ) method, 500 aggregation, 232 AirVehicles assembly, 550 AirVehicles namespace, 550 airvehicles.dll file, 551—552 al utility, Mono, 1570 alert( ) method, 1389 al.exe utility, 575, 1570 aliases, resolving name clashes with, 528—

530 AllKeys property, HttpApplicationState

type, 1484 allowAnonymous attribute, 1504 AllowDBNull property, 890, 891 AllowMultiple property, 612 allSongs object, 314 AllTracks class, 313, 315 AllTracks object, 315, 316 AllTracks variable, 314, 315 alpha, red, green and blue (ARGB), 1259 Alt key shortcut, 1197, 1516 Alt property, 1537 Alt+F shortcut, 1516 Alt+X shortcut, 1516 ALTER PROCEDURE statement, 843 altering configuration files using

SvcConfigEditor.exe, 1059—1061 AlternateText text, 1448 AlternatingRowBackground property, 1243 AlternationCount property, 1243 ampersand (&) suffix, 23, 677 Ancestors<T>( ) method, 1000 Anchor property, 1526 and opcode, 678 angle brackets, 620 Angle property, 1307 Animatable, 1272 Animate<T> parameter, 1305

animated styles, WPF, 1318 Animation classes, 1304, 1305, 1308 animation editor mode, 1360 Animation elements, 1310 Animation objects, 1308, 1309 animation services, WPF

Animation class types, 1304—1305 authoring animation in C# code, 1306—

1307 authoring animation in XAML

discrete key frames, 1311—1312 event triggers, 1310—1311 overview, 1309 storyboards, 1310

looping animation, 1308—1309 overview, 1303 pacing of animation, controlling, 1307—

1308 From property, 1305 By property, 1305 To property, 1305 reversing animation, 1308—1309 Timeline Base class, 1305

Animation token, 1304 animation tools, 1304 animations

authoring, 1304 building, 1304 defining with Expression Blend, 1359—

1363 key frame, 1304 linear interpolation, 1304 path-based, 1304 programmatically starting storyboard,

1363—1364 annotations, Documents tab, 1232—1234 AnnotationService class, 1234 AnnotationService object, 1234 AnnotationStore, 1234 anonymous methods, 9, 427—430, 763 anonymous profiles, 1507 anonymous types, 493

containing anonymous types, 478 equality for, 476—478 internal representation of, 474—475

Page 79: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1589

overview, 473 ToString( ) and GetHashCode( ), 476

AnonymousMethods project, 430 AnonymousTypes project, 474, 479 Any( ) method, 1107 API (application programming interface),

1013, 1014, 1015, 1016, 1017, 1391—1395

API (CardSpace application programming interface), 1023, 1030

API (C/Windows application programming interface), 4

API (Simple application programming interface)XML ( for Extensible Markup Language)SAX (), 993

API (Windows Application Programming Interface), 260, 285, 286, 729

API features 1.0-1.1, 1392—1393 2.0, 1393—1394 3.5 (and .NET 3.5 SP1), 1394 4.0, 1394—1395 overview, 1391

App_Browsers subdirectory, 1414 App_Code directory, 1415 App_Code folder, 1072, 1414, 1415 App_Code subdirectory, 1414 App_Data folder, 1415, 1440, 1503, 1506,

1508 App_Data subdirectory, 1414, 1503 App_GlobalResources subdirectory, 1414 App_LocalResources subdirectory, 1414 App_Theme folder, 1466, 1469 App_Themes folder, 1415, 1465, 1466, 1467 App_Themes subdirectory, 1414 App_WebReferences subdirectory, 1414 App.config file, 557, 558, 849, 852, 857, 871,

932, 984, 986, 1037 AppConfigReaderApp application, 578, 579 AppDomain shutdown, 304 AppDomain.CreateDomain( ) method, 643 AppDomain.DefineDynamicAssembly( )

method, 693 AppDomain.Load( ) method, 645 AppDomains (application domains)

creating loading assemblies into custom

application domains, 645 overview, 643—644 programmatically unloading

AppDomains, 646—648 default, interacting with, 640—643 overview, 637—639 System.AppDomain class, 638—639

AppDomains (application domains), defined, 625

Append member, FileMode enumeration, 787

AppendText( ) method, FileInfo class, 785, 789

AppExit( ) method, 1137 application cache

data caching, 1489—1491 modifying *.aspx file, 1491—1493 overview, 1488

Application class, 1138, 1139, 1144, 1145 Application.Windows collection,

enumerating, 1130 constructing, 1129—1130 overview, 1128

Application Component Object Model (COM) object, 1483

application data, modifying, 1486—1487 Application -derived class, 1137 application directory, 553 application domains (AppDomains),

defined, 625 application error code, C# programming,

76—77 Application markup, 1350 application object, 73, 74, 1129 application programming interface (API),

1013, 1014, 1015, 1016, 1017, 1391—1395

Application property, 1416, 1482, 1483, 1485

application resources, embedding, 1289—1291

application roots, and object lifetime, 294—295

Page 80: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1590

application shutdown, handling, 1488 application state

handling web application shutdown, 1488

maintaining application-level state data, 1484—1486

modifying application data, 1486—1487 overview, 1483

Application tab, 74, 531, 565, 571, 919, 1144, 1514

Application type, 1121, 1522 application variable, web-based, 1124 Application_End( ) method, 1481, 1488 Application_Error( ) event, 1481, 1482 Application_Start( ) event, 1481, 1485,

1489, 1490 <Application> element, 1156 ApplicationCommands class, WPF, 1201 ApplicationCommands object, 1205 ApplicationCommands.Help command,

1203 Application.Current property, 1140 <ApplicationDefinition> element, 1149 Application-derived class, 1130, 1147, 1153 Application-derived type, 1130, 1153, 1166 ApplicationException class, 276 Application.Exit( ) method, 1517 application-level exceptions

(System.ApplicationException), 273—276

application-level resources, 1296—1297 application-level state data, maintaining,

1484—1486 ApplicationPath property, 1418 Application.Resources scope, 1297, 1299 Application.Run( ) method, 1514, 1515,

1522, 1531 applications

building, 1513—1518, 1551—1560 adding infrastructure to

MainWindow type, 1555 capturing and rendering graphical

output, 1557 implementing serialization logic,

1558—1560

implementing Tools menu functionality, 1555—1556

main menu system, 1552—1553 populating controls collection,

1515—1517 ShapeData type, 1553 ShapePickerDialog type, 1553—1555 System.EventArgs and

System.EventHandler, 1517—1518 client, building, 1046—1050 composition of, 1025—1027 web, 1380—1382

Applications folder, 1572 Applications tab, 984 Application.Windows collection,

enumerating, 1130 Application.Windows property, 1138 apply attribute, 575 Apply Resource option, 1297 ApplyingAttributes application, 606 <appSettings> element, 578, 839, 849, 852,

1427 AppStartUp( ) method, 1137 AppState project, 1485 App.xaml file, 1297, 1303, 1313, 1323, 1350,

1354 arbitrary actions, connecting WPF

commands to, 1203—1204 ARGB (alpha, red, green and blue), 1259 Args property, 1140 ArgumentException exception, 631 ArgumentOutOfRangeException class,

260, 272, 277, 278, 279 arguments

array as, 142 command-line, 1139 optional, 180—181 workflow

defining, 1105—1106 defining using workflow designer,

1084—1086 passing to workflows using

WorkflowInvoker class, 1084 retrieving output, 1113—1114

Arguments button, 1084, 1094

Page 81: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1591

arithmetic operations, 756 Array class, 519 Array object, 513 Array of [T] option, 1098 array variable, 137 ArrayList class, 362, 365, 366, 367, 371,

1479 ArrayList.Add( ) method, 366 ArrayOfObjects( ) method, 139, 140 Array.Reverse( ) method, 144 arrays

as arguments, 142 defined, 137 generating documents from, 1004—1005 implicitly typed local, 139 initialization syntax, 138 of interface types, 334 multidimensional, 140—141 of objects, 139—140 overview, 137 primitive, applying LINQ queries to,

496—503 as return values, 142 System.Array class, 142—144

Array.Sort( ) method, 144 as keyword, 249, 307, 330 ASC (ascending), 910 ascending (ASC), 910 ascending operator, 509, 514 AsDataView<T>( ) method, 949 AsEnumerable( ) method, 947, 948 AskForBonus( ) method, 146 AsmReader class, 697 *.asmx file, 1017 ASP (Active Server Pages).NET Web

Application, 1412, 1413, 1414 ASP (Active Server Pages).NET Web page,

1412, 1414 ASP (Active Server Pages).NET Web Site,

1412, 1413 ASP applications, 1475 *.asp file, 1476 asp\: tag prefix, 1403 <asp:> definitions, 1477 <asp\:> tag, 1397

AsParallel( ) method, 771 AsParallel( )method, 772 AsParallel( ) method, 772 <asp\:Button> control, 1392 <asp:Content> scope, 1448, 1449 <asp:ContentPlaceHolder> component,

1449 <asp:ContentPlaceHolder> definition,

1443 <asp:ContentPlaceHolder> element, 1443 <asp:ContentPlaceHolder> tag, 1443, 1448 <asp:ListItem> declarations, 1478 ASP.NET Development web server, 1393 ASP.NET. Java web applications, 1475 ASP.NET master pages, 1442—1448 ASP.NET session state server, 1500, 1502 ASP.NET state management techniques

application cache data caching, 1489—1491 modifying *.aspx file, 1491—1493 overview, 1488

application/session distinction handling web application

shutdown, 1488 maintaining application-level state

data, 1484—1486 modifying application data, 1486—

1487 overview, 1483

cookies creating, 1498—1499 overview, 1497 reading incoming data, 1499

Global.asax file global last-chance exception event

handler, 1481—1482 HttpApplication base class, 1482 overview, 1479

maintaining session data, 1493—1497 overview, 1473 Profile API

accessing profile data programmatically, 1505—1507

ASPNETDB.mdf database, 1503—1504

Page 82: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1592

defining user profiles within Web.config, 1504—1505

grouping profile data and persisting custom objects, 1507—1509

overview, 1502 role of <sessionState> elements

storing session data in ASP.NET session state servers, 1500—1501

storing session data in dedicated databases, 1502

view state adding custom data, 1478—1479 demonstrating, 1477—1478 overview, 1476

ASP.NET themes *.skin files, 1466—1468 applying at page level, 1469 applying sitewide, 1468 assigning programmatically, 1469—1471 overview, 1465 SkinID property, 1469

ASP.NET web controls AutoPostBack property, 1431 categories of

documentation, 1441 overview, 1438 System.Web.UI.HtmlControls,

1440—1441 control and WebControl base classes

dynamically adding and removing controls, 1435—1436

enumerating contained controls, 1432—1435

interacting with dynamically created controls, 1436—1437

WebControl base class, 1437—1438 overview, 1429 server-side event handling, 1430

ASP.NET Web pages, building API features

1.0-1.1, 1392—1393 2.0, 1393—1394 3.5 (and .NET 3.5 SP1), 1394 4.0, 1394, 1395 overview, 1391

client-side scripting, 1388—1390 HTTP

request/response cycle, 1380 stateless protocols, 1380

Hypertext Markup Language (HTML) building forms, 1386—1387 document structure, 1383—1384 forms, 1384 overview, 1382 Visual Studio 2010 designer tools,

1384—1386 incoming HTTP requests

access to incoming form data, 1419—1420

IsPostBack property, 1420 obtaining brower statistics, 1419 overview, 1417

inheritance chain of Page type, 1416 life cycle of

AutoEventWireup attribute, 1424—1425

Error event, 1425—1426 overview, 1423

outgoing HTTP response emitting HTML content, 1422 overview, 1421 redirecting users, 1422—1423

posting back to Web servers, 1390—1391 single file Web pages

adding data access logic, 1397—1401 ASP.NET control declarations, 1403—

1404 ASP.NET directives, 1401—1403 compilation cycle for single-file

pages, 1405—1406 designing UI, 1396—1397 overview, 1395 referencing AutoLotDAL.dll, 1396 "script" block, 1403

using code files compilation cycle for multifile

pages, 1410 debugging and tracing ASP.NET

pages, 1410—1411 overview, 1406

Page 83: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1593

referencing AutoLotDAL.dll assembly, 1409

updating code file, 1409—1410 Web applications and servers

ASP.NET development web server, 1382

IIS virtual directories, 1381 overview, 1380

Web site directory structure App_Code folder, 1415 overview, 1413 referencing assemblies, 1414—1415

Web sites and Web applications, 1412—1413

Web.config files, 1427—1428 ASP.NET Web Service template, Visual

Studio, 1017 aspnet_compiler.exe tool, 1410, 1427 aspnet_regsql.exe, 1503 aspnet_state.exe, 1500, 1501 aspnet_wp.exe, 1500 AspNetCarsSite application, 1456 AspNetCarsSite project, 1442 AspNetCarsSite website, 1457 ASPNETDB.mdf database, 1503—1504,

1506, 1507, 1508, 1509 <asp:TextBox> tag, 1429 .aspx files, 1479 *.aspx files, modifying, 1491—1493 *.aspx page, 1495, 1499 .aspx pages, 1477, 1479 assemblies, 12—19. See also .NET

assemblies CLS compliant, 612 and Common Intermediate Language

(CIL) benefits of, 16—17 compiling to platform-specific

instructions, 17 overview, 14—15

documenting defining assembly, 585 referenced assemblies, 585

dynamically loading, 596—598 exploring using ildasm.exe

overview, 33 viewing assembly metadata, 35 viewing Common Intermediate

Language (CIL) code, 34 viewing type metadata, 34

exploring using Reflector, 35—36 external, 536, 1081 friend, 545 interop, 714, 717 interoperability, 714, 716 loaded

enumerating, 641—642 receiving assembly load

notifications, 643 loading, 553, 645 localized, 598 metadata, 17—18 multi-file, 14 production-ready, 1562 referencing external, 32, 1414—1415

with csc.exe, 45—46 with Visual Studio 2010, 57

resource-only, defining, 1300—1301 shared, 598—600 single-file, 14 workflow, importing, 1105 WPF

Application class, 1128—1130 overview, 1126—1127 Window class, 1130—1135

<assemblies> element, 1414 assembly, 13 Assembly class, 587, 596 .assembly directive, 662, 666, 667 Assembly directory, 559 .assembly extern block, 542 .assembly extern directives, 19, 660, 667 .assembly extern tokens, 542, 554, 660 --assembly flag, 1574 Assembly Information button, 543, 565,

571, 919, 984 assembly linker, 575 assembly manifest, 18—19 assembly metadata, 35, 536, 586 Assembly reference, 596

Page 84: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1594

Assembly table, 585 assembly token, 585, 1159 Assembly type, 596 Assembly Version number, 571 [assembly:] tag, 612 <assemblyBinding> element, 555 AssemblyBuilder member, 689 AssemblyBuilder type, 692, 693 AssemblyCompanyAttribute attribute, 613 AssemblyCopyrightAttribute attribute, 613 [AssemblyCulture] attribute, 562 AssemblyCultureAttribute attribute, 614 AssemblyDescriptionAttribute attribute,

614 <assemblyIdentity> element, 573—577 AssemblyInfo.cs file, 543, 544, 562, 563,

613, 658 [AssemblyKeyFile] attribute, 560, 562 AssemblyKeyFileAttribute attribute, 614 assembly-level (and module-level)

attributes, 612—613 AssemblyLoad event, AppDomain class,

640 Assembly.Load( ) method, 597, 598, 599,

602, 1415 AssemblyLoadEventHandler delegate, 643 Assembly.LoadFrom( ) method, 598, 602 AssemblyName class, System.Reflection

Namespace, 587 AssemblyName type, 599, 693 AssemblyProductAttribute attribute, 614 AssemblyRef #n tokens, 585 AssemblyRef for the

System.Windows.Forms assembly, 585

AssemblyResolve event, AppDomain class, 640

AssemblyTrademarkAttribute attribute, 614

[AssemblyVersion] attribute, 560, 562, 660 AssemblyVersionAttribute attribute, 614 Assets Library, 1212, 1213, 1217, 1222,

1229, 1236, 1320, 1358 Assign activity, 1091, 1107, 1108, 1111

assigning themes programmatically, 1469—1471

Associations folder, 983 AsyncCallback delegate, 736—738, 1069 AsyncCallback object, 736 AsyncCallback parameter, 399 AsyncCallbackDelegate project, 739, 747 AsyncDelegate application, 733 AsyncDelegate project, 735 AsyncDelegate property, 738 asynchronous delegate pattern, .NET, 1086 asynchronous delegates, 762 asynchronous method invocations, 22,

727, 731, 739 asynchronously method, 398 AsyncPattern property, 1035 AsyncResult class, 738, 774 AsyncState property, 739 AsyncWaitHandle property, IAsyncResult

interface, 735 ATL (Active Template Library), 6 Atomic, Consistent, Isolated, Durable

(ACID), 878 atomic operations, 729 attached properties, 1162, 1326 Attribute code snippet, Visual Studio 2010,

610 Attribute suffix, 607 Attribute token, 607 AttributedCarLibrary assembly, 611, 614,

615 AttributedCarLibrary project, 609 AttributedCarLibrary.dll, 615 attributes

.NET applying in C#, 606—607 attribute consumers, 605—606 C# attribute shorthand notation,

607—608 obsolete attribute in action, 608—609 overview, 604 specifying constructor parameters

for, 608 assembly-level (and module-level),

612—613

Page 85: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1595

CIL, 655 custom

applying, 610 named property syntax, 610—611 overview, 609 restricting usage, 611—612

using early binding, 614—615 using late binding, 615—617 using to customize serialization, 823 XAML, 1160—1161

Attributes( ) method, 1000 Attributes property, FileSystemInfo class,

778 AttributeTargets enumeration, 611 [AttributeUsage] attribute, 611, 612 <authentication> element, 1427 authoring animations, 1304 Authorization property, 1040 <authorization> element, 1427 auto attribute, 669 Auto Format link, 1445 Auto Format option, 1399 autocomplete window, 50 autocompletion, 49, 50 AutoEventWireup attribute, 1424—1425 autogenerated code, 932 autogenerated data adapter object, 932 AutoIncrement property, DataColumn

class, 890, 892 autoincrementing fields, 892 AutoIncrementSeed property,

DataColumn class, 890, 892 AutoIncrementStep property,

DataColumn class, 890, 892 AutoLot (Version 2) project, 938 AutoLot (Version Three) folder, 938 AutoLot Data Access Layer project, 862 AutoLot database, 849, 850, 921, 922, 953,

954, 1492, 1493 adding CreditRisks table to, 879—880 creating

authoring GetPetName( ) stored procedure, 843

creating customers and orders tables, 844

creating inventory table, 840—842 visually creating table relationships,

846—847 AutoLot database icon, 849 AutoLot project, 917 AutoLotConnDAL.cs file, 862 AutoLotConnectedLayer class, 1409 AutoLotConnectedLayer namespace, 862,

882, 1073, 1398, 1402, 1492 AutoLotCUIClient application, 871, 877,

882 AutoLotDAL (Version 2) project, 920 AutoLotDAL (Version 3) project, 940 AutoLotDAL Code Library project, 880 AutoLotDAL namespace, 984, 986, 1242 AutoLotDAL project, 862, 871, 882, 984 AutoLotDAL Version 4.0

invoking stored procedure, 985—986 mapping stored procedure, 980—981 navigation properties, 982—985 overview, 979

AutoLotDAL_EF.edmx project, 979 AutoLotDAL.AutoLotDataSetTableAdapter

s namespace, 940 AutoLotDAL.dll assembly

adding disconnection functionality to configuring data adapters using

SqlCommandBuilder class, 918—919

defining initial class types, 917 GetAllInventory( ) method, 919 setting version numbers, 919 testing disconnected functionality,

920—921 UpdateInventory( ) method, 919

referencing, 1396, 1409 AutoLotDAL.sln file, 938 AutoLotDataReader application, 853 AutoLotDataReader project, 861 AutoLotDataSet.xsd file, 938 AutoLotDisconnectedLayer class, 917,

1105 AutoLotDisconnectedLayer namespace,

917, 945

Page 86: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1596

AutoLotDisconnectionLayer namespace, 862

AutoLot.dll assembly, 927, 938, 940, 984, 1105, 1106, 1112

autoLotDS object, 924 AutoLotEDM_GUI application, 986 AutoLotEDMClient application, 984 AutoLotEDMClient example, 986 AutoLotEntities class, 954, 959, 970, 971,

974 AutoLotInventory variable, 1106 AutoLot.mdf file, 189 AutoLotService project, 1076 AutoLotService.cs file, 1073 AutoLotWCFService class, 1071 automatic properties

and default values, 208—210 interacting with, 208 overview, 206—207

automatically referenced feature, 45 autonomous entities, 1021 AutoPageWireUp attribute, 1425 AutoPostBack property, 1431 AutoProps project, 206, 210 AutoResetEvent class, 748—749 AutoResetEvent object, 1087 AutoResetEvent variable, 748 AutoReverse property, 1305, 1308 AutoSize property, 1526 Average( ) method, 516

■B back tick character, 594 BackColor property, 1429, 1437, 1526 Background and Content value, 1352 Background garbage collection, 297 Background property, 1133, 1160, 1161,

1273, 1293, 1297, 1301, 1353 Background threads, 749—750 BackgroundColor property,

System.Console class, 81 BackgroundImage property, 1526

BAML (Binary Application Markup Language), transforming markup into .NET assembly, 1151—1152

*.baml file extension, 1151, 1152 base addresses, specifying, 1038—1040 base classes

casting rules is keyword, 250 as keyword, 249 overview, 247—248

controlling creation of with base keyword, 228—230

libraries, role of in .NET, 8 multiple, 222

base keyword, 229, 237, 254, 654, 1482 <baseAddress> element, 1051, 1052 BaseAddresses property, 1040 baseAddresses scope, 1039 <baseAddresses> element, 1039, 1050 BaseDirectory property, AppDomain class,

639 BasedOn property, 1315 BasedOn, Style class, 1313 BaseStream member, BinaryReader class,

800 BaseStream member, BinaryWriter class,

800 BASIC (Beginner's All-purpose Symbolic

Instruction Code), 997 BasicConsoleIO project, 85 BasicDataTypes project, 88, 97 BasicGreen theme, 1469 BasicGreen.skin file, 1466, 1467 BasicHttpBinding class, 1029, 1031, 1037,

1042, 1046, 1049, 1051, 1053, 1054, 1070

BasicHttpBinding object, 1050 BasicHttpBinding option, 1029 BasicHttpBinding protocol, 1029 <basicHttpBinding> element, 1029, 1050 BasicInheritance project, 219, 225 BasicMath class, 395 *.bat file extension, 76, 77 bear_paper.design file, 1275 Beep( ) method, System.Console class, 81

Page 87: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1597

beforefieldinit item, 611 Begin method, 1035, 1069 BEGIN TRANSACTION statement, 878 BeginAnimation( ) method, 1307, 1309 BeginCatchBlock( ) method, 690 BeginClose( ) method, 1040 BeginEdit( ) method, 893, 896 BeginExceptionBlock( ) method, 690 BeginFinallyBlock( ) method, 690 BeginInvoke( ) method, 399, 400, 732, 734,

736, 738, 760, 774, 1086 Beginner's All-purpose Symbolic

Instruction Code (BASIC), 997 BeginOpen( ) method, 1040 BeginScope( ) method, 690 <BeginStoryboard> element, 1310 BeginTime property, 1305, 1308 BeginTransaction( ) method, 834, 855, 882 behavior, 321 behaviorConfiguration attribute, 1043,

1055 behaviors element, 1042, 1043, 1050 BenefitPackage class, 232, 234 BenefitPackageLevel class, 234 BenefitPackageLevel enumeration, 234 BenefitsPackage type, 233 beq opcode, 678 Bezier curve, 1257 bgt opcode, 678 BigFontButton skin, 1469 BigInteger class, 96 BigInteger data type, 90, 95, 96, 97 BigInteger object, 96 BigInteger structure, 95 BigInteger variable, 89, 96 BigInteger.Multiply( ) method, 97 bin directory, Mono, 1568 Bin folder, 1414, 1415 Bin subdirectory, 1414 Binary Application Markup Language

(BAML), transforming markup into .NET assembly, 1151—1152

binary CIL opcodes, 655

binary format, serializing DataTable/DataSet objects in, 902—903

binary operator overloading, 445—447 binary resources, WPF

embedding application resources, 1289—1291

loose resources configuring, 1287 including files in project, 1286—1287

overview, 1285 programmatically loading images,

1288—1289 BinaryCars.bin file, 903 BinaryFormatter class, 529, 606, 807, 808,

902 BinaryFormatter type, 808

deserializing, 812—813, 819 serializing, 811—813 type fidelity, 810

BinaryOp class, 398, 399 BinaryOp delegate, 398, 399, 402, 403, 404,

729, 730, 732, 733, 736 BinaryOp type, 738 BinaryOp variable, 738 BinaryReader class, 776 BinaryReader type, 27 BinaryReaders class, 799—801 BinaryResourcesApp application, 1285,

1291 BinaryWriter class, 776 BinaryWriterReader project, 800, 801 BinaryWriters class, 799—801 bind early, 600 bin\Debug folder, 602 binders, 709 binding element, 1037 Binding keyword, 1238 <binding> element, 1054 bindingConfiguration attribute, 1054 BindingFlags enumeration, 592 <bindingRedirect> element, 573 bindings

changing settings for, 1053—1054

Page 88: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1598

DataTable objects to Windows Forms GUIs

DataView type, 912—913 deleting rows from DataTable, 907—

908 hydrating DataTable from generic

List<T>, 904—906 overview, 903 selecting rows based on filter

criteria, 908—911 updating rows within DataTable,

911 early, attributes using, 614—615 exposing single services using multiple,

1052—1053 HTTP-based, 1029—1030 late

attributes using, 615—617 invoking methods with no

parameters, 602—603 invoking methods with parameters,

603—604 overview, 600 System.Activator class, 601—602

MSMQ-based, 1031 overview, 1028 selecting, 1056—1057 TCP-based, 1030

bindings element, 1042, 1050, 1054 BindingSource class, 931 Bitmap class, 31 Bitmap type, 1547 BitmapImage class, 1288 BitmapImage objects, 1359 BitVector32 type, 363 black box programming, 195 ble opcode, 678 Blend brush editor, 1269 Blend code editor, 1221 Blend Designer, 1210 Blend editor, 1228 Blend project, 1358 Blend Properties editor, 1209 Blend Properties window, 1217, 1221, 1359 Blend Resources window, 1321

Blend window, 1211 Blend XAML editor, 1210 block elements, Documents API, 1227 Blocks (Collection) property, 1230 Blocks editor, 1230 BlockUIContainer element, 1227 blt opcode, 678 blue value, 717 <body> scope, 1383, 1386 Boo programming language, 50, 1569 booc compiler, Mono, 1569 bool data type, 86, 93, 112, 162 bool field, 736 bool keyword, 89 bool? member, 163 bool parameter, 882 bool value, 1140, 1335 bool variable, 88, 89, 311, 748, 1307 boolArray type, 138 Boolean data type, 162, 1479 Boolean expression, 1107 Boolean parameter, 298 Boolean property, 1235 Boolean variable, 736, 1096 Border control, 1358 Border menu option, 1220 BorderBrush color, 1358 BorderBrush property, Control Type, 1133 BorderColor property, WebControl Base

Class, 1437 BorderStyle property, 1429, 1433, 1437 BorderThickness property, Control Type,

1133 BorderThickness value, 1358 BorderWidth property, 1429, 1437 Bottom property, 1527 Bounds member, 1254 Bounds property, 1527 box opcode, 678 boxedInt object, 364 boxing, 365 boxing operation, 364 br opcodes, 682 <br> tag, 1435

Page 89: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1599

bread crumbs, establishing with SiteMapPath type, 1447

breadcrumbs technique, 1447 break keyword, 117, 122 brower statistics, obtaining, 1419 Browse For Types option, 1095, 1106, 1107 Browse tab, 57, 541, 546, 567 Browser property, 1418, 1419 Brush editors, 1171, 1260, 1269—1271, 1301 Brush object, 1248 Brush type, 1269, 1547, 1550 brushes

configuring in code, 1260—1261 configuring using Visual Studio 2010,

1258—1260 Brushes area, 1269 Brushes class, 1550 Brushes editor, 1222, 1269, 1358 Brushes type, 1547 BSTR data type, 7 btnAddWidgets control, 1435 btnCancel button, 1538 btnCancel control, 771, 772 btnChangeMakes class, 911 btnClear control, 1226 btnClearPanel control, 1436 btnDisplayMakes class, 908 btnDownload control, 768 btnExecute control, 771 btnExitApp variable, 1150 btnExitApp_Clicked( ) method, 1150 btnGetCar button, 1474 btnGetOrderInfo class, 925 btnGetStats control, 768 btnGetStats_Click( ) method, 770 btnGetTextData control, 1436 btnLoad control, 1226 btnOK button, 1538 btnPostback button, 1477 btnReset class, 1387 btnSave control, 1226 btnSetCar button, 1474 btnShow class, 1387, 1389 btnShowAppVariables button, 1486 btnShowCarOnSale button, 1486

btnShowLogicalTree object, 1342 btnShowVisualTree control, 1343 btnSpin control, 1371 btnSpinner object, 1307 btnSubmit button, 1505 btnUpdateDatabase class, 921 btnUpdateInventory control, 937 bubbling events, 1337, 1339 BufferedGraphics type, 1547 BufferedStream class, 776 BufferHeight property, System.Console

class, 82 BufferWidth property, System.Console

class, 82 bugs, 259—260 Build a Car menu item, 1447 Build a Car node, 1446 Build Action property, 1287, 1289, 1292 Build menu, Visual Studio 2010, 1290 Build tab, 110, 657 build tools, automated, 43 Build-a-Car, designing content page,

1455—1457 BuildCar.aspx, 1446 BuildMenuSystem( ) method, 1516 BuildTableRelationship( ) method, 923,

924 Bukovics, Bruce, 1077 business process, defining role of WF 4.0

in, 1078 >> button, 1212, 1213 Button class, 920, 921, 1396, 1397, 1398,

1399, 1408, 1409, 1422, 1423 Button Click event, 1431 Button controls, 718, 768, 1198, 1226, 1292,

1315, 1318, 1319, 1342, 1469 Button element, 1160, 1202, 1338 Button object, implementing Click event,

1175—1176 Button property, 1534, 1535 Button skin, 1469 Button template, 1366 Button type, 1146, 1159, 1164, 1173, 1175,

1341, 1467, 1469 <Button> control, 1337

Page 90: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1600

<Button> definition, 1132, 1160 <Button> element, 1150, 1158, 1172, 1349,

1352 <Button> tag, 1132 </Button> tag, 1161 <Button> tag, 1161, 1293 </Button> tag, 1293 button1_Click event, 1172 <Button.Background> scope, 1161 <Button.Context> scope, 1181 Button.HeightProperty, 1305 Buttons control, 1262 buttons, determining which was clicked,

1535—1536 Buttons widget, 1441 ButtonTemplate application, 1349 ButtonTemplate project, 1356 by GetInvocationList( ) method, 404 by operator, 509 By property, Animation class types, 1305 by value parameter, 160 byte data type, 86, 108, 109, 145, 146 ByteAnimation class, 1304

■C C command, 1257 C string format character, 84 C# 4.0 language features

COM interoperability using, 718—724 COM interoperability without, 722—724

C# applications and .NET Framework 4.0 Software

Development Kit (SDK), 41—42 building with csc.exe

command line flags, 43—44 compiling multiple source files, 46—

47 overview, 42 referencing external assemblies, 45—

46 referencing multiple external

assemblies, 46 response files, 47—49

building with Notepad++, 49—50 building with SharpDevelop

overview, 50 test project, 51—53

building with Visual C# 2010 Express, 53—54

building with Visual Studio 2010 Class View utility, 58—59 code expansions, 63—64 integrated .NET Framework 4.0

documentation, 67—69 New Project dialog box, 56 Object Browser utility, 60 overview, 54 refactoring code, 60—63 Solution Explorer Utility, 56—58 unique features of, 55 Visual Class Designer, 64—67

overview, 41 C# compiler, 15, 32, 44, 47, 172, 605, 609,

703, 704, 1569 C# Console Application project, 263, 277 C# language

anonymous methods, 427—430, 706 custom type conversions

among related class types, 454—455 anonymous types, 473—478 creating routines, 455—457 explicit conversions for square

types, 458 extension methods, 460—470 implicit conversion routines, 458—

459 internal representation of custom

conversion routines, 460 numerical, 454 partial methods, 470—473

events creating custom event arguments,

424—425 event keyword, 419—421 generic EventHandler<T> delegate,

426 hidden methods of, 421 incoming, listening to, 422—423

Page 91: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1601

overview, 418 registrating, simplifying using Visual

Studio 2010, 423—424 indexer methods

definitions on interface types, 444 multiple dimensions, 443—444 overloading, 443 overview, 439—440 string values, 441—442

LINQ query operators aggregation operations, 516—517 basic selection syntax, 510—511 LINQ as better Venn diagramming

tool, 515—516 obtaining counts using enumerable,

513 obtaining subsets of data, 511 overview, 508—509 projecting new data types, 512—513 removing duplicates, 516 reversing result sets, 514 sorting expressions, 514

operator overloading += and -+, 448 binary, 445—447 comparison, 450 equality, 449—450 internal representation of, 451—452 overview, 444 unary, 448—449

pointer types * and & operators, 482 field access with pointers, 484 overview, 479—480 pinning types with fixed keywords,

485—486 sizeof keyword, 486 stackalloc keyword, 485 unsafe (and safe) swap function, 483 unsafe keyword, 481—482

C# programming constructs, 73—123, 125—165

application error code, 76—77 arrays

as arguments, 142

implicitly typed local, 139 initialization syntax, 138 multidimensional, 140—141 of objects, 139—140 overview, 137 as return values, 142 System.Array class, 142—144

command-line arguments, 77—79 data type conversions

narrowing data conversions, 108—110

overflow checking, 110—111 overview, 106—107 System.Convert, 112 unchecked keyword, 111

enum type declaring variables, 146—147 discovering name/value pairs of,

148—150 overview, 144 System.Enum type, 147 underlying storage for, 145—146

if/else statement, 120 implicitly typed local variables

are strongly typed data, 115 overview, 112—113 restrictions on, 114—115 usefulness of, 116

iteration constructs do/while loop, 119 foreach loop, 118 for loop, 117 while loop, 119

methods default parameter-passing behavior,

126—127 named parameters, 133—134 optional parameters, 131—132 out modifier, 127—128 overloading of, 135—137 overview, 125 params modifier, 130—131 ref modifier, 128—129

nullable types ?? operator, 164—165

Page 92: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1602

overview, 162 working with, 163—164

reference types passing by reference, 160 passing by value, 158—160

string data basic manipulation, 98—99 concatenation, 99—100 escape characters, 100—101 overview, 97 strings and equality, 102 strings are immutable, 102—104 System.Text.StringBuilder type,

104—105 verbatim strings, 101—102

structure type, 151—153 switch statement, 121—123 system data types

class hierarchy, 90—92 and new operator, 89—90 numerical data types, 92 overview, 86—87 parsing values from string data, 94 System.Boolean, 93 System.Char, 93—94 System.DateTime, 95 System.Numerics, 95—97 System.TimeSpan, 95 variable declaration, 88—89

System.Console class basic input and output with, 82—83 formatting numerical data, 84—85 formatting output, 83 overview, 81

System.Environment class, 79—81 value types

containing reference types, 157—158 overview, 154 vs. reference types, 155—156, 161—

162 variations on Main( ) method, 75—76

C# Snap-In, 619—620 C# Windows Application solution, 51 C++ Component Object Model (COM)

developers, 260

C++ function pointer, 397 C++/Microsoft Foundation Classes (MFC),

4 cache application Graphical User Interface

(GUI), 1492 Cache object, 1489, 1490 Cache property, 1416, 1421, 1489 Cache type, 1493 Cache variable, 1490 CacheDependency object, 1491 CacheItemRemovedCallback delegate,

1491, 1493 Cache.NoAbsoluteExpiration field, 1491 Cache.NoSlidingExpiration field, 1491 Cache.NoSlidingExpiration parameter,

1491 CacheState project, 1489 Calc class, 14, 15, 17 Calc.Add( ) method, 34 Calc.cs file, 16, 18, 33 Calc.exe application, 35 Calc.exe assembly, 33 Calc.exe file, 18, 19 CalculateAverage( ) method, 130, 131 Calc.vb code file, 16 Calendar control, 1439, 1455 Calendar type, 1467 call opcode, 678, 690 callback functions, 397 CallbackContract property, 1034 callbacks, 397, 398 calling tier, 885, 886 CallMeHere( ) method, 413 callvirt opcode, 690 Cancel button, 1294, 1296, 1297 Cancel( ) method, 772, 858 Cancel property, 1141 cancelation request, 766—767 CancelButton property, 1529, 1541 CancelEdit( ) method, 893 CancelEventArgs class, 1141 CancelEventArgs.Cancel property, 1141 CancelEventHandler delegate, 1141 cancellation tokens, 766 CancellationScope activity, WF 4.0, 1092

Page 93: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1603

CancellationToken property, 767 CancellationTokenSource class, 766 CancellationTokenSource object, 766, 772 CancellationTokenSource token, 767 cancelToken object, 772 cancelToken variable, 766 CanExecute attribute, 1205 CanExecute event, 1203, 1205 CanExecute handler, 1205 CanExecute property, 1205 CanExecuteRoutedEventArgs object, 1205 CanHelpExecute( ) method, 1204 CanRead member, Stream class, 792 CanSeek member, Stream class, 792 Canvas area, 1186 Canvas class, 1138, 1162, 1250, 1252 Canvas object, 1252, 1264, 1276 Canvas panels, 1186—1188 Canvas scope, 1339 Canvas type, 1188 <Canvas> tags, 1186 Canvas.Bottom property, 1187, 1188 Canvas.Left property, 1187, 1188 Canvas.Right property, 1187, 1188 Canvas.Top property, 1187, 1188 CanWrite member, Stream class, 792 Caption property, carIDColumn object,

891 Caption property, DataColumn class, 890 capturing graphical output, 1557 Car constructor, 584 Car reference, 291 Car type

extension methods, 465 viewing type metadata for, 583—584

Car variable, 169, 209 CarAboutToBlow( ) method, 428 Car.Accelerate( ) method, 269, 270 carArray variable, 346 CarAvailableInZipCode( ) method, 471,

473 Car.CarEngineHandler object, 411 Car.cs file, 167, 206, 273, 277, 343, 571, 972 CarDelegate application, 405 CarDelegate project, 411

CarDelegateMethodGroupConversion application, 412

CarDelegateMethodGroupConversion project, 413

CarDelegateWithLambdas project, 437 CardSpace application programming

interface (API), 1023, 1030 CarEngineHandler class, 406 CarEngineHandler delegate, 408, 420, 425 CarEngineHandler objects, 418 carErrors.txt file, 281 CaretIndex property, 1200 CarEventArgs class, 425 CarEventArgs type, 425 CarEvents application, 420 CarEvents example, retrofitting using

lambda expressions, 436—437 CarEvents project, 424 CarExploded( ) method, 428 car.gif file, 1448 CarID column, 842, 890, 898 CarID field, 846 CarID key, 846 CarID value, 843 carIDColumn class, 892 CarIDColumn column, 934 carIDColumn object, 891, 892 CarID/CustID values, 844 CarInfoHelper class, 684 carIsDead variable, 263 CarIsDeadException class, 273, 274, 276,

278, 279, 280, 281 CarIsDeadException constructor, 281 CarIsDeadException object, 280 CarIsDeadException type, 274, 275 CarIsDeadException.cs file, 277 CarLibrary assembly, 538, 561 CarLibrary icon, 566 CarLibrary namespace, 532, 602 CarLibrary project, 541, 545, 546 CarLibrary.dll assembly, 544, 545, 546, 547,

568, 569, 570, 573, 574, 575 CarLibrary.EngineState enumeration, 582,

583 CarLibrary.EngineState.engineAlive, 583

Page 94: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1604

CarLibrary.exe file, 554 CarLibraryPolicy.xml file, 575 CarLocator class, 471, 472 CarLotInfo class, 1485 CarNickname property, 969, 971 CarOrderApp project, 1538, 1545 Cars property, 955, 971, 974 Cars web site, building

defining default content pages, 1448—1449

designing Build-a-Car content page, 1455—1457

designing Inventory content pages, 1450—1452

enabling in-place editing, 1454 enabling sorting and paging, 1453 master pages

AdRotator widget, 1447—1448 bread crumbs, establishing with

SiteMapPath type, 1447 overview, 1442—1444 TreeView control site, 1445—1447

overview, 1441 Cars.cd file, 224 carsDataSet.xml file, 901 cascading style sheet (CSS), 1394 case-sensitive languages, 74 CaseSensitive member, 897 CaseSensitive property, 887 casting operations, 247, 366, 1107 catch blocks, 267, 273, 277, 278, 279, 280,

690 catch keyword, 109, 249, 261 catch logic, 268, 270, 271, 277, 281 catch scope, 274, 278, 279, 281 catching exceptions, 266—267 CDATA scope, 1147 CDATA section, 1390 CenterToScreen( ) method, 1530 -centric dot notation, 667 ceq opcode, 678 CGI applications, 1475 cgt opcode, 678 Change Layout Type menu option, 1211 ChangeDatabase( ) method, 855

Channel property, 1046 char array, 98 char data type, 87 char keyword, 93 char variable, 89 character data, 102 Check button, 1196, 1198 Check for arithmetic overflow/underflow

check box, 110 CheckBox control, 1235, 1431 Checked event, 1220 checked keyword, 73, 108, 109, 110, 111 Checked property, 1554 CheckInventoryWorkflowLib project, 1103 CheckInventoryWorkflowLib.dll assembly,

1112 CheckInventory.xaml file, 1103 Cherries.png file, 1358 child class, 189 ChildRelations member, 897 Choose Data Source dropdown box, 927,

986, 1451 CIL. See common intermediate language CILCar argument, 686 CILCar class, 684 CILCar object, 687 CILCar parameter, 685 CILCarInfo class, 685 CILCarInfo.Display( ) method, 686 CilCars example, 688 CILCars namespace, 684, 685 CILCars.dll assembly, 686 CILCars.il file, 683 CILTypes assembly, 667 CilTypes example, 683 CILTypes.il file, compiling, 672—673 Circle class, 191, 244, 324, 328, 525 Circle type, 243, 246 circleOption RadioButton, 1251 Class attribute, 1146, 1177 class constructor, 675 Class Designer. Name, 66 Class Designer Toolbox, 65, 66, 225 Class Details window, 65, 66, 225 Class Diagram icon, 224

Page 95: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1605

Class Diagram viewer, 65 .class directive, 655, 660, 668, 669, 670, 677 class extern tokens, 551 class hierarchy, of system data types, 90—

92 Class icon, 167 class keyword, 19, 167, 1158 class libraries, isolating strongly typed

database code into deleting data with generated codes,

942—943 inserting data with generated codes,

941—942 invoking stored procedures using

generated codes, 943 overview, 938 selecting data with generated codes,

940—941 viewing generated codes, 939—940

Class Library project, 538, 547, 937, 939 class library relationship, 8 Class Library template, 1023 Class member, 695 class token, 677 class types

access modifiers default, 193 and nested types, 194 overview, 192

automatic properties and default values, 208—210 interacting with, 208 overview, 206—207

Common Type System (CTS), 19 constant field data

constants, 214—216 read-only fields, 215—216 static read-only fields, 216

constructors custom, 172 default, 171—173 overview, 170

conversions, 454—455 defining in CIL, 668—669 encapsulation services

internal representation of properties, 202—203

overview, 194 read-only and write-only properties,

204—205 static properties, 205—206 using .NET properties, 198—200 using properties within class

definition, 200—201 using traditional accessors and

mutators, 195—197 visibility levels of properties, 204

new keyword, 170 object initializer syntax

calling custom constructors with, 212—213

inner types, 213—214 overview, 210—211

and optional arguments, 180—181 overview, 167 partial types, 217—218 static keyword

classes, 187—188 constructors, 185—187 field data, 182—185 methods, 181—182

this keyword chaining constructor calls using,

176—178 and constructor flow, 178—181 overview, 174—175

Class View tool, 59, 939 Class View utility, Visual Studio 2010, 58—

59 Class View window, 970 Class1.cs, 711 ClassDiagram1.cd file, 224 classes

abstract, 240 allocation onto managed heap, 291 characteristics of, 19, 20 creating instances of, 291 custom, 204 generic

Page 96: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1606

default keyword in generic code, 390—391

generic base classes, 391—392 overview, 388—389 specifying type parameters for, 372—

374 sealed, 232

classical inheritance, 220 ClassModifier keyword, 1156, 1159 clean entities, 990 Clean Solution option, Visual Studio 2010,

1290 CleanUp( ) method, 311 Clear( ) method, 82, 143, 888, 1421, 1484,

1515, 1548 Clear Surface menu handler, 1556 ClearCollection<T> activity, WF 4.0, 1092 ClearErrors( ) method, 893 clearing, InkCanvas data, 1226—1227 CLI (Common Language Infrastructure)

mainstream distributions, 1563—1564 role of, 1562—1563

Click event handler, 720, 908, 909, 925, 937, 1251, 1337, 1338, 1398, 1419

Click event, implementing for Button object, 1175—1176

Click implementation, 1343 ClickOnce technology, 1121, 1124 Clicks property, 1534 client applications, building

configuring TCP-based binding, 1049—1050

generating proxy code using svcutil.exe, 1046—1047

generating proxy code using Visual Studio 2010, 1047—1048

client area, invalidating, 1551 Client Assembly, 828 client element, 1042 client proxy, refreshing, 1056—1057 client tier, 885, 886 <client> element, 1046 ClientBuild.rsp file, 1577 Client.cs file, 552 ClientRectangle property, 1527

clients, invoking services asynchronously from, 1067—1069

client-side scripting, 1388—1390 ClientTarget property, 1416 Clip property, 1255 ClipGeometry property, 1255 ClipToBounds property, 1265 Clone( ) method, 323, 350, 351, 352, 353,

354, 888 cloneable objects, building, 349—354 CloneablePoint application, 349 CloneablePoint project, 354 CloneableType class, 323 CloneMe( ) method, 323, 331 cloning, 349 Close( ) member

BinaryReader class, 800 BinaryWriter class, 800 Stream class, 792 TextWriter class, 795

Close( ) method, DatabaseReader class, 189

CloseConnection( ) method, 863 Closed event, implementing, 1177 CloseMainWindow( ) method,

System.Diagnostics.Process class, 629

CloseTimeout property, 1040 Closing event, 1141, 1142 CLR (Common Language Runtime)

data type, 1504 defined, 25—26 property wrappers, 1325, 1326, 1328,

1330 clr-namespace token, 1081, 1159 CLS (Common Language Specification), 3,

7, 23—25, 605, 612 [CLSCompliant] attribute, 25, 605 clt opcode, 678 cnStr value, 849 Code activity, 1109—1111 code annotations, 604 code, autogenerated, 932 Code Definition window, 608 code expansions, Visual Studio 2010, 63—64

Page 97: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1607

code file model, 1401 code files

building Web pages using, 1406—1411 updating, 1409—1410

code library, 532 code reuse, 190, 532 code snippet edit mode, 63 <Code> element, 1147 CodeActivity activity, 1109 CodeActivity<T> value, 1109 CodeActivityContext, 1109 <codeBase> element, 556, 576—577 <codeBase> value, 598 CodeBaseClient application, 576, 577 CodeBaseClient project, 577 code-behind files, building WPF

applications using MainWindow class, adding code file

for, 1165 MyApp class, adding code file for, 1166 processing files with msbuild.exe,

1166—1167 code-behind technique, 1392, 1406 code-conversion utility, 51 CodeFile attribute, 1408 CodePage attribute, 1401 codes

deleting data with, 942—943 inserting data with, 941—942 invoking using stored procedures, 943 selecting data with, 940—941 viewing, 939—940

<codeSubDirectories> element, 1415 coding

keyword color, 49 against ServiceHost type, 1038

Collapse or Expand option, 329 Collect( ) method, 298, 300 Collection (Items) dialog box, 1218 Collection (Items) property, 1217, 1219 collection activities, WF 4.0, 1092—1093 collection objects, applying LINQ queries

to accessing contained subobjects, 506—

507

applying LINQ queries to nongeneric collections, 507—508

filtering data using OfType<T>( ), 508 overview, 505

CollectionCount( ) method, System.GC class, 298

collection/object initialization syntax, 491 collections

nongeneric, applying LINQ queries to, 507—508

of objects, serializing, 816—817 person only, 368

.Collections.Specialized namespace, 363 colon operator, 133, 177, 220, 223, 393 Color class, 1261 color coding, 49 Color enum, 194 Color object, 1225, 1261 Color property, 1110, 1258 color selector, 1259 Color type, 1547 ColorAnimation class, 1304 ColorAnimation type, 1304 ColorChanged handler, 1221 ColorChanged( ) method, 1224, 1225 ColorColumn column, 934 ColorConverter class, 1225 Colors enumeration, 1261 Column Properties editor, 842 <ColumnDefinition> element, 1191 ColumnMapping property, DataColumn

class, 890 ColumnName property, DataColumn

class, 890 Columns class, 890, 891 Columns collection, 900, 941, 943 Columns indexer, 934 Columns property, 890, 892 COM (Application Component Object

Model) object, 1483 COM (C++ Component Object Model)

developers, 260 COM (Component Object Model)

classes, 5 clients, 261

Page 98: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1608

frameworks, 889 interfaces, 261 objects, 1483 programming language comparison, 5—

6 servers, 5

COM (Session Component Object Model) object, 1483

COM interoperability simplifying using dynamic data

common COM interop pain points, 717—718

embedding interop metadata, 716—717

overview, 714 role of Primary Interop Assemblies

(PIAs), 715 using C# 4.0 language features, 718—724 without C# 4.0 language features, 722—

724 COM+ layer, 1016 COM+ objects, 1015, 1022 COM+/Enterprise Services, 1015 Combine menu, 1268 Combine( ) method, 401 CombinedGeometry class, 1255 ComboBox control, Ink API tab, 1224—1226 ComboBoxItem control, 1218, 1225 ComboBoxItem objects, 1219, 1225 comboColors control, 1219 comContracts element, 1042 comma-delimited list, 130, 393 command builder type, 918 command line, generating strong names

at, 561—563 Command object, 827, 828, 834 command prompt

Mono, 1568, 1572, 1577 Visual Studio 2010, 33, 534

Command property, connecting WPF commands to, 1202—1203

CommandBinding objects, 1203 <CommandBinding> definitions, 1205 CommandBindings collection, 1205 CommandCollection property, 937

command-line arguments, C# programming, 77—79

command-line compiler, 537, 550, 552 command-line parameters, 43, 76 CommandText property, 858, 867, 870 CommandTimeout member, 858 CommandTimeout property, 959 CommandType enum, 858 CommandType property, 858 CommandType.StoredProcedure value,

870 Commit( ) method, 879, 882 COMMIT statement, 878 committed transactions, 878 Common Controls section, 1544 common dialog boxes category, 1512 common intermediate language (CIL)

.NET base class library, C#, and CIL data type mappings, 673

and assemblies benefits of, 16—17 compiling to platform-specific

instructions, 17 overview, 14—15

attributes, role of, 655 building .NET assembly with

building CILCarClient.exe, 686—687 building CILCars.dll, 683—686

compiling CILTypes.il file, 672—673 defining and implementing interfaces

in, 670 defining class types in, 668—669 defining current assembly in, 667 defining enums in, 671 defining field data in, 674—675 defining generics in, 671—672 defining member parameters, 676—677 defining namespaces in, 668 defining properties in, 676 defining structures in, 670—671 defining type constructors in, 675 defining type members in, 674—677 directives, role of, 655 exploring assemblies using ildasm.exe,

34

Page 99: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1609

opcodes .maxstack directive, 680 declaring local variables in CIL, 680—

681 hidden this reference, 682 mapping parameters to local

variables in CIL, 681 overview, 677—679 representing iteration constructs in

CIL, 682—683 role of, 655

overview, 653 reasons for learning grammar of, 653—

654 round-trip engineering

authoring CIL code using SharpDevelop, 665—666

compiling CIL code using ilasm.exe, 663—664

interacting with CIL, 662—663 overview, 658—660 role of CIL code labels, 661—662 role of peverify.exe, 666

specifying externally referenced assemblies in, 666

stack-based nature of, 656—658 Common Language Infrastructure (CLI)

mainstream distributions, 1563—1564 role of, 1562—1563

Common Language Runtime (CLR) data type, 1504 defined, 25—26 property wrappers, 1325, 1326, 1328,

1330 Common Language Specification (CLS), 3,

7, 23—25, 605, 612 Common Object Request Broker

Architecture (CORBA), 1014 Common Object Runtime Execution

Engine, 25 Common Properties area, 1214, 1218,

1220, 1236 Common Properties section, 1217, 1219 Common Type System (CTS)

class types, 19

data types, 22—23 delegate types, 21—22 enumeration types, 21 interface types, 20 structure types, 20 type members, 22

commonBehaviors element, 1042 CommonSnappableTypes namespace, 621 CommonSnappableTypes.dll assembly,

618, 619, 621, 622 CommunicationState enumeration, 1041 Company property, 206 [CompanyInfo] attribute, 619, 623 CompanyInfoAttribute attribute, 619 companyName field, 206 comparable objects, building

custom properties, custom sort types, 358

overview, 354—356 specifying multiple sort orders

(IComparer), 357—358 ComparableCar application, 355 ComparableCar project, 359 Compare( ) method, 97, 383 CompareExchange( ) method, Interlocked

class, 756 CompareTo( ) method, 355, 356 CompareValidator control, 1458 CompareValidator type, 1459 CompareValidator widget, 1461—1462 comparison operator overloading, 450 CompensableActivity activity, WF 4.0, 1092 Competed event, 1091 compilation cycle for multifile pages, 1410 compilation cycle for single-file pages,

1405—1406 <compilation> element, 1410 <Compile> elements, 1166 compiler error, 88, 128, 132 compiler flags, 44 compile-time error, 115, 139 Complain( ) method, 181, 182 Completed event, 1307 Completed property, 1088 Complex structure, 95

Page 100: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1610

Component, 1301 Component Object Model. See COM component tray, 931 ComponentCommands class, WPF, 1201 components category, 1512 composition, of applications, 1025—1027 Concat( ) method, 516 concatenation, of string data, 99—100 concatenation symbol, 1094 conceptual model, 958 concurrency, 728—729, 750—758 concurrent garbage collection, 297 Condition editor, 1107 Condition property, 1097 conditional code compilation, partial

methods, 472 *.config file extension, 554 *.config files, 555, 556, 569, 570, 573, 574,

848, 849, 850, 852, 853 configuration files, altering using

SvcConfigEditor.exe, 1059—1061 <configuration> element, 555, 1415 ConfigurationManager class, 1427 ConfigurationManager type, 839 ConfigurationManager.AppSettings

indexer, 849, 852 ConfigurationManager.ConnectionStrings

indexer, 852 ConfigurationName property, 1034 ConfigureAdapter( ) method, 917, 918 ConfigureCUI( ) method, 62 ConfigureGrid( ) method, 1242 configuring tab order, 1540 configuring TCP-based binding, 1049—1050 Connect( ) method, 1151 Connect Timeout segment, 855 connected layer, of ADO.NET

command objects, 858 connection objects, 854—856 ConnectionStringBuilder objects, 856—

857 overview, 853

Connection member, 858 connection object, 827, 833, 839 Connection property, 853, 858, 879, 959

connection string, 854, 856 Connection String property, 849 connection timeout setting, 855 ConnectionState enumeration, 855, 856 ConnectionState values, 856 ConnectionState.Closed value, 856 ConnectionState.Open value, 856 connectionString attributes, 852 ConnectionString property, 849, 855, 857,

1451 <connectionString> element, 1504 ConnectionStringBuilder objects, 856—857 <connectionStrings> element, 847, 852—

853, 871, 932, 1427, 1451 <connectionStrings> value, 1451 ConnectionTimeout property, 855 Consistent, 878 Console Application project, 273, 712 Console class, 28, 75, 81, 82, 181 Console namespace, 30, 532 Console project, 712 Console type, 82, 754 console user interface (CUI), 81 Console window, 566 Console.Beep( ) method, 312 ConsoleClientApp.cs, 1576 ConsoleClientApp.exe, 1578 ConsoleClientApp.exe file, 1576, 1577 ConsoleColor enumeration, 81 ConsoleColor variables, 133 Console.ReadLine( ) method, 61, 75, 750,

875, 1095 Console.WriteLine( ) method, 83, 136, 178,

366, 430, 434, 551, 663, 690, 731 const keyword, 214, 218 constant field data

constants, 214—216 read-only fields, 215—216 static read-only fields, 216

ConstData project, 214, 217 Constraint type, System.Data namespace,

832 constraints, 361 Constraints member, 897 ConstructingXmlDocs application, 1002

Page 101: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1611

ConstructorBuilder, DefineProperty( ) method, 696

ConstructorBuilder member, 689 ConstructorBuilder type, 690, 696 constructors

arguments, 205 chaining calls, 176—178, 180, 199 for classes

custom, 172 default, 171—173 overview, 170

definition, single, 180 emitting, 696—697 flow of, and this keyword, 178—180 static, 185—187

contained controls, enumerating, 1432—1435

ContainerControl class, 1529 containers

generating documents from, 1004—1005 type-safe, 367

ContainerVisual class, 1277 ContainerVisual object, 1258 containment, programming for, 232—235 containment/delegation model, 190, 219,

232 Contains( ) method, 97, 98 content display area, 1354 content model, WPF, 1226 content pages

default, 1448—1449 designing, 1455—1457

Content property, 1131, 1132, 1181, 1185, 1218, 1219, 1236, 1238, 1353, 1354

ContentControl class, 1117, 1131, 1132, 1181, 1185

ContentEncoding property, 1421 ContentPlaceHolderID value, 1449 ContentPresenter class, 1344, 1352, 1354 ContentProperty class, 1241 ContentType property, 1421 context 0 (default context), application

domain, 648 context attributes, 649 Context property, 1489, 1490

ContextBoundObject class, 757 Context.Cache property, 1488 Context.Cache.Insert( ) method, 1490 context.Inventories, 1242 ContextMenu property,

FrameworkElement type, 1133 contextual boundaries, AppDomain, 625 contextual keyword, 199 continue keyword, 117 contract element, 1037 contracts

data, 1070—1076 operational, service types as, 1035—1036 WCF, 1027

contravariance, 9, 10, 414 Control class, 1132, 1314, 1404, 1416, 1512,

1515, 1526—1529 control declarations, ASP.NET, 1403—1404 control flow activities, WF 4.0, 1089 Control Flow area, 1104 Control Library section, 1184 Control Panel, 1500 Control property, 1537 control templates, WPF

building custom with Visual Studio 2010

{TemplateBinding} markup extension, 1352—1353

ContentPresenter, 1354 incorporating templates into styles,

1354—1355 incorporating visual cues using

triggers, 1351—1352 overview, 1348 templates as resources, 1349—1351

default overview, 1341—1343 programmatically inspecting, 1344—

1348 Control type, 1132, 1133, 1346, 1437 control-agnostic events, 1200 ControlBox property, 1529 ControlCollection object, 1432 controls. See also ASP.NET web controls

collection, populating, 1515—1517

Page 102: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1612

contained, enumerating, 1432—1435 created dynamically, 1436—1437 dynamically adding and removing,

1435—1436 dynamically created, 1436—1437 for validation

CompareValidator widget, 1461—1462

creating summaries, 1462—1463 defining groups, 1463—1465 overview, 1457—1458 RangeValidator widget, 1460—1461 RegularExpressionValidator widget,

1460 RequiredFieldValidator widget,

1459—1460 WebControl base class, 1437—1438

Controls node, 1229 Controls property, 1432, 1515, 1516, 1527 Controls.Add( ) method, 1515 ControlsCollection class, 1515 ControlsCollection container, 1515 ControlTemplate class, 1344 ControlTemplate object, 1348 <ControlTemplate> tag, 1351 <ControlTemplate.Triggers> collection,

1352 ControlToValidate property, 1458, 1459,

1461 conversion routines, custom, 460 conversions, numerical, 454 Convert class, 112 Convert( ) method, 1241 Convert to New Resource option, 1301 Convert type, 112 ConvertBack( ) method, 1241 Cookie collection, 1498 cookies

creating, 1498—1499 overview, 1497 reading incoming data, 1499

Cookies property, 1418, 1421 CookieStateApp project, 1498 cool factor, 600 Copy command, 1200

Copy Local property, 568 Copy( ) method, 888, 897 Copy to Output Directory property, 1008,

1287, 1289 CopyTo( ) method

Array class, 143 FileInfo class, 785

CopyToDataTable<T>( ) method, 948 CORBA (Common Object Request Broker

Architecture), 1014 core assemblies of Windows

Communication Foundation (WCF), 1022

core infrastructure category, 1512 Core user input controls, WPF, 1179 CoreLibDumper class, 1572 CoreLibDumper.dll, assigning strong

name to, 1574 CoreLibDumper.dll library, 1572 cores, 761 CorLibDumper folder, 1572, 1575 CorLibDumper project, 1580 CorLibDumper.dll assembly, 1574, 1575,

1577, 1578 CorrelationScope activity, WF 4.0, 1090 corrupted state exceptions (CSE), 285, 286 Count( ) method, 513, 516, 1515 Count property, 934, 1484 Count<>( ) method, 509 covariance, 9, 10, 414 CPU-agnostic intermediate language, 536 CrazyOrange folder, 1467 CrazyOrange theme, 1467, 1469 CrazyOrange.skin file, 1467 Create( ) method

DirectoryInfo class, 778 FileInfo class, 785, 786 FileMode enumeration, 787

Create New SQL Server Database menu option, 840

CREATE PROCEDURE statement, 843 CreateCommand( ) method, 322 CreateDataReader( ) method, 900, 944 CreateDataTable( ) method, 906 CreateDataView( ) method, 912

Page 103: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1613

CreateDomain( ) method, AppDomain class, 638

CreateInstance( ) method, 601, 638 CreateMyAsm( ) method, 691, 692, 693,

697 CreateNew member, FileMode

enumeration, 787 CreateObject<T> ( ) method, 959 CreateSalesMemoActivity.cs, 1109 CreateSubdirectory( ) method,

DirectoryInfo class, 778, 781 CreateText( ) method, FileInfo class, 785,

789 CreateThread( ) function, 626 CreateUsingLateBinding( ) method, 602 CreationTime property, FileSystemInfo

class, 778 Credentials property, 1040 CreditRisks table, adding to AutoLot

database, 879—880 cross-language inheritance, 549 *.cs extension file, 45, 289 *.cs file extension, 43, 46, 47, 50, 55, 217 csc (C-sharp compiler), 42 csc.exe compiler, 15, 24, 41, 43, 45, 46, 47,

48, 1149 csc.exe file, building C# applications with

command line flags, 43—44 compiling multiple source files, 46—47 overview, 42 referencing external assemblies, 45—46 referencing multiple external

assemblies, 46 response files, 47—49

csc.rsp response file, 48 CSE (corrupted state exceptions), 285, 286 C-sharp compiler (csc), 42 CSharpCarClient application, 546 CSharpCarClient project, 546, 547 CSharpCarClient.exe application, 553 CSharpCarClient.exe file, 547, 553, 554, 555 CSharpCarClient.exe.config file, 554, 555,

557 CSharpModule class, 619 CSharpModule type, 620

CSharpSnapIn project, 619, 620 CSharpSnapIn.dll assembly, 618, 621, 623 *.csproj file, 1148, 1150, 1151, 1166 CSS (cascading style sheet), 1394 CssClass property, WebControl Base Class,

1438 CssStyle property, 1465 C-style function pointer, 21 .ctor directive, 675 ctor token, 675, 689 Ctrl+M keystroke, 544, 581 Ctrl+Z keyboard shortcut, 1268, 1523 CTS (Common Type System)

class types, 19 data types, 22—23 delegate types, 21—22 enumeration types, 21 interface types, 20 structure types, 20 type members, 22

CTS (enumeration types, Common Type System), 21

CType operator, 1107 cubic Bezier curve, 1257 CUI (console user interface), 81 curly brackets, 83, 138 currBalance field, 183 Current ( ) method, 344 Current Inventory table, 916 Current property, Application class, 1129 Current value, 896 currentColor variable, 1556 CurrentContext property,

System.Threading.Thread Class, 741

CurrentDomain property, AppDomain class, 639

CurrentNumber property, 1333, 1334, 1335, 1336

CurrentNumberChanged( ) method, 1336 CurrentPriority member, ProcessThread

type, 633 currentShape variable, 1251, 1252, 1555

Page 104: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1614

CurrentThread property, System.Threading.Thread Class, 741

currentVideoGames array, 519 currentVideoGames variable, 500 currInterestRate field, 183, 185 currInterestRate variable, 186 currPay field, Employee class, 196 currSpeed field, 170, 686 Cursor property, 1133, 1198, 1526 curves, cubic Bezier, 1257 CustID field, 846 CustID key, 846 CustID parameter, 882 CustID value, 845 custom attributes

applying, 610 named property syntax, 610—611 overview, 609 restricting usage, 611—612

custom classes, 204, 758 custom constructor, 153 custom conversion routines, internal

representation of, 460 custom event arguments, creating, 424—

425 custom exceptions, building, 273—276 custom interfaces, defining, 325—327 custom layout manager, rendering to,

1280—1282 custom metadata viewer

displaying various odds and ends, 592 fields and properties, 591 generic types, 594 implemented interfaces, 591 implementing Main( ) method, 592—593 method parameters and return values,

594—595 methods, 590 overview, 590

custom namespaces, defining creating nested namespaces, 530 default namespace of Visual Studio

2010, 531 overview, 525—526

resolving name clashes with aliases, 528—530

resolving name clashes with fully qualified names, 527—528

custom objects, persisting, 1507—1509 .custom tokens, 542, 544 custom type conversions

among related class types, 454—455 anonymous types

containing anonymous types, 478 equality for, 476—478 internal representation of, 474—475 overview, 473 ToString( ) and GetHashCode( ), 476

creating routines, 455—457 explicit conversions for square types,

458 extension methods

extending interface types with, 469—470

extension libraries, 467—468 importing types that define, 465—466 IntelliSense mechanism, 466—467 invoking on instance level, 463 invoking statically, 464 overview, 460—462 scope of, 464—465

implicit conversion routines, 458—459 internal representation of custom

conversion routines, 460 numerical, 454 partial methods, 470—473

custom view state data, adding, 1478—1479 CustomAttribute tokens, 586 CustomAttributeBuilder member, 689 CustomBinding class, 1028 CustomConversions project, 455, 460 CustomDepPropApp application, 1331 CustomDepPropApp project, 1337 CustomEnumerator project, 345 CustomEnumeratorWithYield application,

346 CustomEnumeratorWithYield project, 349 <customErrors> element, 1427

Page 105: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1615

customers table, creating in AutoLot database, 844

CustomException class, 273 CustomException namespace, 343 CustomException project, 273 CustomGenericMethods application, 385 CustomGenericMethods project, 388 CustomInterface application, 325 CustomInterface project, 335 customizing Soap/Binary serialization

processes overview, 818—819 using attributes, 823 using ISerializable, 820—822

CustomNamespaces application, 525 CustomNamespaces namespace, 527 CustomNamespaces project, 531 CustomNamespaces.exe assembly, 525 CustomSerialization project, 821 CustomValidator control, 1458 CustomVisualFrameworkElement class,

1283 CustomVisualFrameworkElement objects,

1281 Cut command, 1200 Cut operation, 1202 C/Windows application programming

interface (API), 4

■D D command, 872 D string format character, 84 daemon threads, 750 dash (-) symbol, 44 data

2D graphical, 1254 deleting with generated codes, 942—943 inserting with generated codes, 941—

942 interactive graphical, 1246 interoperability, 716 private, 195 private points of, 207

public point of, 199 read-only field, 215 selecting with generated codes, 940—

941 stack-based, 366

data access library, ADO.NET, reusing adding connection logic, 863 adding deletion logic, 865 adding insertion logic, 863—864 adding selection logic, 866 adding update logic, 865 executing stored procedure, 869—871 overview, 861—862 parameterized command objects, 867—

869 data access logic, adding, 1397—1401 data adapter class, 913 data adapters

configuring using SqlCommandBuilder class, 918—919

mapping database names to friendly names, 916

overview, 913 prepping, 922—923 simple data adapter example, 914—915 strongly typed, 936—937

data allocation, in-memory, 183, 184 data binding

entities, to Windows Forms GUIs, 986—989

WPF Data Binding tab, 1236 DataContext property, 1239 DataGrid tab, 1242—1244 establishing data bindings, 1236—

1238, 1241—1242 IValueConverter interface, data

conversion using, 1240—1241 overview, 1235

Data Binding option, 1236 Data Binding tab, WPF, 1214, 1236 data caching, 1489—1491 Data Connections node, 840 data contracts, designing

examining Web.config files, 1075

Page 106: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1616

implementing service contracts, 1073—1074

overview, 1070 role of *.svc files, 1074 testing services, 1075—1076 using Web-Centric service project

templates, 1071—1073 Data Control Language (DCL), 885 Data Definition Language (DDL), 885 data parallelism, 763—766 data points, 189 Data property, 270—272, 274, 1101, 1254,

1255, 1256, 1257, 1267 data provider factory model, ADO.NET

<connectionStrings> element, 852—853 complete data provider factory

example, 848—851 overview, 847 potential drawback with provide

factory model, 851—852 data providers, ADO.NET

abstracting using interfaces, 837—840 Microsoft-supplied, 829—830 overview, 827—828 system.Data.OracleClient.dll, 830—831 third-party, obtaining, 831

data readers, ADO.NET, 859—861 data relationships and multitabled DataSet

objects building table relationships, 924 navigating between related tables, 925—

927 overview, 921 prepping data adapters, 922—923 updating database tables, 924

Data Source Configuration Wizard, 928, 931, 933, 936

Data Source name, 854 data templates, 1244 data type conversions

narrowing data conversions, 108—110 overflow checking, 110—111 overview, 106—107 System.Convert, 112 unchecked keyword, 111

data type variable, 90 data types

Common Type System (CTS), 22—23 nullable, 837

data validation logic, 210 DataAdapter object, 828 Database Diagrams node, 846 Database Explorer window, 840 Database Management System (DBMS),

827, 829, 830, 886 database management systems (DBMS),

830, 851, 867 database names, mapping to friendly

names, 916 Database property, 855 database tables, updating, 924 database transactions, ADO.NET

adding CreditRisks table to AutoLot database, 879—880

adding transaction method to InventoryDAL class, 880—882

key members of transaction object, 878—879

overview, 877 testing, 882—883

DatabaseReader class, 164, 189 DataBind( ) method, 1432 data-binding logic, 1236 data-binding model, WPF, 1135 DataColumn class, 885, 887, 889, 890, 891,

892, 894, 904 DataColumn objects, 886, 890, 891, 892,

893, 898, 906 DataColumn types

adding objects to DataTable types, 892—893

building, 891—892 enabling autoincrementing fields, 892 overview, 889—890 System.Data namespace, 832

DataContext property, 1239 [DataContract] attribute, 1027, 1070 DataGrid control, 1242 DataGrid objects, 1235 DataGrid tab, WPF, 1214, 1242—1244

Page 107: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1617

DataGridView class, 903, 904, 906, 907, 912, 920, 921, 924, 927, 928

DataGridView control, 927—932 DataGridView object, 906, 921, 986 DataGridView widget, 322 DataGridView wizard, 939 dataGridViewCustomers widget,

DataGridView class, 921 DataGridViewDataDesigner project, 927,

938 dataGridViewInventory widget,

DataGridView class, 921 dataGridViewOrders widget, DataGridView

class, 921 dataGridYugosView class, 912 [DataMember] attribute, 1027, 1070, 1071 DataParallelismWithForEach application,

763 DataParallelismWithForEach project, 768 DataProviderFactory application, 848, 853 DataProviderFactory project, 853 DataProviderFactory.exe assembly, 848 DataReader class, 900 DataReader object, 827 DataRelation class, 885, 887, 925 DataRelation collection, 921 DataRelation objects, 921, 924 DataRelation type, System.Data

namespace, 832 DataRelationCollection class, 887 DataRow class, 885, 893, 895, 896, 934, 935,

939, 941, 946, 947 DataRow indexers, 948 DataRow objects, 886, 893, 894, 895, 896,

907, 908, 916, 947 DataRow type

DataRowVersion property, 896—897 overview, 893 RowState property, 894—896

DataRow type, System.Data namespace, 832

DataRow.AcceptChanges( ) method, 896 DataRow.BeginEdit( ) method, 896 DataRow.CancelEdit( ) method, 896 DataRowCollection class, 895

DataRow.EndEdit( ) method, 896 DataRowExtensions class, 946 DataRowExtensions.Field<T>( ) Extension

method, 948 DataRow.RejectChanges( ) method, 897 DataRows, strongly typed, 935 DataRowState enumeration, 894, 895 DataRowState property, 896 DataRowVersion enumeration, 896 DataRowVersion property, 896—897 DataSet class, 885, 886, 932, 933, 937, 938,

939, 1420, 1479, 1488 DataSet container, 951 Dataset Designer, Visual Studio 2010, 933 DataSet extensions library, 945—946 DataSet member, 897 DataSet model, 929 DataSet objects, 494, 864, 885, 886, 899,

932, 945, 946, 951 DataSet types

building, 889 key methods of, 888 key properties of, 887 overview, 886 programming to with LINQ

DataSet extensions library, 945—946 obtaining LINQ-compatible

datatables, 946—947 overview, 943—944 populating new DataTables from

LINQ queries, 948—950 role of

DataRowExtensions.Field<T>( ) Extension method, 948

System.Data namespace, 832 DataSetName property, 887 DataSets

inserting DataTables into, 898 obtaining data in, 898—899 strongly typed, 932—934

DataSet.WriteXml( ) method, 890 DataSource property, 855, 906, 913, 921,

949 DataSourceID property, 1446, 1447, 1450,

1451

Page 108: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1618

DataTable class, 866, 885, 886, 888, 891, 892, 935, 936, 937, 939

DataTable objects, binding to Windows Forms GUIs

DataView type, 912—913 deleting rows from DataTable, 907—908 hydrating DataTable from generic

List<T>, 904—906 overview, 903 selecting rows based on filter criteria,

908—911 updating rows within DataTable, 911

DataTable type adding objects to, 892—893 inserting into DataSets, 898 obtaining data in DataSets, 898—899 overview, 897 processing data using DataTableReader

objects, 899—901 serializing DataTable/DataSet objects

as XML, 901—902 serializing DataTable/DataSet objects

in binary format, 902—903 System.Data namespace, 832

DataTable variable, 906 DataTable.AcceptChanges( ) method, 896 DataTableCollection class, 887 DataTableCollection type, 443 DataTable/DataSet objects

serializing as XML, 901—902 serializing in binary format, 902—903

DataTableExtensions class, 946, 947 DataTableMapping class, 916 DataTableMappingCollection collection,

916 DataTable.NewRow( ) method, 894 DataTableReader class, 900, 1074 DataTableReader objects, using to

processing data, 899—901 DataTableReader type, System.Data

namespace, 832 DataTables class

hydrating from generic List<T>, 904—906

populating from LINQ queries, 948—950

strongly typed, 934 dataToShow variable, 1342 DataType property, DataColumn class, 890 DataTypeFunctionality( ) method, 93 DataView class, 885, 912, 913, 949 DataView object, 904 DataView type, 832, 912—913 DatePicker control, 1347 DateTime class, 132 DateTime structure, 95 DateTime type, 85, 95 DateTime variable, 89 DateTime.Now.AddSeconds(15)

parameter, 1491 DbCommand class, 827, 847, 957 DbCommand type, 858 DbConnection class, 827, 837, 847, 855,

957 DbDataAdapter class, 828, 847, 886, 913,

914 DbDataReader class, 827, 847 DbDataReader object, 858 DbDataReader type, 859 DBMS (Database Management System),

827, 829, 830, 886 DBMS (database management systems),

830, 851, 867 DbParameter class, 828, 847 DbParameter objects, 858 DbParameter type, specifying parameters

using, 867—869 DbProviderFactories class, 848 DbProviderFactory class, 848 DbProviderFactory object, 848 DbTransaction class, 828, 847 DbType property, 868 DCL (Data Control Language), 885 DCOM (Distributed Component Object

Model), 1014—1015, 1019 DDL (Data Definition Language), 885 Deactivate event, 1531, 1532, 1533 deactivated, 1531 Debug folder, 76, 546, 1114, 1149, 1287 Debug tab, Visual Studio 2010, 79, 80 debugging ASP.NET pages, 1410—1411

Page 109: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1619

DecelerationRatio property, Timeline class, 1305

decimal data type, 87 DeclareImplicitVars( ) method, 113 DeclareLocal( ) method, 690 Decrement( ) method, 756, 757 dedicated databases, storing session data

in, 1502 deep copy, 350 default application domain, 638 default constructor, 89, 153, 211, 212, 393 default content pages, 1448—1449 default context (context 0), application

domain, 648 Default edit area, 1107 default endpoints, 1051—1052 default input button, setting, 1541 default keyword, 390 Default namespace option, 531 Default property, 1106 Default value, 896, 1368 Default.aspx file, 1446, 1449, 1468, 1469,

1493, 1505, 1506 Default.aspx page, 1496, 1505 DefaultDrawingAttributes property, 1224 defaultProvider, 1505 default(T) syntax, 390 defaultValue attribute, 1504 DefaultValue property, DataColumn class,

890 DefaultView member, 897 DefineConstructor( ) method, 696 DefineDefaultConstructor( ) method, 697 DefineDynamicModule( ) method, 694 DefineEnum( ) method, 694 DefineLabel( ) method, 690 DefineMethod( ) method, 697 DefineResource( ) method, 694 DefineType( ) method, 694 defining

groups, 1463—1465 user profiles within Web.config, 1504—

1505 DefiningGeometry property, Shape class,

1248

definitions on interface types, 444 Delay activity, WF 4.0, 1091 Delegate, 412 delegate keyword, 21, 398, 399, 400, 401,

432 delegate variable, 412 Delegate.Combine( ) method, 409, 421 DelegateCovariance application, 413 DelegateCovariance project, 415 delegate/event model, 9 Delegate.Remove( ) method, 410, 421 delegates

.NET delegate type, 397—398 asynchronous nature of

BeginInvoke( ) and EndInvoke( ) methods, 732

overview, 731 System.IAsyncResult interface, 732—

733 defining delegate type in C#, 398—400 delegate covariance, 413—415 generic, 415—418 method group conversion syntax, 411—

413 sending object state notifications using

enabling multicasting, 408—409 overview, 405—407 removing targets from delegate's

invocation list, 410—411 simplest possible delegate example,

402—404 System.MulticastDelegate and

System.Delegate base classes, 400—401

delegation, programming for, 232—235 DELETE command, 914 delete keyword, 9, 289 Delete( ) method

DataRow class, 895, 907 Directory class, 783 DirectoryInfo class, 778 FileInfo class, 785 FileSystemInfo class, 778

Delete statement, 861, 862, 1450 Delete Sticky Note button, 1234

Page 110: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1620

DeleteCar( ) method, 875 DeleteCommand property, 914, 918, 949 Deleted value, 895 DeleteObject( ) method, 959, 975, 976 deleting records, 974—975 Delta property, 1535 demonstrating view state, 1477—1478 dependency properties, WPF

building custom, 1331—1336 CLR property wrappers, 1330 examining existing, 1327—1330 overview, 1325—1326

DependencyObject class, 1135, 1326 DependencyObject parameter, 1335, 1336 DependencyProperty field, 1326, 1330 DependencyProperty object, 1328, 1330,

1336 DependencyProperty variable, 1326 DependencyPropertyChangedEventArgs

parameter, 1335 DependencyProperty.Register( ) method,

1326, 1328, 1329, 1335 <dependentAssembly> element, 573, 574 deprecated, 830 Dequeue( ) method, 382, 383 derived class, casting rules

is keyword, 250 as keyword, 249 overview, 247—248

derived types, 323, 324 DerivedCars.cs file, 540 DESC (descending), 910 DescendantNodes<T>( ) method, 1000 Descendants( )method, 1008 Descendants<T> method, 1000 descending (DESC), 910 descending operator, 509, 514 Description property, 610, 615, 1065 Desendants( ) method, 1001 deserialization, defined, 804 Deserialize( ) method

BinaryFormatter type, 811, 813 IFormatter interface, 809 SoapFormatter type, 813

deserializing objects, 812—813

Design tab, SharpDevelop, 52 designer toolbox, SharpDevelop, 52 <Designer> element, 970 .Designer.cs file, 1520 *.Designer.cs files, 1521 desktop applications, WPF and XAML,

1121—1123 desktop markup, 1119 desktop program, navigation-based, 1124 Detached value, 895 development web server, ASP.NET, 1382 diagnostics element, 1043 dialog boxes

designing configuring tab order, 1540 DialogResult property, 1539 displaying dialog boxes, 1542—1543 overview, 1538 setting form's default input button,

1541 Tab Order Wizard, 1540—1541 understanding form inheritance,

1543—1545 WPF, 1183

Dialog class, 1538 DialogResult enumeration, 1539 DialogResult property, 1539 DialogResult type, 1532 DialogResult values, 1542, 1553 diamond button, 1293 dictionaries, merged resource, 1298—1299 Dictionary object, 1088, 1105 Dictionary<> object, 1094 Dictionary<> variable, 1086 Dictionary<K,V> object, 952 Dictionary<string, object> variable, 1084 Dictionary<TKey, TValue> class, 377 DictionaryEntry type, 271 digital signature, 560, 561 dimensions, indexers with multiple, 443—

444 direct event, 1338 Direct Selection button, 1213 Direction property, 843, 868, 871 directives

Page 111: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1621

ASP.NET, 1401—1403 role of CIL, 655

directly creating types, 797—798 Directory class, 776, 777 Directory method, FileInfo class, 785 Directory types, 782—783 DirectoryApp project, 783 Directory.GetFiles( ) method, 764 DirectoryInfo class, 776, 777 DirectoryInfo types

abstract FileSystemInfo base class, 777—778

creating subdirectories with DirectoryInfo type, 781—782

enumerating files with DirectoryInfo type, 780—781

DirectoryName method, FileInfo class, 785 DirectX layer, 1120 dirty entities, 990 dirty window, 1549 DisableAllButton style, 1319 Disassembler window, 36 disco utility, Mono, 1571 disco.exe utility, Microsoft .NET, 1571 disconnected functionality, testing, 920—

921 disconnected layer, of ADO.NET

adding disconnection functionality to AutoLotDAL.dll

configuring data adapters using SqlCommandBuilder class, 918—919

defining initial class types, 917 GetAllInventory( ) method, 919 setting version numbers, 919 testing disconnected functionality,

920—921 UpdateInventory( ) method, 919

binding DataTable objects to Windows Forms GUIs

DataView type, 912—913 deleting rows from DataTable, 907—

908 hydrating DataTable from generic

List<T>, 904—906

overview, 903 selecting rows based on filter

criteria, 908—911 updating rows within DataTable,

911 data adapters

mapping database names to friendly names, 916

overview, 913 simple data adapter example, 914—

915 DataColumn types

adding objects to DataTable types, 892—893

building, 891—892 enabling autoincrementing fields,

892 overview, 889—890

DataRow type DataRowVersion property, 896—897 overview, 893 RowState property, 894—896

DataSet types building, 889 key methods of, 888 key properties of, 887 overview, 886

DataTable type inserting into DataSets, 898 obtaining data in DataSets, 898—899 overview, 897 processing data using

DataTableReader objects, 899—901 serializing DataTable/DataSet

objects as XML, 901—902 serializing DataTable/DataSet

objects in binary format, 902—903 isolating strongly typed database code

into class libraries deleting data with generated codes,

942—943 inserting data with generated codes,

941—942 invoking stored procedure using

generated codes, 943

Page 112: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1622

overview, 938 selecting data with generated codes,

940—941 viewing generated codes, 939—940

multitabled DataSet objects and data relationships

building table relationships, 924 navigating between related tables,

925—927 overview, 921 prepping data adapters, 922—923 updating database tables, 924

overview, 885 programming with LINQ to DataSet

types DataSet extensions library, 945—946 obtaining LINQ-compatible

datatables, 946—947 overview, 943—944 populating new DataTables from

LINQ queries, 948—950 role of

DataRowExtensions.Field<T>( ) Extension method, 948

Windows Forms database designer tools

app.config files, 932 completing Windows Forms

applications, 937 DataGridView control, 927—932 strongly typed data adapters, 936—

937 strongly typed DataRows, 935 strongly typed DataSets, 932—934 strongly typed DataTables, 934

disconnection functionality, adding to AutoLotDAL.dll

configuring data adapters using SqlCommandBuilder class, 918—919

defining initial class types, 917 GetAllInventory( ) method, 919 setting version numbers, 919 testing disconnected functionality,

920—921

UpdateInventory( ) method, 919 discrete key frames, authoring animation

in XAML, 1311—1312 DiscreteStringKeyFrame elements, 1312 Dispatcher class, 1135 Dispatcher property, 1135 DispatcherObject class, 1135 Display( ) method, 685 display name, 598, 599 Display property, 1458, 1462 DisplayBaseClass<T> method, 388 DisplayCarInfo( ) method, 684 DisplayCompanyData( ) method, 623 DisplayDefiningAssembly( ) method, 461,

462, 463 DisplayDelegateInfo( ) method, 404 DisplayFancyMessage( ) method, 133, 134 displaying dialog boxes, 1542—1543 DisplayName property, 1093, 1094, 1104 DisplayStats( ) method, 203, 208, 237, 239,

240 DisplayTable( ) method, 874 DisplayTypes( ) method, 596 disposable objects, 305—309 Dispose( ) method, 305, 306, 307, 308, 309,

310, 311, 312, 833, 1550 Distinct( ) method, 509, 516 Distributed Component Object Model

(DCOM), 1014—1015, 1019 distributed computing APIs

.NET remoting, 1016 COM+/Enterprise Services, 1015 Distributed Component Object Model

(DCOM), 1014—1015 Microsoft Message Queuing (MSMQ),

1015—1016 named pipes, sockets, and P2P, 1019 overview, 1013 XML web services, 1016—1019

distributed system, 1013 div opcode, 678 Divide( ) method, 394 *.dll assembly, 44, 1103, 1159, 1500 *.dll code library, 534

Page 113: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1623

*.dll file extension, 12—13, 14, 532, 559, 663, 1083

DLL hell, 6, 577 *.dll module, 14 *.dll .NET binaries, 12 [DllImport] attribute, 605 DLR. See dynamic types and Dynamic

Language Runtime DNS (Domain Name Service), 1380, 1381 DNS (Domain Name System), 1418 do keyword, 682 Dock property, 1326, 1526 DockPanel class, 1138, 1162, 1326 DockPanel panels, 1193—1194 DockPanel types, 1194 <DockPanel> element, 1194, 1196, 1198,

1264 DOCTYPE instruction, 1383 document annotations, 1120 document controls, WPF, 1183 document layout managers, WPF, 1228 Document Object Model (DOM), 993, 995,

1011, 1388, 1389 Document Outline window, 1181, 1182,

1295 Document property, 1229, 1230 document structure, HTML, 1383—1384 documentation, 585—586, 1441 Documents API, WPF

block elements, 1227 document layout managers, 1228 inline elements, 1227

documents, generating from arrays and containers, 1004—1005

Documents tab, WPF annotations, enabling, 1232—1234 overview, 1228—1229 populating FlowDocument

using Blend, 1230—1231 using code, 1231—1232

saving and loading FlowDocument, 1234—1235

sticky notes, enabling, 1232—1234 Doing more work in Main( )! message, 734 DoIt( ) method, 619, 620, 622

DOM (Document Object Model), 993, 995, 1011, 1388, 1389

DOM models vs. XML APIs, 995—996 domain first programming, 962 Domain Name Service (DNS), 1380, 1381 Domain Name System (DNS), 1418 DomainUnload event

AppDomain class, 640 AppDomain type, 647

DontUseCorLibDumper.dll, 1578 dot (.) prefix, 655 dot operator, 152, 290, 302, 339, 519, 703 dotNetFx40_Client_x86_x64.exe runtime

profile, 37 dotNetFx40_Client_x86.exe setup

program, 37 dotnetfx40_full_setup.exe setup program,

41 dotNetFx40_Full_x86_x64.exe runtime

profile, 37 dotNetFx40_Full_x86.exe setup program,

37 DotNetLanguages.net, 11 double arguments, 131 double array, 130 double data type, 87, 96, 130, 135 double value, 1240, 1261 DoubleAnimation class, 1304 DoubleAnimation object, 1304, 1307, 1309 <DoubleAnimation> element, 1310 DoubleAnimationUsingKeyFrames class,

1304 DoubleAnimationUsingPath class, 1304 DoubleAnimationUsingPath property,

1255 DoubleClick event, 1528 doubles array, 130 DoWhile activity, WF 4.0, 1089 do/while loop, 117, 119, 872 download cache, 537, 576 download page, Mono website, 1565 Download tab, Mono website, 1565 DownloadString( ) method, 768 DownloadStringAsyn( ) method, 768 DownloadStringCompleted event, 768

Page 114: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1624

DragDrop event, 1528 DragEnter event, 1528 DragLeave event, 1528 DragOver event, 1528 Draw( ) method, 242, 243, 244, 245, 246,

337, 338, 340, 341, 342 DrawArc( ) method, 1548 DrawBeziers( ) method, 1548 DrawCurve( ) method, 1548 DrawEllipse( ) method, 1548 DrawIcon( ) method, 1548 DrawIn3D( ) method, 332 DrawInBoundingBox( ) method, 340 Drawing class, 1258, 1271 Drawing object, 1258, 1271 Drawing type, 1272 DrawingAttributes object, 1224 DrawingBrush

building using geometries, 1272—1273 painting with, 1273—1274

DrawingBrush class, 1258 DrawingBrush object, 1272, 1278 DrawingBrush type, 1258 DrawingContext class, 1278, 1279 DrawingContext object, 1278, 1279 <DrawingGeometry> element, 1273 DrawingGroup property, 1255 DrawingGroup type, 1271 DrawingImage, containing drawing types

in, 1274—1275 DrawingImage object, 1272 drawings and geometries, rendering

graphical data using building DrawingBrush using

geometries, 1272—1273 containing drawing types in

DrawingImage, 1274—1275 painting with DrawingBrush, 1273—

1274 DrawingVisual class, 1135, 1277, 1278—

1279, 1282 DrawingVisual instance, 1279 DrawingVisual object, 1258, 1272, 1280 DrawLine( ) method, 1548, 1550 DrawLines( ) method, 1548

DrawPath( ) method, 1548 DrawPie( ) method, 1548 DrawRectangles( ) method, 1548 DrawString( ) method, 1548, 1550 DrawUpsideDown( ) method, 340 dreamCar object, 549 DriveInfo class, 776 DriveInfo class types, 783—784 DriveInfoApp project, 784 DriveNames variable, 1098, 1099 driverName field, 175 Drop activity here area, 1081 dropdown area, 1217 DropDownItems property, 1516 Dump menu option, 659 dumpbin.exe file, 535 DumpTypeToFile( ) method, 1572 duplex messaging, 1030 Duration object, 1307 Duration property, 1306, 1307, 1310 dynamic assemblies

emitting assembly and module set, 693—694 constructors, 696—697 HelloClass type and String Member

variable, 695—696 overview, 691—692 SayHello( ) method, 697

ModuleBuilder type, role of, 694—695 overview, 688 System.Reflection.Emit namespace,

689—690 System.Reflection.Emit.ILGenerator,

role of, 690—691 using dynamically generated assembly,

697 dynamic data, 720 dynamic keyword, 7, 10, 115, 701, 705, 706,

709, 713, 714, 718 dynamic loading, 596, 617 dynamic types and Dynamic Language

Runtime (DLR) C# dynamic keyword

calling members on dynamically declared data, 703—704

Page 115: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1625

limitations of, 706—707 overview, 701—702 practical uses of, 707 role of Microsoft.CSharp.dll

assembly, 705 scope of, 706

COM interoperability simplifying using dynamic data,

714—718 using C# 4.0 language features, 718—

724 without C# 4.0 language features,

722—724 role of DLR

dynamic runtime lookup of expression trees, 709—710

expression trees, 708 overview, 707 System.Dynamic namespace, 709

simplifying late bound calls using dynamic types

leveraging dynamic keyword to pass arguments, 711—713

overview, 710 dynamic typing, 115 dynamic variable, 703 dynamically adding and removing

controls, 1435—1436 dynamically created controls, 1436—1437 dynamically generated assembly, 697 DynamicAsmBuilder application, 691 DynamicAsmBuilder project, 698 DynamicCtrls, Empty Web Site, 1433 DynamicCtrls website, 1437 DynamicKeyword application, 701

■E E string format character, 84 E_FILENOTFOUND constant, 260 early binding, attributes using, 614—615 Easton, Mark, 1561 theEBook class level string variable, 768

ECMA (European Computer Manufacturers Association), 1562

ECMA International web site, 654 ECMA-334 specification, 38, 1562 ECMA-335 specification, 38, 1562 Edit Columns dialog, 988 Edit menu, 1196, 1202 edit mode, for code snippets, 63 EditingCommands class, WPF, 1202 EditingMode property, 1222 EDM. See entity data model EdmGen.exe file, 961 *.edmx file, 958

generating, 961—965 viewing generated data, 968—970

<edmx:ConceptualModels> element, 969 <edmx:Edmx> element, 968 edmxResourcesToEmbed subdirectory,

970 <edmx:Runtime> element, 968 EF. See Entity Framework EightBallClient class, 1046 EightBallServiceMEXBehavior element,

1043 Element Property tab, 1237 ElementName value, 1238 elements, XAML, 1160—1161 Elements<T> method, 1000 Ellipse area, 1352 ellipse button, 1097, 1106, 1107, 1230 Ellipse class, 1162, 1247, 1256 Ellipse element, 1258 Ellipse object, 1250, 1252, 1339, 1340 Ellipse types, 1254, 1339 <Ellipse> element, 1225, 1267 <Ellipse> tag, 1132 EllipseGeometry class, 1255 EllipseGeometry object, 1255 ellipses

adding to canvas, 1249—1252 removing from canvas, 1252—1253

Else branch, 1110, 1111 else statement, 120 Embed Interop Types property, 716, 718,

720, 722

Page 116: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1626

embedding, interop metadata, 716—717 Emit( ) method, 690, 691, 696 EmitCall( ) method, 690 emitting HTML content, 1422 EmitWriteLine( ) method, 690, 697 empAge field, 200 empBenefits object, 232 empID field, Employee class, 196 Employee class, 195, 196, 227, 228, 229,

230, 232, 234, 235, 237 Employee object, 200, 240 Employee type, 203, 205, 233 EmployeeApp project, 195, 206, 217, 218,

226 EmployeeApp.exe assembly, 202 Employee.cs file, 195, 217, 226 Employee.Internal.cs file, 217, 226 Employees project, 241 empName field, 196, 197 empSSN variable, 203 Empty Web Site project, 1473, 1477, 1485,

1489, 1494, 1498, 1504 Empty Web Site template, Visual Studio,

1406, 1407 EmpType enumeration, 144, 145, 146, 147,

149 EmpType variable, 146 Enable Deleting check box, 1454 Enable Editing check box, 1454 Enable( ) method, 1234 EnableAnnotations( ) method, 1233 EnableClientScript property, 1458 Enabled property, 1437, 1527 EnabledStateGroup, 1366 EnableTheming attribute, 1401 EnableTheming property, 1432 EnableViewState attribute, 1402, 1477,

1478 EnableViewState property, 1478 enabling

autoincrementing fields, 892 in-place editing, 1454 metadata exchange, 1043—1045 sorting and paging, 1453

Encapsulate Field refactoring, 61

encapsulation of classes

internal representation of properties, 202—203

overview, 194 read-only and write-only properties,

204—205 static properties, 205—206 using .NET properties, 198—200 using properties within class

definition, 200—201 using traditional accessors and

mutators, 195—197 visibility levels of properties, 204

as pillar of OOP, 189 End( ) method, 1035, 1069, 1421 EndClose( ) method, 1040 EndEdit( ) method, 893 EndExceptionBlock( ) method, 690 EndInvoke( ) method, 399, 400, 732, 733,

734, 738, 774, 1086 EndOpen( ) method, 1040 <endpoint> element, 1032, 1037, 1039,

1043, 1046, 1050, 1051, 1052, 1054, 1075

endpoints, 1037, 1051—1052, 1072 EndScope( ) method, 690 EnforceConstraints property, 888 EngineState enumeration, viewing type

metadata for, 582—583 enlist each command object, 882 Enqueue( ) method, 382, 383 EnterLogData( ) method, 131, 132 EntiryDataReader, 961 entities, 953—955 entity classes, 973 entity client, 956—957 Entity Client Data Reader Object, 978—979 entity data model (EDM), building and

analyzing enhancing generated source code, 972—

973 generating *.edmx file, 961—965 reshaping Entity Data, 965—967

Page 117: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1627

viewing generated *.edmx file data, 968—970

viewing generated source code, 970—971

viewing mappings, 967 Entity Framework (EF)

AutoLotDAL Version 4.0 invoking stored procedure, 985—986 mapping stored procedure, 980—981 navigation properties, 982—984, 984—

985 overview, 979

building and analyzing entity data model (EDM)

enhancing generated source code, 972—973

generating *.edmx file, 961—965 reshaping Entity Data, 965—967 viewing generated *.edmx file data,

968—970 viewing generated source code, 970—

971 viewing mappings, 967

data binding entities to Windows Forms GUIs, 986—989

programming against conceptual model

deleting records, 974—975 Entity Client Data Reader Object,

978—979 overview, 973 querying with Entity SQL, 977—978 querying with LINQ to Entities, 975—

977 updating records, 975

role of *.edmx file, 958 entities, 953—955 entity client, 956—957 object services, 956 ObjectContext and ObjectSet<T>

classes, 958—960 overview, 951—952

Entity model, 929 Entity Model Data Wizard, 963

Entity Set Name field, 967 Entity Set value, 967 Entity SQL, querying with, 977—978 Entity Types folder, 965 EntityCommand class, 957 EntityConnection class, 957 EntityDataReader class, 957, 961 EntityKey object, 974 EntityObject class, 956 EntityState property, 975 <EntityType> node, 969 .entrypoint directive, 662 .entrypoint opcode, 687 enum attribute, 671 enum keyword, 21, 654 enum type

declaring variables, 146—147 discovering name/value pairs of, 148—

150 overview, 144 System.Enum type, 147 underlying storage for, 145—146

enum value, 675 enum variable, 147, 148 EnumBuilder member, 689 enumData object, 947 Enumerable class, 513, 514, 515, 516, 517,

520 Enumerable methods, 503 enumerable types, building

building iterator methods with yield keyword, 346

building named iterator, 347—348 internal representation of iterator

method, 348—349 overview, 343—345

Enumerable.OfType<T>( ) method, 507 EnumerableRowCollection class, 947, 948 Enumerable.Where( ) method, 519 EnumerateMachineDataWF project, 1093 EnumerateMachineInfoWF project, 1103 enumerating contained controls, 1432—

1435 enumerating files, with DirectoryInfo type,

780—781

Page 118: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1628

enumeration types, Common Type System (CTS), 21

enumerations, 21, 144, 145, 147, 671 Enum.Format( ) method, 148 Enum.GetUnderlyingType( ) method, 147,

148 Environment class, 79, 181 Environment type, 80, 81 Environment.GetCommandLineArgs( )

method, 1140 ephemeral generations, 296, 297 Equal value, 1461 equality operator, 164, 449—450, 476—478 Equals( ) method, 91, 97, 102, 251, 253, 449,

450, 476, 477 Erase mode, 1223 Erase Mode! value, 1218 EraseByStoke mode, 1223 eraseRadio control, 1219 Error event, 1425—1426, 1481 error handling activities, WF 4.0, 1092—

1093 Error List window, Visual Studio 2010, 605,

608 error window, Visual Studio 2010, 246 ErrorMessage property, 1458, 1459 escape characters, 100—101, 1174 European Computer Manufacturers

Association (ECMA), 1562 event handling, server-side, 1430 event keyword, 397, 406, 419—421 event model, WPF, 1139 event triggers, authoring animation in

XAML, 1310—1311 EventArgs class, 1424, 1517, 1518 EventBuilder member, 689 EventHandler<T> delegate, generic, 426 EventInfo class, System.Reflection

Namespace, 587 events, C#

creating custom event arguments, 424—425

event keyword, 419—421 generic EventHandler<T> delegate, 426 hidden methods of, 421

incoming, listening to, 422—423 overview, 418 registrating, simplifying event using

Visual Studio 2010, 423—424 Events tab, 1171, 1181, 1370 <EventTrigger> element, 1311 Except( ) method, 515 Exception base class, 272 exception block, 690 Exception class, 267 Exception code snippet template, 277 exception event handler, 1481—1482 exception handling. See structured

exception handling Exception object, 1101 Exception property, 1097 exception-derived type, 272 Exchange( ) method, Interlocked class, 756 *.exe assembly, 686 *.exe file extension, 12, 13, 14—15, 532, 664,

1124 *.exe module, 14 Execute button, 771 Execute( ) method, 1109 ExecuteAssembly( ) method, AppDomain

class, 638 Executed attribute, 1205 Executed events, 1203, 1205 Executed handlers, 1206 ExecuteFunction( ) method, 985 ExecuteFunction<T>( ) method, 959 ExecuteNonQuery( ) method, 859, 861,

862, 863, 871, 882 ExecuteReader( ) method, 834, 853, 858,

859, 861 ExecuteScalar( ) method, 859 ExecuteStoreCommand( ) method, 959 Existing Item menu option, 1287 Exists property, FileSystemInfo class, 778 ExistsInCollection<T> activity, WF 4.0,

1092 Exit event, 1128, 1129, 1136, 1137, 1147 Exit handler, 1130 Exit menu, 1516, 1523, 1538 Exit option, 1196

Page 119: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1629

ExitCode property, System.Environment class, 81

ExitEventArgs class, 1137 ExitEventHandler delegate, 1137 ExitTime property, System.Diagnostics.

Process class, 628 exitToolStripMenuItem menu, 1523 Expander control, 1198, 1206 Expander widget, 1195 ExpenseIt WPF sample program, 1124 explicit attribute, 669 explicit cast operation, 107, 249, 1107 explicit conversions

for square types, 458 when required, 454

explicit interface implementation, 336, 337, 339, 342

explicit keyword, 455, 456 explicit load, 554 explicitly implemented interface, 338 explicitly pop, 679 Exploded event, 420, 421, 428 exponential format, 84 exponential notation, 84 Export All button, 1276 Export button, 720 Export dialog box, 1276 Export menu option, 1276 exporting, design document to XAML,

1275—1276 ExportToExcel( ) method, 720, 722 exposing single services using multiple

bindings, 1052—1053 Expression area, 1107 Expression Blend

building user interface with key aspects of, 1207—1213 TabControl control, 1213—1215

establishing data bindings using, 1236—1238

extracting resources in, 1301—1303 generating WPF styles with, 1320—1324 populating FlowDocument, 1230—1231 UserControls, building custom

animation, defining, 1359—1362

initial C# code, 1359 overview, 1356 programmatically starting

storyboard, 1363—1364 renaming initial, 1357—1358 SpinControl, 1358

working with shapes using brush and transformation editors,

1269—1271 combining shapes, 1268 converting shapes to paths, 1267—

1268 overview, 1266 selecting shape to render from tool

palette, 1266—1267 Expression property, DataColumn class,

890 expression trees, 708—710 extendable applications

C# Snap-In, 619—620 CommonSnappableTypes.dll, 619 extendable Windows Forms

application, 621—624 overview, 618 Visual Basic Snap-In, 620

extendable Windows Forms application, 621—624

ExtendedProperties collection, 898 ExtendedProperties property, 887 extending interface types, 469—470 extends attribute, 655, 660, 669, 670 extends clause, 670 Extends token, 583 Extensible Application Markup Language

(XAML), 993 Extensible Hypertext Markup Language

(XHTML), 1383, 1392 Extensible Markup Language (XML), 995,

996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004

Extensible Markup Language (XML) schema editor, 902

Extensible Markup Language Path Language (XPath), 993

Page 120: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1630

Extensible Markup Language Query (XQuery), 993

Extensible Markup Language Schema Definition (XSD) editor, 902

Extensible Stylesheet Language Family Transformations (XSLT), 993

extension libraries, 467—468 extension methods

extending interface types with, 469—470 extension libraries, 467—468 importing types that define, 465—466 IntelliSense mechanism, 466—467 invoking on instance level, 463 invoking statically, 464 overview, 460—462 scope of, 464—465

Extension property, FileSystemInfo class, 778

ExtensionMethods project, 461, 467 Extensions class, 1000 extern attribute, 662 external assemblies

loading, 596 referencing, 32

External AssemblyReflector application, 597

external attribute, 666 external code libraries, 1083 external XAML files, 1082 ExternalAssemblyReflector application,

596 Extract Interface refactoring, 61 Extract Method option, 61 Extract Method refactoring, 61 Extract value to Resource option, 1293 extracting resources

changing after, 1295 in Expression Blend, 1301—1303

■F F string format character, 84 F suffix, 87 F# language, 10

Factory property, Task class, 766 false branch, 1097 false operator, 445 false value, 330 FCLs (Framework class libraries), 3 feed project template, RSS, 1024 Field #n token, 583 field access, with pointers, 484 field data

defining in CIL, 674—675 static, 182—185

.field directive, 674 Field<T>( ) method, 948 FieldBuilder member, 689 FieldBuilder type, 696 FieldCount property, 860 FieldInfo array, 591 FieldInfo class, System.Reflection

Namespace, 587 FieldModifier keyword, 1156, 1159 fields, custom metadata viewer, 591 FIFO (first-in, first-out), 362, 377 Figure class, 1230 Figure element, 1227 Figure type, 1227 File | Open menu option, 33, 35 File class, 776, 777 file extensions, 532 File menu, 1205, 1516, 1523, 1552 File Open dialog box, 622 .file token, 551 File Transfer Protocol (FTP), 1381, 1407 file types, 789—791 file-centric methods, 790—791 FileExit_Click( ) method, 1197 FileInfo class

AppendText( ) method, 789 Create( ) method, 786 CreateText( ) method, 789 function of, 776, 777 Open( ) method, 786—788 OpenRead( ) method, 788 OpenText( ) method, 789 OpenWrite( ) method, 788 overview, 785

Page 121: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1631

File(Info) types, 777—778 FileMode enumeration, 787 FileName property, 1559 FileNotFoundException class, 260, 281 FileNotFoundException error, 1578 FileNotFoundException exception, 554,

555, 569 FileNotFoundException object, 281 File.Open( ) method, 281, 1175 FilePath property, 1418 files

enumerating with DirectoryInfo type, 780—781

watching programmatically, 801—804 FileStream class, 776 FileStream object, 788 FileStreamApp project, 793, 794 FileStreams class, 793—794 FileSystemInfo abstract base class, 777—

778 FileSystemWatcher class, 776, 801, 802 Fill color, 1368 Fill( ) method, 835, 914, 915, 916, 919, 937 Fill property, 1249, 1250, 1258, 1260, 1273,

1294, 1352, 1353, 1365, 1368 FillBehavior property, Timeline class, 1306 FillContains( ) method, 1254 FillDataSet( ) method, 891, 898 FillDataSetUsingSqlDataAdapter

application, 914 FillDataSetUsingSqlDataAdapter project,

917 FillEllipse( ) method, 1549, 1550 FillPath( ) method, 1549 FillPie( ) method, 1549 FillPolygon( ) method, 1549 FillRectangle( ) method, 1549 FillTheseValues( ) method, 128 filter criteria, selecting rows based on, 908—

911 Filter property, 1559 filtering data, using OfType<T>( ), 508 finalizable objects, 302—305 FinalizableDisposableClass project, 310,

312

finalization queue, 305 finalization reachable table, 305 Finalize( ) method, 252, 298, 302, 303, 305,

306, 310 finally blocks, 282, 304, 690 finally clause, 756 finally keyword, 261 FindAll( ) method, 430, 431, 432, 491 FindByCarID( ) method, 934 FindLongestWord( ) method, 769 FindLongestWord( )method, 770 FindMembers( ) method, System.Type

class, 588 Find/Replace dialog box, 1542 FindTenMostCommon( ) method, 769, 770 Finish button, 930, 1456 FinishButtonClick event, 1456 First<T>( ) method, 500 FirstChanceException event, AppDomain

class, 640 first-in, first-out (FIFO), 362, 377 FirstName property, 379, 702 firstName variable, 99 FirstOrDefault( ) method, 976 FirstWorkflowExampleApp project, 1079,

1088 fixed keywords, pinning types with, 485—

486 fixed pointer-centric keyword, 479 <FixedDocument> element, 1228 fixeddocuments (WYSIWYG), 1120 fixed-point formatting, 84 flags, 44, 535 Flip value, 129 Flip Y Access option, 1360 float data type, 87, 154 float variable, 87 Floater class, 1230 Floater element, 1227 Floater type, 1227 Flop value, 129 flow chart workflow, 1089 Flow Control area, 1107 flow documents, 1120 flowchart activities, WF 4.0, 1089—1090

Page 122: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1632

Flowchart activity, 1090, 1093, 1094, 1107 Flowchart section, Toolbox, 1093 flowchart workflows

connecting activities in, 1094 defining workflow wide variables, 1095—

1096 FlowDecision activity, 1096—1097, 1098 ForEachT activity, 1099—1100 InvokeMethod activity, 1094—1095 overview, 1093 TerminateWorkflow activity, 1097

FlowDecision activity, 1090, 1094, 1096—1097, 1098

FlowDocument loading, 1234—1235 populating, 1230—1232 saving, 1234—1235

FlowDocument container, 1231 FlowDocument data, 1235 FlowDocument object, 1228, 1234 FlowDocumentPageViewer manager, 1228 FlowDocumentReader control, 1229 FlowDocumentReader manager, 1228 FlowDocumentReader object, 1231, 1233 FlowDocumentScrollViewer manager,

1228, 1231 FlowSwitch<T> activity, 1090, 1097 Flush( ) method

BinaryWriter class, 800 Stream class, 792 TextWriter class, 795

Focusable property, UIElement type, 1134 Focused property, 1527 FocusedStateGroup, 1366 Font property, 1438, 1526 Font type, 1547 FontFamily property, Control Type, 1133 FontFamily type, 1547 FontSize attribute, 1326 FontSize property, Control Type, 1133 FontStretch property, Control Type, 1133 FontWeight property, Control Type, 1133 Foo( ) method, 704, 705 for keyword, 117, 122, 682 for loop, 77, 78, 117, 682

for statement, 117 ForAll( ) method, 771 forcing garbage collection, 299—302 ForEachT activity, 1099—1100 foreach code, 63 foreach construct, 63, 343, 345, 346, 497,

500 foreach enumeration, 346, 1100 foreach iteration, 906 foreach keyword, 78, 118, 344, 346, 349,

682, 771, 1099 foreach logic, 502 foreach loop, 118, 245, 346, 590, 594, 985 foreach scope, 623 foreach style, 362 foreach syntax, 346 ForEach<T> activity, WF 4.0, 1089 ForEach<T> mini designer, 1100 foreach/in loop, 117 foreach-like iteration, 368 foreach-style iteration, 376 ForeColor property, 1438, 1458, 1526 Foreground color, 1351 Foreground property, Control Type, 1133 foreground threads, 749—750 ForegroundColor property,

System.Console class, 81 Fork class, 334 Form class, 766, 1473, 1514, 1515, 1529—

1530, 1538 Form collection, 1476 form data, accessing, 1419—1420 form elements, 1396 form inheritance, 1543—1545 Form property, 1418, 1419, 1420 form statement, 1417 Form string, 1532 Form type

Control class, 1526—1529 Form class, 1529—1530 life cycle, 1531—1533 overview, 1525

<form> element, 1384, 1385, 1387, 1390, 1397, 1403, 1442, 1448, 1449, 1478

Form1.cs file, 763, 920, 1552

Page 123: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1633

Form1.cs icon, 1520 Format drop-down list, 1276 Format( ) method, String system type, 97 FormatException class, 260 FormatNumericalData( ) method, 84 FormattedResponse argument, 1105, 1107 FormattedResponse variable, 1108, 1111 FormattedText object, 1279 formatters, for serialization

IFormatter and IRemotingFormatter interfaces, 809—810

overview, 808 type fidelity among formatters, 810—811

formatting, 84 FormBorderStyle enumeration, 1529 FormBorderStyle property, 1529, 1538 FormBorderStyle.FixedDialog property,

1538 FormClosed event, 989, 1531, 1532 FormClosing event, 1531, 1532 FormClosingEventArgs event, 1532 FormClosingEventArgs.Cancel property,

1531 FormClosingEventHandler delegate, 1531 Form.cs file, 1549 form's client area, invalidating, 1551 form's default input button, setting, 1541 Forms designer, 1522, 1523 forms, HTML, 1384 Forms-based authentication model, 1507 FormStartPosition enumeration, 1530 FormWindowState enumeration, 1530 Fortran syntax, 12 Frame class, 1124, 1155 Framework class libraries (FCLs), 3 FrameworkElement class, 1117, 1248,

1271, 1278, 1280, 1281, 1282, 1292, 1327, 1329

FrameworkElement type, 1133, 1134, 1272 FrameworkPropertyMetadata constructor,

1329 FrameworkPropertyMetadata object, 1329,

1335 FrameworkPropertyMetadataOptions

enum, 1329

freachable table, 305 friend assemblies, 545 friendly names, mapping database names

to, 916 FriendlyName property, 639 from operator, 497, 510, 517, 518 From property, 1305, 1307, 1310 FromHdc( ) method, 1548 FromHwnd( ) method, 1548 FromImage( ) method, 1548 FTP (File Transfer Protocol), 1381, 1407 Full Installation option, Mono website,

1566 FullName property, FileSystemInfo class,

778 fully qualified name, 31, 252, 532 Func<> delegates, 492, 517, 518, 519, 520 Func<> type, 521 Func<T> delegate, 763 Function Imports folder, 980 function pointer, C-style, 21 FunWithArrays application, 144 FunWithArrays project, 137 FunWithEnums project, 144, 150 FunWithGenericCollections project, 385 FunWithLinqExpressions application, 509 FunWithLinqExpressions project, 517 FunWithMethods application, 134 FunWithMethods proyect, 126 FunWithPageMembers website, 1419 FunWithProfiles project, 1504 FunWithStrings project, 98, 106 FunWithStructures project, 151, 154 FunWithThemes web site, 1471 FunWithThemes website, 1466

■G G string format character, 84 GAC (Global Assembly Cache), 32, 51, 533,

559, 560, 561, 565—566, 1022, 1414 gacutil utility, Mono, 1570, 1575 gacutil.exe utility, 565, 566, 576, 1570, 1575 GainFocusStar, 1366

Page 124: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1634

Garage class, 209, 343, 346, 347 Garage object, 210 garbage collection

background (.NET 4.0), 297 concurrent (.NET 1.0 - 3.5), 297 forcing, 299—302

GC.Collect( ) method, 298, 299, 300, 301, 302

GCCollectionMode enumeration, 298, 300 *.g.cs file, 1150, 1165 GC.SuppressFinalize( ) method, 310 GC.WaitForPendingFinalizers( ) method,

300 GDI+, rendering graphical data using,

1545—1551 Graphics type, 1548—1549 invalidating form's client area, 1551 obtaining Graphics object with Paint

event, 1549—1550 overview, 1545—1546 System.Drawing namespace, 1547

general catch statements, 279—280 general exceptions, throwing, 265—266 Generate Asynchronous Operators check

box, 1068 Generate option, 963 generation 0 objects, 296 generation 1 objects, 296, 297 generation 2 objects, 296, 297 generational value, 297 generic List<T>, hydrating DataTables

from, 904—906 generic members, 22 generic types, 22, 594 GenericDelegate application, 415 GenericDelegate project, 418 GenericPoint project, 388, 391 generics

constraining type parameters examples using where keyword,

393—394 lack of operator constraints, 394—395 overview, 392

creating custom generic methods, 385—388

creating custom generic structures and classes, 388—392

defining in CIL, 671—672 generic type parameters, 371—375 non-generic collections, issues with

overview, 361—362 performance, 363—367 type safety, 367—371

System.Collections.Generic namespace collection initialization syntax, 378 List<T> class, 379—380 overview, 376—377 Queue<T> class, 382—383 SortedSet<T> class, 383—385 Stack<T> class, 380—381

geometries. See drawings and geometries Geometry class, 1254, 1255, 1257 Geometry objects, 1246, 1248, 1254, 1255 Geometry property, 1255 Geometry type, 1257 GeometryDrawing class, 1246 GeometryDrawing object, 1258 GeometryDrawing property, 1255 GeometryDrawing type, 1271 <GeometryDrawing> element, 1275 GeometryGroup class, 1255 GeometryGroup object, 1255 <GeometryGroup> element, 1272 GeometryTransform property, Shape class,

1248 get ( ) methods, 592 get block, 204 Get button, 1474 get directive, 676 get keyword, 204 get method, 195, 196, 198, 202 GET method, 1384, 1391, 1417, 1418, 1420 get scope, 198, 199 get_ prefix, 202, 676 get_PetName( ) method, 584 get_SocialSecurityNumber( ) method, 203 get_XXX( ) method, 202 GetAllInventory( ) method, 919, 921, 1107 GetAllInventoryAsDataTable( ) method,

874

Page 125: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1635

GetAllInventoryAsList( ) method, 874 GetAllTracks( ) method, 314, 315 GetArea( ) method, 1254 GetAssemblies( ) method, 638, 641 GetBenefitCost( ) method, 232 GetBoolFromDatabase( ) method, 163 GetChanges( ) method, 888 GetChildren( ) method, 1342 GetCoffee( ) method, 382, 383 GetColumnError( ) method, 893 GetColumnsInError( ) method, 893 GetCommandLineArgs( ) method, 78, 79 GetConstructors method ( ), System.Type

class, 588 GetCurrentPay( ) method, 197 GetCurrentProcess( ) method,

System.Diagnostics.Process class, 629

GetCurrentThreadId( ) method, AppDomain class, 639

GetDirectories( ) method, DirectoryInfo class, 778

GetDomain( ) method, System.Threading.Thread Class, 741

GetDomainID( ) method, System.Threading.Thread Class, 741

GetDrives( ) method, DriveInfo class, 783 GetEnumerator( ) method, 343, 344, 345,

346, 348, 349 <GetEnumerator>d__0 type, 348 GetEvents( ) method, System.Type class,

588 GetFactory( ) method,

DbProviderFactories class, 848, 849

GetFields( ) method, System.Type class, 588

GetFiles( ) method, DirectoryInfo class, 779, 780

GetGeneration( ) method, System.GC class, 298

GetHashCode( ) method, 91, 251, 252, 255, 476

GetID( ) method, 197 GetILGenerator( ) method, 696 GetInterfaces( ) method, 588, 591 GetIntFromDatabase( ) method, 163, 164 GetInventory( ) method, 1072 GetInvocationList( ) method, 402 GetLogicalDrives( ) method, 782, 1098 GetMembers( ) method, System.Type

class, 588 GetMethods( ) method, System.Type class,

588 GetMsg( ) method, 691 GetName( ) method, 197 GetNestedTypes( ) method, System.Type

class, 588 GetNumberOfPoints( ) method, 324 GetObjectByKey( ) method, 959, 974, 975 GetObjectData( ) method, 820, 822 GetParameters( ) method, 594 GetPerson( ) method, 368 GetPetName( ) method, 67, 843 GetPetName procedure, 869, 943 GetPosition( ) method, 1143 GetProcesses( ) method,

System.Diagnostics.Process class, 629

GetProperties( ) method, System.Type class, 588

GetRandomNumber( ) method, 181, 182 GetRenderBounds( ) method, 1254 GetSchema( ) method, 855 GetStringArray( ) method, 142 GetStringSubset( ) method, 505 getter method, 194 Getter/Setter tokens, 584 GetTheCars( ) method, 348 <GetTheCars>d__6 type, 348 GetTotalMemory( ) method, System.GC

class, 298 GetType( ) method, 140, 147, 252, 324, 588 GetUserAddress( ) method, 1507 GetUserData( ) method, 82 GetValue( ) method, 578, 1109, 1135, 1328,

1330 GetValues( ) method, 148

Page 126: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1636

GetVisualChild( ) method, 1281 GiveBonus( ) method, 235, 236, 237, 239,

240 GivePromotion( ) method, 249, 250 Glade 3 tool, Mono, 1571, 1572 Global Application Class icon, 1479 global application object, 1140 Global Assembly Cache, 848 Global Assembly Cache (GAC), 32, 51, 533,

559, 560, 561, 565—566, 1022, 1414 global last-chance exception event

handler, 1481—1482 Global.asax file

global last-chance exception event handler, 1481—1482

HttpApplication base class, 1482 overview, 1479—1480

Global.asax script, 1482 Global.asax.cs, 1485 <globalization> element, 1427 globally unique identifier (GUID), 351, 560,

889, 899 GlyphRunDrawing type, 1271 -godmode option, 79 goto keyword, 117, 122 GoToState( ) method, 1367 GoToStateAction, 1367 gradient brush, 1259, 1292 gradient offset, 1259 gradient stop, 1259 gradient strip, 1259 Gradient Tool icon, 1269 GradientStop objects, 1261 graphical content, 1188 graphical data, rendering using GDI+

Graphics type, 1548—1549 invalidating form's client area, 1551 obtaining Graphics object with Paint

event, 1549—1550 overview, 1545—1546 System.Drawing namespace, 1547

graphical layer, 1277 graphical output, capturing and rendering,

1557 graphical systems, immediate-mode, 1245

graphical transformation objects, 1264 Graphical User Interface (GUI), 38, 81, 903,

904, 1006, 1007, 1059, 1060, 1061, 1389

Graphical User Interface Toolkit (GTK#), 1565, 1566

graphics retained-mode, 1245 vector, 1120

Graphics class, 1549 Graphics object, obtaining with Paint

event, 1549—1550 Graphics type, 1548—1549 GreaterThan value, 1461 *.g.resources file, 1151 Grid class, 1138, 1160, 1162 Grid control, 1349 Grid panels, 1186, 1191—1193 <Grid> control, 1228 <Grid> layout manager, 1211 <Grid> type, 1173, 1174, 1191, 1196, 1198,

1216 Grid.Column property, 1192 <Grid.ColumnDefinitions> element, 1191 gridInventory, 1242 Grid.Row property, 1192 Grid.RowDefinitions element, 1191 GridSplitter types, 1192—1193 <GridSplitter> control, 1192, 1193 GridView class, 1396, 1397, 1398, 1399,

1403, 1408, 1479, 1492, 1493 GridView control, 1441, 1450, 1451, 1453,

1454 GridView widget, 1451 GridWithSplitter.xaml file, 1193 group box, 1220 group name, 1220 group operator, 509 <group> elements, 1508 GroupBox class, 907, 925 grouping

conceptual, 1078 profile data, 1507—1509

GroupName property, 1220 groups, defining, 1463—1465

Page 127: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1637

GrowLabelFont.xaml file, 1309 Grunt value, 147 GTK# (Graphical User Interface Toolkit),

1565, 1566 GUI (cache application Graphical User

Interface), 1492 GUI (Graphical User Interface), 38, 81, 903,

904, 1006, 1007, 1059, 1060, 1061, 1389

GUI (session application Graphical User Interface), 1495

GUI animation tools, 1304 GUI editor, 543 GUI framework, 618 GUID (globally unique identifier), 351, 560,

889, 899 GZIP standard, 1394

■H H command, 1257 <h1> tag, 1386 Halo8.exe application, WPF, 43 Handle property, System. Diagnostics.

Process class, 628 Handled property, 1339, 1341, 1537 [HandledProcessCorruptedStateException

s] attribute, 286 hard-code, 1236 has-a relationship, 5, 190, 213, 219, 232,

806 HasChanges( ) method, 888 HasControls( ) method, 1432 HasErrors property, 888, 893 hash code, 255, 256, 560, 561 HashSet<T> class, 377 Hashtable class, 362, 1479 Hashtable types, 251, 255 HasValue property, 163, 164 HatchBrush object, 1550 header information, Windows, 534 Header property, 1214 Header values, 1196 Headers property, 1418

HeaderText property, 1462 heap allocation, 291, 366 Height attribute, 1146 Height property, 1133, 1145, 1152, 1187,

1193, 1304, 1305, 1326, 1327, 1438 Height value, 1188, 1189, 1193 HeightProperty field, 1329 Helicopter class, 550 helicopter.cs file, 550, 551 Hello World application, 27 -HelloClass constructor, 696 HelloClass type, emitting, 695—696 HelloMsg.cs file, 46 HelloProgram.cs file, 658 HelloProgram.exe file, 659 HelloProgram.il file, 664 HelloWebService.asmx file, 1017 HelloWorld class, 691, 695, 697 HelloWorld( ) method, 1018 helloWorldClass variable, 697 HelloWorldWebService project, 1019 Help cursor, 1314 Help Library Manager, 68 Help menu, SharpDevelop, 53 Help page, 68 Helper class, rigging up UI to, 1009—1011 HelpExecuted( ) method, 1204 HelpLink property, 262, 268, 269—270 [helpstring] attribute, 658 hexadecimal formatting, 84 Hexagon class, 189, 191, 324, 525 Hexagon object, 333 Hexagon type, 243, 328, 329 hidden this reference, 682 Hide( ) method, 1529 hit test operations, responding to, 1282—

1284 HitTest( ) method, 1283 HitTestResult object, 1252 HitTestResultCallback delegate, 1283 Home node, 1446 Horizontal split button, 1170 Horizontal value, 1190 HorizontalAlignment property,

FrameworkElement type, 1133

Page 128: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1638

HorizontalContentAlignment property, Control Type, 1133

HorseAndBuggy class, 607 HorseAndBuggy type, 607 <host> element, 1039, 1043 hosting

services within Windows services creating Windows service installer,

1064—1065 enabling MEX, 1064 installing Windows service, 1066—

1067 overview, 1061 specifying ABCs in code, 1062—1063

Windows Communication Foundation (WCF) services

<system.serviceModel> element, 1042

coding against ServiceHost type, 1038

enabling metadata exchange, 1043—1045

establishing ABCs within App.config files, 1037

overview, 1036 ServiceHost type, 1040—1041 specifying base addresses, 1038—

1040 href property, 577 HRESULTs, 260 HTML. See HyperText Markup Language HTML attributes, 1441 HTML controls, 1441 HTML tab, Visual Studio, 1384 HTML widget, 1440 <html> tag, 1383 HtmlButton tag, 1440 HtmlInputControl tag, 1440 HtmlTable tag, 1440 HTTP. See Hypertext Transfer Protocol HTTP GET method, 1043 HttpApplication class, 1481, 1482, 1488 HttpApplication type, 1473, 1483 HttpApplicationState class, 1484

HttpApplicationState object, 1484, 1485, 1488

HttpApplicationState type, 1482, 1483, 1484, 1486, 1487, 1488, 1489

HTTP-based bindings, 1029—1030 HttpBrowserCapabilities class, 1419 HttpBrowserCapabilities object, 1419 HttpCookie class, 1498 HttpCookie collection, 1421 HttpCookie type, 1497, 1498 HttpCookie.Expires property, 1498 HttpMethod property, 1418 HttpRequest class, 1417, 1418, 1419, 1420 HttpRequest object, 1482 HttpRequest.Browser property, 1389 HttpRequest.Cookies property, 1498, 1499 HttpRequest.Form form, 1436 HttpRequest.Form property, 1419 HttpRequest.QueryString property, 1419 HttpResponse class, 1419, 1421, 1422 HttpResponse object, 1482 HttpResponse.Redirect( ) method, 1422 HttpResponse.Write( ) method, 1422 HttpResponse.WriteFile( ) method, 1422 HttpServerUtility object, 1417, 1482 HttpServerUtility.ClearError( ) method,

1426 HttpServerUtility.GetLastError( ) method,

1426 HttpServerUtility.Transfer( ) method, 1422 HttpSessionState class, 1483, 1496—1497 HttpSessionState object, 1482, 1483, 1493,

1496, 1502 HttpSessionState type, 1483, 1494 HyperLink widget, 1433 HyperText Markup Language (HTML)

building forms, 1386—1387 document structure, 1383—1384 forms, 1384, 1477 overview, 1382 representation, 1477 requests, 1482 response, 1477, 1482 Visual Studio 2010 designer tools, 1384—

1386

Page 129: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1639

widgets, 1476 Hypertext Transfer Protocol (HTTP)

overview, 1379 request/response cycle, 1380 requests, incoming, 1417—1420 response, outgoing, 1421—1423 stateless protocols, 1380

■I I command, 872 -i command, 566 i parameter, 433 i variable, 682, 683 <i> tag, 1386 IAdvancedDraw interface, 340 IAppFunctionality interface, 619, 620, 622 IAsyncResult compatible object, 733 IAsyncResult interface, 399, 734, 735, 774 IAsyncResult parameter, 732, 736, 738, 739 IAsyncResult-compatible object, 732 IAsyncResult-compatible parameter type,

732 IAutoLotService.cs file, 1072 IBasicMath class, 1054 IBasicMath interface, 469 IBasicMath.cs file, 1057 IClassFactory interface, 7 ICloneable class, 323 ICloneable interface, 158, 323, 349—354,

362 ICloneableExample application, 323 ICloneableExample project, 324 ICollection interface, 362, 377, 378 ICollection<T> interface, 376, 377, 378 ICommand interface, 1201, 1205 IComparable interface

building, 354—359 overloading comparison operators, 450

IComparable<T> interface, 354 IComparer interface, 143, 357—358 IComparer<T> interface, 358, 376, 383 IComponent interface, 1525 IComponentConnector interface, 1151

Icon type, 1547 IContextProperty interface, 651 ICreateErrorInfo interface, 261 ICustomFormatter interface, 85 ID attribute, 1397 Id member, ProcessThread type, 633 ID property, 198, 200, 628, 1429, 1432 IDataAdapter interface, 828, 835 IDataAdapter type, System.Data

namespace, 832 IDataParameter interface, 828, 834—835 IDataParameter type, System.Data

namespace, 832 IDataReader interface, 827, 836 IDataReader type, System.Data

namespace, 832 IDataReader.IsDBNull( ) method, 837 IDataRecord interface, 827, 836 IDbCommand interface, 827, 834 IDbCommand type, System.Data

namespace, 832 IDbConnection interface, 321, 327, 827,

833 IDbConnection parameter, 837 IDbDataAdapter interface, 828 IDbDataAdapter type, System.Data

namespace, 833 IDbDataAdapterinterface, 835 IDbDataParameter interface, 828, 834—835 IDbTransaction interface, 828, 834, 878,

879 IDbTransaction type, System.Data

namespace, 833 IDE (integrated development

environment), 932, 996, 1024, 1025, 1379, 1381, 1382, 1386, 1396, 1410

IdealProcessor member, ProcessThread type, 633

IDictionary interface, 262, 270, 362 IDictionary<string, object> interface, 1113 IDictionary<TKey, TValue> interface, 376 IDispatch interface, 7, 709 IDisposable class, 863, 1550

Page 130: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1640

IDisposable interface, 289, 305, 306, 307, 308, 309

IDraw3D interface, 331, 332, 333 IDrawable interface, 339, 341, 393 IDropTarget interface, 322 IDynamicObject interface, 709 IEightBall interface, 1033, 1046 IEnumerable interface, building

building iterator methods with yield keyword, 346

building named iterator, 347—348 internal representation of iterator

method, 348—349 overview, 343—345

IEnumerable type, 504 IEnumerable<int> interface, 499 IEnumerable<string>, 498, 505 IEnumerable<T> class, 497, 504, 505, 506,

507, 945, 948 IEnumerable<T> enumeration, 961 IEnumerable<T> interface, 376, 377, 500,

763, 765, 1000 IEnumerable<T> object, 507 IEnumerable<T> variable, 499 IEnumerator interface, building

building iterator methods with yield keyword, 346

building named iterator, 347—348 internal representation of iterator

method, 348—349 overview, 343—345

IEnumerator<T> interface, 376 IErrorInfo interface, 261 If activity, 1089, 1107—1108, 1110 if keyword, 122 if scope, 250 if statement, 120, 1317 if/else branches, 1104 if/else statement, 119, 120 if/else/then statement, 1107 IFormatter interface, 809—810 IIS (Internet Information Services), 1025,

1026, 1036, 1037, 1040, 1071, 1074, 1379, 1381, 1382

IIS virtual directories, 1381

IL (Intermediate Language), 12, 13 *.il file, modifying, 662—663 ilasm compiler, Mono, 1569 ilasm utility, Mono, 1571 ilasm.exe compiler, 666 ildasm.exe file

compiling CIL code using, 663—664 exploring assemblies using

overview, 33 viewing assembly metadata, 35 viewing Common Intermediate

Language (CIL) code, 34 viewing type metadata, 34

ILGenerator class, 691, 696, 697 ILGenerator member, 689 ILGenerator objects, 690 ILGenerator type, 690, 696 IList interface, 362 IList<T> interface, 376 Image control, 1274, 1275, 1278, 1279,

1286, 1289, 1358, 1359 Image property, 1544 Image type, 1547 ImageAnimator type, 1547 ImageBrush type, 1258 ImageDrawing class, 1246 ImageDrawing object, 1258 ImageDrawing type, 1271 ImageOrderAutoDialog class, 1545 ImageOrderAutoDialog.cs file, 1543 images

2D vector, 1271 programmatically loading, 1288—1289

ImageSource object, 1258 ImageSource property, 1258 ImageUrl image, 1448 IMetadataExchange class, 1055 imgDisplay control, 1358 imgFirst object, 1371 imgSecond object, 1371 imgThird object, 1371 immediate-mode graphical systems, 1245 immutability, 103 implemented interfaces, custom metadata

viewer, 591

Page 131: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1641

implements attribute, 655, 669, 670 implements clause, 670 Implements keyword, 620 implicit cast, 248 implicit conversion

routines, 458—459 when required, 454

implicit keyword, 455, 456, 459 implicit load, 554 implicit typing, 113, 701, 702 implicitly pop, 680 implicitly sealed, 223 implicitly typed local arrays, 139 implicitly typed local variables

are strongly typed data, 115 overview, 112—113 restrictions on, 114—115 usefulness of, 116

ImplicitlyTypedLocalVars project, 112, 117 <%@Import%> directives, 1398, 1402, 1403 <Import> elements, 1149 importing

Inventory.xml files, 1007—1008 types that define, 465—466

Imports area, 1105 Imports button, 1105 Imports editor, 1105 Imports keyword, 548 Imports statement, 548 in operator, 497, 509, 510, 517, 518 In32Animation class, 1304 InArgument<> properties, 1109 InArgument<T> class, 1109 InArgument<T> object., 1109 inaryFormatter class, 529 Include attribute, 1149 incoming cookie data, reading, 1499 incoming HTTP requests

access to incoming form data, 1419—1420

IsPostBack property, 1420 obtaining brower statistics, 1419 overview, 1417—1418

incoming parameter, 146 Increment( ) method, 756, 757

index operator ([]), accessing items from arrays, 439

indexer methods definitions on interface types, 444 function of, 439 multiple dimensions, 443—444 overloading, 443 overview, 439—440 string values, 441—442

IndexOutOfRangeException class, 260 IndexOutOfRangeException type, 262 infrastructure, adding to MainWindow

type, 1555 inheritance. See also polymorphism

base class/derived class casting rules is keyword, 250 as keyword, 249 overview, 247—248

basic mechanics of multiple base classes, 222 overview, 219 sealed keyword, 222—223 specifying parent class of existing

class, 220—221 cross-language, 549 details of

adding sealed class, 231—232 controlling base class creation with

base keyword, 228—230 overview, 226—227 protected keyword, 230

multiple, with interface types, 341—342 overview, 219 pillar of OOP, 189—191 programming for

containment/delegation, 232—235 revising Visual Studio class diagrams,

224—225 System.Object class

overriding system.Object.Equals( ), 254—255

overriding System.Object.GetHashCode( ), 255—256

Page 132: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1642

overriding system.Object.ToString( ), 254

overview, 250—253 testing modified person class, 257—

258 testing your modified person class,

256 inheritance chain, 615, 1416 Inheritance icon, Class Designer Toolbox,

66 Inheritance Picker dialog box, 1544 Inherited Form icon, 1543 Inherited property, 612 Inherits attribute, 1402, 1409 Inherits keyword, 549 init attribute, 681 Init event, 1423, 1476 InitClass( ) method, 934 InitDAD( ) method, Program class, 643 Initial Catalog name, 854 initial class types, 917 InitializeComponent( ) method, 1151,

1153, 1165, 1203, 1520, 1521, 1523, 1524

InitializeCorrelation activity, WF 4.0, 1090 InitialValue property, 1459 Ink API controls, 1183 Ink API support types, 1183 Ink API tab, WPF

ComboBox control, 1224—1226 InkCanvas control, 1222—1227 overview, 1216 RadioButton control, 1220—1222 ToolBar, 1217—1219

ink controls, WPF, 1182—1183 Ink mode, 1223 Ink Mode! value, 1218 InkCanvas control, WPF, 1222—1227 InkCanvasEditingMode enumeration, 1223 inkRadio control, 1219 inkToolbar control, 1217 inkToolbar node, 1217 inline elements, WPF, 1227 inline menu editor, 1522, 1523 in-memory data allocation, 183, 184

in-memory representation, 9 inner exceptions, 281 innerEllipse object, 1339 InnerException property, 263, 281 in/out parameter, 871 in-place editing, enabling, 1454 input button, setting default, 1541 input parameter, 78, 871 input/output (I/O), 8 INSERT command, 914 Insert( ) method, 97, 365, 380, 441, 1489,

1490 Insert request, 861 Insert Snippet option, 63 Insert Standard Items option, 1522 Insert statement, 862, 863, 955, 974, 1450 InsertAuto( ) method, 863, 864, 865, 868,

875, 876, 1074 InsertCar( ) method, 1072, 1073 InsertCommand property, 914, 918, 949 Insert/Delete logic, 882 InsertNewCar( ) method, 875—876 InsertNewElement( ) method, 1008 installing

Mono, 1565—1568 strongly named assemblies to GAC,

565—566 Windows service, 1066—1067

InstallSqlState.sql file, 1502 installutil MathWindowsServiceHost.exe

command, 1066 instance attribute, 675 instance data, 182 instance level, invoking extension

methods on, 463 int data type, 86, 87, 92, 96, 106, 107, 108,

112, 116, 145 int parameters, 106 int type, 356 int variable, 107, 363, 364, 1289 intArray declaration, 138 IntCollection class, 369 integer (0), 1335 Integer data type, 135, 1479

Page 133: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1643

integrated development environment (IDE), 932, 996, 1024, 1025, 1379, 1381, 1382, 1386, 1396, 1410

IntelliSense, 136, 466—467, 704 IntelliSense window, 423 interactive graphical data, 1246 interface attribute, 670 interface implementation, 336, 337, 339,

342 interface keyword, 20, 325 Interface member, 695 interface types

Common Type System (CTS), 20 definitions on, 444 extending, 469—470

InterfaceExtensions project, 469, 470 InterfaceHierarchy application, 339 InterfaceHierarchy project, 340 InterfaceNameClash application, 336 InterfaceNameClash project, 339 interfaces

building cloneable objects, 349—354 building comparable objects, 354—359 building enumerable types

building iterator methods with yield keyword, 346

building named iterator, 347—348 internal representation of an

iterator method, 348—349 overview, 343—345

custom, defining, 325—327 defining and implementing in CIL, 670 designing hierarchies, 339—342 explicit implementation of, resolving

name clashes via, 336—339 generic, specifying type parameters for,

374—375 implementing, 327—328 invoking interface members at object

level, 329—331 as parameters, 331—333 as return values, 333 types

arrays of, 334

interface types vs. abstract base classes, 322—325

overview, 321 Interlocked class, 740, 756, 757 Interlocked.CompareExchange( ) method,

757 Interlocked.Exchange( ) method, 757 Interlocked.Increment( ) method, 757 Intermediate Language (IL), 12, 13 Intermediate Language Disassembler

utility, 33 internal data, of objects, 194 internal keyword, 20, 125, 193, 194, 545 internal modifier, 193, 194 internal reference counter, 292 internal representation

of anonymous types, 474—475 of overloaded operators, 451—452

InternalsVisibleToAttribute class, 545 International Organization for

Standardization (ISO), 1562 Internet Information Services (IIS), 1025,

1026, 1036, 1037, 1040, 1071, 1074, 1379, 1381, 1382

Internet Protocol (IP) address, 1380, 1381, 1418

interop assemblies, 10, 714, 717 interop library, 716 interoperability assemblies, 714, 716 interoperability data, 716 interoperating, 1121 Interrupt( ) method, 742 Intersect( ) method, 515 Intersect<>( ) method, 509 into operator, 509 intrinsic control command objects, WPF,

1201 intVal variable, 757 Invalidate( ) method, 1246, 1529, 1551,

1556, 1557 invalidating form's client area, 1551 InvalidCastException exception, 329, 365 InvalidOperationException errors, 636 Inventories property, 959 Inventory database, 973

Page 134: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1644

Inventory objects, 984, 989, 1242 Inventory property, 932, 934 Inventory schema, 954 Inventory table, 840—842, 850, 853, 860,

861, 862, 863, 864, 865 Inventory table icon, 842 Inventory variable, 1107 Inventory.aspx file, 1446, 1450 Inventory.aspx page, 1454 InventoryDAL class, 862, 863, 864, 865,

874, 875, 880—882 InventoryDAL object, 863, 872 InventoryDAL type, 867, 870, 875, 1492 InventoryDALDisconnectedGUI

application, 920 InventoryDALDisconnectedGUI project,

921 InventoryDALDisLayer class, 917, 920,

1106 InventoryDALDisLayer object, 918, 921 InventoryDALDisLayer variable, 1106,

1107 InventoryDataSet class, 932, 933, 936 InventoryDataSet.Designer.cs file, 933 InventoryDataSet.xsd file, 933 InventoryDataTable class, 934, 936, 941 InventoryDataTable variable, 934 InventoryEDMConsoleApp application,

961 InventoryEDMConsoleApp example, 979 InventoryEDM.Designer.cs file, 970 InventoryEDM.edmx file, 962, 968 InventoryEDM.edmx node, 970 InventoryRecord class, 1072, 1074 InventoryRow class, 934 InventoryTableAdapter class, 936, 937, 940 Inventory.xlsx file, 721, 1007—1008 invisible brushes, 1249 Invoke( ) method, 398, 399, 400, 403, 602,

711, 730, 1084, 1086 InvokeMember( ) method, System.Type

class, 588 InvokeMethod activity, 1091, 1094—1095,

1096, 1098, 1099 invoking extension methods, 463—464

invoking services asynchronously from clients, 1067—1069

invoking statically, 464 I/O (input/output), 8 I/O and object serialization

abstract stream class, 792—794 BinaryWriters and BinaryReaders

classes, 799—801 configuring objects for serialization

overview, 806 public fields, private fields, and

public properties, 807—808 serializable types, 807

customizing Soap/Binary serialization processes

overview, 818—819 using attributes, 823 using ISerializable interface, 820—

822 Directory type, 782—783 Directory(Info) and File(Info) types,

777—778 DirectoryInfo type

creating subdirectories with, 781—782

enumerating files with, 780—781 overview, 778—779

DriveInfo class type, 783—784 file type, 789—791 FileInfo class

AppendText( ) method, 789 Create( ) method, 786 CreateText( ) method, 789 Open( ) method, 786—788 OpenRead( ) method, 788 OpenText( ) method, 789 OpenWrite( ) method, 788 overview, 785

files, watching programmatically, 801—804

object serialization, 804—806 overview, 775 serialization formatters

IFormatter and IRemotingFormatter interfaces, 809—810

Page 135: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1645

overview, 808 type fidelity among formatters, 810—

811 serializing collections of objects, 816—

817 serializing objects using

BinaryFormatter type, 811—813 serializing objects using SoapFormatter

type, 813 serializing objects using XmlSerializer

type, 814—816 StreamWriters and StreamReaders

classes directly creating types, 797—798 overview, 794 reading from text files, 796—797 writing to text files, 795—796

StringWriters and StringReaders classes, 798—799

System.IO namespace, 775—776 IO namespace, 530 IP (Internet Protocol) address, 1380, 1381,

1418 IPointy interface, 325, 326, 327, 328, 329,

330, 333, 334, 335 IPrintable interface, 341 IRemotingFormatter interface, 809—810 IronPython language, 708 IronRuby language, 708 is keyword, 250, 272, 307, 330—331 is-a relationships, 189, 190, 219, 220, 228,

248, 806 IsAbstract property, System.Type class,

588 IsAlive property, 741 IsArray property, System.Type class, 588 IsBackground property, 741, 750 IsChecked property, 1220 IsCOMObject property, System.Type class,

588 IsCompleted property, 734, 735 IsCreditRisk column, 880 IsEnabled property, UIElement type, 1134 IsEnum property, System.Type class, 588 ISerializable interface, 262, 818, 820—822

IService1.cs file, 1057 IService.cs file, 1072 ISet<T> interface, 376 IsEvenNumber( ) method, 431 isFlipped variable, 1265 IsFocused property, UIElement type, 1134 IsGenericParameter property,

System.Type class, 588 IsGenericTypeDefinition property,

System.Type class, 588 IShape interface, 341 IsInitiating property, 1035 IsInterface property, System.Type class,

588 IsMDIChildIsMDIContainer property,

1529 IsMouseDirectlyOver property, UIElement

type, 1134 IsMouseOver property, 1134, 1318 IsNestedPrivate property, System.Type

class, 588 IsNestedPublic property, System.Type

class, 588 IsNull( ) method, 893 IsNullable property, 868 ISO (International Organization for

Standardization), 1562 IsolationLevel enumeration, 879 IsolationLevel property, 879 IsOneWay property, 1035 IsPetNameNull( ) method, 935 IsPostBack property, 1417, 1420 IsPrimitive property, System.Type class,

588 IsSealed property, System.Type class, 588 IsSecureConnection property, 1418 IssuesWithNon-genericCollections

project, 371 IsTabStop property, Control Type, 1133 IsTerminating property, 1035 ISupportErrorInfo interface, 261 IsValueType property, System.Type class,

588 IsVisible property, UIElement type, 1134 ItemArray property, 893

Page 136: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1646

<ItemGroup> element, 1149 ItemHeight value, 1189 Items (Collection) dialog box, 1218 Items (Collection) property, 1217, 1219 Items property, 1455, 1477, 1516 ItemsSource collection, 1242 ItemsSource property, 1164 ItemWidth value, 1189 iteration constructs

do/while loop, 119 foreach loop, use of var within, 118 for loop, 117 representing in CIL, 682—683 while loop, 119

IterationsAndDecisions project, 117, 122 iterator methods

building with yield keyword, 346 internal representation of, 348—349

iterators, 346 IUnknown interface, 7 IValueConverter interface, data conversion

using, 1240—1241

■J Jackpot Deluxe WPF application

.NET 4.0 visual states changing using VisualStateManager

class, 1370 overview, 1366 for StarButton control, 1367—1368 state transition timings, 1368—1369 viewing generated XAML, 1369—1370

extracting UserControl from drawing geometry, 1365—1366

finalizing, 1371—1375 overview, 1364

Jackpot.jpg file, 1358 jagged arrays, 141 JaggedMultidimensionalArray( ) method,

141 Java, programming language comparison,

5 Java Virtual Machine (JVM), 25

JavaScript language, 1389 JIT (just-in-time) compiler, 536 JIT compiler, 17, 544, 656 Jitter, 17 Join( ) method, 742 JpegBitmapEncoder class, 1280 *.jpg files, 763, 764 just-in-time (JIT) compiler, 536 JVM (Java Virtual Machine), 25 -k flag, 561

■K kaxaml editor, 1155, 1256, 1263, 1276, 1309 kaxaml.exe file, 1154—1156, 1173, 1186,

1187, 1341 key frame animations, 1304 Key property, DictionaryEntry type, 271 keyboard activity, 1534—1537 keyboard events, intercepting, 1143—1144 KeyCode property, 1537 KeyDown event, 1143, 1144, 1528, 1536,

1537 KeyEventArgs class, 1143, 1517, 1536, 1537 KeyEventArgs type, 1537 KeyEventHandler delegate, 1536 keyframes, 1360 KeyNotFoundException exception, 377 KeyPress event, 1528 keys, determining which was pressed,

1536—1537 KeyUp event, 1134, 1143, 1528, 1536 keyword color coding, 49 keywords

pinning types with, 485—486 XAML, 1156—1159

Kill( ) method, System.Diagnostics.Process class, 629, 635

King, Jason, 1561 Knife class, 334

■L L command, 566, 872, 876

Page 137: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1647

L suffix, 87 Label class, 912, 920, 925, 1241, 1396, 1397,

1399, 1403, 1404, 1408 Label control, 1227, 1240, 1331, 1354, 1434,

1436, 1439, 1455, 1485, 1495 Label object, 1236, 1309 Label type, 1304, 1456, 1506 Label widget, 322, 1422, 1433, 1474 <Label> control, 1241 <Label> element, 1132, 1225 lambda expressions, 430—437, 491—492

building query expressions using enumerable type and, 519—520

with multiple (or zero) parameters, 435—436

parts of, 433 processing arguments within multiple

statements, 433—434 retrofitting CarEvents example using,

436—437 lambda operator, 10, 397, 491, 765 LambdaExpressionsMultipleParams

application, 435 LambdaExpressionsMultipleParams

project, 436 LambdaExpressionSyntax( ) method, 434 LAN (Local Area Network), 1019 language attribute, 1401 Language Integrated Queries. See LINQ language integration, 16 language keywords, 23 language-neutral form, 532 LastAccessTime, 778 LastChildFill attribute, 1194 last-in, first-out (LIFO), 362, 377 LastName property, 379, 702 LastWriteTime property, FileSystemInfo

class, 778 late binding

attributes using, 615—617 calls, simplifying using dynamic types,

710—713 invoking methods with no parameters,

602—603

invoking methods with parameters, 603—604

overview, 600 System.Activator class, 601—602

LateBindingApp application, 601 LateBindingWithDynamic application, 711 LateBindingWithDynamic project, 711,

712 Layout area, 1218 layout buttons, 1231 Layout controls, WPF, 1180 Layout section, 1217 LayoutMdi( ) method, 1530 LayoutRoot icon, 1211 LayoutRoot item, 1211 LayoutRoot node, 1213 LayoutTransform property, 1262, 1264 lazy objects, 313—317 Lazy<> class, 314, 315, 316 Lazy<> type, 315 Lazy<> variable, 315, 316 LazyObjectInstantiation project, 313, 316 lblControlInfo control, 1434 lblFavCar widget, 1474 lblTextBoxData control, 1436 lblUserData label, 1505, 1506, 1507 ldarg opcode, 679, 681 ldc opcode, 679 ldfld opcode, 679 ldflda opcode, 686 ldloc opcode, 679 ldnull opcode, 293 ldobj opcode, 679 ldstr opcode, 104, 655, 657, 679 Left property, 1527 Length member

FileInfo class, 785 Stream class, 792

Length property Array class, 143, 144 String system type, 97

LessThan value, 1461 lexical scope, 690 lib\mono\gac directory, Mono, 1568 libraries

Page 138: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1648

.NET code, 581 COM type, 581 consuming workflow, 1112—1114 of extension, 467—468 external code, 1083 isolating workflows into dedicated

arguments, defining, 1105—1106 assemblies, importing, 1105 Assign activity, 1107 Code activity, 1109—1111 defining project, 1103—1104 If activity, 1107—1108 namespaces, importing, 1105 Switch activity, 1107—1108 variables, defining, 1106—1107

unloading, 639 LibraryBuild.rsp file, 1573, 1574 life cycle

of ASP.NET Web pages AutoEventWireup attribute, 1424—

1425 Error event, 1425—1426 overview, 1423

of Form type, 1531—1533 lifeTimeInfo string, 1532 lifeTimeInfo variable, 1532 LIFO (last-in, first-out), 362, 377 Lightning Bolt button, 1221, 1523 lightweight class type, 151 lightweight events, 473 Limes.jpg file, 1358 Line class, 1247, 1256 line geometry, 1261 Line object, 1250, 1252 Line type, 1254 <Line> element, 1267 linear gradient, 1258 linear interpolation animations, 1304 LinearGradientBrush class, 1161 LinearGradientBrush object, 1550 LinearGradientBrush type, 1161, 1258 LineBreak class, 1230 LineBreak element, 1227 LineBreak type, 1227 LineGeometry class, 1255

LineGeometry object, 1255 lines

adding to canvas, 1249—1252 removing from canvas, 1252—1253

LinkedList<T> class, 377 LinkedListNode<T> type, 377 LINQ

programming to DataSet types with DataSet extensions library, 945—946 obtaining LINQ-compatible

datatables, 946—947 overview, 943—944 populating new DataTables from

LINQ queries, 948—950 role of

DataRowExtensions.Field<T>( ) Extension method, 948

queries, populating new DataTables from, 948—950

LINQ to DataSet term, 494 LINQ to Entities, querying with, 975—977,

984—985 LINQ to Objects

applying LINQ queries to collection objects

accessing contained subobjects, 506—507

applying LINQ queries to nongeneric collections, 507—508

filtering data using OfType<T>( ), 508

overview, 505 applying LINQ queries to primitive

arrays extension methods, 500 implicitly typed local variables, 498—

500 overview, 496—497 result set, 498 role of deferred execution, 501—502 role of immediate execution, 502—

503 applying to collection objects, 508 C# LINQ query operators

aggregation operations, 516—517

Page 139: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1649

basic selection syntax, 510—511 LINQ as better Venn diagramming

tool, 515—516 obtaining counts using enumerable,

513 obtaining subsets of data, 511 overview, 508—509 projecting new data types, 512—513 removing duplicates, 516 reversing result sets, 514 sorting expressions, 514

internal representation of LINQ query statements

building query expressions using enumerable type and anonymous methods, 520

building query expressions using enumerable type and lambda expressions, 519—520

building query expressions using enumerable type and raw delegates, 521—522

building query expressions with query operators, 518

overview, 517 LINQ specific programming constructs

anonymous types, 493 extension methods, 492—493 implicit typing of local variables, 490 lambda expressions, 491—492 object and collection initialization

syntax, 491 overview, 489

returning result of LINQ query, 503—505 role of LINQ, 493—495

LINQ to XML System.Xml.Linq namespaces, 997—

1002 XElement and XDocument objects

generating documents from arrays and containers, 1004—1005

loading and parsing XML content, 1006

overview, 1002—1003 XML APIs

vs. DOM models, 995—996 overview, 993—994 Visual Basic (VB) literal syntax, 996—

997 XML documents

building UI of LINQ to XML App, 1007

defining LINQ to XML Helper class, 1008—1009

importing Inventory.xml files, 1007—1008

overview, 1006 rigging up UI to Helper class, 1009—

1011 LINQ-compatible datatables, obtaining,

946—947 LinqOverArray application, 496 LinqOverArray project, 503 LinqOverArrayUsingEnumerable project,

522 LinqOverCollections project, 505, 508 LinqOverDataSet example, 949 LinqOverDataTable( ) method, 945 LinqRetValues application, 504 LinqRetValues project, 505 LinqToDataSetApp application, 946 LinqToXmlFirstLook application, 993 LinqToXmlObjectModel class, 1008 LinqToXmlWinApp application, 1007 LinqUsingEnumerable application, 518 Linux operating system, executing

Windows Forms application under, 1580

List block, 1231 List class, 1230 List element, 1227, 1231 List type, 1227 List<> class, 370 List<> object, 371, 372 List<Car> collection, 906 List<Car> parameter, 506 List<NewCar> object, 866 List<T> class, 371, 373, 374, 377, 379—380,

491, 719, 763, 1074 List<T> container, 1004

Page 140: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1650

List<T> object, 952 List<T> type, 373, 493, 505 List<T> variable, 374, 506, 671, 905, 1556,

1557, 1559 ListBox class, 1164 ListBox control, 1224, 1225, 1319, 1431,

1439, 1455, 1477, 1478 ListBox type, 621 ListBox web control, 1477 ListBoxes control, 1531 listCars variable, 905 ListControl type, 1431 ListDictionary type, 363 ListFields( ) method, 591 ListInterfaces( ) method, 591 ListInventory( ) method, 874 ListInventoryViaList( ) method, 874 ListMethods( ) method, 590, 594, 595 listOfHandlers delegate, 406 listOfHandlers variable, 407, 418 lists

comma-delimited, 130 semicolon-delimited, 46

literal attribute, 674 literal floating point data, 96 Load event, 719, 989, 1409, 1420, 1423,

1424, 1478, 1492, 1496, 1506 Load( ) method, 554, 596, 639, 1006 loaded assemblies, 641—643 Loaded event, 1173, 1174, 1278, 1288, 1289,

1311, 1359 LoadExternalModule( ) method, 622, 623 LoadFrom( ) method, 554, 596 loading

assemblies, into custom application domains, 645

images programmatically, 1288—1289 InkCanvas data, 1226—1227 XML content, 1006

Local Area Network (LAN), 1019 local variables

accessing, C#, 429—430 declaring in CIL, 680—681 mapping parameters to in CIL, 681

LocalBuilder member, 689

localized assemblies, 598 LocalNullableVariables( ) method, 163 .locals directive, 657, 681 LocalVarDeclarations( ) method, 89 Location property, 1535 lock keyword, synchronization using, 753—

754 Lock( ) method, HttpApplicationState

type, 1484, 1487 lock scope, 754 lock statement, 757 lock token, 753 locks, threading primitives, 729 logging support, 1078 logical model, 958 logical operators, C#, 120, 121 logical resources, 1285 logical trees, WPF, 1341—1348 logical view, 1341 LogicalTreeHelper class, 1342 Login controls, 1440 lollipop notation, 328 long data type, 87 longhand notation, 718 longhand reflection calls, 711 lookless, 1341 LookUpColorsForMake( ) method, 1009 LookUpPetName( ) method, 876 looping animation, 1308—1309 loops. See iteration constructs loose resources, WPF

configuring, 1287 including files in project, 1286—1287

lstTextBoxData control, 1431

■M M command, 1257 MacDonald, Matthew, 1395 machine.config file, 1051, 1063, 1503, 1505 MachineName class, 1031 MachineName property,

System.Diagnostics.Process class, 628

Page 141: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1651

MachineName property, System.Environment class, 81

magic numbers, 146 MagicEightBallService class, 1033, 1052 MagicEightBallServiceClient application,

1046 MagicEightBallServiceClient project, 1048,

1075 MagicEightBallServiceClient.exe.config

file, 1050 MagicEightBallServiceHost project, 1036,

1045, 1051 MagicEightBallServiceHost.exe

application, 1059 MagicEightBallServiceHTTP directory,

1036, 1045, 1048 MagicEightBallServiceHTTPDefaultBindin

gs project, 1057 MagicEightBallServiceLib namespace,

1036 MagicEightBallServiceLib project, 1032,

1036 MagicEightBallServiceLib.dll assembly,

1036, 1049 MagicEightBallTCP project, 1050 main menu system, 1552—1553 Main( ) method

implementing, 872 Program class, 34 variations on, 75—76 WPF application, 626

MainControl.xaml file, 1357 MainForm class, 905, 906, 989 MainForm_Load( ) method, 937 MainForm.cs file, 763, 920 MainMenuStrip property, 1516 MainWindow class

adding code file for, 1165 defining, 1146—1147

MainWindow property, 1129, 1137 MainWindow type, 1516, 1535, 1553, 1555 MainWindow_Paint( ) method, 1549 MainWindow.baml file, 1151 MainWindow.cs file, 1520, 1534, 1549, 1552 MainWindow.cs icon, 1520

MainWindow.Designer.cs file, 1520, 1523 MainWindow.g.cs file, 1150, 1165 MainWindowTitle property,

System.Diagnostics.Process class, 629

MainWindow.xaml file, 1146, 1149, 1151, 1165, 1173, 1174, 1294, 1366

Make Into UserControl option, 1365 Make property, 1110 MakeACar( ) method, 291, 292, 293 MakeColumn column, 934 MakeNewAppDomain( ) method, 645 Manage Help Settings tool, 68 managed attributes, 675 managed code, 10 managed heap, 289, 291, 292, 293, 294 managed resources, 311 ManagedThreadId property, 731 Manager class, 226, 227, 228 Manager object, 229 Manager type, 229, 230 MANIFEST assembly, 544, 712 MANIFEST data, 542 MANIFEST icon, 35, 542 MapPath( ) method, 1418 mapping database names to friendly

names, 916 Mapping Details window, 967, 968, 969 mappings, viewing, 967 Margin property, 1195 markup, 1119 markup extensions, XAML, 1163—1165 markup tags, 1440 MarkupExtension class, 1163 massive numerical value, 96 master constructor, 177, 178, 179, 201 *.master file, 1442, 1444, 1446, 1447, 1448 master pages

AdRotator widget, 1447—1448 bread crumbs, establishing with

SiteMapPath type, 1447 overview, 1442—1444 TreeView control site navigation Logic,

1445—1447 Master property, 1450

Page 142: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1652

<%@Master%> directive, 1443 MasterPage class, 1443 MasterPageFile attribute, 1402, 1449 MasterPageFile property, 1417 MasterPage.master file, 1443 Math class, 181 MathClient application, 1067 MathClient project, 1070, 1075 MathExtensions class, 469 MathLib.dll code library, 43 MathLibrary assembly, 574 MathLibrary project, 711 MathLibrary.dll assembly, 711, 712 MathMessage delegate, 435 MathService.cs file, 1058 MathServiceLibrary namespace, 1057,

1058 MathServiceLibrary project, 1057 MathServiceLibrary.dll assembly, 1062 MathWindowsServiceHost project, 1062,

1066, 1067 MathWinService.cs file, 1062 MatrixTransform type, 1262 Max( ) method, 516 MAX_IMAGES constant, 1289 Max<>( ) method, 509 Max<T>( ) method, 500 MaxGeneration method, System.GC class,

298 MaxHeight property, FrameworkElement

type, 1133 MaximizeBox property, 1530, 1538 MaximumValue property, 1460 MaxSpeed variable, 263 .maxstack directive, 662, 680 MaxValue property, 92, 93 MaxWidth property, FrameworkElement

type, 1133 mcs compiler, Mono, 1569 MDI (multiple document interface)

application, 1525 MdiChildActive event, 1531 Media controls, WPF, 1180 MediaCommands class, WPF, 1201 MediaPlayer type, 1272

member parameters, defining in CIL, 676—677

member shadowing, 245—247 member variables, 167 MemberInfo class, System.Reflection

Namespace, 587 members, 22, 374 MemberType property, MethodBase

object, 268 MemberwiseClone( ) method, 252, 349,

351, 353, 354 MemoryStream class, 776 MemoryStream object, 1234 Menu class, 1196 Menu control, 1439, 1445, 1446 Menu item, 1447 Menu property, 1530 menu systems

building visually, 1522—1524 building window frame using nested

panels, 1196—1197 <Menu> definition, 1197 MenuItem element, 1202, 1205 MenuItem objects, 1196 Menus & Toolbars node, 1522 MenuStrip component, 621 MenuStrip control, 1522 MenuStrip object, 1516 MenuStrip type, 1516 Merge( ) method, 888 merged resource dictionaries, defining,

1298—1299 Message property, 109, 263, 265, 267, 273,

275, 276, 284 Message Transmission Optimization

Mechanism (MTOM), 1029 MessageBox class, 540, 1137 MessageBox.Show( ) method, 663, 686,

746, 1349, 1532 messageDetails field, 274 MessageToShow argument, 1084, 1085 messaging activities, WF 4.0, 1090—1091 metadata. See also type metadata

of assemblies, 17—18 interop, embedding, 716—717

Page 143: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1653

tables, 494 types, 536

metadata exchange (MEX) behavior configuration, 1054—1055 enabling, 1043—1045

metadata viewer. See custom metadata viewer

MetaInfo window, 586 method attribute, 1417 method group conversion, 9, 412 method implementation, 13 method invocations, asynchronous, 22 Method member, 401 method overriding, 236 method parameters and return values,

594—595 Method property, 404 method scope, 186, 290, 296 method signature, 132, 1572 MethodAttributes.Public method, 697 MethodBase object, 263, 268 MethodBase.DeclaringType property, 268 MethodBuilder class, 697 MethodBuilder member, 689 MethodBuilder type, 690 MethodInfo class, 587, 710, 711 MethodInfo object, 602 MethodInfo type, 590 MethodInfo.Invoke( ) method, 602 MethodInfo.Name property, 590 MethodName property, 1095, 1098 MethodOverloading application, 137 MethodOverloading project, 135 methods

anonymous, C#, 427, 429—430 custom generic, creating, 385—388 custom metadata viewer, 590 of DataSet types, 888 default parameter-passing behavior,

126—127 extension, 10 invoking asynchronously

overview, 733 passing and receiving custom state

data, 738—739

role of AsyncCallback delegate, 736—738

role of AsyncResult class, 738 synchronizing calling thread, 734—

735 named parameters, 133—134 with no parameters, invoking, 602—603 optional parameters, 131—132 out modifier, 127—128 overloading of, 135—137 overridable, 238 overview, 125 with parameters, invoking, 603—604 params modifier, 130—131 ref modifier, 128—129 static, 181—182

MEX. See metadata exchange MFC (C++/Microsoft Foundation Classes),

4 MFC (Microsoft Foundation Classes), 4, 25 mfc42.dll library, 25 MI (multiple inheritance), with interface

types, 341—342 Microsoft Expression Blend, 1119 Microsoft Foundation Classes (MFC), 4, 25 Microsoft GAC, 1575 Microsoft Intermediate Language (MSIL),

13 Microsoft Message Queuing (MSMQ),

1015—1016, 1019, 1020, 1023, 1028, 1031, 1032

Microsoft namespace, 30 Microsoft SQL Server data provider, 829 Microsoft SQL Server Management Studio,

1502 Microsoft SQL Server Mobile data

provider, 829 Microsoft Transaction Server (MTS), 1015 Microsoft.CSharp namespace, 30 Microsoft.CSharp.dll assembly, 705 Microsoft.CSharp.RuntimeBinder

namespace, 705 Microsoft.CSharp.Targets file, 1149 Microsoft.ManagementConsole

namespace, 30

Page 144: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1654

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

Microsoft.SqlServer.Server namespace, 831

Microsoft-supplied data providers, 829—830

Microsoft.Win32 namespace, 30, 1183, 1206

Microsoft.WinFX.targets file, 1149 MIInterfaceHierarchy application, 341 MIInterfaceHierarchy project, 342 MIME (Multipurpose Internet Mail

Extensions), 1421 Min( ) method, 516 Min<>( ) method, 509 MinHeight property, FrameworkElement

type, 1133 MinimizeBox property, 1530, 1538 MinimumValue property, 1460 MiniVan class, 220, 221, 222, 602 MiniVan objects, 453, 602 MinValue property, 92, 93 MinWidth property, FrameworkElement

type, 1133 Miscellaneous category, 1229 MissingPrimaryKeyException exception,

832 mnuFile object, 1516 mnuFileExit type, 1517 Model Browser window, 966, 983 Model-View-Controller (MVC) pattern,

1395 Modified value, 895 ModifierKeys property, 1527 modifiers, for methods

out, 127—128 params, 130—131 ref, 128—129

Modifiers property, 1537, 1543 modifying application data, 1486—1487 Module class, System.Reflection

Namespace, 587 module option, 550 module set of process, 634 [module:] tag, 612

Module1.vb code file, 548 ModuleBuilder class, 694 ModuleBuilder member, 689 ModuleBuilder type, 694—695 ModuleBuilder.CreateType( ) method, 695 ModuleBuilder.SetEntryPoint( ) method,

689 module-level manifest, 537, 551 modules, 14, 44, 536 Modules property,

System.Diagnostics.Process class, 629

modulo statement, 433, 434 Monitor class, 740, 756 Monitor object, 740 Monitor.Enter( ) method, 756 Monitor.Exit( ) method, 756 MonitoringIsEnabled property,

AppDomain class, 639 Monitor.Pulse( ) method, 756 Monitor.PulseAll( ) method, 756 monitors, threading primitives, 729 Monitor.Wait( ) method, 756 Mono

building .NET applications with building console application in

Mono, 1576—1578 building Mono code library, 1572—

1575 building Windows Forms Client

program, 1578—1580 development languages

MonoDevelop IDE, 1569—1570 working with C# compiler, 1569

development tools, Microsoft-compatible

Mono-specific development tools, 1571—1572

overview, 1570 directory structure of, 1567—1568 further study of, 1581—1582 obtaining and installing, 1565—1568 overview, 1561 scope of, 1564—1565 who uses, 1581

Page 145: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1655

Mono <version> For Windows option, 1568

Mono GAC, installing assemblies into, 1575

mono print, 1572 Mono project, 39, 1126 Mono SDK, 1565 MonoDevelop IDE, 666, 1569—1570 monodis tool, viewing updated manifest

with, 1574—1575 monodis utility, Mono, 1571 monop tool, Mono, 1571, 1572 Moonlight, Silverlight API, 1565 Motorcycle class, 173, 174, 176, 177, 178,

606, 610 Motorcycle object, 179 mouse activity

determining which button was clicked, 1535—1536

overview, 1534 mouse events, intercepting, 1142—1143 mouse operation, 1280 mouseActivity variable, 1339 MouseAndKeyboardEventsApp project,

1534, 1538 MouseButtonEventArgs, 1252 MouseButtons enumeration, 1534, 1535 MouseButtons property, 1527 MouseClick event, 1535 MouseDoubleClick event, 1133, 1535 MouseDown event, 1134, 1142, 1248, 1276,

1283, 1338, 1339, 1370, 1371, 1373 MouseDownStar state, 1366, 1367, 1368,

1369 MouseEnter event, 1134, 1142, 1172, 1196,

1197, 1199, 1306, 1370, 1528 MouseEnterStar state, 1366, 1367, 1368 MouseEventArgs class, 1142, 1535 MouseEventArgs parameter, 1534 MouseEventArgs type, 1517 MouseExit event, 1196 MouseExit handler, 1197 MouseExitStar state, 1366, 1368 MouseHover event, 1528

MouseLeave event, 1134, 1142, 1199, 1370, 1528

MouseLeftButtonDown event, 1250, 1251 MouseMove event, 1134, 1142, 1143, 1430,

1528, 1534, 1535 MouseRightButtonDown event, 1252 MouseStateGroup, 1366, 1367, 1368 MouseUp event, 1142, 1338, 1528, 1535 MouseWheel event, 1528 MoveNext( ) method, 344, 348 MoveTo( ) method

DirectoryInfo class, 779 FileInfo class, 785

MSBuild, 43 msbuild.exe utility, 1148, 1149, 1150, 1151,

1153 processing files with

building WPF applications using code-behind files, 1166—1167

building WPF applications with XAML, 1148—1150

mscoree.dll library, 25, 26, 37 mscorlib reference, 662 [mscorlib]System.Collection.ArrayList, 677 [mscorlib]System.Collections.ArrayList

type, 677 [mscorlib]System.Enum, 671 [mscorlib]System.ValueType, 671 mscorlib.dll assembly, 22, 26, 27, 32, 361,

587, 590, 595, 601, 1572 MSIL (Microsoft Intermediate Language),

13 MSMQ (Microsoft Message Queuing),

1015—1016, 1019, 1020, 1023, 1028, 1031, 1032

MSMQ-based bindings, 1031 MsmqIntegrationBinding class, 1031, 1032 <msmqIntegrationBinding> element, 1031 msvbvm60.dll library, 25 MTOM (Message Transmission

Optimization Mechanism), 1029 MTS (Microsoft Transaction Server), 1015 mul opcode, 678 MulticastDelegate class, 401, 403, 412 multicasting, 22

Page 146: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1656

multicore processors, 727 multidimensional array, 866 multidimensional arrays, 140—141 multi-file assemblies, 14, 536—538, 586 multifile NET assemblies, building and

consuming airvehicles.dll file, 551—552 consuming multifile assembly, 552 overview, 550 ufo.netmodule file, 551

multifile pages, compilation cycle for, 1410 MultifileAssembly code files, 553 multi-language, programming languages,

12 Multiline property, 1007 multiple (or zero) parameters, lambda

expressions with, 435—436 multiple base classes, 222 multiple bindings, exposing single services

using, 1052—1053 multiple conditions, 1317 multiple dimensions, indexers with, 443—

444 multiple document interface (MDI)

application, 1525 multiple exceptions

finally blocks, 282 general catch statements, 279—280 inner exceptions, 281 overview, 277—278 rethrowing, 280

multiple inheritance (MI), with interface types, 341—342

multiple sort orders, specifying, 357—358 multiple statements, processing

arguments within, 433—434 Multiply( ) method, 96, 394 Multipurpose Internet Mail Extensions

(MIME), 1421 multitabled DataSet objects and data

relationships building table relationships, 924 navigating between related tables, 925—

927 overview, 921

prepping data adapters, 922—923 updating database tables, 924

MultitabledDataSetApp application, 921 MultitabledDataSetApp project, 927 multithreaded and parallel programming

asynchronous nature of delegates BeginInvoke( ) and EndInvoke( )

methods, 732 overview, 731 System.IAsyncResult interface, 732—

733 brief review of .NET delegate, 729—731 CLR thread pool, 760—761 concurrency, 750—758 invoking methods asynchronously

overview, 733—735 passing and receiving custom state

data, 738—739 role of AsyncCallback delegate, 736—

738 role of AsyncResult class, 738 synchronizing calling thread, 734—

735 overview, 727 parallel LINQ queries (PLINQ)

canceling, 772—774 opting in to, 772 overview, 771

parallel programming under .NET platform

handling cancelation request, 766—767

overview, 761 role of Parallel class, 763 Task class, 765—766 task parallel library API, 762—763 task parallelism, 768—771 understanding data parallelism,

763—766 process/appdomain/context/thread

relationship overview, 727 problem of concurrency, 728—729 role of thread synchronization, 729

Page 147: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1657

programmatically creating secondary threads

AutoResetEvent class, 748—749 foreground and background

threads, 749—750 overview, 744 ParameterizedThreadStart delegate,

747 ThreadStart delegate, 745—746

programming with timer callbacks, 758—759

synchronization using [Synchronization] attribute,

757—758 using C# lock keyword, 753—754 using System.Threading.Interlocked

type, 756—757 using System.Threading.Monitor

type, 755—756 System.Threading namespace, 739—740 System.Threading.Thread class

Name property, 743 obtaining statistics about current

thread, 742 overview, 741 Priority property, 744

MultiThreadedPrinting project, 751, 755 MultiThreadSharedData program, 756 <MultiTrigger> element, 1317 MusicMedia enum, 570 mutator method, 194, 195, 196, 198, 200,

206 Mutex class, System.Threading

namespace, 740 MVC (Model-View-Controller) pattern,

1395 My other string value, 104 My3DShapes namespace, 527, 530 MyApp class, adding code file for, 1166 MyApp.g.cs file, 1150, 1153, 1166 MyApp.xaml file, 1147, 1149, 1166 MyAssembly.dll assembly, 691 MyBaseClass namespace, 668, 669 myBrush key, 1296 myBrush resource, 1294

MyBrushesLibrary project, 1300 MyBrushes.xaml file, 1299, 1300, 1301 myCar object, 291, 474, 475 myCar reference, 291 myCars list, 506 MyCars.dll assembly, 532 MyCompany namespace, 668 MyConnectionFactory project, 837, 840 MyConnectionFactory.dll assembly, 840 MyConnectionFactory.exe application,

840 MyControls.dll library, 1159 MyCoolApp.exe application, 48 myCtrls tag, 1159 <myCtrls:ShowNumberControl> scope,

1333 MyCustomControl namespace, 1364 MyCustomControl project, 1356, 1364 MyCustomControl.dll assembly, 1364 MyDefaultNamespace namespace, 531 MyDerivedClass class, 669 MyDirectoryWatcher project, 804 myDocumentReader control, 1229, 1233 MyDoubleConverter class, 1240 MyEBookReader project, 771 MyEBookReader, Windows Forms

application, 768 MyEnum enumeration, 674 MyEventHandler( ) method, 427 MyExtendableApp.exe assembly, 618 MyExtensionsLibrary project, 469 MyExtensionsLibraryClient project, 469 MyExtensionsLibrary.dll assembly, 468 MyGenericDelegate<T>, 416 MyGenericMethods class, 388 myInkCanvas control, 1222 myKeyFile.snk file, 564 myListBox listbox, 1477 MyLocalVariables( ) method, 680 MyMathClass class, 214, 215 MyMathClass.PI constant, 215 MyPage_aspx class, 1405 MyPaintProgram namespace, 1554 myPanel control, 1433 MyPoint type, 155

Page 148: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1658

MyPrivateQ queue, 1032 myProxy.cs file, 1046 MyResourceWrapper class, 303, 304, 306,

310, 311, 312 MySDWinApp solution, 51 myShapes array, 245 MyShapes namespace, 525, 526, 527 MyShell.exe application, 43 MySqlConnection class, 828 myTabSystem control, 1213 MyTarget method, 417 MyTestKeyPair folder, 561 MyTestKeyPair.snk file, 561, 562 myTestKeyPair.snk file, 1575 MyTypeViewer assembly, 595 MyTypeViewer.exe, 593 MyWordPad application, 1195 MyWordPad project, 1207 MyXamlPad project, 1168, 1178 MyXamlPad.exe application, 1309 MyXamlPad.exe file, 1175, 1177, 1186,

1187, 1311

■N N string format character, 84 name attribute, 577, 1037, 1054, 1505 name clashes, resolving via explicit

interface implementation of, 336—339

Name edit area, 1213 name field, 174, 175 Name keyword, 1158 Name method, FileInfo class, 785 name parameter, 174 Name property

Employee class, 200, 201 FileSystemInfo class, 778 FrameworkElement type, 1133 System.Threading.Thread class, 743

Name values, 511, 595 named argument syntax, 180 named arguments, 133 named parameters, for methods, 133—134

named pipes, 1019 NameOfControl_NameOfEvent( ) method,

1524 namespace concept, 27 .namespace directive, 655, 668 namespace keyword, 525 Namespace property, 1034 namespaces, 27—32, 1512—1513

accessing programmatically, 30—32 custom, 525—531 default, of Visual Studio 2010, 531 defining in CIL, 668 Microsoft root namespace, 30 nested, 530 referencing external assemblies, 32 workflow, 1105

<namespaces> element, 1427 name/value pairs, 147, 493, 1088 naming convention, 537 narrowing conversion, 107 narrowing operation, 106, 107 NarrowingAttempt( ) method, 108 naturally dirty windows, 1551 Navigate to Event Handler menu option,

1205 navigating between related tables, 925—927 Navigation node, 1439 Navigation Properties section, 982 navigation properties, using within LINQ

to Entity queries, 984—985 Navigation tab, 1447 navigation-based applications, 1124 navigation-based desktop program, 1124 NavigationCommands class, WPF, 1202 NavigationWindow class, 1124, 1155 NavigationWindow element, 1341 ndexOutOfRangeException class, 272 nested assembly attribute, 669 nested famandassem attribute, 669 nested family attribute, 669 nested famorassem attribute, 669 nested namespaces, creating, 530 nested panels, WPF, building window

frame using finalizing UI design, 1198

Page 149: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1659

menu system, 1196—1197 MouseEnter event handler,

implementing, 1199 MouseLeave event handler,

implementing, 1199 overview, 1195 spell checking logic, implementing,

1200 StatusBar, 1198 ToolBar, 1197—1198

nested private attribute, 669 nested public attribute, 669 nested type definitions, 233—235 Nested Types node, InventoryDataSet

icon, 934 NestedAssembly member, 695 NestedFamAndAssem member, 695 NestedFamily member, 695 NestedFamORAssem member, 695 NestedPrivate member, 695 NestedPublic member, 695 .NET 4.0 visual states

changing using VisualStateManager class, 1370

overview, 1366 for StarButton control, 1367—1368 state transition timings, 1368—1369 viewing generated XAML, 1369—1370

.NET assemblies <codeBase> element, 576—577 building with CIL

building CILCarClient.exe, 686—687 building CILCars.dll, 683—686

defining custom namespaces creating nested namespaces, 530 default namespace of Visual Studio

2010, 531 overview, 525—526 resolving name clashes with aliases,

528—530 resolving name clashes with fully

qualified names, 527—528 format of

CIL (common intermediate language) code, type metadata, and assembly manifest, 536

CLR file header, 535 optional assembly resources, 536 overview, 533 single-file and multifile assemblies,

536—538 Windows file header, 534—535

multifile, building and consuming airvehicles.dll file, 551—552 consuming multifile assembly, 552 overview, 550 ufo.netmodule file, 551

private configuration files and Visual Studio

2010, 556—558 configuring private assemblies, 554—

556 identity of private assembly, 553 probing process, 553—554

publisher policy assemblies, 574—575 role of, 532—533 shared

configuring, 569—574 consuming, 567—569 generating strong names at

command line, 561—563 generating strong names using

Visual Studio 2010, 563—564 installing strongly named

assemblies to GAC, 565—566 overview, 558—559 strong names, overview, 560—561 viewing .NET 4.0 GAC using

Windows Explorer, 566 single-file assembly, building and

consuming building C# client application, 545—

547 building Visual Basic client

application, 547—549 CIL (common intermediate

language), 544

Page 150: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1660

cross-language inheritance in action, 549

manifest, 541—544 overview, 538—540 type metadata, 544—545

System.Configuration namespace, 577 transforming markup into

BAML, 1151—1152 mapping application data to C#

code, 1153 mapping window data to C# code,

1150—1151 XAML-to-assembly process, 1153—

1154 .NET attributes

applying in C#, 606—607 attribute consumers, 605—606 C# attribute shorthand notation, 607—

608 obsolete attribute, 608—609 overview, 604 specifying constructor parameters for,

608 .NET exception handling, 260—262 .NET executable program, process entry

point, 626 .NET Framework 4.0 SDK documentation,

282, 299, 307, 530, 545, 740, 756, 773, 1184, 1336

.NET Framework 4.0 Software Development Kit (SDK), 41—42, 67—69

.NET module, 536

.NET platform, parallel programming under

data parallelism, 763—766 handling cancelation request, 766—767 overview, 761 role of Parallel class, 763 Task class, 765—766 task parallel library API, 762—763 task parallelism, 768—771

.NET properties, using for encapsulation of classes, 198—200

.NET remoting, 1016

.NET-aware programming languages, 10—12

*.netmodule file extension, 537, 548, 550, 586

NetMsmqBinding class, 1031, 1032 netMsmqBinding class, 1042 <netMsmqBinding> element, 1031 NetNamedPipeBinding class, 1030, 1032 <netNamedPipeBinding> element, 1030 NetPeerTcpBinding class, 1030, 1032 <netPeerTcpBinding> element, 1030 NetTcpBinding class, 1030, 1032, 1049,

1054, 1070 NetTcpBinding object, 1050 <netTcpBinding> element, 1030, 1050 New button, 1229 New Connection button, 929, 963 new( ) constraint, 393 New Data Source option, 1447 <New Event Handler> option, 1172 New Folder menu option, 1286 new instance, 253 new keyword, 89, 90, 125, 153, 170, 171,

209, 291, 292—293, 588 new object pointer, 292 new operator, and system data types, 89—

90 New option, 563 New Project button, 1207 New Project dialog box, 51, 56, 621, 1024,

1057, 1079, 1103, 1207 New project menu command, 1207, 1356 New Project menu option, 538, 1300, 1518 New Solution menu option, 665 New Storyboard button, 1359 New Web Site dialog box Visual Studio

2010, 1025 newarr opcode, 678 NewCar class, 864 NewCar object, 876 NewCarDialog.cs file, 719 NewCarDialog.designer.cs file, 719 NewCarDialog.resx file, 719 NewLine member, TextWriter class, 795

Page 151: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1661

NewLine property, System.Environment class, 81

newobj instruction, 292 newobj opcode, 678 newVersion attribute, 573 Next button, 928 next object pointer, 292 NextResult( ) method, 861 ngen.exe command-line tool, 17 ngen.exe utility, Microsoft .NET, 1570 nheritance chain, 1326 Nodes<T> method, 1000 nonabstract, 1145 None radio button, 981 non-ephemeral generation, 297 non-generic collections

applying LINQ queries to, 507—508 issues with

overview, 361—362 performance, 363—367 type safety, 367—371

nonnullable variable, 162 non-optional parameters, 132 [NonSerialized] attribute, 605, 606 nonstatic class data, 182 nonstatic method, 182, 188 NoNullAllowedException exception, 832 not opcode, 678 not System.Int32, 366 Notepad++, building C# applications with,

49—50 NotEqual value, 1461 Nothing value, 1107 NotPublic member, 695 notserialized token, 606 Now property, DateTime class, 132 null brush, 1259 null reference, 209, 254, 293, 330 null, setting object references to, 293—294 nullable types

?? operator, 164—165 overview, 162 working with, 163—164

Nullable<T> structure type, 163 NullableTypes application, 165

NullableTypes project, 162 NullReferenceException, 407 numb1 value, 106 numb2 value, 106 numerical conversions, 454 numerical data types, 92, 127 numerical formatting, 84 numerical value, 96, 298

■O obj variable, 602 object (logical) resources, WPF

{DynamicResource} markup extension, 1295—1296

{StaticResource} markup extension, 1294

application-level resources, 1296—1297 changing after extraction, 1295 extracting in Expression Blend, 1301—

1303 merged resource dictionaries, defining,

1298—1299 resource-only assembly, defining,

1300—1301 Resources property, 1292 window-wide resources, defining,

1292—1294 object argument, 1335 Object Browser utility, Visual Studio 2010,

60, 223, 1247, 1404 Object class, 189, 251, 252, 1137, 1416,

1424 object construction, parameterized, 4 object context boundaries

context-agile and context-bound types, 649

defining context-bound object, 649—650 inspecting object's context, 650—651 overview, 648

object data type, 87 object generations, 296—297 object graphs, 294, 295, 805—806 object initializer syntax

Page 152: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1662

calling custom constructors with, 212—213

inner types, 213—214 overview, 210—211

object instance, 194 object keyword, 251 object lifetime

and application roots, 294—295 classes, defined, 289—290 disposable and finalizable blended

technique, 309—312 disposable objects, 305—309 finalizable and disposable blended

technique, 309—312 finalizable objects, 302—305 garbage collection, 297—302 lazy objects, 313—317 and new keyword, 292—293 object generations, 296—297 object references, setting to null, 293—

294 objects, defined, 289—290 overview, 291—294 references, defined, 289—290 System.GC type, 298—302

object model Excel, 721 Microsoft Office, 718 Microsoft Office Excel, 715

Object option, 987 object parameters, 386, 399, 1139, 1337,

1536 object references, setting to null, 293—294 object resources, 1285 object serialization. See I/O and object

serialization object services, 956 Object type, 513 object user, 306 object variable, 196, 365, 702 ObjectContext class, 958—960, 967, 970,

971, 973, 974 ObjectIDGenerator type,

System.Runtime.Serialization namespace, 818

ObjectInitializers application, 211 ObjectInitilizers project, 214 object-oriented layer, 4 object-oriented programming (OOP)

overview, 188 pillars of

encapsulation, 189 inheritance, 189—191 polymorphism, 191—192

ObjectOverrides application, 252 ObjectOverrides namespace, 253 ObjectOverrides project, 253, 257 ObjectParameter object, 986 ObjectParameter type, 986 ObjectQuery<T> object, 976 ObjectResourcesApp application, 1292 ObjectResourcesApp project, 1300, 1301,

1303 objects

2D geometric, 1246 adding to DataTable types, 892—893 allocation onto managed heap, 293 arrays of, 139—140 command, 834 connection, 833 disposable, 311, 312 transaction, 834 unreachable, 291 urgency level of, 298

Objects and Timeline editor, 1213, 1215, 1217, 1222, 1229, 1236, 1359, 1360, 1361, 1365

Objects window, 1270 ObjectSet<Car> collection, 977 ObjectSet<Car> data member, 971 ObjectSet<Car> field, 974 ObjectSet<Car> variable, 960 ObjectSet<Inventory> member, 959 ObjectSet<Order> variable, 959 ObjectSet<T> classe, 958—960 ObjectSet<T> field, 975 ObjectSet<T> property, 967 ObjectSet<T> variables, 967, 971 obsolete attribute, 608—609 [Obsolete] attribute, 605, 607, 608, 609

Page 153: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1663

ObsoleteAttribute class, 607 ObtainAnswerToQuestion( ) method, 1035,

1059 ObtainVehicleDelegate delegate, 415 Octagon class, 337 Octagon object, 337 Octagon type, 337 ODBC data provider, 829, 830 OdbcConnection class, 828 OdbcConnection object, 321 OdbcDataAdapter class, 913 OfType<T>( ) method, 507, 508 oldVersion attribute, 573, 574 OLE DB data provider, 829, 830 on operator, 509 On prefix, 1528 OnCarEngineEvent( ) method, 408 OnCarNicknameChanged( ) method, 972 OnCarNicknameChanging( ) method, 972 OnClick attribute, 1389, 1398, 1409 [OnDeserialized] attribute, 818 [OnDeserializing] attribute, 818 OnDragDrop( ) method, 322 OnDragEnter( ) method, 322 OnDragLeave( ) method, 322 OnDragOver( ) method, 322 OnKeyUp event, 1528 OnMouseMove event, 1528 OnPaint event, 1528 OnPaint( ) method, 1245 [OnSerialized] attribute, 819 [OnSerializing] attribute, 819 OnStart( ) method, 1062 OnStop( ) method, 1062 OnTransformDirty( ) method, 1329 OnZipCodeLookup( ) method, 473 OO wrapper, 599 OOP. See object-oriented programming Opacity property, 1307, 1521, 1527 opcodes

.maxstack directive, 680 declaring local variables in CIL, 680—

681 hidden this reference, 682

mapping parameters to local variables in CIL, 681

overview, 677—679 representing iteration constructs in

CIL, 682—683 role of CIL, 655

OpCodes class, 696 OpCodes member, 689 Open command, WPF, 1204—1206 Open member, FileMode enumeration,

787 Open( ) method, 189, 322, 785, 786—788,

855, 1040, 1051 OpenConnection( ) method, 863 OpenFileDialog dialog box, 1183 OpenFileDialog type, 1559 OpenOrCreate member, FileMode

enumeration, 787 OpenRead( ) method, FileInfo class, 785,

788 OpenText( ) method, FileInfo class, 785,

789 OpenTimeout property, 1040, 1053 OpenWrite( ) method, FileInfo class, 785,

788 operation codes, 655 operational contracts, service types as,

1035—1036 OperationCanceledException error, 767 [OperationContract] attribute, 1027, 1033,

1034, 1035, 1073 operations, Venn diagramming, 1268 operator keyword, 654 operator overloading

+= and -+, 448 binary, 445—447 comparison, 450 equality, 449—450 internal representation of, 451—452 overview, 444 unary, 448—449

Operator property, 1461 optional arguments, 131, 133, 134 optional parameters, for methods, 131—132 [OptionalField] attribute, 819

Page 154: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1664

or opcode, 678 or zero (multiple) parameters, lambda

expressions with, 435—436 OracleConnection class, 828 OracleConnection object, 321 Order Automobile menu, 1538 OrderAutoDialog class, 1544, 1545 OrderAutoDialog object, 1542 OrderAutoDialog.cs file, 1538 OrderAutoDialog.Designer.cs file, 1543 OrderBy( ) method, 519, 520 orderby operator, 497, 509, 514, 517, 518 OrderedEnumerable type, 519 OrderedEnumerable<TElement, TKey>

type, 498 OrderedEnumerable`2, 498 OrderID values, 844, 845 Orders column, 988 Orders property, 959 Orders table, 840, 844, 845, 846, 921, 939,

979, 984 Ordinal property, DataColumn class, 891 Orientation property, 1189, 1190, 1263 Original value, 896 OSVersion property, 1163 Other Windows menu option, 840, 965,

1181 out argument, 400 out keyword, 127 out modifier, 127—128, 159 out parameter, 400, 429 [out] token, 677 outer variables, 429 outerEllipse control, 1338 outerEllipse object, 1339 outgoing HTTP response, 1421—1423

emitting HTML content, 1422 redirecting users, 1422—1423

output argument, 1105 output, formatting for System.Console

class, 83—85 output parameters, 127, 128, 129, 843, 871,

1103 Output property, 1421 Output Type setting, 1144

output variables, 127 OutputStream property, 1421 overflow checking, 110—111 overflow condition, 109 OverloadedOps project, 453 overloading methods, 135—137, 443 overloading operators

+= and -+, 448 binary, 445—447 comparison, 450 equality, 449—450 internal representation of, 451—452 overview, 444 unary, 448—449

overridable methods, 238 override keyword, 236—238, 246, 303, 549

■P P command, 872, 876 <p> tag, 1386 P2P (peer-to-peer) services, 1019 pacing of animation, controlling, 1307—

1308 Padding property, 1133, 1195 PadLeft( ) method, String system type, 97 PadRight( ) method, String system type, 97 Page class, 1124, 1144, 1155, 1379, 1406,

1411, 1416, 1417, 1421, 1423 Page element, 1341 page level themes, applying, 1469 Page objects, 1124, 1125, 1155, 1450, 1474 Page property, 1432 Page type, inheritance chain of, 1416 Page_Load event, 1493 Page_Load( ) method, 1434, 1493 Page_NameOfEvent method, 1424 Page_PreInit( ) method, 1470, 1471 <Page> control, 1155 <Page> definition, 1163 <Page> element, 1149, 1155, 1156, 1164 <Page> scope, 1276 Pages control, 1292 <pages> element, 1468

Page 155: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1665

paging, enabling, 1453 Paint event, 1245, 1528, 1529, 1549—1550,

1555, 1556, 1557 PaintEventApp project, 1549, 1551 PaintEventArgs class, 1518 PaintEventArgs parameter, 1549, 1550 PaintEventHandler delegate, 1549 Panel class, 1433 Panel control, 1433, 1436 Panel object, 1463 Panel type, 1184, 1433 Panel widget, 1436 PanelMarkup folder, 1186 panels, WPF

enabling scrolling for, 1194—1195 nested, building window frame using

finalizing UI design, 1198 menu system, 1196—1197 MouseEnter/MouseLeave event

handlers, implementing, 1199 overview, 1195 spell checking logic, implementing,

1200 StatusBar, 1198 ToolBar, 1197—1198

overview, 1184—1185 positioning content within

Canvas panels, 1186—1188 DockPanel panels, 1193—1194 Grid panels, 1191—1193 StackPanel panels, 1190—1191 WrapPanel panels, 1188—1190

Paragraph block, 1230, 1231 Paragraph class, 1230 Paragraph element, 1227, 1231 Paragraph type, 1227 <Paragraph> element, 1227 Parallel activity, WF 4.0, 1089 Parallel class, 763, 771 Parallel Language Integrated Query

(PLINQ), 494, 762, 771—774, 1010 parallel programming. See multithreaded

and parallel programming parallel programming library, 761 ParallelEnumerable class, 771

Parallel.For( ) method, 763, 766 Parallel.ForEach( ) method, 763, 765, 766,

767 ParallelForEach<T> activity, WF 4.0, 1089 Parallel.Invoke( ) method, 768, 771 ParallelOptions object, 766, 767 parameter arrays, 9, 130 parameter modifiers, 126, 159 Parameter object, 828 parameter values, 133 ParameterBuilder member, 689 ParameterInfo class, System.Reflection

Namespace, 587 parameterized command objects, 867—869 parameterized object construction, 4 parameterized queries, 867 ParameterizedThreadStart delegate, 740,

744, 745, 747, 750 ParameterName property, 868, 869 parameters. See also type parameters

interfaces as, 331—333 for methods

default passing behavior, 126—127 named, 133—134 optional, 131—132

specifying using DbParameter type, 867—869

type, 372 Parameters member, 858 Parameters property, 834 params argument, 131 params keyword, 130, 400, 676 params modifier, for methods, 130—131 parent class, of existing class, 220—221 Parent member, DirectoryInfo class, 779 Parent property, 1432 parent/child relationships, 190 ParentRelations member, 897 Parse( ) method, 96, 1006 ParseFromStrings( ) method, 94 parsing XML content, 1006 partial class types, 217—218 partial keyword, 9, 217, 218, 471, 472, 972 partial methods, 470—473 partial rollback, 879

Page 156: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1666

PartialMethods project, 471, 473 partitions, of ECMA-335, 38, 1563 PasswordBox control, 1227 Paste command, 1200 Path class, 776, 1247, 1253, 1254, 1255,

1257, 1271 Path definition, 1267 Path menu, 1268 Path objects, 1256, 1257, 1268, 1276, 1365,

1366 Path settings, 1273 PATH variable, 42 <Path> element, 1256 path-based animations, 1304 PathGeometry class, 1255, 1256 PathGeometry property, 1255 paths, 1254—1257, 1267—1268 PathSegment class, 1257 PathSegment type, 1257 Patient Details button, 1122 Pause( ) method, 313 Pay property, Employee class, 200 Peek( ) method, 381, 382, 383, 796 PeekChar( ) method, BinaryReader class,

800 peer-to-peer (P2P) services, 1019 Pen button, 1365 Pen class, 1261 Pen object, 1262, 1273, 1550 Pen tool, 1266, 1267 Pen type, 1547 Pencil control, 1365 Pencil tool, 1266, 1267, 1365 pens, configuring, 1261—1262 Pens type, 1547 PeopleCollection class, 440 performance issues, non-generic

collections, 363—367 PerformanceCar.vb file, 549 Persist activity, WF 4.0, 1091 persistence support, 1078 persistent cookie, 1498 persisting custom objects, 1507—1509 Person class, 158, 159, 160, 254, 256, 367,

382, 702

Person objects, 159, 253, 368, 371, 373, 379, 380, 385, 442, 493

person only collection, 368 Person type, 160 PersonCollection class, 368 PetName column, 170, 892, 910, 916 PetName property, 242, 247, 506, 549, 966 PetName string, 66 PetNameComparer class, 359 peverify.exe file, 666, 672, 687 PHP applications, 1475 physical model, 958 PI constant, 216 PIAs (Primary Interop Assemblies), 715 Pick activity, WF 4.0, 1089 Pick Color menu option, 1556 Pick Your Color link, 1455 PickBranch activity, WF 4.0, 1089 PictureBox control, 1544 PID (process identifier), 625, 631 pinning types, with fixed keywords, 485—

486 PInvoke (Platform Invocation Services),

303 Place code in separate file checkbox, 1407 placeholder parameter, 373, 867 placeholder value, 84 placeholders, 9, 83, 135, 372, 375, 1393 Platform Invocation Services (PInvoke),

303 platform-independent, nature of .NET, 37—

39, 1561—1565 platform-independent .NET development.

See Mono Play( ) method, 313 PLINQ (Parallel Language Integrated

Query), 494, 762, 771—774, 1010 PLINQDataProcessingWithCancellation

application, 771 PLINQDataProcessingWithCancellation

project, 773 plug-ins, Silverlight, 1126 plus (+) operator, 23, 99, 100, 1094 plus token (+), 589 Point class

Page 157: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1667

overloading binary operators, 445, 446, 448

overloading comparison operators, 450 overloading equality operators, 449 overloading unary operators, 448

Point objects, 211, 378, 491 point of no return, 1091 Point structure, 151, 153, 155, 156, 388 Point type, 152, 212, 213, 1143, 1547 Point variable, 152, 153, 211 PointAnimationUsingKeyFrames class,

1304 PointAnimationUsingPath class, 1304 PointColor enum, 212 PointDescription type, 351 PointDescription variable, 351 pointer types

* and & operators, 482 field access with pointers ( -> operator),

484 overview, 479—480 pinning types with fixed keywords, 485—

486 sizeof keyword, 486 stackalloc keyword, 485 unsafe (and safe) swap function, 483 unsafe keyword, 481—482

PointF type, 1547 PointRef class, 155, 156 Points property, 327, 329, 1253 PointyTestClass project, 335 policies, 1021, 1022 Polygon class, 1247, 1253 Polygon object, 1349 Polygon type, 1253, 1254 Polyline class, 1247, 1253, 1261 Polyline type, 1253, 1254 polylines and polygons, 1253—1254 polymorphic behavior, 22 polymorphic fabric, 618 polymorphic interface, 191, 241, 323, 619 polymorphism. See also inheritance

abstract classes, 240 member shadowing, 245—247 override keyword, 236—238

overview, 235 pillar of OOP, 191—192 polymorphic interface, 241—245 virtual keyword, 236—238 virtual members, 238—239

Pop( ) method, 380, 381 pop opcode, 679 PopulateDocument( ) method, 1231 populating controls collection, 1515—1517 populating new DataTables from LINQ

queries, 948—950 Port value, 1031 Portable.NET, 39 <portType> elements, 1034 Position member, Stream class, 793 positional parameters, 134 POST method, 1384, 1391, 1417, 1418, 1420 posting back to Web servers, 1390—1391 precious items, 305 Predicate<T> delegate, 432 Predicate<T> object, 430 PreInit event, 1423, 1450, 1471 pre-JIT, 17 Prepare( ) method, 859 prepared query, 859 PreRender event, 1424 PresentationCore.dll assembly, 1127, 1135,

1157, 1168, 1183, 1271, 1304 PresentationFramework.dll assembly,

1127, 1135, 1146, 1157, 1168, 1180, 1183, 1232, 1247, 1346

Preview suffix, 1339 PreviewKeyDown event, 1341 PreviewMouseDoubleClick event, Control

type, 1133 PreviewMouseDown event, 1339 PrimAndProperCarEvents project, 426,

427, 436 Primary Interop Assemblies (PIAs), 715 primary module, 14 primary namespace, 1157 primary thread, 626 PrimaryKey member, 897 PrimaryKey property, 898 primitive arrays, applying LINQ queries to

Page 158: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1668

extension methods, 500 implicitly typed local variables, 498—500 overview, 496—497 result set, 498 role of deferred execution, 501—502 role of immediate execution, 502—503

primitives activities, WF 4.0, 1091 Primitives area, 1107 Primitives section, 1080 PrintArray( ) method, 142 PrintCustomerOrders( ) method, 985 PrintDataSet( ) method, 898, 900, 906, 915,

916 PrintDocument( ) method, 17 Printer class, 745, 751, 757, 760 Printer instance, 751 Printer object, 751 Printer.PrintNumbers( ) method, 750 printf( ) method, 83 PrintInventory( ) method, 941 PrintMessage( ) method, 657 PrintNumbers( ) method, 745, 751, 752,

754, 760 PrintState( ) method, 168, 169 PrintTable( ) method, 900 PrintTime( ) method, 759 Priority property,

System.Threading.Thread class, 741, 744

PriorityLevel member, ProcessThread type, 633

private assembly, 533, 547 private attribute, 669 private backing field, 207 private data, 152, 195 private fields, 807—808 private key data, 561 private keys, 560 private keyword, 188, 189, 193, 194, 196,

233 private method, 753 private modifier, 192, 194 private .NET assemblies

configuration files and Visual Studio 2010, 556—558

configuring private assemblies, 554—556 identity of private assembly, 553 probing process, 553—554

private object member variable, 753 private points of data, 207 private static object member variable, 754 privatePath attribute, 555, 556 <privatePath> element, 569, 576 Pro WF: Windows Workflow in .NET 4.0,

1077 <probing> element, 555 process identifier (PID), 625, 631 Process type, System.Diagnostics

namespace, 628 ProcessCreditRisk( ) method, 880, 882 processes

interacting with under .NET platform controlling process startup using

ProcessStartInfo class, 636—637 enumerating running processes, 630 investigating process's module set,

634 investigating process's thread set,

631—634 investigating specific process, 631 overview, 627—629 starting and stopping processes

programmatically, 635—636 role of Windows process, 626—627, 652

Processes tab, Windows Task Manager utility, 625

ProcessExit event, AppDomain class, 640 ProcessExit event, AppDomain type, 647 ProcessFiles( ) method, 764, 766 Process.GetProcessById( ) method, 631 Process.GetProcesses( ) method, 630 ProcessIntData( ) method, 773 ProcessManipulator application, 630 ProcessModule type, System.Diagnostic

namespace, 628 ProcessModuleCollection type,

System.Diagnostic namespace, 628

ProcessMultipleExceptions project, 277

Page 159: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1669

ProcessNameproperty,System.Diagnostics.Process class, 629

ProcessorAffinity member, ProcessThread type, 633

ProcessorCount property, 1163 processors, multicore, 727 ProcessStartInfo class, controlling process

startup using, 636—637 ProcessStartInfo type, System.Diagnostic

namespace, 628 ProcessThread type, System.Diagnostic

namespace, 628 ProcessThreadCollection type,

System.Diagnostic namespace, 628

ProductInfo objects, 509 ProductInfo[] parameter, 511, 512, 514 production-ready assemblies, 1562 Profile API

accessing profile data programmatically, 1505—1507

ASPNETDB.mdf database, 1503—1504 defining user profiles within

Web.config, 1504—1505 grouping profile data and persisting

custom objects, 1507—1509 overview, 1502

profile data accessing programmatically, 1505—1507 grouping, 1507—1509

Profile property, 1504, 1506, 1508 <profile> element, 1504 Profile.Address group, 1507 ProfileCommon type, 1508 Program class, 1521—1522 Program type, 107, 155, 660 Program.cs file, 73, 507, 712, 1083, 1086,

1112, 1513 programmatic idiom, 23 programmatically assigning themes, 1469—

1471 programmatically watching files, 801—804 Programmer value, 132 programming languages

.NET-aware, 10—12

comparison of .NET, 6—7 C++/Microsoft Foundation Classes

(MFC), 4 Component Object Model (COM),

5—6 C/Windows application

programming interface (API), 4 Java, 5 overview, 3 Visual Basic 6.0, 4

programming logic, 1147 Project menu, 1018, 1298, 1331, 1538 Project node, 225 Project Properties editor, Visual Studio

2010, 74 Project Properties, viewing with Solution

Explorer Utility, 58 Project Properties window, 58 project templates, 1023—1025, 1071—1073 Project window, 1321 Projects menu option, 1207 Projects tab, 1207, 1357 Project/Solution menu option, 1242 propdp code snippet, 1333, 1334 properties

automatic and default values, 208—210 interacting with, 208 overview, 206—207

custom, 358 custom metadata viewer, 591 defining in CIL, 676 and encapsulation of classes

.NET, 198—200 within class definition, 200—201 internal representation of, 202—203 read-only and write-only, 204—205 static, 205—206 visibility levels of, 204

Properties editor, 543, 565, 940, 1211, 1214, 1218, 1236, 1350, 1360, 1361

Properties icon Solution Explorer, 58, 613 Visual Studio 2010, 79

Page 160: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1670

Properties list box, 1237 Properties node, 543, 562, 919 Properties page, 563 Properties property, 1129, 1139 Properties tab, 1208 Properties window

SharpDevelop, 52 Solution Explorer, 1008 Visual Studio 2010, 849, 966, 1095, 1106,

1250, 1287, 1385, 1386, 1429, 1526 <properties> scope, 1508 .property directive, 676 -Property suffix, 1242 property syntax, automatic, 207 property values, setting, 10 PropertyBuilder ( ) method, 689, 696 PropertyChangedCallback delegate, 1329 PropertyChangedCallback object, 1335 PropertyCollection object, 887 property-element syntax, XAML, 1132,

1161, 1260 <PropertyGroup> element, 1149 PropertyInfo class, System.Reflection

Namespace, 587 PropertyInfo.GetValue( ) method, 617 property/value pairs, 1312 Proposed value, 896, 897 protected field, 231 protected internal modifiers, 193, 194 protected keyword, 189, 193, 194, 204, 230 protected methods, 231 protected modifier, 193, 194 ProtectionLevel property, 1034 <protocolMapping> element, 1051 protocols, stateless, 1380 Provider attribute, 1505 provider value, 849 proxy class, 1018, 1046 proxy code, generating

using svcutil.exe, 1046—1047 using Visual Studio 2010, 1047—1048

PTSalesPerson class, 231, 236, 239 public access modifier, 168 public attribute, 655, 669 public fields, 195, 807—808

public key token, 569, 573 public key value, 532 public keys, 560 public keyword, 20, 125, 152, 193, 194,

1543 public methods, 196, 695, 753 public modifier, 192, 193, 194 public point of data, 199 public properties, 152, 807—808 public read-only field, 195 PublicDelegateProblem project, 419 publicKeyToken attribute, 577 .publickeytoken directive, 542 .publickeytoken instruction, 542 .publickeytoken tag, 569 publicKeyToken values, 566, 577, 599 PublicKeyToken=null convention, 598 public/private key data, 560, 561 publisher policy assemblies, 574—575 <publisherPolicy> element, 575 Push( ) method, 380

■Q Q command, 872, 876 QC (Queued Components), 1016 queries. See also LINQ QueriesTableAdapter class, 943 query expressions, 116, 494, 495 query operators, 494, 495, 518 query pattern implementation, 945 querying

with Entity SQL, 977—978 with LINQ to Entities, 975—977

QueryOverInts( ) method, 501 QueryOverStrings( ) method, 496, 497, 498 QueryString collection, 1476 QueryString property, 1418, 1419, 1420 QueryStringsWithAnonymousMethods( )

method, 520 QueryStringsWithEnumerableAndLambda

s( ) method, 519, 520 QueryStringsWithOperators( ) method,

518, 520

Page 161: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1671

Queue class, 362 Queue<T> class, 377, 382—383 Queue<T> object, 382 Queued Components (QC), 1016 QueueUserWorkItem( ) method, 760

■R radial gradient brush, 1258, 1259 RadialGradientBrush object, 1294 RadialGradientBrush type, 1258, 1293 Radio class, 190, 193, 263 Radio type, 273 RadioButton class, 1218, 1220, 1223 RadioButton control, Ink API tab, 1220—

1222 RadioButton objects, 1249, 1553 radioButtonCircle object, 1553 RadioButtonClicked handler, 1221 RadioButtonClicked( ) method, 1223 radioButtonRect object, 1553 Radio.cs file, 273, 277, 343 RadiusX property, 1250 RadiusY property, 1250 Random member variable, 182 RangeValidator control, 1458 RangeValidator type, 1459 RangeValidator widget, 1460—1461 Rank property, Array class, 143 raw Predicate<T> delegate, 491 RawUrl property, 1418 RCW (Runtime Callable Wrapper), 714, 715 Read( ) member

BinaryReader class, 800 Stream class, 793 TextReader class, 796

ReadAllBytes( ) method, File class, 790 ReadAllLines( )method, File class, 790 ReadAllText( )method, File class, 791 ReadBlock( ) methhod, TextReader class,

797 ReadByte( ) method, FileStream class, 793 ReadByte( ) method, Stream class, 793 reading, from text files, 796—797

reading incoming cookie data, 1499 ReadLine( ) method, TextReader class, 82,

797 readOnly attribute, 1505 read-only fields, constant field data, 215—

216 readonly modifier, 216, 218 ReadOnly property, DataColumn class, 891 ReadToEnd( ) method, TextReader class,

797 ReadXml( ) method, 889, 901 ReadXmlSchema( ) method, 901 ReadXXXX( ) method, BinaryReader class,

800 real types, 1082 Really Simple Syndication (RSS) library,

1024 Reason property, 1098 Receive activity, WF 4.0, 1090 Recent tab, 57, 541 Record Keyframe button, 1360 record mode, 1360 records

deleting, 974—975 updating, 975

Rectangle class, 213, 214, 341, 378, 1247, 1256

Rectangle element, 1192 Rectangle objects, 491, 1248, 1250, 1252 Rectangle type, 157, 455, 456, 457, 458, 459,

1250, 1254, 1547, 1548 Rectangle variable, 157, 213 <Rectangle> element, 1267, 1268 RectangleF type, 1548 RectangleGeometry class, 1255 RectangleGeometry object, 1255 rectangular array, 140, 141 RectMultidimensionalArray( ) method, 141 Redirect( ) method, 1421 redirecting users, 1422—1423 ref arguments, 10, 400 ref keyword, 129, 483 ref modifier, 126, 128—129, 159, 160 ref parameter, 126, 400, 429 Refactor menu, 60, 61, 336

Page 162: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1672

refactoring code, Visual Studio 2010, 60—63 reference count, 292, 293 Reference folder, 568 Reference parameters, 129 reference, passing reference types by, 160 reference types

passing by reference, 160 passing by value, 158—160 vs. value types, 155—156, 161—162 value types containing, 157—158

reference variable, 290 References folder, Solution Explorer, 57,

620, 716 referencing

assemblies, 1414—1415 AutoLotDAL.dll, 1396—1409

reflection obtaining Type reference using

System.Object.GetType( ), 588—589 obtaining Type reference using

System.Type.GetType( ), 589 obtaining Type reference using typeof(

), 589 overview, 586 System.Type class, 587

reflection calls, longhand, 711 ReflectionOnly value, 694 Reflector, exploring assemblies using, 35—

36 reflector.exe file, 36, 498, 581, 658, 755,

1151, 1157, 1290, 1327 ReflectOverQueryResults( ) method, 498 ref/out parameters, 291 RefreshGrid( ) method, 1492 refreshing client proxy, 1056—1057 RefTypeValTypeParams project, 158, 161 Region type, 1548 RegisterWithCarEngine( ) method, 406,

407, 408, 409 registrating events, simplifying using

Visual Studio 2010, 423—424 RegularExpressionValidator control, 1458 RegularExpressionValidator widget, 1459,

1460 RejectChanges( ) method, 889, 893

relational data, 494 Relations property, 887 relationships

class library, 8 has-a, 5, 190, 213, 219, 232 is-a, 189, 190, 219, 220, 228, 248 parent/child, 190

Relative value, 1291 relaxed delegates, 414 Release( ) method, 292 rem opcode, 678 remoting layer, 1016 RemotingFormat member, 897 RemotingFormat property, 888, 902 Remove( ) method, 98, 365, 402, 410, 1000,

1484, 1486, 1496, 1515 Remove Parameters refactoring, 61 remove_ prefix, 421 remove_AboutToBlow( ) method, 421 remove_Exploded( ) method, 421 Remove<T>( ) method, 1000 RemoveAll( ) method, 402, 1484, 1486,

1496 RemoveAt( ) method, 1484, 1515 RemoveFromCollection<T> activity, WF

4.0, 1092 RemoveInventoryRow( ) method, 934 RemoveMemoryPressure( ) method,

System.GC class, 298 removeon directive, 421 RemoveRecord( ) method, 975 removing controls, dynamically, 1435—

1436 Rename option, 1520 Rename refactoring, 61 RenamedEventHandler delegate type, 802 rendering graphical data using GDI+

Graphics type, 1548—1549 invalidating form's client area, 1551 obtaining Graphics object with Paint

event, 1549—1550 overview, 1545—1546 System.Drawing namespace, 1547

rendering graphical output, 1557 RenderingWithShapes application, 1247

Page 163: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1673

RenderingWithShapes project, 1263 RenderingWithVisuals application, 1278 RenderOpen( ) method, 1279 RenderTargetBitmap object, 1279, 1280 RenderTransform object, 1265, 1307 RenderTransform property, 1134, 1248,

1263, 1307 Reorder Parameters refactoring, 61 RepeatBehavior property, 1306, 1308, 1310 RepeatBehavior.Forever method, 1309 Replace( ) method, 98, 99 Request object, 1476 Request property, 1417, 1482 RequestedColor argument, 1105, 1107 RequestedMake argument, 1105, 1107 RequestedMake variable, 1110 request/response cycle, 1380 RequestType property, 1418 RequiredFieldValidator control, 1458 RequiredFieldValidator type, 1459 RequiredFieldValidator widget, 1459—1460 Reset Current Workspace menu option,

1212 Reset( ) method, 344, 348 ResetPoint( ) method, 390 resource system, WPF

binary resources embedding application resources,

1289—1291 loose resources, 1286—1287 overview, 1285 programmatically loading images,

1288—1289 object (logical) resources

{DynamicResource} markup extension, 1295—1296

{StaticResource} markup extension, 1294

application-level resources, 1296—1297

changing after extraction, 1295 extracting in Expression Blend,

1301—1303 merged resource dictionaries,

defining, 1298—1299

resource-only assembly, defining, 1300—1301

Resources property, 1292 window-wide resources, defining,

1292—1294 ResourceDictionary object, 1292 <ResourceDictionary> elements, 1299,

1321 <ResourceDictionary.MergedDictionaries>

scope, 1299 resource-only assembly, defining, 1300—

1301 resources

managed, 311 unmanaged, 289, 303, 305, 311

Resources indexer, 1296 Resources link, 11 Resources property, 1134, 1292, 1295 Resources tab, 1303 Resources view, 1322 Responding property,

System.Diagnostics.Process class, 629

response files, for csc.exe, 47—49 Response property, 1417, 1421, 1482 Response.Cookies property, 1498 Result property, 1095 Results View option, 502 Resume( ) method, 742 ret opcode, 678 retained-mode graphics, 1245 Rethrow activity, WF 4.0, 1092 rethrowing exceptions, 280 return keyword, 75 return values, 871

array as, 142 interfaces as, 333

ReturnType property, 594 Reverse( ) method, 143 Reverse<>( ) method, 509 Reverse<T>( ) method, 514 ReverseDigits( ) method, 461, 462 reversing animation, 1308—1309 RichTextBox control, 1228, 1231, 1234 RichTextBox manager, 1228

Page 164: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1674

Right property, 1527 right-click operation, 1203 Rollback( ) method, 879 ROLLBACK statement, 878 rolled back, 878 Root member, DirectoryInfo class, 779 root namespace, 30 RotateTransform object, 1263, 1264, 1307 RotateTransform type, 1262 RoundButtonStyle, 1354 RoundButtonTemplate, 1350, 1351, 1353 round-trip engineering, 658 RoundTrip example, 666 RountedEventArgs parameter, 1339 routed events, WPF

overview, 1337 routed bubbling events, 1338—1339 routed tunneling events, 1339—1341

RoutedEventArgs class, 1139 RoutedEventHandler delegate, 1139, 1337 routines

creating custom conversion, 455—457 custom conversion, 460 implicit conversion, 458—459

routing strategies, 1337 row filtering, 909 RowBackground property, 1243 <RowDefinition> element, 1191 RowError property, 893 RowFilter property, DataView class, 913 RowNotInTableException exception, 832 rows

deleting from DataTables, 907—908 selecting based on filter criteria, 908—

911 updating within DataTables, 911

Rows category, 1243 Rows collection, 900, 941, 943 Rows indexer, 934 RowState enumeration, 893 RowState property, 893, 894—896, 919 RowState.Added value, 919 RowState.Deleted value, 919 RowState.Modified value, 919 *.rsp file extension, 47, 48, 659

RSS (Really Simple Syndication) library, 1024

rtspecialname attribute, 675 rtspecialname token, 689 RTTI (Runtime Type Identification)

method, 252 Run element, 1227 Run( ) method, 1086, 1128 Run objects, 1231 Run value, 694 RunAndSave value, 694 runat="server" attribute, 1403, 1467, 1477 RunMyApplication( ) method, 286 running processes, enumerating, 630 runtime

activities, WF 4.0, 1091 deploying .NET, 36—37 exceptions, 249

Runtime Callable Wrapper (RCW), 714, 715 runtime engine

Mono, 1577 WF 4.0, 1083—1088

runtime type discovery, 586 Runtime Type Identification (RTTI)

method, 252 <runtime> element, 555 RuntimeBinderException class, 704, 705 rw object, 312 rw2 object, 312

■S S command, 872 safe swap function, 483 SAFEARRAY data type, 6, 7 SAFEARRAY structure, 6 SalesPerson class, 226, 227, 236, 237, 239 SalesPerson constructor, 229 SalesPerson type, 230, 231 SalesPerson.cs file, 227 Samples menu selection, 1275 sane subset, 4 satellite assemblies, 536 Save button, 1235

Page 165: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1675

Save command, WPF, 1204—1206 Save( ) method, 879 save points, 879 Save value, 694 SaveAs( ) method, 1418 SaveChanges( ) method, 958, 959, 974, 990 SaveFileDialog dialog box, 1183 SaveFileDialog type, 1558, 1559 saving, InkCanvas data, 1226—1227 SavingChanges event, 959, 973 SavingsAccount class, 183, 184, 185 SavingsAccount object, 183, 185, 186, 187 SayHello( ) method, 691, 697 sbyte data type, 86 ScaleTransform type, 1262 Scene elements list box, 1237 <Schema> node, 969 scope, 464—465 scope ambiguity, 174, 175 <script> block, 1395, 1403, 1405, 1424,

1429, 1480, 1481 <script> scope, 1409 ScrollableControl class, 1529 ScrollBar object, 1236, 1237, 1238 ScrollBar type, 1240 ScrollBar value, 1240 ScrollBars property, 1007 scrolling, enabling for panels, 1194—1195 ScrollViewer class, 1194 ScrollViewer.xaml file, 1194 SDK (.NET Framework 4.0 Software

Development Kit), 41—42, 67—69 SDK (software development kit), 997, 1015,

1022, 1026, 1042, 1046, 1074, 1395, 1410, 1423

sealed attribute, 669 sealed class, adding, 231—232 sealed keyword, 222—223, 239 Sealed member, 695 sealing, virtual members, 239 Search box, 1297 Search edit box, 68, 69 search editor, 1231 secondary threads

creating programmatically

AutoResetEvent class, 748—749 foreground and background

threads, 749—750 overview, 744 ParameterizedThreadStart delegate,

747 ThreadStart delegate, 745—746

worker threads, 626 Section class, 1230 Section element, 1227 Section type, 1227 SELECT command, 914 Select items, 1213 Select( ) method, 519, 520, 793, 800, 908,

909, 910, 911 Select mode, 1223, 1224 Select Mode! value, 1218 Select New Data Source option, 1451 Select Object editor, 1218, 1219 select operator, 497, 509, 510, 517 SELECT statement, 914, 974, 977 Select statements, 512, 861, 862, 1450 SelectCommand property, 914, 915, 918,

949 SelectedIndex property, 1224 SelectedItem method, 1225 SelectedItem property, 1224 SelectedNodeChanged event, 1447 SelectedShape enumeration, 1554, 1555 SelectedShape property, 1554 SelectedShape type, 1554 SelectedShape value, 1251 SelectedShape.Circle property, 1554 SelectedShape.Rectangle property, 1554 SelectedValue property, 1224 selecting bindings, 1056—1057 Selection button, 1213 selection method, 866 Selection tool, 1222, 1229 SelectionChanged event, 1221, 1319 selectRadio control, 1219 self-describing, 533 semantically related, 33 semantics, 666

Page 166: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1676

Semaphore class, System.Threading namespace, 740

semicolon-delimited list, 46 Send activity, WF 4.0, 1090 SendAndReceiveReply activity, WF 4.0,

1090 SendAPersonByReference( ) method, 160 SendAPersonByValue( ) method, 159, 160 Separator control, 1218 <Separator> element, 1196 Sequence activity, 1089, 1093, 1104, 1106,

1107, 1110, 1111 Sequence node, 1107 sequential attribute, 669 Serializable member, 695 serializable token, 606 serializable types, 807 [Serializable] attribute, 605, 606, 807, 1070,

1502, 1508, 1553, 1558 [Serializable] type, 1503, 1508 serialization. See I/O and object

serialization SerializationFormat.Binary class, 902 SerializationInfo class, 819 Serialize( ) method

BinaryFormatter type, 811, 812 IFormatter interface, 809, 816 SoapFormatter type, 813

serializeAs attribute, 1505 serializing

collections of objects, 816—817 DataTable/DataSet objects as XML,

901—902 DataTable/DataSet objects in binary

format, 902—903 objects using BinaryFormatter type,

811—813 objects using SoapFormatter type, 813 objects using XmlSerializer type, 814—

816 server controls, 1429 Server Explorer, Visual Studio 2010, 955,

1450 Server name text box, 841

Server property, 1417, 1422, 1426, 1481, 1482

servers, 1380—1382 server-side event handling, 1430 Server.Transfer( ) method, 1471 ServerVariables property, 1418 Service assembly, WCF, 1025, 1026 service behavior, 1043 service contracts, 1027 service contracts, implementing, 1073—

1074 Service host, WCF, 1026 Service Library option, WCF, 1025 Service Library Project template, WCF

altering configuration files using SvcConfigEditor.exe, 1059—1061

building simple math services, 1057—1058

testing with WcfTestClient.exe, 1058—1059

Service Library template, Visual Studio 2010, 1023, 1024

Service References folder, 1056 service types, 1027 service types as operational contracts,

1035—1036 Service Website project templates, 1025 <service> element, 1037, 1043, 1055 Service1.cs file, 1058 [ServiceContract] attribute, 1027, 1033,

1034, 1035 ServiceContractAttribute class, 1034 Service.cs file, 1073 serviced component, 1015 ServiceHost class, 1026, 1037, 1038, 1039,

1040, 1041, 1043, 1062, 1063 ServiceHost object, 1051 ServiceHost type, 1026, 1038, 1040—1041 serviceInstaller1 component, 1065 <serviceMetadata> element, 1055 ServiceName property, 1065 service-oriented architecture (SOA) tenets,

1021—1022 serviceProcessInstaller1 component, 1065 ServiceReference namespace, 1048

Page 167: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1677

services exposing using multiple bindings,

1052—1053 invoking asynchronously from clients,

1067—1069 testing, 1075—1076

Services applet, Control Panel, 1500, 1501 services element, 1037, 1043 <service.serviceModel> element, 1040,

1042, 1043 Service.svc file, 1074 session application Graphical User

Interface (GUI), 1495 Session Component Object Model (COM)

object, 1483 session cookie, 1498 session data

maintaining, 1493—1497 storing in ASP.NET session state

servers, 1500—1501 storing in dedicated databases, 1502

session ID, 1494, 1495, 1496 session information, 1495 Session property, 1417, 1482, 1483 session state

handling web application shutdown, 1488

maintaining application-level state data, 1484—1486

modifying application data, 1486—1487 overview, 1483

Session_End( ) event, 1481, 1494, 1496 Session_Error( ) event, 1496 Session_Start( ) method, 1481, 1494, 1495,

1496 SessionID property, HttpSessionState

class, 1496 SessionMode property, 1035 SessionState project, 1494 <sessionState> element, 1427, 1497, 1500—

1502 set block, 204, 1330 Set button, 1474 set directive, 676 set keyword, 204

set method, 195, 196, 198, 202, 676 Set( ) method, 749 Set Primary Key option, 842 set scope, 198, 199 set_ prefix, 202, 676 set_PetName( ) method, 584 set_SocialSecurityNumber( ) method, 203 set_XXX( ) method, 202 SetBinding( ) method, 1241, 1327 SetBindings( ) method, 1241 SetCurrentPay( ) method, 197 SetDriverName( ) method, 174 SetF1CommandBinding( ) method, 1203 SetID( ) method, 197 SetInterestRateObj( ) method, 185 SetLength( ) method, Stream class, 793 SetMathHandler( ) method, 436 SetName( ) method, 196, 197 setter method, 194 Setter objects, 1312, 1313 <Setter> elements, 1317 Setters collection, 1312, 1313 Setters property, 1312 settings, changing for bindings, 1053—1054 setup.exe program, 50 SetupInformation property, AppDomain

class, 639 SetValue( ) method, 1135, 1328, 1330 shadowing, members, 245—247 shallow copy, 349, 350, 351 Shape array, 332, 333 Shape class, 189, 191, 192, 242, 243, 244,

245, 324, 1247, 1253 Shape objects, 333, 1252, 1253 Shape property, 1262 Shape references, 245 Shape types, 330, 1271, 1272 ShapeData type, 1553, 1557 ShapeData.cs file, 1553 ShapeInfo variable, 157 ShapePickerDialog class, 1553—1555 shapes

adding rectangles, ellipses, and lines to canvas, 1249—1252

overview, 1247—1248

Page 168: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1678

paths, 1254—1257 polylines and polygons, 1253—1254 removing rectangles, ellipses, and lines

from canvas, 1252—1253 working with using Expression Blend

brush and transformation editors, 1269—1271

combining shapes, 1268 converting shapes to paths, 1267—

1268 overview, 1266 selecting shape to render from tool

palette, 1266—1267 Shapes application, 242 *.shapes files, 1559 Shapes project, 247 Shapes types, 1253 ShapesLib.cs file, 525 shared assemblies

.NET consuming, 567—569 generating strong names at

command line, 561—563 generating strong names using

Visual Studio 2010, 563—564 installing strongly named

assemblies to GAC, 565—566 overview, 558—559 strong names, 560—561 viewing .NET 4.0 GAC using

Windows Explorer, 566 configuring, 533 reflecting on, 598—600

SharedCarLibClient application, 568, 569 SharedCarLibClient directory, 573 SharedCarLibClient.exe file, 569, 573, 574 SharpDevelop

authoring CIL code using, 665—666 building C# applications with, 50—53

Shift property, 1537 Shift+Click operation, 1220 Shift-Click operation, 1220 ShoppingCart class, 1502 short circuit, 121 short data type, 86, 87, 106, 107, 108

short variables, 106 Show All Files button, 546, 711, 970, 1287 Show button, 1389 Show Errors check box, 1383 Show( ) method, 1137, 1529, 1530, 1532,

1542 Show Table Data option, 842, 882 ShowConnectionStatus( ) method, 856 ShowDialog( ) method, 1137, 1183, 1530,

1542 ShowEnvironmentDetails( ) method, 80 ShowInstructions( ) method, 872, 873 ShowInTaskbar property, 1530, 1538 ShowMessageBox property, 1463 ShowNumberControl.xaml, 1331 ShowSummary property, 1463 Sign the assembly check box, 563 Signing tab, 563 Silverlight plug-ins, 1126 Silverlight, WPF and, 1126 Simple application programming interface

(API) for Extensible Markup Language (XML) (SAX), 993

simple data adapters, 914—915 simple math services, building, 1057—1058 Simple Object Access Protocol (SOAP),

261, 1016, 1019, 1029 Simple Styles.xaml file, 1320, 1321, 1323 SimpleArrays( ) method, 137 SimpleBoxUnboxOperation( ) method, 363 SimpleButton icon, 1322 SimpleCanvas.xaml file, 1187 SimpleClassExample project, 167, 181 SimpleCSharpApp project, 73, 81 SimpleCSharpApp.bat file, 76 SimpleDataSet application, 889, 903 SimpleDataSet project, 891, 902 SimpleDelegate application, 402 SimpleDelegate project, 405 SimpleDispose application, 306 SimpleDispose project, 309 SimpleDockPanel.xaml file, 1193 SimpleException class, 273 SimpleException project, 263 SimpleException.Car class, 268

Page 169: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1679

SimpleFileIO project, 792 SimpleFinalize application, 303 SimpleFinalize project, 305 SimpleGC class, 289 SimpleGC project, 302 SimpleGrid.xaml file, 1191 SimpleIndexer project, 440, 441 SimpleLambdaExpressions project, 435 SimpleMath class, 403, 404, 435, 711 SimpleMultiThreadApp application, 745 SimpleMultiThreadApp project, 747 SimpleSerialize project, 807, 818 SimpleStackPanel.xaml file, 1190 SimpleStateExample project, 1473 SimpleVSWinFormsApp application, 1518 SimpleVSWinFormsApp project, 1533 SimpleWinFormsApp application, 1513 SimpleWinFormsApp project, 1518 SimpleWrapPanel.xaml file, 1188 SimpleXamlApp.csproj file, 1148, 1149 SimpleXamlApp.exe assembly, 1149 single constructor definition, 180 single file Web pages, building

adding data access logic, 1397—1401 ASP.NET control declarations, 1403—

1404 ASP.NET directives, 1401—1403 compilation cycle for single-file pages,

1405—1406 designing UI, 1396—1397 overview, 1395 referencing AutoLotDAL.dll, 1396 "script" block, 1403

single logical parameter, 130 single services, exposing using multiple

bindings, 1052—1053 single-file assemblies

building and consuming, 536—549 building C# client application, 545—

547 building Visual Basic client

application, 547—549 CIL (common intermediate

language), 544 cross-language inheritance, 549

manifest, 541—544 type metadata, 544—545

vs. multi-file assemblies, 14 single-file page model, 1395 single-file pages, compilation cycle for,

1405—1406 single-threaded apartment, 1522 single-threaded process, 626 *.sitemap file, 1445 SiteMap icon, 1447 SiteMapDataSource class, 1447 SiteMapDataSource component, 1446,

1447 SiteMapDataSource instance, 1446 <siteMapNode> elements, 1446 SiteMapPath control, 1439, 1445 SiteMapPath type, establishing bread

crumbs with, 1447 SiteMapPath widget, 1447 sitewide themes, applying, 1468 Size property, 868 Size type, 1548 SizeF type, 1548 sizeof keyword, 486 SkewTransform type, 1262 <SkewTransform> element, 1263 *.skin files, 1466—1468 SkinID property, 1432, 1469 slash symbol, 44 Sleep( ) method, System.Threading.Thread

Class, 741 slider bar, 1231 *.sln file, 55 SlowDown( ) method, 465 slugbug.jpg file, 1448 smart tag, 335 SMEs (subject matter experts), 1078 sn command-line utility, Mono, 1571, 1574 Snap In Module menu, 621, 622 sn.exe utility, 560, 561, 1571 Snippets group, 63 *.snk file, 563, 564, 664 SOA (service-oriented architecture) tenets,

1021—1022

Page 170: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1680

SOAP (Simple Object Access Protocol), 261, 1016, 1019, 1029

Soap/Binary serialization processes, customizing

overview, 818—819 using attributes, 823 using ISerializable interface, 820—822

SoapFormatter class, 807, 808 SoapFormatter type, 809, 810, 813 SocialSecurityNumber property, 203, 204,

229, 256 sockets, 1019 software development kit (SDK), 997, 1015,

1022, 1026, 1042, 1046, 1074, 1395, 1410, 1423

SolidBrush type, 1547 SolidColorBrush type, 1258 Solution Explorer Utility, Visual Studio

2010, 56—58 Solution Explorer window, 224, 225, 1520 Solution menu option, 51 Song objects, 313, 315 Sort( ) methods, 143, 355, 358, 374 sort types, custom, 358 Sort<T>( ) method, 374 SortByPetName property, 358 SortedDictionary<TKey, TValue> class, 377 SortedList class, 362 SortedSet<T> class, 377, 383—385 SortedSet<T> type, 376 sorting enabling, 1453 Source button, SharpDevelop, 52 Source Code/Downloads area, Apress web

site, 55 source files, compiling multiple with

csc.exe, 46—47 Source property, 263, 1275, 1279, 1286,

1289, 1358 Source value, 1278 space-sensitive, 1301 spaghetti code, 4 Span class, 1230 Span element, 1227 Span type, 1227 specialname attribute, 675, 676

specialname token, 689 specifying base addresses, 1038—1040 Speed property, 220, 221, 506 SpeedRatio property, Timeline class, 1305 SpeedUp( ) method, 168, 169 spell checking logic, building window

frame using nested panels, 1200 SpellCheck.IsEnabled property, 1200 Spelling Hints menu item, 1197 SpellingError object, 1200 Spin( ) method, 1358, 1359, 1364 SpinControl objects

designing, 1358 renaming, 1357—1358

SpinControl_Loaded method, 1359 SpinControl.xaml file, 1357 SpinImageStoryboard, 1360, 1361 SpinningButtonAnimationApp

application, 1306 SpinningButtonAnimationApp project,

1309 Split( ) method, String system type, 98 splitters, 1192 SportsCar class, 13, 66, 67, 194, 414, 532,

544 SportsCar icon, 66 SQL (Structured Query Language), 908,

910, 912, 914, 915, 918, 919, 922, 945, 1394

SQL queries, 490 SQL Server 2010 database, 1503 SQL Server 7.0, 1503 SQL Server database, 1502 SQL Server Express, 53 SQL Server Management Tool, 840 SQL statement, 865 SQL# tool, Mono, 1571, 1572 SqlCommand class, 918 SqlCommand objects, 882, 918, 937 SqlCommand type, 858 SqlCommandBuilder class, using to

configure data adapters, 918—919 SqlConnection class, 828 SqlConnection object, 321, 863 sqlConnectionString attribute, 1502

Page 171: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1681

SqlConnectionStringBuilder ( ) method, 857

SqlDataAdapter class, 913, 914, 918, 922 SqlDataAdapter object, 919 SqlDataAdapter parameter, 917 SqlDataAdapter variable, 917 SqlDataReader class, 828, 957 SqlDataSource class, 1450, 1451, 1454 SqlDataSource component, 1450, 1451,

1452 SqlDataSource type, 1451 SqlParameter class, 918 SqlParameter objects, 918, 937 SqlParameter type, 869 SqlProfileProvider type, 1504 SqlTransaction data provider, 878 SqlTransaction object, 879, 882 SqlTransaction type, 879 square brackets, 620 Square class, 342, 525 Square type, 455, 456, 457, 458, 459 SquareIntPointer( ) method, 482 SquareNumber( ) method, 403 st (store) prefix, 679 stack, 154 Stack class, 362 Stack<T> class, 377, 380—381, 656 stackalloc keyword, 485 stackalloc pointer-centric ketword, 479 stack-allocated integer, 366 stack-based data, 366 StackOverflowException class, 272 StackPanel class, 1138, 1160, 1216, 1222,

1225, 1228 StackPanel control, 1341 StackPanel layout manger, 1332 StackPanel node, 1217 StackPanel objects, 1371 StackPanel panels, 1190—1191 <StackPanel> elements, 1225 <StackPanel> tag, 1132 <StackPanel> type, 1174, 1176, 1181, 1198,

1239, 1253, 1293 stackTemplatePanel, 1345 StackTrace documents, 269

StackTrace property, 81, 263, 267, 268—269 Standard area, Toolbox, 1439 StarButton control, 1341, 1367—1368, 1371 starg opcode, 679 Start Debugging menu selection, Debug

menu, 284 Start icon, 1094 Start( ) method, 629, 635, 742, 745 StartAddress member, ProcessThread

type, 633 StartAndKillProcess( ) method, 635, 637 StartNew( ) method, 766 StartPosition property, 1530, 1538 StartTime member, ProcessThread type,

633 StartTime property,

System.Diagnostics.Process class, 629

StartType property, 1065 Startup event, 1128, 1129, 1130, 1136, 1137,

1139, 1140, 1145 Startup Object dropdown list box, Visual

Studio 2010, 74 StartupEventArgs class, 1137, 1140 StartupEventHandler delegate, 1137 StartupUri property, 1129, 1153 StartupUrl property, 1147 state data, maintaining, 1484—1486 state management techniques. See

ASP.NET state management techniques

state of exceptions, configuring Data property, 270—272 HelpLink property, 269—270 overview, 267 StackTrace property, 268—269 TargetSite property, 268

State property, 855, 856, 1041 StateBag type, 1478 stateConnectionString attribute, 1501 stateless protocols, 1380 stateless wire protocol, 1473 States tab, 1367 [STAThread] attribute, 1136, 1522 static assemblies, 688

Page 172: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1682

static attribute, 674 static class, defining extension methods,

461 static constructor, 186, 187, 216 static data, 182, 184 static keyword

classes, 187—188 constructors, 185—187 field data, 182—185 methods, 181—182

static members, 176, 181, 182, 187, 738 static methods, 182, 404 static read-only fields, constant field data,

216 statically invoking extension methods, 464 statically typed, 703 StaticData project, 182, 188 StaticMethods application, 182 StatusBar, building window frame using

nested panels, 1198 StatusBar widget, 322 StatusCode property, 1421 StatusDescription property, 1421 stfld opcode, 685 Sticky Notes API, 1228 sticky notes, Documents tab, 1232—1234 stloc opcode, 679 stloc.0 opcode, 293, 657 stobj opcode, 679 Stop( ) method, 313 storage, for enum type, 145—146 store (st) prefix, 679 Stored Procedure Name dropdown box,

981 stored procedures, invoking using

generated codes, 943 Stored Procedures node, 843 storing session data

in ASP.NET session state servers, 1500—1501

in dedicated databases, 1502 <Storyboard> element, 1310, 1362 storyboards

authoring animation in XAML, 1310 programmatically starting, 1363—1364

Storyboard.TargetName value, 1312 Storyboard.TargetProperty value, 1312 stream wrappers, 793 Stream-derived type, 1175 StreamingContext type, 821 streamlined syntax, 210 StreamReader class, 776 StreamReader type, 789 StreamReaders class

directly creating types, 797—798 overview, 794 reading from text files, 796—797 writing to text files, 795—796

streams, I/O manipulation, 792 StreamWriter class, 776 StreamWriter object, 789 StreamWriter type, 795 StreamWriterReaderApp project, 798 StreamWriters class

directly creating types, 797—798 overview, 794 reading from text files, 796—797 writing to text files, 795—796

Stretch property, Shape class, 1249, 1358 string argument, 132, 1084 string array, 78, 98, 496, 769 String class, 104, 223, 256 string concatenation technique, 23, 99 string data

basic manipulation, 98—99 concatenation, 99—100 escape characters, 100—101 overview, 97 parsing values from, 94 strings and equality, 102 strings are immutable, 102—104 System.Text.StringBuilder type, 104—

105 verbatim strings, 101—102

string field, 66 string keyword, 68, 93 string literals, documenting, 586 String Member variable, emitting, 695—696 string objects, 86, 102, 103, 104, 394, 498,

513, 1099

Page 173: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1683

string parameter, 229, 589 string types, 75, 103, 104, 133, 394, 865,

1099, 1105 string values, 441—442, 1095, 1100 string variables, 98, 99, 129, 255, 768, 1095,

1339 string[] args array, 75 string[] type, 1098 StringAnimationUsingKeyFrames class,

1304, 1312 <StringAnimationUsingKeyFrames>

element, 1312 StringAnimation.xaml file, 1311 stringArray variable, 138 StringBuilder object, 105 StringCollection type, 363 String.Concat( ) method, 99, 100 StringDictionary type, 363 string.Format( ) method, 85, 86 StringFormat type, 1548 stringified format, 589 StringIndexer project, 442 String.Length property, 120 StringReaders class, 776, 798—799 StringReaderWriterApp project, 799 strings array, 76 StringsAreImmutable( ) method, 103 StringTarget( ) method, 416 StringWriters class, 798—799 stroke, 1223 Stroke property, 1249, 1273, 1365 Stroke value, 1273 StrokeCollection object, 1223 StrokeDashArray property, Shape class,

1249 StrokeEndLineCap property, Shape class,

1249 Strokes property, 1223 StrokeThickness property, 1249, 1262, 1368 StrokeThickness value, 1273 [Strong Name Key] file extension, 560 strong names

generating at command line, 561—563 generating using Visual Studio 2010,

563—564

installing strongly named assemblies to GAC, 565—566

overview, 560—561 strongly typed

database code, isolating into class libraries

adapters for, 936—937 deleting data with generated codes,

942—943 inserting data with generated codes,

941—942 invoking stored procedure using

generated codes, 943 overview, 938 selecting data with generated codes,

940—941 viewing generated codes, 939—940

DataRows, 935 DataSets, 932—934 DataTables, 934 exceptions, 273 object model, 943

StronglyTypedDataSetConsoleClient application, 940

StronglyTypedDataSetConsoleClient project, 943

struct keyword, 20, 151 StructuralObject.SetValidValue( ) method,

971 structure types

Common Type System (CTS), 20 creating variables, 152—153 overview, 151

structure variable, 154 structured exception handling

.NET, 260—262 application-level exceptions

(System.ApplicationException), 273—276

configuring state of Data property, 270—272 HelpLink property, 269—270 overview, 267 StackTrace property, 268—269 TargetSite property, 268

Page 174: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1684

corrupted state exceptions (CSE), 285 example of, 263—267 multiple exceptions

finally blocks, 282 general catch statements, 279—280 inner exceptions, 281 overview, 277—278 rethrowing, 280

overview, 259 system-level exceptions

(System.SystemException), 272 throws, identifying, 282—283 unhandled exceptions, result of, 283 Visual Studio debugger, 284—285

Structured Query Language (SQL), 908, 910, 912, 914, 915, 918, 919, 922, 945, 1394

structures defining in CIL, 670—671 generic, specifying type parameters for,

372—374 stsfld opcode, 679 stub code, 424, 1205 Style class, 1312 style inheritance, 1312 Style object, 1313, 1317 Style property, 1313, 1314, 1316, 1317, 1355 Style resource, 1316 style sheets, 1465 styles, WPF

animated, 1318 applying, 1313—1314 assigning programmatically, 1319—1320 defining

with multiple triggers, 1317 overview, 1313—1314 with triggers, 1317

generating with Expression Blend, 1320—1324

incorporating control templates into styles, 1354—1355

overriding settings, 1314 overview, 1312 subclassing existing, 1315 unnamed, 1316

sub opcode, 678, 680 subclassing existing WPF styles, 1315 subdirectories, creating with DirectoryInfo

type, 781—782 subject matter experts (SMEs), 1078 submit button, 1390, 1391, 1461 subset data type, 116 subset variable, 497, 498, 502 .subsystem directive, 668 Subtract( ) method, 394, 404, 470 Suggestions property, 1200 Sum( ) method, 516 Sum<>( ) method, 509 summaries, creating, 1462—1463 summary pane, 1462 Summary window, 223 Sun Microsystems, 1562 SuppressContent property, 1421 SuppressFinalize( ) method, System.GC

class, 298 Surround With group, 63 Surround With menu, 64 SuSe Linux, 1580 Suspend( ) method, 742 *.svc files, 1074 SvcConfigEditor.exe, altering

configuration files using, 1059—1061

svcutil.exe file, generating proxy code using, 1046—1047

Swap( ) method, 385, 394, 483 Swap Panes button, 1170 Swap<T>( ) method, 386, 387, 388, 394 SwapStrings( ) method, 129 Switch activity, 1107—1108 switch construct, 390 Switch editor, 1108 switch keyword, 122 switch opcode, 678 switch statement, 119, 121—123, 872 Switch<T> activity, WF 4.0, 1089, 1107 SyncDelegateReview program, 730 SyncDelegateReview project, 731 synchronization

thread synchronization, 729

Page 175: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1685

using [Synchronization] attribute, 757—758

using C# lock keyword, 753—754 using System.Threading.Interlocked

type, 756—757 using System.Threading.Monitor type,

755—756 [Synchronization] attribute, 649, 729, 757—

758 synchronous blocking manner, 1084 synchronous call, 734 synchronous manner, 730 synchronously method, 398 syntactic constructs, C#, 8 syntax, 666 syntax folding, 49 system data types

class hierarchy, 90—92 enum type

declaring variables, 146—147 discovering name/value pairs of,

148—150 overview, 144 System.Enum type, 147 underlying storage for, 145—146

and new operator, 89—90 nullable types

?? operator, 164—165 overview, 162 working with, 163—164

numerical data types, 92 overview, 86 parsing values from string data, 94 reference types

passing by reference, 160 passing by value, 158—160

structure type, 151—153 System.Boolean, 93 System.Char, 93—94 System.DateTime, 95 System.Enum type, 147 System.Numerics, 95—97 System.Text.StringBuilder, 104—105 System.TimeSpan, 95 value types

containing reference types, 157—158 overview, 154 vs. references types, 155—156, 161—

162 variable declaration, 88—89

System. Messaging namespace, 1031 System namespace, 23, 29, 73, 86, 95, 149,

223, 314, 517, 732 system types, class hierarchy of, 91 System. ValueType class, 161 System. Web.UI.TemplateControl class,

1416 System.Activator class, 601—602 System.Activities namespace, 1083 System.Activities.Activity object, 1082 System.Activities.dll assembly, 1088, 1112 System.Activities.Statements namespace,

1088 System.AppDomain class, 638—639 System.AppDomain type, 692 System.ApplicationException

(application-level exceptions), 273—276

System.ApplicationException class, 276 System.Array class, 142—144, 148, 355, 361,

500, 501, 507, 758 System.Array method, 144 System.Array namespace, 494 System.Array object, 513 System.Array type, 344, 496 System.AsyncCallback argument, 732 System.Attribute class, 604, 609, 610 System.Boolean class, 674 System.Boolean data type, 23, 162 System.Boolean parameters, 399 System.Boolean structure, 89 System.Boolean system type, 86, 113 System.Boolean type, 93, 1164 SystemBrushes type, 1547 System.Byte class, 673 System.Byte data type, 22 System.Byte system type, 86, 109, 147 System.Char class, 673 System.Char data type, 23 System.Char system type, 87, 93—94

Page 176: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1686

System.Collections class, 363, 507 System.Collections namespace, 270, 271,

344, 357, 358, 361, 363, 368, 507 System.Collections.ArrayList variable, 365,

368 System.Collections.Generic namespace

collection initialization syntax, 378 List<T> class, 379—380 overview, 376—377 Queue<T> class, 382—383 SortedSet<T> class, 383—385 Stack<T> class, 380—381

System.Collections.Hashtable class, 255 System.Collections.IEnumerator interface,

344 System.Collections.Specialized class, 363 SystemColors type, 1547 System.ComponentModel.CancelEventArg

s class, 1141 System.ComponentModel.Component

class, 1525 System.Configuration namespace, 577,

578, 839, 849, 923 System.Configuration.AppSettingsReader

type, 578 System.Configuration.dll assembly, 839,

849, 871, 923 System.Console class

basic input and output with, 82—83 formatting numerical data, 84—86 formatting output, 83 overview, 81

System.Console namespace, 30 System.Console type, 45 System.Console.WriteLine( ) method, 657 System.ContextBoundObject base class,

649 System.Convert class, 112 System.Core.dll assembly, 377, 495, 498,

517, 709 System.Data namespace, types

IDataReader and IDataRecord interfaces, 836

IDbCommand interface, 834 IDbConnection interface, 833

IDbDataAdapter and IDataAdapter interfaces, 835

IDbDataParameter and IDataParameter interfaces, 834—835

IDbTransaction interface, 834 overview, 832

System.Data .NET namespace, 29 System.Data.Common class, 838 System.Data.Common namespace, 827,

831, 847, 848, 849, 851, 916 System.Data.Common .NET namespace,

29 System.Data.Common.DataTableMapping

class, 916 System.Data.Common.DbProviderFactory

class, 848 System.Data.DataSetExtensions .NET

namespace, 29 System.Data.DataSetExtensions.dll

assembly, 495, 945, 946, 1105 System.Data.DataTable object, 866, 1107 System.Data.dll assembly, 494, 826, 829 System.Data.EntityClient namespace, 957,

978 System.Data.EntityClient .NET

namespace, 29 System.Data.Entity.dll assembly, 955, 956,

984, 986, 1105, 1242 System.Data.Objects namespace, 958, 986 System.Data.Objects.ObjectSet<T> class,

959 System.Data.Odbc namespace, 829, 830 System.Data.OleDb data provider, 850 System.Data.OleDb namespace, 829, 830 System.Data.OleDb types, 851 System.Data.OracleClient.dll library, 830—

831, 1415 System.Data.Sql namespace, 831 System.Data.SqlClient class, 838 System.Data.SqlClient namespace, 829,

830, 853, 914, 917, 922 System.Data.SqlClient .NET namespace,

29 System.Data.SqlClient type, 863

Page 177: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1687

System.Data.SqlClientCe namespace, 830 System.Data.SqlClient.dll assembly, 494,

831 System.Data.SqlServerCe namespace, 829 System.Data.SqlServerCe.dll assembly, 829 System.Data.SqlTypes namespace, 831 System.DateTime type, 95 System.Decimal data type, 23 System.Decimal system type, 87 System.Delegate class, 91, 398, 401, 402,

729 System.Diagnostics namespace, members

of, 627 System.Diagnostics.Process class, 628 System.Diagnostics.Process.ExitCode

property, 76 SystemDirectory property,

System.Environment class, 81 System.dll assembly, 363, 376, 377, 379 System.Double class, 673 System.Double data type, 23 System.Double system type, 87, 92 System.Drawing namespace, 31, 1546,

1547, 1553 System.Drawing .NET namespace, 29 System.Drawing.* assembly, 1128 System.Drawing.Bitmap class, 32 System.Drawing.Color variable, 1555 System.Drawing.dll assembly, 32, 533,

1117, 1118, 1511, 1513, 1545, 1546 System.Drawing.Drawing2D namespace,

1546, 1550 System.Drawing.Graphics class, 1548 System.Drawing.Imaging namespace, 1546 System.Drawing.Printing namespace, 272,

1546 System.Drawing.Text namespace, 1546 System.Dynamic namespace, 709 System.EnterpriseServices namespace,

878, 1015, 1016, 1022 System.Enum class, 21, 147, 148, 671 System.Enum.Format( ) method, 148 System.Environment class, 79—81, 1098,

1163 System.EventArgs argument, 1517

System.EventArgs class, 424, 1403, 1517—1518

System.EventArgs parameter, 1517 System.EventArgs type, 1517 System.EventHandler class, 1402, 1517—

1518 System.EventHandler delegate, 1141, 1398,

1403, 1424, 1516 System.Exception catch block, 286 System.Exception class, 91, 261—262, 265,

270, 272, 273, 274, 278, 279 System.Exception object, 266, 267, 269,

1426 System.Exception.Message property, 269,

275 System.Exception.StackTrace property,

268 System.Exception.TargetSite property, 268 System.Func<> delegate, 315, 316 System.Func<T> delegate, 763 System.Func<T1, TResult> delegate

parameter, 519 System.GC class, 289 System.GC type, 298—302 System.Guid class, 95, 889 System.IAsyncResult interface, 732—733 System.IComparable interface, 354 SystemIcons type, 1547 System.IdentityModel.dll assembly, 1023 System.Int16 class, 673 System.Int16 data type, 22 System.Int16 system type, 86 System.Int32 class, 366, 369, 673 System.Int32 data type, 22, 28 System.Int32 system type, 86, 92, 107, 113,

145, 155 System.Int32 variable, 680 System.Int32.ToString( ) method, 686 System.Int64 class, 673 System.Int64 data type, 22 System.Int64 system type, 87 System.IntPtr type, 674 System.IO namespace, 27, 272, 281, 775—

776, 902, 1206, 1226 System.IO .NET namespace, 29

Page 178: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1688

System.IO, System.Data namespace, 30 System.IO.Compression .NET namespace,

29 System.IO.FileStream class, 307 System.IO.Pipes namespace, 1019 System.IO.Ports .NET namespace, 29 System.Lazy<> class, 289, 316 system-level exceptions

(System.SystemException), 272 System.Linq namespace, 495, 771 System.Linq .NET namespace, 29 System.Linq.Enumerable class, 492, 493,

500, 501, 509, 518 System.Linq.Enumerable type, 521 System.MarshalByRefObject class, 1525 System.Messaging namespace, 1015, 1022 System.MulticastDelegate class, 398, 400,

401, 729 System.MulticastDelegate delegate, 21 System.Net class, 768 System.Net namespace, 768 System.Net.PeerToPeer namespace, 1019 System.Net.Sockets namespace, 1019 System.NotImplementedException, 336 System.Nullable<T> structure type, 163 System.Numerics type, 95—97 System.Numerics.dll assembly, 96 System.Object argument, 424, 732, 1517 System.Object class

overriding system.Object.Equals( ), 254—255

overriding System.Object.GetHashCode( ), 255—256

overriding system.Object.ToString( ), 254

overview, 250—253 static members of, 257—258 static members of System.Object class,

257—258 testing modified person class, 256

System.Object collections, 10 System.Object data type, 23 System.Object parameter, 747, 758, 759,

1517, 1534, 1549

System.Object reference, 602 System.Object system type, 91 System.Object types, 368, 602, 1292, 1479,

1485, 1489, 1494 System.Object variables, 364, 366, 680, 722 system.Object.Equals( ) method, 254—255 System.Object.Finalize( ) method, 161,

289, 303—304, 306, 309 System.Object.GetHashCode( ) method,

255—256 System.Object.GetType( ) method, 140,

588—589 System.Objects array, 361 System.Objects class, 363, 366, 367, 508 system.Object.ToString( ) method, 254 System.OperatingSystem, System.String,

323 System.OverflowException exception, 109 SystemPens type, 1547 System.Predicate<T> delegate, 430 System.Predicate<T> type, 430 System.Random member variable, 182 System.Reflection namespace, 68, 494,

587, 590, 595, 599, 600, 601, 621, 691

System.Reflection .NET namespace, 29 System.Reflection object model, 595 System.Reflection, System.Xml

namespace, 1346 System.Reflection.Assembly class, 554 System.Reflection.Emit namespace, 654,

688, 689—690, 691 System.Reflection.Emit .NET namespace,

29 System.Reflection.Emit.ILGenerator, 690—

691 System.Reflection.Emit.OpCodes class,

691 System.Reflection.MethodBase object, 268 System.Reflection.MethodInfo objects,

401, 590 System.Reflection.TypeAttributes enum,

695 System.Runtime.ExceptionServices

namespace, 285, 286, 287

Page 179: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1689

System.Runtime.InteropServices namespace, 718

System.Runtime.InteropServices .NET namespace, 29

System.Runtime.InteropServices.Marshal type, 303

System.Runtime.Remoting namespace, 1016, 1022

System.Runtime.Remoting.Contexts namespace., 757

System.Runtime.Remoting.Contexts.Context object, 728

System.Runtime.Remoting.Messaging namespace, 738

System.Runtime.Serialization namespace, 818, 823, 1023, 1027

System.Runtime.Serialization.dll assembly, 1022, 1023, 1027

System.Runtime.Serialization.Formatters.Binary and System.IO namespace, 1558

System.Runtime.Serialization.Formatters.Binary class, 529

System.Runtime.Serialization.Formatters.Binary namespace, 902

System.SByte class, 673 System.SByte data type, 22 System.SByte system type, 86 System.Security .NET namespace, 30 System.Serializable attribute, 276 System.ServiceModel namespace, 1020,

1023, 1027, 1029, 1032, 1036 System.ServiceModel .NET namespace, 29 <system.serviceModel> element, 1037,

1038, 1042 System.ServiceModel.Activities.dll

assembly, 1090 System.ServiceModel.ClientBase<T> class,

1046 System.ServiceModel.Configuration

namespace, 1023 System.ServiceModel.Description

namespace, 1023 System.ServiceModel.dll assembly, 1022,

1023, 1032, 1036, 1037, 1047, 1062

System.ServiceModel.MsmqIntegration namespace, 1023

System.ServiceModel.Security namespace, 1023

System.Single class, 673 System.Single data type, 23 System.Single system type, 87 System.String class, 73, 91, 104, 497, 674 System.String data type, 23, 28, 1479, 1504 System.String instance, 102 System.String system type, 87, 93, 97, 98,

102, 113, 1175 System.String variable, 680 System.String.Format( ) method, 686 System.Structure class, 154 system-supplied collection, 118 System.SystemException (system-level

exceptions), 272 System.SystemException class, 273 System.Text namespace, 104 System.Text.RegularExpressions

namespace, 1460 System.Text.StringBuilder class, 73 System.Text.StringBuilder type, 104—105 System.Threading class, 758, 762, 768 System.Threading namespace, 739—740,

745, 747, 749, 753, 756, 760, 761, 765

System.Threading .NET namespace, 30 System.Threading.Interlocked type, 756—

757 System.Threading.Monitor class, 755, 756 System.Threading.Monitor type, 755—756 System.Threading.Tasks class, 761, 762 System.Threading.Tasks namespace, 762,

765, 768, 771, 774 System.Threading.Tasks .NET namespace,

30 System.Threading.Tasks.Parallel class, 763 System.Threading.Thread class

Name property, 743 obtaining statistics about current

thread, 742 overview, 741 Priority property, 744

Page 180: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1690

System.Threading.ThreadPriority enumeration, 744

System.Threading.Thread.txt, 1577 System.Threading.Timer class, 758 System.TimeSpan type, 95 System.Transactions namespace, 878 System.Type class, 91, 147, 587, 595, 1158 System.Type parameter, 590, 623 System.Type.GetType( ) method, 589 System.UInt16 class, 673 System.UInt16 data type, 23 System.UInt16 system type, 86 System.UInt32 class, 673 System.UInt32 data type, 23 System.UInt32 system type, 86 System.UInt64 class, 673 System.UInt64 data type, 23 System.UInt64 system type, 87 System.UIntPtr type, 674 System.Uri class, 1027, 1031, 1038, 1043 System.Uri object, 1288 System.ValueType class, 91, 92, 154, 161,

670, 671 System.Void class, 95, 674 System.Web namespace, 33, 1481 System.Web .NET namespace, 29 <system.web> element, 1504 <system.web> root element, 1468 System.Web.Caching.Cache class, 1489 System.Web.Caching.Cache object, 1488 System.Web.dll library, 1404, 1416 System.Web.HttpApplication class, 1481,

1482 System.Web.HttpCookie class, 1498 System.Web.RegularExpressions

namespace, 1460 System.Web.Services namespace, 1016,

1022 System.Web.UI.Control class, 1423, 1430,

1432, 1478 System.Web.UI.HtmlControls class, 1440—

1441 System.Web.UI.LiteralControl, 1435 System.Web.UI.Page class, 1402, 1405,

1409, 1410, 1411, 1416, 1423, 1476

System.Web.UI.Page type, 1482, 1489 System.Web.UI.Page.Request property,

1417 System.Web.UI.StateBag type, 1478, 1479 System.Web.UI.WebControls namespace,

1404, 1429, 1430, 1440, 1441 System.Web.UI.WebControls.BaseValidato

r class, 1458 System.Web.UI.WebControls.WebControl

class, 1430, 1465 System.Windows namespace, 29, 33, 1127,

1128, 1137, 1156, 1280, 1342 System.Windows .NET namespace, 29 System.Windows.Annotations namespace,

1232 System.Windows.Application class, 1128,

1136 System.Windows.Controls namespace,

1127, 1138, 1157, 1180, 1183, 1185, 1430

System.Windows.Controls .NET namespace, 29

System.Windows.Controls.Button type, 1150

System.Windows.Controls.ContentControl class, 1131—1132

System.Windows.Controls.Control class, 1132

System.Windows.Data namespace, 1127, 1157, 1240

System.Windows.DependencyObject class, 1135, 1330

System.Windows.Documents namespace, 1127, 1183, 1227

System.Windows.Documents.Block class, 1227

System.Windows.Documents.Inline class, 1227

System.Windows.Forms namespace, 33, 45, 322, 571, 746, 1008, 1430, 1512

System.Windows.Forms .NET namespace, 29

System.Windows.Forms.* assembly, 1128 System.Windows.Forms.ColorDialog type,

1556

Page 181: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1691

System.Windows.Forms.ContainerControl class, 1526

System.Windows.Forms.Control class, 322, 1515, 1526

System.Windows.Forms.DataVisualization.Charting namespace, 1511

System.Windows.Forms.DataVisualization.dll, 1511

System.Windows.Forms.dll assembly, 45, 46, 48, 533, 540, 542, 558, 599, 662, 746

System.Windows.Forms.Form class, 1513, 1526, 1543

System.Windows.Forms.MessageBox class, 45, 585

System.Windows.Forms.MessageBox.Show( ) method, 662

System.Windows.Forms.MouseEventHandler delegate, 1534

System.Windows.Forms.ScrollableControl class, 1526

System.Windows.FrameworkElement, 1133

System.Windows.Ink namespace, 1128, 1157, 1183, 1226

System.Windows.Input namespace, 1280 System.Windows.Input.KeyEventHandler

delegate, 1143 System.Windows.Input.MouseEventArgs

class, 1142 System.Windows.Input.MouseEventHandl

er delegate, 1142 System.Windows.Markup namespace,

1128, 1151, 1157, 1173, 1235, 1346 System.Windows.Media namespace, 1128,

1157, 1252, 1280, 1343 System.Windows.Media.Animation

namespace, 1304, 1364 System.Windows.Media.Animation.Timeli

ne class, 1305 System.Windows.Media.Brush, 1257 System.Windows.Media.ColorConverter

class, 1260 System.Windows.Media.Drawing class,

1246, 1271

System.Windows.Media.Geometry class, 1254

System.Windows.Media.Imaging namespace, 1279, 1280, 1288

System.Windows.Media.Stretch enumeration, 1249

System.Windows.Media.Transform class, 1262

System.Windows.Media.Visual class, 1134, 1135, 1246, 1277

System.Windows.Navigation namespace, 1128, 1157

System.Windows.RoutedEventArgs parameter, 1337

System.Windows.Shapes namespace, 1128, 1246, 1247, 1248, 1253, 1256, 1270

System.Windows.Shapes .NET namespace, 29

System.Windows.Style class, 1312 System.Windows.Threading.DispatcherOb

ject, 1135 System.Windows.UIElement, 1134 System.Windows.Window class, 1130,

1146, 1175 System.Workflow.Activities .NET

namespace, 30 System.Workflow.Runtime .NET

namespace, 30 System.Xaml.dll assembly, 1127, 1135 System.Xml DOM model, 995 System.Xml namespace, 993 System.Xml namespaces, 494 System.Xml .NET namespace, 30 System.Xml.dll assembly, 494, 993, 995,

996, 1011 System.Xml.Linq class, 995, 1000 System.Xml.Linq namespaces

LINQ to XML axis methods, 1000—1001 overview, 997—999 XName (and XNamespace) class, 1001—

1002 System.Xml.Linq .NET namespace, 29 System.Xml.Linq, System.Xml.Schema

namespace, 997

Page 182: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1692

System.Xml.Linq.dll assembly, 495, 997, 998, 1011

System.Xml.Serialization namespace, 815 System.Xml.XPath namespace, 997

■T t variable, 703 Tab key, 63, 423, 424 tab order, configuring, 1540 Tab Order Wizard, 1540—1541 TabControl control, 1213—1215, 1227 TabIndex property, 1133, 1438, 1527, 1540 TabIndex value, 1540 tabInk object, 1222 TabItem control, 1214, 1216, 1228 Table class, 1230 Table element, 1227 Table property, 891, 893 table relationships

in AutoLot database, visually creating, 846—847

building, 924 Table type, 1227 TableAdapter class, 931 TableMappings property, 835, 916 TableName member, 897 TableName property, 915 Tables collection, 898, 934, 943 tables, navigating between related, 925—

927 Tables node, 841, 842 Tables property, 887, 932 TabOrder property, 1540 TabStop property, 1527, 1540 tag prefix, 1159 Tag property, 1225 Target member, 401 Target property, 404 TargetProperty property, 1310 *.targets files, 1148, 1149, 1150, 1153 TargetSite property, 263, 267, 268, 269 TargetType attribute, 1313, 1314—1315,

1351

TargetType property, 1095, 1098, 1316 TargetUrl image, 1448 Task class, 765—766, 768 Task Parallel Library (TPL), 727, 729, 736,

762, 763, 764, 765, 768, 771, 772 task parallelism, 768—771 TaskFactory object, 766 TCP (Transmission Control Protocol),

1017, 1020, 1022, 1025, 1028, 1030, 1031, 1032, 1050, 1052

TCP-based bindings, 1030, 1049—1050 TCP/IP (Transmission Control

Protocol/Internet Protocol) address value, 1501

Teenager class, 181, 182 tempdb database, 1502 Template property, 1133, 1344, 1348, 1350 TemplateControl class, 1416 templates, 1071—1073

Service Website, 1025 Visual Studio 2010, 1023—1025 Visual Studio Windows Forms, 1518—

1524 templating services, 1132 temporary cookie, 1498 TerminateWorkflow activity, 1091, 1097,

1098 Test Client application, WCF, 1058 TestApp application, 45 TestApp class, 47 TestApp file, 43, 44, 45 TestApp.exe application, 46, 48 TestApp.exe assembly, 43, 48 TestApp.exe file, 44, 45 TestApp.rsp file, 47 TestApp.rsp response file, 48 TesterUtilClass class, 462 testing

ADO.NET database transactions, 882—883

modified person class, 256 services, 1075—1076

TestWindow.xaml, 1296 Text attribute, 1082 Text edit box, 1081

Page 183: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1693

text files reading to, 796—797 writing to, 795—796

Text property, 1085, 1094, 1241, 1373, 1420, 1422, 1429, 1436, 1441, 1456

Text value, 1429 TextBlock controls, 1198, 1227, 1354, 1371 TextBox class, 907, 908, 910, 925, 1007,

1008, 1009, 1173, 1474 TextBox control, 768, 1198, 1206, 1227,

1431, 1439, 1455, 1487, 1495, 1505 TextBox objects, 1317 TextBox scope, 1429 TextBox style, 1317 TextBox type, 1174, 1175, 1177, 1467, 1536 TextBoxes control, 1262 TextBoxes widget, 1441 TextBoxLineDrawingVisual, 1344 TextChanged event, 1431 TextureBrush type, 1547 Theme property, 1417 themes

*.skin files, 1466—1468 applying at page level, 1469 applying sitewide, 1468 assigning programmatically, 1469—1471 overview, 1465 SkinID property, 1469

themes, ASP.NET. See ASP.NET themes theMessage variable, 691 Then area, 1107 TheString property, 676 Thickness objects, 1305 third-party data providers, obtaining, 831 This application has succeeded message,

77 this keyword

chaining constructor calls using, 176—178

and constructor flow, 178—180 overview, 174—175

this operator, 492 this reference, 682 this[] syntax, 440 Thread class, 728, 740, 741, 743, 762

Thread Local Storage (TLS), 627 Thread objects, 398, 742, 743, 745, 746,

751, 760, 761 thread scheduler, 728, 744 thread set of process, 631—634 thread synchronization, 729 Thread type, 742, 744 Thread.CurrentContext property, 651, 728 Thread.CurrentThread property, 728, 731,

742 Thread.GetDomain( ) method, 697, 728 threading primitives, 729 ThreadPool class, 740, 760 ThreadPoolApp project, 761 ThreadPool.QueueUserWorkItem( )

method., 760 ThreadPriority enumeration, 740, 741 ThreadPriority property, 744 ThreadPriority.Highest value, 744 ThreadPriority.Normal value, 744 Threads property,

System.Diagnostics.Process class, 629, 632

Thread.Sleep( ) method, 730, 731, 735, 748, 753

ThreadStart delegate, 740, 744, 745—746, 747, 750

Thread.Start( ) method, 744, 750 ThreadState enumeration, 740, 741 ThreadState member, ProcessThread type,

633 ThreadState property, 741 ThreadStats Console Application, 742 ThreadStats project, 744 thread-volatile operations, 729 ThreeDCircle class, 245, 246, 247, 324, 328 three-letter abbreviation (TLA), 25 Throw activity, WF 4.0, 1092 throw keyword, 261, 265, 280 ThrowException( ) method, 691 ThrowIfCancellationRequested( ) method,

767 throwing general exceptions, 265—266 throws, identifying, 282—283 thumb, 1259

Page 184: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1694

tilde symbol (~), 303 time line editor, 1360 time slice, 627 Timeline area, 1211 Timeline Base class, 1305 Timeline window, 1270 Timeout attribute, 1497 Timeout property, 1496, 1497 Timeout value, 1497 timer callbacks, programming with, 758—

759 Timer class, 739, 740, 758 Timer constructor, 759 Timer object, 759 Timer types, 740 TimerApp Console Application, 758 TimerApp project, 760 TimerCallback delegate, 740, 758, 759 TimeSpan object, 1308, 1309 TimeSpan structure, 95 TimeUtilClass class, 187 Title attribute, 1146 Title property, 1338 Title property, System.Console class, 82 <title> tags, 1384 TLA (three-letter abbreviation), 25 TLS (Thread Local Storage), 627 To edit box, 1107 To property, 1305, 1307, 1310 ToArray( ) method, 380, 513 ToArray<> ( )method, 509 ToArray<>( ) method, 513 ToArray<T>( ) method, 502, 503, 977 ToDictionary<K,V>( ) method, 977 ToDictionary<TSource,TKey>( ) method,

502 toggle button, 1265 <ToggleButton> element, 1264 token, 753 token class, 393 token set, 654 token value, 199 ToList<>( ) method, 509 ToList<T>( ) method, 502, 503, 977 ToLower( ) method, String system type, 98

tool support, 1082 ToolBar

building window frame using nested panels, 1197—1198

Ink API tab, WPF, 1217—1219 toolbar buttons, 1195, 1196 ToolBar class, 1197 ToolBar control, 1198, 1217, 1228 ToolBar element, 1198 ToolBar objects, 1198 ToolBar type, 1198 <ToolBar> element, 1264 <ToolBarTray> element, 1198 Toolbox, Visual Studio 2010, 1080, 1093,

1180, 1438, 1522 Tools area, 1212, 1215 Tools editor, 1211, 1212 Tools menu functionality, implementing,

1555—1556 Tools menu system, 1552 tools, Visual Studio 2010, 1384—1386 Tools window, 1212, 1213, 1222 ToolsSpellingHints_Click( ) method, 1197,

1200 ToolStripMenuItem method, 1516 ToolStripMenuItem object, 1516 ToolTip property, FrameworkElement

type, 1134 ToolTip property, WebControl Base Class,

1438 Top property, 1527 ToString( ) method, 91, 148, 252, 253, 255,

263, 351, 379, 390, 476 TotalProcessorTime member,

ProcessThread type, 633 ToUpper( ) method, 98, 103, 704, 705 TPL (Task Parallel Library), 727, 729, 736,

762, 763, 764, 765, 768, 771, 772 Trace attribute, 1402, 1411 Trace property, 1411, 1417 <trace> element, 1427 TraceContext object, 1417 Trace.Write( ) method, 1411 tracing ASP.NET pages, 1410—1411 tracing support, 1411

Page 185: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1695

TraditionalDelegateSyntax( ) method, 430 TransactedReceiveScope activity, WF 4.0,

1090 transaction activities, WF 4.0, 1091—1092 Transaction object, 828, 834 Transaction property, 882 transactional literature, 878 transactions, 877 TransactionScope activity, WF 4.0, 1092 Transform class, 1262 Transform editor, 1360 Transform member, 1254 Transform objects, 1254, 1262 Transform pane, 1270 transformation editors, 1269—1271 TransformGroup type, 1262 TranslateTransform type, 1262 Transmission Control Protocol (TCP),

1017, 1020, 1022, 1025, 1028, 1030, 1031, 1032, 1050, 1052

Transmission Control Protocol/Internet Protocol (TCP/IP) address value, 1501

TreesAndTemplatesApp project, 1348 TreeView control, 1439, 1444, 1445—1447 TreeView widget, 322 TreeViews control, 1531 Triangle class, 327 Trigger objects, 1317 <Trigger.EnterActions> element, 1318 <Trigger.ExitActions> scope, 1318 triggers

defining WPF styles with multiple, 1317 overview, 1317

incorporating visual cues in WPF control templates using, 1351—1352

Triggers collection, 1317 Triggers editor, 1363 Triggers, Style class, 1313 Trim( )method, String system type, 98 trokeStartLineCap property, Shape class,

1249 true argument, 311

true blue value, 717 true operator, 445 true value, 347, 1140 TrueString property, 93 Truncate member, FileMode enumeration,

787 try block, 267, 277, 280, 756 try keyword, 109, 249, 261 try scope, 304 TryCatch activity, WF 4.0, 1092 try/catch block, 64, 266, 705, 706, 1176 try/catch construct, 250 try/catch logic, 283, 330, 365, 1113 try/catch scope, 282 try/final logic, 308 try/finally block, 308 try/finally logic, 309 TryFindResource( ) method, 1296, 1319 tunneling events, 1338, 1339 TurboBoost( ) method, 539, 540, 544, 549,

602, 603 TurnOnRadio( ) method, 604 *.txt files, 1109, 1114, 1204 txtAttempts control, 1371 txtColor control, 1538 txtFavCar textbox, 1474 txtInstructions control, 1371 txtInstructions property, 1373 txtMake control, 1538 txtMakeToView class, 908 txtNewSP textbox, 1487 txtPrice control, 1538 txtRequiredField text box, 1459 txtScore control, 1371 txtUserMessage class, 1387 TypDefName token, 583 Type attribute, 1461, 1504, 1505, 1508 type boundary, 532 Type class, 588, 1063 type constructors, defining in CIL, 675 type converters, XAML, 1160—1161 type definition (TypeDef), 582 type fidelity among formatters, 810—811 type indexer, 366 type members

Page 186: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1696

Common Type System (CTS), 22 defining in CIL, 674—677

type metadata, 544—545, 581—586 documenting referenced assemblies,

585 documenting string literals, 586 documenting the defining assembly,

585 TypeRef, 585 viewing

for Car type, 583—584 for EngineState enumeration, 582—

583 exploring assemblies using

ildasm.exe, 34 Type Name edit area, 1095 Type object, 588, 601 type parameters

constraining, 392 constraining type parameters

examples using where keyword, 393—394

lack of operator constraints, 394—395 inference of, 387—388 overview, 371 specifying

for generic classes / structures, 372—374

for generic interfaces, 374—375 for generic members, 374

type reference (TypeRef), 582 type safety, 367—371, 373, 403 type system, 6 TypeAttributes enumeration, 695 TypeBuilder class, 689, 696, 697 TypeBuilder member, 689 TypeBuilder.DefineConstructor( ) method,

696 TypeBuilder.DefineField( ) method, 696 TypeConversions project, 106, 112 typed variable, 702 TypeDef #n token, 582 TypeDef (type definition), 582 TypeDef block, 585 TypedTableBaseExtensions class, 946

TypeDumper.DumpTypeToFile( ) method, 1577

Type.GetCustomAttributes( ) method, 615 Type.GetFields( ) method, 591 Type.GetMethod( ) method, 602 Type.GetMethods( ) method, 590 Type.GetType( ) method, 592, 593, 594 Type.Missing value, 717 Type.Missing values, 717 typeof( ) method, 386, 589 typeof operator, 147, 578, 1158 TypeRef, 585 TypeRef #n token, 582 TypeRef (type reference), 582 TypeRef block, 585 types

directly creating, 797—798 pinning with fixed keywords, 485—486

Types array, 493 type-safe container, 367 typing variables, implicitly, 112

■U U command, 872 UAC (User Access Control) settings, 565 UDTs (user-defined types), 20 Ufo class, 550, 551 ufo.cs file, 550 ufo.netmodule file, 550, 551 UI (web User Interface), 1474 UI markup, 1147 UIElement class, 1117, 1134, 1142, 1143,

1248 UIElement objects, 1252, 1253, 1256 UIElement property, 1255 UIElement type, 1134 UIElements, 1255, 1256, 1272 uint data type, 86 UIPropertyMetadata constructor, 1335 UIPropertyMetadata object, 1335 unary operator overloading, 448—449 unbox opcode, 678 unboxing operations, 364, 365

Page 187: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1697

Unchanged value, 895 Unchecked event, 1220 unchecked keyword, 73, 108, 111 undefined symbols error, 74 underflow condition, 109 unhandled exceptions, result, 283 UnhandledException event, AppDomain

class, 640 Uniform Resource Identifier (URI), 768,

1032, 1034, 1047, 1050, 1071, 1394 Uniform Resource Locator (URL), 261, 269,

1044, 1055, 1067, 1380, 1381, 1384, 1391, 1418

UninstallSqlState.sql file, 1502 Union( ) method, 515 Union<>( ) method, 509 Unique property, DataColumn class, 891 uniquely named, 1072 Unload event, 1424 Unload( ) method, 639 unloading AppDomains,

programmatically, 646—648 UnLock( ) method, HttpApplicationState

type, 1484 Unlock( ) method, HttpApplicationState

type, 1487 unmanaged code, 10 unmanaged resources, 289, 298, 303, 305,

311 unnamed styles, WPF, 1316 unreachable object, removing, 291 UnRegisterWithCarEvent( ) method, 410 unsafe keyword, 481—482, 654 unsafe swap function, 483 UnsafeCode project, 486 UPDATE command, 914 Update( ) method, 835, 914, 918 Update request, 861 Update Service Reference menu option,

1056 Update statement, 862, 1450 UpdateCarInventory( ) method, 1491 UpdateCarPetName( ) method, 876 UpdateCommand property, 914, 918, 949 UpdateInventory( ) method, 919, 921

updating code file, 1409—1410 records, 975

upward cast, 106 urgency level, 298 URI (Uniform Resource Identifier), 768,

1032, 1034, 1047, 1050, 1071, 1394 Uri array, 1039 Uri class, 1063 Uri objects, 1291 UriKind value, 1291 URL (Uniform Resource Locator), 261, 269,

1044, 1055, 1067, 1380, 1381, 1384, 1391, 1418

url attribute, 1446 url value, 1446 UseGenericList( ) method, 372 User Access Control (UAC) settings, 565 User Control library, 1300 user interface (UI)

of LINQ to XML App, building, 1007 rigging up to Helper class, 1009—1011

User Interface (UI) element, 1385 user profiles, defining within Web.config,

1504—1505 User Strings token, 586 UserControl class, 1144, 1366 UserControl types, 1331 <UserControl> element, 1156 <UserControl> scope, 1356 UserControl1.xaml file, 1300 UserControls

building custom with Blend animation, defining, 1359—1362 initial C# code, 1359 overview, 1356 programmatically starting

storyboard, 1363—1364 renaming initial, 1357—1358 SpinControl, 1358

extracting from drawing geometry, 1365—1366

UserControls class, 1292 UserControls control, 1442 user-defined collection, 118

Page 188: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1698

user-defined types (UDTs), 20 userFavoriteCar variable, 1473, 1474, 1475 UserHostAddress property, 1418 UserHostName property, 1418 user-interface (UI), designing, 1396—1397 UserName property, System.Environment

class, 81 UserName type, 1094 UserShoppingCart class, 1494, 1495 UserShoppingCart type, 1495, 1496 ushort data type, 86 using block, 309 using directive, 271 using keyword, and disposable objects,

308—309 using scope, 309, 1038 using statement, 1409 UsingNamespace( ) method, 691 utility classes, 181, 187

■V v4.0 prefix, 566 v4.0_major.minor.build.revision__publicK

eyTokenValue directory, 567 Validate attribute, 1418 ValidateCurrentNumber, 1335 ValidateInput( ) method, 1418 ValidateValueCallaback delegate, 1330,

1335 ValidateValueCallback delegate, 1329, 1335 Validation area, 1439 validation controls

CompareValidator widget, 1461—1462 creating summaries, 1462—1463 defining groups, 1463—1465 overview, 1457—1458 RangeValidator widget, 1460—1461 RegularExpressionValidator widget,

1460 RequiredFieldValidator widget, 1459—

1460 ValidationExpression property, 1460 ValidationGroup property, 1464

ValidationGroups.aspx project, 1463 ValidationSummary control, 1458, 1463 ValidationSummary type, 1462 ValidationSummary widget, 1462 ValidatorCtrls project, 1459 ValidatorCtrls website, 1465 value attribute, 671 value, passing reference types by, 158—160 Value property, 163, 164, 271, 315, 868,

1107, 1237, 1389 value token, 199 value types

containing reference types, 157—158 overview, 154 vs. reference types, 155—156, 161—162

ValueAndReferenceTypes project, 155, 158 ValueChanged event, 1236 Values property, 1099 ValueType class, 91, 154, 251 ValueTypeAssignment( ) method, 156 var data type, 113, 116 var keyword, 73, 112, 113, 114, 115, 116,

118, 139, 490, 500 var token, 113 var-defined data point, 115 Variable Type drop down list, 1098 Variable Type dropdown list box, 1106 variables

assignment of, 1106 data type, 90 declaration of, 88—89, 680—681 declaring with fully qualified name, 31 for enum type, 146—147 implicitly typing, 112 local, 88, 127, 290, 429—430 mapping parameters to in CIL, 681 object, 196 output, 127 reference, 290 structure, 154 for structure type, 152—153 web-based application, 1124 workflow

defining, 1106—1107 workflow wide, defining, 1095—1096

Page 189: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1699

XAML, declarations, 1159 Variables aspect, 1095 Variables button, 1095, 1098, 1106 Variant data types, 115, 717, 718, 722 VB (Visual Basic) literal syntax, 996—997 VB code, 1097 VB statements, 1094 VB6 Component Object Model (COM)

developers, 261 vbc.exe compiler, 24 vbc.exe file, 16 vbnc compiler, Mono, 1569 VBScript language, 1389 VbSnapIn library, 620 VbSnapIn.dll assembly, 618, 623 VbSnapIn.dll library, 621 vector graphics, generating using

expression design, 1275—1276 [VehicleDescription] attribute, 610, 612 VehicleDescriptionAttribute attribute, 609,

610 VehicleDescriptionAttribute class, 615 VehicleDescriptionAttributeReader

application, 614 Venn diagramming operations, 1268 Venn diagramming tool, LINQ as, 515—516 .ver directives, 542, 666 .ver token, 542, 562 verbatim strings, 101—102 VerifyDuplicates( ) method, 471, 472, 473 version numbers, setting, 919 Version type, 693 <version> element, 48 Vertical split button, 1170 Vertical value, 1189 VerticalAlignment property,

FrameworkElement type, 1133 VerticalContentAlignment property,

Control Type, 1133 VeryComplexQueryExpression class, 521 VeryDynamicClass, 706 VES (Virtual Execution System), 37 VideoDrawing object, 1258 VideoDrawing type, 1272 View Class Diagram button, 64, 225, 932

View Code menu option, 1081, 1104, 1554 View Code option, 621, 933, 1513, 1520 View Detail link, 285 View In Browser menu option, 1387, 1388,

1399, 1465 View Inventory menu item, 1452 View Inventory node, 1446 View menu, 56, 58, 60, 65, 223, 568, 608,

939, 1169, 1450 View Source, 1477 view state

adding custom data, 1478—1479 demonstrating, 1477—1478 overview, 1476

Viewport3DVisual class, 1277 Viewport3DVisual object, 1258 ViewState property, 1478, 1485 ViewStateApp project, 1477 virtual, 22 virtual directories, IIS, 1381 virtual execution stack, 656 Virtual Execution System (VES), 37 virtual keyword, 125, 236—238, 243 virtual members

overriding using Visual Studio 2010, 238—239

sealing, 239 virtual methods, 236, 243, 493 Visibility property, UIElement type, 1134 visibility trait, 22 Visible property, 1432, 1433, 1527, 1529 visual base class and derived child classes,

1277 Visual Basic (VB) literal syntax, 996—997 Visual Basic 6.0, programming language

comparison, 4 Visual Basic, building client application,

547—549 Visual Basic compiler, 16, 1565, 1569 Visual Basic Snap-In, 620 Visual C# 2010 Express and Visual C++

2010 Express, 53 Visual C# 2010 Express, building C#

applications with, 53—54 Visual class, 1134, 1258, 1277, 1283

Page 190: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1700

Visual Class Designer, Visual Studio 2010, 64—67

visual designer surface, 1519—1520 visual layer, rendering graphical data using

DrawingVisual class, 1278—1279 overview, 1277 rendering to custom layout manager,

1280—1282 responding to hit test operations, 1282—

1284 visual base class and derived child

classes, 1277 Visual object, 1258 visual state groups, 1366 Visual State Manager (VSM), .NET 4.0,

1356, 1366 Visual Studio 2010

AssemblyInfo.cs file, 613 class diagrams, revising, 224—225 Class View utility, 58—59 code expansions, 63—64 configuration files and, 556—558 configuring brushes using, 1258—1260 default namespace of, 531 generating proxy code using, 1047—1048 generating strong names using, 563—

564 HTML designer tools, 1384—1386 implementing interfaces using, 335—336 integrated .NET Framework 4.0

documentation, 67—69 New Project dialog box, 56 Object Browser utility, 60 overriding virtual members using, 238—

239 overview, 54 project templates, 1023—1025 refactoring code, 60—63 Solution Explorer Utility

overview, 56 referencing external assemblies, 57 viewing Project Properties, 58

unique features of, 55 Visual Class Designer, 64—67 WPF applications, building using

Button Click event, implementing, 1175—1176

Closed event, implementing, 1177 designer tools, 1169—1172 GUI, designing, 1173—1174 Loaded event, implementing, 1174 overview, 1167 project templates, 1168 testing, 1177—1178

WPF control templates, building custom

{TemplateBinding} markup extension, 1352—1353

ContentPresenter class, 1354 incorporating into styles, 1354—1355 incorporating visual cues using

triggers, 1351—1352 overview, 1348 as resources, 1349—1351

WPF controls, 1181—1182 Visual Studio debugger, 284—285 Visual Studio Windows Forms project

template initial Form, 1520—1521 overview, 1518 Program class, 1521—1522 visual designer surface, 1519—1520 visually building menu systems, 1522—

1524 visual trees, 1252, 1278, 1341—1348 Visual type, 1135, 1277 Visual Web Developer 2010 Express, 53 VisualBasicCarClient project, 549 VisualBasicCarClient.exe file, 553 VisualBrush class, 1258 VisualBrush type, 1258 VisualChildrenCount property, 1281 VisualCollection container, 1282 VisualCollection variable, 1280, 1281 VisualStateGroup class, 1367 VisualStateManager class, 1367, 1370 VisualTreeHelper class, 1252, 1343 VisualTreeHelper.HitTest( ) method, 1252,

1253, 1283 void return value, 75, 76, 77

Page 191: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1701

void value, 127, 171 Vs2010Example application, 56 VSM (Visual State Manager), .NET 4.0,

1356, 1366

■W W3C (World Wide Web Consortium), 995,

1019 WaitCallback delegate, 760 WaitForPendingFinalizers( ) method,

System.GC class, 298 WaitHandle class, 735 WaitHandle.WaitOne( ) method, 735 WaitOne( ) method, 735, 748 WaitReason member, ProcessThread type,

633 WAS (Windows Activation Service), 1026 WCF. See Windows Communication

Foundation WCF (core assemblies of Windows

Communication Foundation), 1022

WcfMathService.MyCalc class, 1054 WcfTestClient.exe, 1024, 1058—1059, 1075 web application, 1412 Web Application model, 1413 web application shutdown, handling, 1488 Web Application Templates, Visual Studio,

1412 Web applications, 1412—1413 Web applications and servers

ASP.NET development web server, 1382 IIS virtual directories, 1381 overview, 1380

web controls categories of, 1438 data centric, 1439 security, 1440 standard, 1439

web controls, ASP.NET. See ASP.NET web controls

Web Form, 1408, 1473, 1477, 1485, 1489, 1498

Web Form controls, 1416, 1429 Web Form icon, Solution Explorer, 1408 web method, 1018 Web pages

building single file adding data access logic, 1397—1401 ASP.NET control declarations, 1403—

1404 ASP.NET directives, 1401—1403 compilation cycle for single-file

pages, 1405—1406 designing UI, 1396—1397 overview, 1395 referencing AutoLotDAL.dll, 1396 "script" block, 1403

building using code files, 1406—1411 Web Parts, 1393 Web servers, posting back to, 1390—1391 Web Service Definition Language (WSDL),

1019, 1021, 1034, 1044, 1055, 1072, 1073

web service specifications (WS-*), 1020 Web Services Addressing (WS-Addressing),

1029 Web Services Basic (WS-Basic), 1029 Web Services Enhancements (WSE), 1019 Web Services Federation (WS-Federation),

1029 Web Services Interoperability

Organization (WS-I), 1019, 1029 Web Services Reliability (WS-Reliability),

1028 Web Services SecureConversation (WS-

SecureConversation), 1030 Web Services Security (WS-Security), 1028,

1030 Web Services Transactions (WS-

Transactions), 1028 Web Services Trust (WS-Trust), 1030 Web Site dialog box, 1017 Web site directory structure

App_Code folder, 1415 overview, 1413 referencing assemblies, 1414—1415

Web sites applications, 1412—1413

Page 192: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1702

web User Interface (UI), 1474 Web-Centric service project templates,

1071—1073 WebClient class, 768 Web.config files, 1075, 1427—1428, 1504—

1505 WebControl class, 1404, 1430, 1437, 1438 WebControl types, 1432 webdev.webserver.exe utility, Microsoft

.NET, 1571 [WebMethod] attribute, 605, 606, 1016,

1018 <%@WebService%>directive, 1018 website administration utility, ASP.NET,

1428 Website option, 1409 Web.sitemap file, 1445, 1446 Welcome dialog box, 1207 where clauses, 393, 394 where keyword, constraining type

parameters using, 393—394 Where( ) method, 517, 519, 520 where operator, 497, 509, 511, 517, 518 where T : class constraint, 392 where T : NameOfBaseClass constraint,

393 where T : NameOfInterface constraint, 393 where T : new( ) constraint, 392 where T : struct constraint, 392 WhereArrayIterator<T> class, 499 While activity, WF 4.0, 1089 while keyword, 682 while loop, 117, 119 widening operation, 106 Width attribute, 1146 Width property, 1133, 1145, 1152, 1187,

1193, 1219, 1304, 1326, 1438, 1527 Width value, 1188, 1189, 1193 wildcard character (*), 47 wildcard token, 562 <%windir%>\Assembly directory, 1578 Window and control adornments, WPF,

1180 Window class

overview, 1130

System.Windows.Controls.ContentControl, 1131—1132

System.Windows.Controls.Control, 1132

System.Windows.DependencyObject, 1135

System.Windows.FrameworkElement, 1133

System.Windows.Media.Visual, 1134—1135

System.Windows.Threading.DispatcherObject, 1135

System.Windows.UIElement, 1134 Window construction, 1138 Window designer, WPF, 1170 window, dirty, 1549 Window menu, 1303 Window objects, 1130, 1135, 1137, 1138,

1155, 1173 Window type, 1121, 1130, 1135, 1137, 1146,

1173, 1175, 1177, 1196, 1204 <Window> element, 1155, 1156, 1158,

1159, 1160, 1173, 1175, 1185, 1205, 1232

WindowCollection type, 1129 <Window.CommandBindings> scope,

1205 Window-derived class, 1137, 1146 Window-derived object, 1138 WindowHeight property, System.Console

class, 82 WindowLeft property, System.Console

class, 82 <Window.Resources> scope, 1294 windows

closing, 1141—1142 mapping data to C# code, 1150—1151 naturally dirty, 1551 strongly typed, 1137—1138

Windows Activation Service (WAS), 1026 Windows Application Programming

Interface (API), 260, 285, 286, 729 Windows Communication Foundation

(WCF)

Page 193: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1703

addresses, bindings, and contracts (ABCs)

addresses, 1031—1032 bindings, 1028—1031 contracts, 1027

building client applications configuring TCP-based binding,

1049—1050 generating proxy code using

svcutil.exe, 1046—1047 generating proxy code using Visual

Studio 2010, 1047—1048 building services

[OperationContract] attributes, 1035 [ServiceContract] attributes, 1034 overview, 1032 service types as operational

contracts, 1035—1036 composition of applications, 1025—1027 core assemblies of, 1022 data in one process, 625 designing data contracts

examining Web.config files, 1075 implementing service contracts,

1073—1074 overview, 1070 role of *.svc files, 1074 testing services, 1075—1076 using Web-Centric service project

templates, 1071—1073 distributed computing APIs

.NET remoting, 1016 COM+/Enterprise Services, 1015 Distributed Component Object

Model (DCOM), 1014—1015 Microsoft Message Queuing

(MSMQ), 1015—1016 named pipes, sockets, and P2P, 1019 overview, 1013 XML web services, 1016—1019

features, 1020 hosting services

<system.serviceModel> element, 1042

coding against ServiceHost type, 1038

enabling metadata exchange, 1043—1045

establishing ABCs within App.config files, 1037

ServiceHost type, 1040—1041 specifying base addresses, 1038—

1040 hosting services within Windows

services creating Windows service installer,

1064—1065 enabling MEX, 1064 installing Windows service, 1066—

1067 overview, 1061 specifying ABCs in code, 1062—1063

invoking services asynchronously from clients, 1067—1069

overview, 1013 service-oriented architecture (SOA)

tenets, 1021—1022 simplifying configuration settings with

WCF 4.0 changing settings for bindings,

1053—1054 default endpoints in, 1051—1052 default MEX behavior configuration,

1054—1055 exposing single services using

multiple bindings, 1052—1053 overview, 1050 refreshing client proxy and selecting

bindings, 1056—1057 using Service Library project templates

altering configuration files using SvcConfigEditor.exe, 1059—1061

building simple math services, 1057—1058

testing with WcfTestClient.exe, 1058—1059

Visual Studio project templates, 1023—1025

Windows control, 1292

Page 194: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1704

Windows Explorer, viewing .NET 4.0 GAC using, 566

Windows file header, 534—535 Windows Forms applications

completing, 937 executing under Linux, 1580 extendable, 621—624

Windows Forms Client program, building, 1578—1580

Windows Forms database designer tools app.config files, 932 completing Windows Forms

applications, 937 DataGridView control, 927—932 strongly typed data adapters, 936—937 strongly typed DataRows, 935 strongly typed DataSets, 932—934 strongly typed DataTables, 934

Windows Forms Graphics object, 1279 Windows Forms GUI toolkit, 903, 904, 906,

907, 913, 918, 920, 921, 927, 931 Windows Forms GUIs

binding DataTable objects to DataView type, 912—913 deleting rows from DataTables, 907—

908 hydrating DataTables from generic

List<T>, 904—906 selecting rows based on filter

criteria, 908—911 updating rows within DataTables,

911 data binding entities to, 986—989

Windows Forms message box, 540 Windows Forms, programming with

building applications overview, 1513 populating controls collection,

1515—1517 System.EventArgs and

System.EventHandler, 1517—1518 building complete applications

adding infrastructure to MainWindow type, 1555

capturing and rendering graphical output, 1557

implementing serialization logic, 1558—1560

implementing Tools menu functionality, 1555—1556

main menu system, 1552—1553 overview, 1551 ShapeData type, 1553 ShapePickerDialog type, 1553—1555

designing dialog boxes configuring tab order, 1540 DialogResult property, 1539 displaying dialog boxes, 1542—1543 overview, 1538 setting form's default input button,

1541 Tab Order Wizard, 1540—1541 understanding form inheritance,

1543—1545 Form type

Control class, 1526—1529 Form class, 1529—1530 life cycle, 1531—1533 overview, 1525

mouse and keyboard activity determining which button was

clicked, 1535—1536 determining which key was pressed,

1536—1537 overview, 1534

namespaces, 1512—1513 overview, 1511 rendering graphical data using GDI+

Graphics type, 1548—1549 invalidating form's client area, 1551 obtaining Graphics object with

Paint event, 1549—1550 overview, 1545—1546 System.Drawing namespace, 1547

Visual Studio Windows Forms project template

initial Form, 1520—1521 overview, 1518 Program class, 1521—1522

Page 195: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1705

visual designer surface, 1519—1520 visually building menu systems,

1522—1524 Windows Forms properties, 1392 Windows header information, 534 Windows help file, 269 Windows Management Instrumentation

(WMI), 1043 Windows menu, 1363 Windows network identity, 1507 Windows Open dialog box, 621 Windows Presentation Foundation (WPF),

1285—1324, 1325—1375 animation

Animation class types, 1304—1305 authoring in C# code, 1306—1307 authoring in XAML, 1309—1312 looping, 1308—1309 overview, 1303 pacing of, controlling, 1307—1308 To property, 1305 By property, 1305 From property, 1305 reversing, 1308—1309 Timeline Base class, 1305

control templates building custom with Visual Studio

2010, 1348—1355 default, 1341—1348 default, programmatically

inspecting, 1344—1348 dependency properties

building custom, 1331—1336 CLR property wrappers, 1330 examining existing, 1327—1330 overview, 1325

Jackpot Deluxe WPF application .NET 4.0 visual states, 1366—1370 extracting UserControl from

drawing geometry, 1365—1366 finalizing, 1371—1375 overview, 1364

logical trees overview, 1341

programmatically inspecting, 1342—1343

resource system binary resources, 1285—1291 object (logical) resources, 1292—1303

routed events overview, 1337 routed bubbling events, 1338—1339 routed tunneling events, 1339—1341

styles animated, 1318 assigning programmatically, 1319—

1320 automatically applying with

TargetType, 1314—1315 defining and applying, 1313—1314 defining with multiple triggers, 1317 defining with triggers, 1317 generating with Expression Blend,

1320—1324 overriding settings, 1314 overview, 1312 subclassing existing, 1315 unnamed, 1316

UserControls, building custom with Blend

animation, defining, 1359—1362 initial C# code, 1359 overview, 1356 programmatically starting

storyboard, 1363—1364 renaming initial, 1357—1358 SpinControl, 1358

visual trees overview, 1341—1342 programmatically inspecting, 1343—

1344 Windows Presentation Foundation (WPF)

applications assemblies

Application class, 1128—1130 overview, 1126—1127 Window class, 1130—1135

building using code-behind files

Page 196: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1706

MainWindow class, adding code file for, 1165

MyApp class, adding code file for, 1166

processing files with msbuild.exe, 1166—1167

building using only XAML application object, defining, 1147 MainWindow class, defining, 1146—

1147 overview, 1144—1145 processing files with msbuild.exe,

1148—1150 building using Visual Studio 2010

Button Click event, implementing, 1175—1176

Closed event, implementing, 1177 designer tools, 1169—1172 GUI, designing, 1173—1174 Loaded event, implementing, 1174 overview, 1167 project templates, 1168 testing, 1177—1178

building without XAML application level data, interacting

with, 1139—1140 closing window, 1141—1142 keyboard events, intercepting, 1143—

1144 mouse events, intercepting, 1142—

1143 overview, 1135—1136 strongly typed window, 1137—1138 user interface, 1138—1139

flavors of desktop applications, 1121—1123 navigation-based applications, 1124 WPF/Silverlight relationship, 1126 XBAP applications, 1124—1125

motivation behind optimized rendering model, 1120 overview, 1117 separation of concerns, 1119 simplifying UI programming, 1120—

1121

unifying APIs, 1118—1119 syntax of

attached properties, 1162 class and member variable

declarations, controlling, 1159 kaxaml, 1154—1156 kaxamlXAML XML namespaces and

XAML, 1156—1159 markup extensions, 1163—1165 property-element syntax, 1161 XAML elements, XAML attributes

and type converters, 1160—1161 transforming markup into .NET

assembly BAML, 1151—1152 mapping application data to C#

code, 1153 mapping window data to C# code,

1150—1151 overview, 1150 XAML-to-assembly process, 1153—

1154 Windows Presentation Foundation (WPF)

controls commands

connecting to arbitrary actions, 1203—1204

connecting to Command property, 1202—1203

intrinsic control command objects, 1201

Open command, 1204—1206 overview, 1200 Save command, 1204—1206

core, 1179—1181 data-binding model

Data Binding tab, 1236 DataContext property, 1239 DataGrid tab, 1242—1244 establishing data bindings, 1236—

1238, 1241—1242 IValueConverter interface, data

conversion using, 1240—1241 overview, 1235

dialog boxes, 1183

Page 197: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1707

document controls, 1183 Documents API

block elements, 1227 document layout managers, 1228 inline elements, 1227

Documents tab, building annotations, enabling, 1232—1234 loading FlowDocument, 1234—1235 overview, 1228 populating FlowDocument, 1230—

1232 saving FlowDocument, 1234—1235 sticky notes, enabling, 1232—1234

Expression Blend, building user interface with

key aspects of, 1207—1213 TabControl control, 1213—1215

Ink API tab, building ComboBox control, 1224—1226 InkCanvas control, 1222—1227 overview, 1216 RadioButton control, 1220—1222 ToolBar, 1217—1219

ink controls, 1182—1183 overview, 1179 panels

enabling scrolling for, 1194—1195 nested, building window frame

using, 1195—1200 overview, 1184—1185 positioning content within, 1186—

1194 using Visual Studio 2010, 1181—1182

Windows Presentation Foundation (WPF) graphics rendering services

applying graphical transformations, 1262—1266

brushes configuring in code, 1260—1261 configuring using Visual Studio

2010, 1258—1260 generating complex vector graphics

using expression design, 1275—1276

options, 1246—1247

overview, 1245 pens, 1261—1262 rendering graphical data using

drawings and geometries building DrawingBrush using

geometries, 1272—1273 containing drawing types in

DrawingImage, 1274—1275 overview, 1271 painting with DrawingBrush, 1273—

1274 rendering graphical data using visual

layer DrawingVisual class, 1278—1279 rendering to custom layout

manager, 1280—1282 responding to hit test operations,

1282—1284 visual base class and derived child

classes, 1277 shapes

adding rectangles, ellipses, and lines to canvas, 1249—1252

overview, 1247—1248 paths, 1254—1257 polylines and polygons, 1253—1254 removing rectangles, ellipses, and

lines from canvas, 1252—1253 working with using Expression

Blend, 1266—1271 Windows property, 1129, 1130 Windows services

creating installer, 1064—1065 hosting services within

creating Windows service installer, 1064—1065

enabling MEX, 1064 installing Windows service, 1066—

1067 overview, 1061 specifying ABCs in code, 1062—1063

installing, 1066—1067 Windows Start button, 1572 Windows Task Manager utility, 625 Windows thread scheduler, 728

Page 198: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1708

Windows Workflow Foundation 4.0 (WF) activities

collection, 1092—1093 control flow, 1089 error handling, 1092—1093 flowchart, 1089—1090 messaging, 1090—1091 overview, 1088 primitives, 1091 runtime, 1091 transaction, 1091—1092

business process, defining, 1078 overview, 1077 runtime engine

WorkflowApplication class, hosting workflows using, 1086—1088

WorkflowInvoker class, hosting workflows using, 1083—1086

workflows consuming libraries, 1112—1114 flowchart, 1093—1103 isolating into dedicated libraries,

1103—1111 simple, 1079—1083

WindowsBase.dll assembly, 1127, 1135, 1157, 1168

WindowsFormsDataBinding application, 904

WindowsFormsDataBinding project, 904, 913

<Windows.Resources> scope, 1297 WindowsStartupLocation attribute, 1146 WindowState property, 1530 WindowTop property, System.Console

class, 82 window-wide resources, defining, 1292—

1294 WindowWidth property, System.Console

class, 82 WinFormsClientApp.cs, 1578 WinFormsClientApp.rsp, 1579 Winnebago class, 611 WithCancellation( ) method, 771 WithCancellation( )method, 773 Wizard control, 1439, 1441, 1455

wizards, 4 Workflow Activity Library project, 1083 Workflow Console Application project,

1083 workflow designer, defining arguments

using, 1084—1086 Workflow Foundation (WF), 1024 Workflow node, 1103 Workflow Service Application project

template, WCF, 1083 Workflow1.xaml file, 1081, 1084 WorkflowApplication class, hosting

workflows using, 1086—1088 workflow-enabled applications, 30 WorkflowInvoker class, hosting workflows

using defining arguments using workflow

designer, 1084—1086 overview, 1083 passing arguments to workflow, 1084

WorkflowInvoker.Invoke( ) method, 1084, 1113

WorkflowLibraryClient project, 1112, 1114 WorkflowRuntime class, 1086 workflows

consuming libraries, 1112—1114 flowchart

activities, connecting in, 1094 FlowDecision activity, 1096—1098 ForEachT activity, 1099—1100 InvokeMethod activity, 1094—1095 overview, 1093 TerminateWorkflow activity, 1097 variables, workflow wide, 1095—1096

hosting using WorkflowApplication class, 1086—1088

hosting using WorkflowInvoker class defining arguments using workflow

designer, 1084—1086 overview, 1083 passing arguments to workflows,

1084 isolating into dedicated libraries

arguments, defining, 1105—1106 assemblies, importing, 1105

Page 199: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1709

Assign activity, 1107 Code activity, 1109—1111 defining project, 1103—1104 If activity, 1107—1108 namespaces, importing, 1105 Switch activity, 1107—1108 variables, defining, 1106—1107

simple, 1079—1083 WorkflowServiceHost class, 1088 WorkWithArrayList( ) method, 367 World Wide Web (WWW) environment,

1473 World Wide Web Consortium (W3C), 995,

1019 WPF. See Windows Presentation

Foundation WPF Fundamentals node, 1336 WPF triggers, 1366 WPF User Control Library project, 1300 WpfAppAllCode namespace, 1137 WpfAppAllCode project, 1135, 1144 WpfAppAllXaml application, 1167 WpfAppAllXaml project, 1154 WpfAppCodeFiles folder, 1165 WpfAppCodeFiles project, 1167 WpfControlsAndAPIs application, 1207 WpfControlsAndAPIs project, 1244 WPFRoutedEvents project, 1337, 1341 WpfStyles application, 1313 WpfStyles project, 1320 WrapPanel panel control, WPF, 1186 WrapPanel panels, 1188, 1190 Write( ) method, 82, 793, 795, 800, 1421,

1422 WriteAllBytes( )method, 791 WriteAllLines( )method, 791 WriteAllText( )method, 791 WriteByte( ) member, 793 WriteFile( ) method, 1421 WriteLine activity, 1080, 1081, 1084, 1085,

1093, 1094, 1097, 1098, 1099, 1100 WriteLine( ) member, 795 WriteLine( ) method, 75, 82, 83, 181, 704 WriteXml( ) method, 889, 901 WriteXmlSchema( ) method, 901

writing, to text files, 795—796 WS-* (web service specifications), 1020 WS-* specifications, 1019 WS-Addressing (Web Services Addressing),

1029 WS-Basic (Web Services Basic), 1029 WSDL (Web Service Definition Language),

1019, 1021, 1034, 1044, 1055, 1072, 1073

wsdl link, 1055 wsdl utility, Mono, 1571 wsdl.exe file, 1018 wsdl.exe utility, Microsoft .NET, 1571 WSDualHttpBinding class, 1029, 1030,

1031 WSDualHttpBinding option, 1029 <wsDualHttpBinding> element, 1029 WSE (Web Services Enhancements), 1019 WS-Federation (Web Services Federation),

1029 WSFederationHttpBinding class, 1029,

1031 WSFederationHttpBinding option, 1029 WSFederationHttpBinding protocol, 1030 <wsFederationHttpBinding> element,

1029 WSHttpBinding class, 1029, 1063, 1070 WSHttpBinding option, 1029 WSHttpBinding protocol, 1029, 1058 <wsHttpBinding> element, 1029 WS-I (Web Services Interoperability

Organization), 1019, 1029 WS-Reliability (Web Services Reliability),

1028 WS-SecureConversation (Web Services

SecureConversation), 1030 WS-Security (Web Services Security), 1028,

1030 WS-Transactions (Web Services

Transactions), 1028 WS-Trust (Web Services Trust), 1030 WWW (World Wide Web) environment,

1473 WYSIWYG (fixeddocuments), 1120

Page 200: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1710

■X x: Array keyword, 1163 x: ClassModifier keyword, 1158 X icon, 1142 x: Key keyword, 1158 x: Name keyword, 1158 x; prefix, 1157 X property, 211, 378, 1535 X string format character, 84 x: tag prefix, 1146 X value, 212 X1 property, 1250 X2 property, 1250 XAML

.NET 4.0 visual states, 1369—1370 authoring animation in

discrete key frames, 1311—1312 event triggers, 1310—1311 overview, 1309 storyboards, 1310

exporting design document to, 1275—1276

for simple workflows, 1081—1083 transforming markup into .NET

assembly, 1153—1154 WPF applications, building using

application object, defining, 1147 MainWindow class, defining, 1146—

1147 overview, 1144—1145 processing files with msbuild.exe,

1148—1150 WPF applications, building without

application level data, interacting with, 1139—1140

closing window, 1141—1142 keyboard events, intercepting, 1143—

1144 mouse events, intercepting, 1142—

1143 overview, 1135—1136 strongly typed window, 1137—1138 user interface, 1138—1139

WPF, syntax of

attached properties, 1162 class and member variable

declarations, controlling, 1159 kaxaml tool, 1154—1156 markup extensions, 1163—1165 overview, 1154 property-element syntax, 1161 type converters, 1160—1161 XAML, 1156—1159 XAML attributes, 1160—1161 XAML elements, 1160—1161 XAML XML namespaces, 1156—1159

XAML (Extensible Application Markup Language), 993

XAML (x:Name Extensible Application Markup Language) token, 1146

XAML attribute, 1160 XAML browser application (XBAP), 1124 XAML browser applications (XBAP

applications), 1124—1125 XAML dialect, 1079 XAML editor, 1239, 1309, 1321, 1357 .xaml file, 1298 *.xaml files, 1082, 1103, 1145, 1146, 1147,

1149, 1150, 1151, 1152, 1153 XAML files, external, 1082 XAML markup, 1152 XAML pane, 1155 XAML scope, 1316 XAML scrubber option, 1154 XAML string, 1347 XAML tab, 1369 XamlAnimations folder, 1309 XamlAnimations subdirectory, 1312 *.xaml.cs, 1165 XamlReader class, 1235 XamlReader type, 1173 XamlReader.Load( ) method, 1175 XamlSpecificStuff, 1157, 1158 XamlWriter class, 1235 XamlWriter type, 1173 x:Array keyword, 1158 x:Array markup extension, 1164 XAttribute class, 995, 998 XBAP (XAML browser application), 1124

Page 201: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1711

XBAP applications (XAML browser applications), 1124—1125

XButton1 property, 1143 XButton1 value, 1536 XButton2 property, 1143 XButton2 value, 1536 XCData class, 998 x:Class attribute, 1104, 1150, 1156, 1159,

1357 x:Class keyword, 1158 x:Class value, 1104 x:ClassModifier attribute, 1159 x:Code attribute, 1159 x:Code keyword, 1158 <x:Code> element, 1147 XComment class, 998 XContainer class, 1000, 1001 x-coordinate, 1535 Xcopy deployment, 553 XDeclaration class, 998, 1003 XDocument class, 998, 1000, 1002, 1003,

1006, 1008, 1011 XDocument objects

generating documents from arrays and containers, 1004—1005

loading and parsing XML content, 1006 overview, 1002

XDocuments class, 1004 XElement class, 995, 996, 999, 1000, 1003,

1004, 1006, 1011 XElement objects

generating documents from arrays and containers, 1004—1005

loading and parsing XML content, 1006 overview, 1002

XElements class, 1004, 1005 x:FieldModifier attribute, 1159 XHTML (Extensible Hypertext Markup

Language), 1383, 1392 x:Key attribute, 1293, 1315 x:Key value, 1293, 1316 XML (Extensible Markup Language), 995,

996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004

XML (Extensible Markup Language) schema editor, 902

XML APIs vs. DOM models, 995—996 overview, 993—994 Visual Basic (VB) literal syntax, 996—997

XML content, loading and parsing, 1006 XML data, 815—816 XML documents

building UI of LINQ to XML App, 1007 defining LINQ to XML Helper class,

1008—1009 importing Inventory.xml files, 1007—

1008 overview, 1006 rigging up UI to Helper class, 1009—

1011 XML Editor option, 968 XML markup, 1119 XML namespace (xmlns) attribute, 1383 XML namespaces, XAML, 1156—1159 XML Paper Specification (XPS), 1120, 1183,

1227 XML, serializing DataTable/DataSet

objects as, 901—902 XML web services, 1016—1019 [XmlAttribute] attribute, 815 XML-based grammar, 1088 XmlDocument class, 995 XmlElement class, 995 [XmlElement] attribute, 815 [XmlEnum] attribute, 815 xmlns (XML namespace) attribute, 1383 [XmlnsDefinition] attribute, 1157 XmlReader class, 993 [XmlRoot] attribute, 815 XmlSerializer type, serializing objects

using, 814—816 [XmlText] attribute, 815 [XmlType] attribute, 815 XmlWriter class, 993 x:Name attribute, 1150, 1156, 1159, 1275,

1276, 1293, 1357 XName class, 1001—1002

Page 202: Programming with Windows Forms - Springer Link978-1-4302-2550-8/1.pdf · Programming with Windows Forms Since the release of the .NET platform (circa 2001), ... you will learn the

INDEX ■

1712

x:Name Extensible Application Markup Language (XAML) token, 1146

x:Name keyword, 1158 XName object, 1001 x:Name property, 1181 XNamespace class, 999, 1001—1002 XNode class, 999, 1000 x:Null keyword, 1158, 1163 xor opcode, 678 XPath (Extensible Markup Language Path

Language), 993 XProcessingInstruction class, 999 XPS (XML Paper Specification), 1120, 1183,

1227 XQuery (Extensible Markup Language

Query), 993 XSD (Extensible Markup Language

Schema Definition) editor, 902 *.xsd file, 901, 902 xsd utility, Mono, 1571 xsd.exe utility, Microsoft .NET, 1571 XSLT (Extensible Stylesheet Language

Family Transformations), 993 XSP server, 1566 xsp2 utility, Mono, 1571 x:Static keyword, 1158, 1163 x:Static markup extension, 1163 XStreamingElement class, 999

x:Type keyword, 1158, 1163 x:Type markup extension, 1164 x:TypeArguments keyword, 1158

■Y Y property, 211, 378, 1535 Y value, 212 Y1 property, 1250 Y2 property, 1250 y-coordinate, 1535 YesOrNo variable, 1095, 1097 yield keyword, building iterator methods

with, 346 yield return statement, 346 yield return syntax, 346, 349 YourCars.dll assembly, 532 YourXaml.xaml file, 1174, 1175, 1176 Yugo value, 515 yugosOnlyView variable, 912

■Z zero second mark, 1360 zero-code, 1452 zooming, 49