Microsoft Windows is a graphical interface. Users interact with applications through windows, which are graphical representations of application data and options. To take advantage of the rich user experience that Windows offers, you should design your applications so that they expose their functionality to the user graphically.
Although the .NET Framework provides a wide array of graphical controls and methods that allow you to create fully visual applications, you might want to render your own graphic content in your application or create a custom appearance for a control.
GDI+ is the name given to the .NET Framework's managed implementation of the GDI, which is used to display graphical information on the computer screen. This interface is wrapped into six different namespaces, which are broken down by related functionality.
The System.Drawing Namespaces
The array of functionality exposed by the System.Drawing namespaces is vast. Although an exhaustive dissection of these namespaces and their associated functionality is beyond the scope of this book, this lesson will familiarize you with the techniques involved in accessing the classes and methods they contain.
Almost all of the classes you will need to render graphics are provided in the System.Drawing namespace. For advanced rendering, you might need some classes in the System.Drawing.2D namespace, and to enable printing, you will need classes in the System.Drawing.Printing namespace.
The Graphics Object
The principal object used in rendering graphics is the Graphics object. The Graphics object is located in the System.Drawing namespace. A Graphics object represents the drawing surface of a visual element, such as a form, a control, or an Image object. Thus, a form has an associated Graphics object that can be used to draw inside the form; a control has an associated Graphics object that is used to draw inside the control, and so on. All of the actual rendering of visual elements is done by the Graphics object.
Because each Graphics object must be associated with a visual element, you cannot directly instantiate one with a call to the constructor. Instead, you must create a Graphics object directly from the visual element. Classes that inherit from Control (including Form) expose a CreateGraphics method that allows you to get a reference to the Graphics object associated with that control.
To render a complex shape
Obtain a reference to the Graphics object associated with the drawing surface you want to render on.
Create a new instance of the GraphicsPath class.
Add figures to the GraphicsPath using the methods the GraphicsPath class provides.
Call Graphics.DrawPath to draw the outline of the path or Graphics.FillPath to draw a filled GraphicsPath.
Dispose the Graphics object.
RELATED POST
DAY 11 OOPS INTRODUCTION
DAY 12 POLYMORPHISM
DAY 13 INHERITANCE AND POLYMORPHISM
DAY 14 EBUGGING TOOLS IN DOT NET
DAY 15 DEBUG AND TRACE IN CLASSES
DAY 16 UNIT TEST PLAN
DAY 17 EXCEPTIONS IN VISUAL STUDIO
DAY 19 ADO.NET INTRODUCTION
DAY 20 DATA ACCESSING IN DOT NET
DAY 21 DATA BASE OBJECTS
Although the .NET Framework provides a wide array of graphical controls and methods that allow you to create fully visual applications, you might want to render your own graphic content in your application or create a custom appearance for a control.
GDI+ is the name given to the .NET Framework's managed implementation of the GDI, which is used to display graphical information on the computer screen. This interface is wrapped into six different namespaces, which are broken down by related functionality.
The System.Drawing Namespaces
The array of functionality exposed by the System.Drawing namespaces is vast. Although an exhaustive dissection of these namespaces and their associated functionality is beyond the scope of this book, this lesson will familiarize you with the techniques involved in accessing the classes and methods they contain.
Almost all of the classes you will need to render graphics are provided in the System.Drawing namespace. For advanced rendering, you might need some classes in the System.Drawing.2D namespace, and to enable printing, you will need classes in the System.Drawing.Printing namespace.
The Graphics Object
The principal object used in rendering graphics is the Graphics object. The Graphics object is located in the System.Drawing namespace. A Graphics object represents the drawing surface of a visual element, such as a form, a control, or an Image object. Thus, a form has an associated Graphics object that can be used to draw inside the form; a control has an associated Graphics object that is used to draw inside the control, and so on. All of the actual rendering of visual elements is done by the Graphics object.
Because each Graphics object must be associated with a visual element, you cannot directly instantiate one with a call to the constructor. Instead, you must create a Graphics object directly from the visual element. Classes that inherit from Control (including Form) expose a CreateGraphics method that allows you to get a reference to the Graphics object associated with that control.
To render a complex shape
Obtain a reference to the Graphics object associated with the drawing surface you want to render on.
Create a new instance of the GraphicsPath class.
Add figures to the GraphicsPath using the methods the GraphicsPath class provides.
Call Graphics.DrawPath to draw the outline of the path or Graphics.FillPath to draw a filled GraphicsPath.
Dispose the Graphics object.
RELATED POST
DAY 11 OOPS INTRODUCTION
DAY 12 POLYMORPHISM
DAY 13 INHERITANCE AND POLYMORPHISM
DAY 14 EBUGGING TOOLS IN DOT NET
DAY 15 DEBUG AND TRACE IN CLASSES
DAY 16 UNIT TEST PLAN
DAY 17 EXCEPTIONS IN VISUAL STUDIO
DAY 19 ADO.NET INTRODUCTION
DAY 20 DATA ACCESSING IN DOT NET
DAY 21 DATA BASE OBJECTS
No comments:
Post a Comment