Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Studio.NET Part 2 dbg --- Using the VS.NET Integrated Development Environment.

Similar presentations


Presentation on theme: "Visual Studio.NET Part 2 dbg --- Using the VS.NET Integrated Development Environment."— Presentation transcript:

1 Visual Studio.NET Part 2 dbg --- Using the VS.NET Integrated Development Environment

2 2 Visual Studio.NET A development “shell” for creating applications –Visual designer –Context editor with Intellisense for typing code –Programming language compilers –Run/Debug environment

3 3 Visual Studio.NET We will use Visual Studio.NET and the C# programming language to develop Graphical User Interface (GUI) applications. Notice that GUIs look very different from the console applications you made in CIS202.

4 4 Installing Visual Studio.NET 2005 If you have Windows XP with Service Pack 2, Windows Vista, or a Macintosh Computer running Windows XP via Bootcamp or Parallels, you can install Visual Studio V2005. Obtain 2 CDROMs from School of Math & Science office (2 nd floor, Madison Avenue end of Science Center). Follow the provided instructions.

5 5 Starting Visual Studio.NET 1.Start Visual Studio.NET from a Desktop shortcut. -or- 2., Programs:

6 6 Creating a New Project

7 7 Select a Language

8 8 Select a Template

9 9 Assign Path and Meaningful Name

10 10 The Visual Studio IDE

11 11 Adjust the View in the IDE To undock a docked window so it floats on the screen, drag it by its title bar away from the edge of the application window or double-click its title bar. Double-click a window’s title bar to return the window to its default location. To hide a docked window, click its Auto Hide button. The window will be displayed as a tab at the edge of the screen. You can redisplay it by placing the mouse pointer over the tab. To return all windows to their original Visual Studio positions, choose Window, Reset Window Layout in the menu.

12 12 Setting Default Location for Projects Choose Tools, Options in the menu. Click the + in front of Projects and Solutions. Click General under Projects and Solutions. Click the Browse button next to Visual Studio projects location: and choose the folder you created for this course. Make a folder on drive c: rather than in My Documents!

13 13 Visual Studio Solutions A solution is comparable to a workspace in C++ V6. The first project created in the solution gives its name to the solution and thus to the namespace as well. At times, it may be advisable to change the name of either the project or the namespace.

14 14 The Designer View The IDE displays a design-time view of the visible portion, if any, of the object being designed. A Designer view of a form object appears by default in a new project. The form will be a window at run time.

15 15 The Code View The IDE provides an editor for building the actual code for the class or classes that make up your new project. Pre-existing (library) code is not visible here. Choose View Code icon in Solution Explorer or click Code tab in Designer Window.

16 16 Adjusting Properties at Design Time The IDE provides a convenient window for assigning values to object properties at design time. The Properties Window displays all available properties for any object that is selected within the IDE. Use F4 or View, Properties Window from menu, if the Properties Window is not visible.

17 17 Some Form Properties A number of form properties can be changed at design time. Dimensions of the form can be adjusted by dragging the selection handles or by assigning values to the Size Property in the property window. The screen position of the window can be adjusted by choosing values for the StartPosition property.

18 18 More Form Properties Every form should have a Text property that reflects the role of the form in the project; the text typed as the Text Property appears in the Titlebar of the window. The form icon can also be changed by assigning a new icon file to the Icon property; later, we will learn how to create a custom icon.  FormWithChangedProperties

19 19 Compiling and Running Choose Build, Build Solution from menu to compile without running. 3 ways to run (and build, if necessary) an application: –Choose Debug, Start Debugging from menu –Press F5 –Click the Debug tool in the toolbar

20 20 The Compilation Process

21 21 The Window Control Box When the Windows Application project runs, the form appears as a Window object. The project remains running until the window is closed. The window can be closed by clicking the in the Control Box in the Titlebar.

22 22 The Window Control Box The Control Box also contains icons for minimizing the window to a taskbar item and maximizing the window to full screen size. The Maximize icon becomes a Restore Down icon if the window is maximized. All, some, or none of these icons may be displayed by setting the ControlBox, MinimizeBox, and/or MaximizeBox properties to true or false.  ControlBox Minimize Maximize Restore Down Close

23 23 Show in TaskBar You may not wish to have a Taskbar item appear to represent your window. Setting the Show in TaskBar property to False at design time will accomplish this.

24 24 Let’s Review C++ File Structure Before looking at the C#.NET V2005 file structure of the project we just created, we’ll review how C++ V6 and. NET versions of projects look in My Computer.

25 File Structure of a C++ V6 or.NET Console Application HW777.dsw or (.sln) HW777.ncb HW777.dsp HW777.plg HW777.opt source.cpp HW777.exe * source.obj * HW777.pdb HW777.pch * HW777.ilk vc60.pdb vc60.idb * Note: Debug folder contains all 7 subfiles. Release folder only contains 4 asterisked subfiles. HW777 Debug or Release

26 26 Structure of a C# Solution The IDE creates a collection of files called a solution. Normally, a solution contains one project. A project generates an application. Multiple projects may be contained within one solution.

27 27 C#.NET V2005 Solution Explorer Window

28 28 Let’s Look at C# V2005 File Structure Now we’ll look at how the C#.NET V2005 project we just created looks in My Computer.

29 29 File Structure of C#.NET V2005 Project

30 HW999binobjPropertiesDebug HW999.sln HW999.suo HW999.csproj HW999.exe frmDeesDiner.cs frmDeesDiner.Designer.cs Program.cs frmDeesDIner.resx File Structure of a C#.NET V2005 Windows Application HW999

31 31 Important Files The project file (with an extension of.csproj) keeps track of the files that make up the project and records various settings for the project. The solution file (with an extension of.sln) keeps track of the projects that make up the solution. When you open a project file, Visual Studio opens the solution that contains the project. And when you open a solution file, Visual Studio automatically opens all the projects contained in the solution.

32 32 Form Files In C# 2005, each form is defined by two C# files. Each file contains a partial class. The file with the.cs extension contains the code that is entered by the programmer; the file with the Designer.cs extension contains the code that is generated when the programmer works with the Form Designer. When the project is compiled, these two partial classes are combined into a single class that determines the appearance and operation of the form.

33 33 Other Files A source code file that doesn’t define a form is usually stored in a single C# source file that contains a single class. The References folder contains references to the assemblies for the namespaces that the application can use. These namespaces contain the classes that the project requires. In most cases, all the references that you need are included when the project is created.

34 34 Opening a C#.NET V2005 Project from My Computer To open a project from My Computer, double- click the solution file (ex. Homework999.sln). The solution file (ex. Homework999.sln), which is a file that contains pointers to all Projects within a Solution, is now stored outside of the Project folder.

35 35 Opening a C#.NET V2005 Project from Visual Studio.NET

36 36 E-mailing Assignments to Professor When e-mailing an assignment to me, you must submit the circled folder and all of its contents. You should “zip” this folder into 1 file for easy transmission using a program like WinZip, 7- Zip, ZipItFree, or JZip. The course website has links to the appropriate download sites.

37 37 “Zipping” a Folder via WinZip 1.Navigate to folder in My Computer. 2.Right-click and choose WinZip from context menu. 3.Choose 2 nd option, Add to Homework999.zip. 4.One file, Homework999.zip, containing the contents of entire Homework999 folder, is created.

38 38 Start a New E-mail Message 1.Start http://mail.strose.edu and click New message. Add professor e-mail address in To: area and assignment number in Subject: area.

39 39 Adding.zip File as an Attachment 1.Click in message toolbar. You will see the Attachments dialog. 2.Browse for your.zip file.

40 40 Adding.zip File as an Attachment 1.After the file name displays in Choose a file to attach box, click the Attach button. 2.The.zip file will then show as a Current File Attachment. Click the Close button.

41 41 Send E-mail Message Your e-mail message should now display the attached.zip file. Send the e-mail message.

42 Events Application Lifetime and Object Responses to Stimuli

43 43 Event-Driven Applications Objects can both send, and react to, special messages or stimuli called events. By and large, event-driven applications run until they are stopped by user intervention. Event driven applications respond to any events that they detect.

44 44 Events EventOccurs when… Common control events Click…the user clicks the control Double-click…the user double-clicks the control Enter…the focus is moved to the control Leave...the focus is moved from the control Common form events Load…the form is loaded into memory Closing…the form is closing Closed…the form is closed

45 45 Reacting to a Click Event An object can react to the event caused by clicking the mouse. Objects react to events by executing code within a special method (function) called an event handler. A specific event (clicking this object) causes the event handler to run. Any instructions coded within the event handler are then executed.  FirstEvent

46 46 Associating Handlers with Events An event handler is a method (function) that contains the code that will be executed when a particular event occurs for the a specific object. Event handlers may be associated with objects and their events in several ways: –The default handler for a control (often the Click event handler) will be added automatically to the code area, when you double-click the control in the Designer View. –Or, you may double-click a particular event in the Properties Window.

47 47 Associating Events via the Property Window A list of all available events for an object is available in the Properties window if the is toggled. Double-click the appropriate event. Selecting an event here causes an event handler skeleton to be created in the code area.

48 48 A New Handler Function Event Handler methods are named with a combination of the object and the event.

49 49 “Event Wiring” A separate line of code is automatically written (in the Windows Generated Code region of the formName.Designer.cs file) to connect the event handler to the event. You can think of this as “event wiring” or “automatic registration” of the event handler method.

50 50 Structure of a Handler An event handler is a void method with two arguments. The sender argument of type Object represents the originator of the event.

51 51 Structure of a Handler The e argument of type EventArgs represents the set of data fields, if any, that arrive with the event. EventArgs fields vary with the class that originates, or raises, the event.


Download ppt "Visual Studio.NET Part 2 dbg --- Using the VS.NET Integrated Development Environment."

Similar presentations


Ads by Google