Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering1 The.NET Framework and the CLI 2D Graphics with GDI+ Visual Studio.NET 2008.

Similar presentations


Presentation on theme: "Software Engineering1 The.NET Framework and the CLI 2D Graphics with GDI+ Visual Studio.NET 2008."— Presentation transcript:

1 Software Engineering1 The.NET Framework and the CLI 2D Graphics with GDI+ Visual Studio.NET 2008

2 Software Engineering2 The.NET Platform Based on the Common Language Infrastructure (CLI) Based on the Common Language Infrastructure (CLI) –ECMA (European Computer Manufacturers’ Association) and ISO standard –CLI exists only for Windows but is being developed for other platforms (Linux, Mac …) Contains a collection of classes called Framework Class Library (FCL) Contains a collection of classes called Framework Class Library (FCL) FCL is shared by all.NET languages FCL is shared by all.NET languages –C++, C#, J#, COBOL, Fortran, Eiffel, …

3 Software Engineering3 Common Language Runtime (CLR) Executes managed code Executes managed code Compilation is performed in two phases: Compilation is performed in two phases: 1.Program is compiled into the Microsoft Common Intermediate Language (CIL) CIL is composed of instructions for the CLRCIL is composed of instructions for the CLR 2.CLR links FCL function calls and compiles the program to machine code.NET Web Services are applications that expose (make available) functionality to clients through the Internet.NET Web Services are applications that expose (make available) functionality to clients through the Internet

4 Software Engineering4 Common Language Infrastructure (CLI)

5 Software Engineering5 C++/CLI When we program in C++ using the.NET framework, we program in an extension of C++ called C++/CLI When we program in C++ using the.NET framework, we program in an extension of C++ called C++/CLI C++/CLI is a binding between the ISO standard C++ language and CLI C++/CLI is a binding between the ISO standard C++ language and CLI C++/CLI retains all the features of C++ C++/CLI retains all the features of C++ C++/CLI can use the.NET FCL C++/CLI can use the.NET FCL C++/CLI can use all CTS types C++/CLI can use all CTS types

6 Software Engineering6 C++ and the CTS types Classes can be defined in C++/CLI in four ways: Classes can be defined in C++/CLI in four ways: class MyClass { … };//native C++ class ref class MyClass { … };//abstract base class value class MyClass { … };//concrete class interface class MyClass { … };//interface class A new safe pointer type called handle is introduced A new safe pointer type called handle is introduced MyClass ^ myObject = gcnew MyClass( ); // ^ is for handle myObject->myMethod( “Hello” );// old -> syntax When myObject goes out of scope its memory is automagically released – no need to worry about destructors and such.

7 Software Engineering7 C++/CLI Handles In C++/CLI a handle is created using the In C++/CLI a handle is created using thegcnewkeyword –With native pointers new is still used –gc stands for “garbage collected” Literal strings like ”Hello” are resolved to the Literal strings like ”Hello” are resolved to the System::String ^ type (ISO C++ would resolve to const char* )

8 Software Engineering8 2D Graphics in.NET FCL contains a 2D graphics API called Graphical Device Interface Plus or GDI+ FCL contains a 2D graphics API called Graphical Device Interface Plus or GDI+ GDI+ is part of the System::Drawing namespace and some other namespaces GDI+ is part of the System::Drawing namespace and some other namespaces Such as System::Drawing::Drawing2D Such as System::Drawing::Drawing2D and System::Drawing::Drawing3D and more.. and System::Drawing::Drawing3D and more.. There is a newer graphics API called Direct2D There is a newer graphics API called Direct2D but it is criticized as to complex and having other issues but it is criticized as to complex and having other issues

9 Software Engineering9 Graphics Coordinate System x-axis ( 0, 0 ) y-axis (x, y) Coordinates are measured in pixels

10 Software Engineering10 Graphics Context and Objects All Windows Form objects inherit a All Windows Form objects inherit a virtual void Paint( PaintEventArgs * paintEvent ) event handler that contains all drawing code In the Paint event the Graphics, Pen, and Brush objects (and others) are extracted to perform drawing Text is drawn by DrawString( ) calls

11 Software Engineering11 2-D Drawing Functions DrawLine( Pen *p, int x1, int x2, int y1, int y2 ) DrawLine( Pen *p, int x1, int x2, int y1, int y2 ) DrawRectangle( Pen * p, int x, int y, int w, int h ) DrawRectangle( Pen * p, int x, int y, int w, int h ) FillRectangle( Brush *b, int x, int y, int w, int h ) FillRectangle( Brush *b, int x, int y, int w, int h ) DrawEllipse( Pen *p, int x, int y, int w, int h ) DrawEllipse( Pen *p, int x, int y, int w, int h ) FillEllipse( Brush *b, int x, int y, int w, int h ) FillEllipse( Brush *b, int x, int y, int w, int h ) DrawArc( Pen *p, int x, int y, int w, int h, int, stA, int swA ) DrawArc( Pen *p, int x, int y, int w, int h, int, stA, int swA ) DrawPie( Pen *p, int x, int y, int w, int h, int, stA, int swA ) DrawPie( Pen *p, int x, int y, int w, int h, int, stA, int swA ) FillPie( Brush *b, int x, int y, int w, int h, int, stA, int swA ) FillPie( Brush *b, int x, int y, int w, int h, int, stA, int swA ) DrawLines( Pen *p, Point [ ] ) DrawLines( Pen *p, Point [ ] ) DrawPolygon( Pen *p, Point [ ] ) DrawPolygon( Pen *p, Point [ ] ) FillPolygon( Brush *b, Point [ ] ) FillPolygon( Brush *b, Point [ ] )

12 Software Engineering12 Mouse Event Handling GUI controls are derived from the class GUI controls are derived from the class System::Windows::Forms::Control System::Windows::Forms::Control All can handle mouse and keyboard events All can handle mouse and keyboard events Mouse event information is passed by a MouseEventArgs object Mouse event information is passed by a MouseEventArgs object The Mouse Events are: The Mouse Events are: –MouseEnter, MouseLeave, MouseDown, MouseHover, MouseMove, MouseUp The MouseEventArgs Properties are: The MouseEventArgs Properties are: –Button, Clicks, x, y

13 Software Engineering13 Keyboard Event Handling Keyboard event information is passed by a Keyboard event information is passed by a KeyEventArgs object KeyEventArgs object The Keyboard Events are: The Keyboard Events are: –KeyUp, KeyDown, KeyPress The KeyEventArgs Properties are: The KeyEventArgs Properties are: –KeyChar, Handled, Alt, Control, Shift, KeyCode, KeyData, KeyValue, Modifiers

14 Software Engineering14 The ArrayList Container.NET equivalent of a dynamic array (vector).NET equivalent of a dynamic array (vector) Has Capacity and Count properties Has Capacity and Count properties Main methods: Main methods: –Add –Clear –Contains –IndexOf –Insert array still can be used array still can be used –Remove –RemoveAt –RemoveRange –Sort –TrimToSize

15 Software Engineering15 Explicit Type Conversions in.NET Standard C++ supports two explicit cast operations: Standard C++ supports two explicit cast operations: –static_cast ( old_type ) –dynamic_cast ( old_type ) –const_cast ( old_type ) –reinterpret_cast ( old_type ) The operation static_cast performs conversion at compile time The operation static_cast performs conversion at compile time The operation dynamic_cast converts at run-time The operation dynamic_cast converts at run-time.NET boxing converts a value type to a managed type using the __box( ) operation (byte by byte).NET boxing converts a value type to a managed type using the __box( ) operation (byte by byte)

16 Software Engineering16 Spatial Visual App


Download ppt "Software Engineering1 The.NET Framework and the CLI 2D Graphics with GDI+ Visual Studio.NET 2008."

Similar presentations


Ads by Google