Neal Stublen [email protected]. Overview of.NET Windows Applications Microsoft Windows OS / Intel...
If you can't read please download the document
Neal Stublen [email protected]. Overview of.NET Windows Applications Microsoft Windows OS / Intel Platform Windows Application File SystemNetworkDisplay
Windows Applications Microsoft Windows OS / Intel Platform
Windows Application File SystemNetworkDisplay
Slide 4
.NET Applications.NET Framework Class Libraries Common Language
Runtime (CLR).NET Application (or "Assembly") Non-Microsoft OS? /
Non-Intel Platform? Microsoft Windows OS / Intel Platform File
SystemNetworkDisplay
Slide 5
C#,.NET, and Windows C# Source Files.NET "Assembly" (MSIL) C#
Compiler.NET "Assembly" (MSIL) CLR "Native" Code
Slide 6
How does C# compare? VB.NET, F#, Managed VC++ are other.NET
languages. They all compile into MSIL assemblies that run on
the.NET CLR. Java has many similarities, but the.NET class library
is different from the Java support classes. Might be considered a
"safer" version of C++.
Slide 7
Using Visual Studio
Slide 8
Visual Studio Summary Open/close a project/solution Project A
collection of files that are used to generate an application or
class library.csproj file extention Solution A collection of
projects.sln file extension Projects target a specific version of
the.NET Framework
Slide 9
Visual Studio Summary Menus and toolbars can be customized
Solution Explorer manages project files Form Designer allows us to
create and modify forms Controls are added to a form using the
Toolbox Properties change the appearance and/or function of a form
or control
Slide 10
Visual Studio Summary Tabbed windows can be docked just about
anywhere Tabbed windows can be floating or docked Tabbed windows
can be pinned or hidden Code Editor allows you to edit source code
Editing window can be split into two panes
Slide 11
Visual Studio Summary Settings can be imported and exported We
will work with WinForms applications in this class.
Slide 12
Designing a Form
Slide 13
Form Design Summary Control Toolbox Tab Order Properties Window
Name, Text Enabled, ReadOnly, TabOrder, TabStop, TextAlign
AcceptButton, CancelButton, StartPosition Access keys (&)
Document Outline View Renaming and saving files
Slide 14
Form Exercise Create a project named "InvoiceTotal" in your S:
folder Reproduce the following form: Consider tab order, access
keys, etc.
Slide 15
Object Oriented Programming
Slide 16
Object-Oriented Programming .NET represents everything as an
"object" What objects can we identify in our InvoiceTotal
application? Forms, Controls Objects are made up of data and a set
of functions that act on that data What data would be stored in the
InvoiceTotal form and controls? Position, Text What functions might
use that data?
Slide 17
Objects and Classes An object is represented by a "class" A
class has member data Variables A class has member functions
Methods
Slide 18
A class Definition class Counter { };
Slide 19
A class Definition class Counter { // class is a keyword that
tells the // compiler we are defining a new type of // object.
};
Slide 20
The class Name (or Type) class Counter { // Counter is the name
of the new class // type. };
Slide 21
Member Variables class Counter { private int mValue; // We
declare member variables that will // hold data for the class.
};
Slide 22
Member Visibility class Counter { private int mValue; //
private is a keyword that tells the // compiler the class member is
not visible // to other objects. };
Slide 23
Member Type class Counter { private int mValue; // int is a
built-in type that tells the // compiler we are defining an integer
// value. };
Slide 24
Member Name class Counter { private int mValue; // mValue is
the name we will use when // referring to this data member. };
Slide 25
Member Initializer class Counter { private int mValue = 0; //
(Optional) We can assign an initial value to // the data member.
};
Slide 26
A class Constructor class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } };
Slide 27
Constructor Visibility class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // public is a keyword that tells the // compiler
the class member is visible to // other objects. };
Slide 28
Constructor Name class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // Counter repeats the class name, which // tells
the compiler we are defining a // constructor for the class.
};
Slide 29
Constructor Parameter class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // int inInitialValue is a parameter of // the
constructor. It is used to set the // initial state of the object.
};
Slide 30
Constructor Body class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // The body of the constructor assigns // initial
values to any data members of // the class. };
Slide 31
Assignment Operator class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // = is an assignment operator that assigns // a
value to a variable. };
Slide 32
A class Method class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // Increment the counter by one. public int
Increment() { return ++mValue; } };
Slide 33
Method Visibility class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // Increment the counter by one. public int
Increment() { return ++mValue; } };
Slide 34
Method Return Type class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // Increment the counter by one. public int
Increment() { return ++mValue; } };
Slide 35
Method Name class Counter { private int mValue; // Constructor
public Counter(int inInitialValue) { mValue = inInitialValue; } //
Increment the counter by one. public int Increment() { return
++mValue; } };
Slide 36
Method Body class Counter { private int mValue; // Constructor
public Counter(int inInitialValue) { mValue = inInitialValue; } //
Increment the counter by one. public int Increment() { return
++mValue; } };
Slide 37
Prefix/Postfix Operators class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // Increment the counter by one. public int
Increment() { return ++mValue; } };
Slide 38
Code Comments class Counter { private int mValue; //
Constructor public Counter(int inInitialValue) { mValue =
inInitialValue; } // Increment the counter by one. public void
Increment() { mValue = mValue + 1; } }; Counter myCounter = new
Counter(0);
Slide 39
Instantiating a class class Counter {... }; Counter myCounter =
new Counter(0); Counter yourCounter = new Counter(10);
Slide 40
Instantiating a class class Counter {... }; Counter myCounter =
new Counter(0); Counter yourCounter = new Counter(10); // new is a
keyword that tells the compiler // we want to create an instance of
the class. // We have created two instances of the Counter //
class.
Slide 41
Instantiating a class class Counter {... }; Counter myCounter =
new Counter(0); myCounter.Increment(); // We call a method by using
the . operator on // a class instance. // All statements are
terminated by a semi-colon.
Slide 42
A Closer Look at Our Form
Slide 43
Form Summary The Code Editor allows us to expand and collapse
blocks of code. Forms are just objects Forms are created by making
changes to the objects properties and calling the objects methods.
The Designer just adds code to the forms class.
Slide 44
Making the Form Do Something
Slide 45
Event Summary Forms and controls dispatch events Event handlers
respond to events
Slide 46
Suggestions Install Visual Studio Visual Studio Express 2013
for Windows Desktop Projects at end of each chapter Experiment