Bringing an Existing Project into the IDE for Further Work

 

A First Look at the IDE Main Window (Home or Professional version)

Click on the Visual Studio C# compiler shortcut that you created earlier on your desktop to bring up the IDE. The first window presented to you is the Microsoft IDE Start Page, shown in Figure 3-2.

image from book
Figure 3-2: Microsoft IDE Start Page

Note the main menu across the top of the window. Click on File in the main menu, followed by New and then Project. The New Project window opens, as shown in Figure 3-3.

image from book
Figure 3-3: The new HokeyPokey project

Every project we discuss from here to Chapter 24 uses the C# language with the Windows subchoice (in the Project types column). In Chapter 25, when we demonstrate how to build a deployment project, we will choose the Setup and Deployment option from Other Project Types.

Having picked a computer language (C#) and a project type (Windows), we next pick a template: Windows Application. As soon as Windows Application is highlighted, the project Name and Location text boxes are enabled. In the Name text box we enter HokeyPokey; this information immediately appears in the Solution Name text box. If you leave blank spaces between the words in the name of a project, the IDE replaces the blanks with underscores (so Hokey Pokey would become Hokey_Pokey ).

The default location of your projects is C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects. However, you have the option of extending this by clicking at the end of the default location and adding a subdirectory to the path (e.g., \KT101). Whatever you type as the project path this time will appear in the Location text box the next time you begin a new project.

Be sure the Create directory for solution option is checked.

Click on the OK button at the bottom of the window to begin the HokeyPokey project.

There are numerous ways to display this IDE window, which is unnecessarily confusing. However, once you have set up the IDE the way you like it, the format will be remembered by the IDE software and copied each time you open a new project.

The important elements in the IDE are the Solution Explorer, Properties window, Toolbox, and source code, as discussed below.

  • The Solution Explorer should occupy the far-right edge of the screen. This listing of the various elements of the project provides an easy way to access them and bring them to the forefront of the window.

  • The Properties window normally occupies the far-left edge of the screen (or it can be placed below the Solution Explorer). This window is a combination of two windows ” one that displays the properties of a form or control that is currently highlighted in the window template and one that displays the prebuilt source code (events) that may be executed when the user clicks the control. To toggle from properties to events, the programmer must click on the Events icon (the bolt of lightning at the top of the window). To return to the Properties window from the Events window, the Properties icon (to the left of the bolt of lightning) must be clicked.

  • The Toolbox contains all the prebuilt code for all controls. It is shown as a tab on the left edge of Figure 3-4. It must be placed on the screen to continue work on the project.

    image from book
    Figure 3-4: The HokeyPokey project in the IDE main screen

  • The source code listing supports the Form1 template. Since the window template and the source code both occupy so much room in the IDE window, the programmer is forced to display one or the other (not both) in the center of the screen. The F7 key on the keyboard toggles between the Form1 template and the source code. The items in the center of the IDE window are also equipped with tabs at the top (just below the main menu and toolbars ). There is a tab for each window template (FormX.cs[Design]) and source code (FormX.cs).

    If you create several forms in a project, the tabs tend to cover one another, so there is an alternate way to choose what to display: At the top-right corner of the window template area there is a down arrow. If you pass the mouse over the down arrow the words Active Files appear. Clicking on this down arrow presents you with all the files that are actively present in the IDE, and you can choose the one you want to display.

    You do not want to click on the black X just to the right of the down arrow ” this is the mechanism for closing the active file in the center of the IDE completely.

Since the Properties window, the Solution Explorer, and the Toolbox all occupy so much space on the IDE, it was necessary to invent a way to hide these subwindows to provide more space for the source code listing.

Note that there are pushpins in the HokeyPokey IDE window in Figure 3-4. In the Properties window (on the left) and the Solution Explorer (on the right), the pushpins at the top of their respective windows are vertical. If you click on a pushpin, the window immediately hides at the left or right edge of the IDE screen and the name of the window is shown in a tab where the window disappeared. This way, more room can be provided for the window template and the source code listing. If you click on the tab at the left or right edge of the IDE screen, the window that you hid reappears, but the pushpin is in a horizontal position. The only way to keep this window displayed for an extended period of time is to click on the pushpin so it turns to a vertical position.

To operate a project properly in the IDE window, you must have access to the Toolbox. If the Toolbox is not present, click on View in the main menu, followed by Toolbox. The Toolbox will immediately appear adjacent to and partially covering the Properties window, as shown in Figure 3-5.

image from book
Figure 3-5: Adding the Toolbox

We now have the Toolbox and the Properties window competing for the same space. One way to solve this dilemma is to move the Toolbox to the lower right of the IDE screen, below the Solution Explorer. But this requires that we reset the Toolbox window s appearance option from Dockable to Floating, drag the window to a point below the Solution Explorer, convert its appearance option back to Dockable, and dock the window to the right edge of the IDE screen.

Warning  

If you choose Tabbed Document for the presentation form of any subwindow in the IDE screen, the only way to change to another form of presentation is to place the cursor over the subwindow and right-click to change the presentation form.

Another option is to let both windows occupy the same space by hiding one of them. To do this, highlight a window (Properties or Toolbox), click on the pushpin at the top of the window to make it horizontal, and allow the window to hide, leaving its tab displayed along the edge of the IDE screen.

It would have been nice if Microsoft offered some basic layout for the IDE screen, one that the programmer could pick by clicking on an icon at the top of the IDE window. Then the important elements of the project (window template, source code listing, Toolbox, Properties window, and Solution Explorer) could all move to their appointed places.

We normally keep the Toolbox and the Solution Explorer hidden at the left and right extremes of the IDE window, but we keep the Properties window open since the properties of every control that you highlight in the window template must be displayed here. If you are creating a window template with numerous controls on the window, you may want to open the Toolbox and affix its pushpin in the vertical position (to keep it open) until all controls have been placed on the window template. Then you can hide the Toolbox ” you are finished with it. You will always need a wide space in the center of the IDE screen to view the source code.

At this time, the Properties window is in partial view at the left edge of the IDE screen (partially hidden by the Toolbox), and it will remain there because its pushpin is in a vertical position. To uncover the Properties window, click on the Toolbox pushpin to hide it at the left edge of the IDE screen. There should be plenty of room to display the window template or the source code that supports the window template. But if you need more room, click on the pushpin at the top of the Solution Explorer and hide it as well.

Main Menu

The main menu and toolbar at the top of the IDE window include the standard tools for performing all file management functions. They are: File, Edit, View, Project, Build, Debug, Data, Tools, Test, Window, Community, and Help. File is used primarily for project creation, Edit has little or no use in the IDE window, View allows the programmer to add or change subwindows in the IDE screen, Project allows the programmer to add elements to the project, Build builds the project, and Debug runs/executes the project. Data, Tools, Test, Window, and Community are rarely used. The Help menu item can be immensely useful if the programmer remembers to install all of the help files on her PC when the compiler is loaded. Searching the MSDN files on the Internet tends to be an unforgiving process because there is tons of data out there that you cannot use.

Disappearing Subwindows

If any IDE subwindow suddenly disappears (and these sorts of things do happen), you can always bring the window back into the IDE by clicking on the View main menu item. Then click on the window you need in the submenu list to display it on the IDE.

Properties and Events

A property of a control or form (window) includes such items as size , position within the screen, color , fonts, font sizes, etc. An event is associated with a control and causes something significant to happen in the sequence of events. The event occurs when the user of the software either clicks or double-clicks over a specific control. For example, when the user clicks on a button (the most common control in modern Windows programming), the event that has been prescribed occurs. Usually, clicking on a button brings up another window. The code that produces that window is the event. Every control has a default event, and the form of the event is placed in the source code as soon as the programmer highlights the control in the window template and double-clicks it. That is, as soon as the programmer double-clicks on a highlighted control, a default procedure is placed in the source code to support that control.

If only default events were needed, the programmer would never need to use the list of events that is displayed as soon the Events icon is clicked (double-clicking on the control in the window template would create source code for every event). But there are many events that are not the defaults, and instantiating these events requires the Events subwindow.

It is possible to add two event handlers to a particular control: one that is executed every time something happens within the control and one that is executed after the control is exited. For example, say you have a text box control. Each time a keystroke is recorded in the text box, the ASCII character entered is examined by the Text Change handler. A second handler named Leave may be executed only after the text box control has been exited.

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

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