280 likes | 289 Views
Lecture Set 2. Part A: Creating an Application with Visual Studio – Solutions, Projects, Files. Objectives.
E N D
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files
Objectives (Much of this Lecture Set should be read with Visual Studio open in another window. The figures in these slides are VB and not C#. You may prefer to see actual C# versions as shown in the text.) • Introduction to Console and Windows Applications • Understand basic terminology – Solutions Projects, Applications, etc. • See how to create new Solutions, new Applications/Projects • General navigation around a Windows Application and the Solution Explorer and other windows in the Visual Studio IDE
BIG WARNING • Name everything you create with a meaningful name • more on this to come • do not let the system name things for you • we will discuss naming conventions later • from the creation of you application to the smallest of buttons – use meaningful names!!
Console Applications • Visual Studio supports the creation of a number of different types of Applications • Each different type of Application has a different structure and automatically provides support for different applications code • Types of Applications we will work with in this course • Windows Applications • (if time permits) A little work with Web Applications
Windows Applications • We now move on to examine (more thoroughly) Windows Applications • We begin with a look at the Visual Studio 2012 interface for a sample Windows Application • Note the default list of References and the Form (as distinguished from what we saw in the Console interface) • To get full views of information )all files, etc. click on “Show All Files” (top of Solution Explorer window) • More solution information shows up after you do a Build
Solutions and Applications • Look again at the VS 2012 Interface for a Windows Application (one slide back) • What do we see? • Applications? • Solutions • Projects • Toolbox • Look at the files associated with solution
What are these things? • Solution • Each Application that you create is organized by Visual Studio into a Solution • The Solution file is the heart of an Application’s structure • A Solution in turn consists of numerous files and folders, including one or more Projects • Multiple folders – look at slide 7 • The is also a Solution File (.sln) • (not to be monkeyed with)
Project Characteristics • Again, refer back to Slide 11 • A project contains one or more namespaces • Every project has one root namespace • But projects can have many other Namespaces • Every project has a type (Console, Windows, Web etc.) • Each project gets compiled into an Assembly • Every project has an entry point • Usually a function included in the partial class for the main form • Forms apply only to Windows Application projects
Project References • A project has references to .NET Framework class library namespaces (See Slide 11) • .NET automatically adds references to commonly used namespaces based on the type of project template • Use the References tab of the project property page to add additional namespace references
Creating a New Solution (you did this already) • Click on VS 2012 Icon on your desktop. Click on CreateNewProject to display the New Project dialog box • Specify the project template and the project file name • OR pull down the File menu and follow the same directions • Different templates appear based on the installed Visual Studio edition
Creating a New Project • A new project does not exist in a vacuum – it must be part of an application • In VS, you begin with the application you wish to create, and VS organizes everything you do into a Solution (with one or more Projects) • The Application, and everything related to it is encapsulated in a Visual Studio solution • There may be multiple projects inside a solution • The solution takes on the name of the first Project created
Saving a Visual Studio Project • Click File, SaveAll to save the solution the first time • Be sure you understand where all the solution files are being saved (discussed in other documentation related to this course) • By default, a new folder is created for a new solution
Organization of a Visual Studio Solution • The Solution Explorer is used to manage the elements of a solution • The folder named My Project contains configuration information common to all projects • The file AssemblyInfo.cs contains assembly metadata • The References folder contains references to namespaces containing other assemblies • The bin folder contains the executable file produced as a result of compiling the application • A project contains one or more parts
Using the Solution Explorer • The Solution Explorer is a tool window as opposed to adocument window • Use the drill-down interface to expand and collapse folders • Icons appear to identify different file types • File names appear to the right of the file type icon • Use the Solution Explorer to rename files rather than Windows Explorer (Again – look at an example with Visual Studio open and focused on items such as the options menu, the toolbox, and the solution explorer.)
The Solution Explorer Toolbar • The Properties button displays the Properties window • The View Code button displays the Code Editor for a module • The View Designer button displays a visual designer • The visual designer varies based on the file’s contents • Not all files have an associated visual designer • The Refresh button synchronizes files • The Show All Files button displays all folders and files • The View in Diagram button displays a class in a hierarchical view
Windows of the Visual Studio IDE • Windows are of two types • Tool windows are common to all applications • Tool windows are used for development in all Visual Studio languages • Document windows are used to create the visual interface and code for an application • You will see examples of both types of windows in your work
Tool Windows • The Solution Explorer groups the elements of a solution • The Properties window is used to set properties for objects • The Toolbox contains controls that are created on a form • Several tool windows exist for debugging • Refer to Appendix A in the Lecture Notes • The Error List window displays syntax errors • The Output window displays information as a project is compiled
Displaying Tool Windows • Tool windows can be anchored along an edge of the IDE • The process is called docking • Docked windows can be Auto Hidden • Auto Hidden windows appear when the mouse is positioned over the hidden window tab • Floating windows appear anywhere on the desktop • Some tool windows can be configured to appear as document windows
The Appearance of Tool Windows in the Visual Studio IDE (VB)