creating an application

Upload: mahreen-ilahi

Post on 27-Feb-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Creating an Application

    1/37

    Lecture 2

    Creating an Application

    with Visual Studio Solutions, Projects, Files

  • 7/25/2019 Creating an Application

    2/37

    Slide2

    Objectives

    (Much of this Lecture Set should be read with Visual Studio open inanother window)

    Introduction to Console and WindowsApplications

    nderstand basic ter!inolo"# $ Solutions%rojects& Applications& etc'

    See how to create new Solutions& newApplications%rojects

    eneral navi"ation around a WindowsApplication and the Solution *+plorer andother windows in the Visual Studio I,*

  • 7/25/2019 Creating an Application

    3/37

    Slide3

    -I WA./I/

    /a!e ever#thin" #ou create with a!eanin"ful na!e !ore on this to co!e

    do not let the s#ste! na!e thin"s for #ou

    we will discuss na!in" conventions later

    fro! the creation of #ou application to thes!allest of buttons $ use !eanin"fulna!es00

  • 7/25/2019 Creating an Application

    4/37

    Slide4

    Console Applications

    Visual Studio supports the creation of anu!ber of di1erent t#pesof Applications

    *ach di1erent t#pe of Application has adi1erent structure and auto!aticall#

    provides support for di1erent applicationscode

    2#pes of Applications we will wor3 with inthis course Console Applications

    Windows Applications

  • 7/25/2019 Creating an Application

    5/37

    Slide5

    2#pes of Applications

  • 7/25/2019 Creating an Application

    6/37

    Slide

    2he Console Class (review)

    Console is S#ste! class (it is in the S#ste!/a!espace) $ it is part of the !scorlib librar#which as we have seen is one of the librar#,LLs that is auto!aticall# loaded with thee+ecution of ALL VS applications' !scorlib is discussed in the Chapter 4 Lecture

    Set - (around slide 56)' We will discuss.eferences a little later in this slide set'

    2his Console class supports a nu!ber of

    !ethods& includin" !ethods perfor!in"actions related to 3e#board input (.ead and.eadLine) and screen output (Write andWriteLine)

  • 7/25/2019 Creating an Application

    7/37Slide!

    Co!!ents re Console Applications(optional)

    .ecall that Visual Studio 5776 provides us with aconvenient interface for applicationsdevelop!ent'

    We now e+a!ine the VS 5776 interface for a

    Console Application

    2he Console Application provides a Module for#ou to write code (a Windows App provides b#default a 8or! for the insertion of tools) 9ouhave a !ini!al set of referenced na!espaces(classes fro! the 8CL) 2here are no classes to support 8or!s or ,rawin"&

    etc

  • 7/25/2019 Creating an Application

    8/37Slide"

    VS Interface : Console Application(optional)

  • 7/25/2019 Creating an Application

    9/37Slide#

    Windows Applications

    We now !ove on to e+a!ine (!ore thorou"hl#)Windows Applications

    We be"in with a loo3 at the Visual Studio 5776interface for a sa!ple Windows Application

    /ote the default list of .eferences and the 8or!(as distin"uished fro! what we saw in theConsole interface) 2o "et full views of infor!ation )all ;les& etc' clic3 on

  • 7/25/2019 Creating an Application

    10/37Slide$%

    VS 5776 Interface for WindowsApplication

  • 7/25/2019 Creating an Application

    11/37Slide$$

    Solution with 2wo %rojects

  • 7/25/2019 Creating an Application

    12/37Slide$2

    Solutions and Applications

    Loo3 a"ain at the VS 5776 Interface for aWindows Application (one slide bac3)

    What do we see> Applications>

    Solutions

    %rojects

    Other

  • 7/25/2019 Creating an Application

    13/37Slide$3

    What are these thin"s>

    Solution *ach Application that #ou create is

    or"ani?ed b# Visual Studio into a Solution

    2he Solution ;le is the heart of an

    Application@s structure A Solution in turn consists of nu!erous ;les

    and folders& includin" one or !ore %rojects

    Multiple folders $ loo3 at slide 47

    2he is also a Solution 8ile ('sln) (not to be !on3e#ed with)

  • 7/25/2019 Creating an Application

    14/37Slide$4

    A Visual Studio Solution

  • 7/25/2019 Creating an Application

    15/37Slide$5

    Solution *+plorer

  • 7/25/2019 Creating an Application

    16/37Slide$

    A Solution $ As Seen in 9our 8ilesS#ste!

  • 7/25/2019 Creating an Application

    17/37Slide$!

    %roject Characteristics

    A"ain& refer bac3 to Slide 44 A project contains one or !ore na!espaces

    *ver# project has one root na!espace -ut projects can have !an# other /a!espaces

    *ver# project has a t#pe (Console& Windows& etc') *ach project "ets co!piled into an Asse!bl#

    *ver# project has an entr# point A Subprocedure na!ed Main or a for! 8or!s appl# onl# to Windows Application projects

  • 7/25/2019 Creating an Application

    18/37Slide$"

    A %roject (continued)

  • 7/25/2019 Creating an Application

    19/37Slide$#

    %roject .eferences

    A project has references to '/*28ra!ewor3 class librar# na!espaces (ne+t 5 slides)

    '/*2 auto!aticall# adds references to

    co!!onl# used na!espaces based onthe t#pe of project te!plate

    se the .eferences tab of the project

    propert# pa"e to add additionalna!espace references

  • 7/25/2019 Creating an Application

    20/37Slide2%

    %roject %ropert# %a"e $ .eferences2ab

  • 7/25/2019 Creating an Application

    21/37Slide2$

    So!e 8CL /a!espaces 2hat Can -e.eferenced

  • 7/25/2019 Creating an Application

    22/37Slide22

    Creatin" a /ew Solution (#ou did thisalread#)

    Clic3 on VS 5776 Icon on #our des3top'Clic3 on Create&ewProjectto displa#the /ew %roject dialo" bo+ Specif# the project te!plate and the project

    ;le na!e O. pull down the 8ile !enu and follow

    the sa!e directions

    ,i1erent te!plates appear based on theinstalled Visual Studio edition

  • 7/25/2019 Creating an Application

    23/37

    Slide23

    /ew %roject ,ialo" -o+

  • 7/25/2019 Creating an Application

    24/37

    Slide24

    Creatin" a /ew %roject

    A new project does not e+ist in a vacuu! $ it!ust be part of an application

    In VS& #ou be"in with the application #ou wishto create& and VS or"ani?es ever#thin" #ou do

    into a Solution (with one or !ore %rojects) 2he Application& and ever#thin" related to it is

    encapsulated in a Visual Studio solution 2here !a# be !ultiple projects inside a solution

    2he solution ta3es on the na!e of the ;rst %rojectcreated

  • 7/25/2019 Creating an Application

    25/37

    Slide25

    View of a new project (in asolution)

    Solution with 2hree (related) %rojects

  • 7/25/2019 Creating an Application

    26/37

    Slide2

    Solutions and %rojects

    HangmanGameis the na!e of the solution $ it is atthe heart of #our application and controlsever#thin"

    A new solution is created fro! a project te!plate

    2his solution contains three %rojects (/ote $ pic3#our solution& projects& and co!ponents na!escarefull#') *ach allows #ou to rena!e $ ,O I2 $ in a !eanin"ful

    wa# before #ou do #our ;rst save'

    2he solution ;le has a su+ .sln' ,o not chan"e this e+tension

    2e!plate Application Solution (with one or !oreprojects)

  • 7/25/2019 Creating an Application

    27/37

    Slide2!

    Savin" a Visual Studio %roject

    Clic3 File& Sa'eAllto save the solutionthe ;rst ti!e

    Specif# the solution na!e and the folderwhere the solution will be created -# default& a new folder is created for a new

    solution

    A"ain $ pic3 all na!es carefull#

  • 7/25/2019 Creating an Application

    28/37

    Slide2"

    Save %roject ,ialo" -o+

  • 7/25/2019 Creating an Application

    29/37

  • 7/25/2019 Creating an Application

    30/37

    Slide3%

    Solution *+plorer with All 8olders*+panded

  • 7/25/2019 Creating an Application

    31/37

    Slide3$

    Solution 8iles Appearin" in Windows*+plorer

  • 7/25/2019 Creating an Application

    32/37

    Slide32

    sin" the Solution *+plorer

    2he Solution *+plorer is a tool window asopposed to adocu!ent window se the drill:down interface to e+pand and

    collapse folders

    Icons appear to identif# di1erent ;le t#pes 8ile na!es appear to the ri"ht of the ;le

    t#pe icon

    se the Solution *+plorer to rena!e ;les

    rather than Windows *+plorer(A"ain $ loo3 at an e+a!ple with Visual Studio open and focused

    on ite!s such as the options !enu& the toolbo+& and thesolution e+plorer')

  • 7/25/2019 Creating an Application

    33/37

    Slide33

    2he Solution *+plorer 2oolbar

    2he %roperties button displa#s the %ropertieswindow 2he View Code button displa#s the Code *ditor for

    a !odule 2he View ,esi"ner button displa#s a visual

    desi"ner 2he visual desi"ner varies based on the ;le@s contents /ot all ;les have an associated visual desi"ner

    2he .efresh button s#nchroni?es ;les

    2he Show All 8iles button displa#s all folders and;les 2he View in ,ia"ra! button displa#s a class in a

    hierarchical view

  • 7/25/2019 Creating an Application

    34/37

    Slide34

    Windows of the Visual Studio I,*

    Windows are of two t#pes 2ool windows are co!!on to all applications

    2ool windows are used for develop!ent in allVisual Studio lan"ua"es

    ,ocu!ent windows are used to create thevisual interface and code for an application

  • 7/25/2019 Creating an Application

    35/37

    Slide35

    2ool Windows

    2he Solution *+plorer "roups the ele!entsof a solution 2he %roperties window is used to set

    properties for objects

    2he 2oolbo+ contains controls that arecreated on a for! Several tool windows e+ist for debu""in"

    .efer to Appendi+ A

    2he *rror List window displa#s s#nta+ errors 2he Output window displa#s infor!ation as

    a project is co!piled

  • 7/25/2019 Creating an Application

    36/37

    Slide3

    ,ispla#in" 2ool Windows

    2ool windows can be anchored alon" aned"e of the I,* 2he process is called doc3in" ,oc3ed windows can be Auto Bidden

    Auto Bidden windows appear when the !ouseis positioned over the hidden window tab

    8loatin" windows appear an#where on thedes3top

    So!e tool windows can be con;"ured toappear as docu!ent windows

  • 7/25/2019 Creating an Application

    37/37

    2he Appearance of 2ool Windows in theVisual Studio I,*