Showing posts with label C sharp How to create graphics in csharp. Show all posts
Showing posts with label C sharp How to create graphics in csharp. Show all posts

Tuesday, April 5, 2011

C sharp How to create graphics in csharp


Persistent Graphics
An important point to note before proceeding with is chapter is that simply creating a Graphics Object for a component and then drawing on that component does not create persistent graphics. In fact what will happen is that as soon as the window is minimized or obscured by another window the graphics will be erased.
For this reason, steps need to be taken to ensure that any graphics are persistent. Two mechanisms are available for achieving this. One is to repeatedly perform the drawing in thePaint() event handler of the control (which is triggered whenever the component needs to be redrawn), or to perform the drawing on a bitmap image in memory and then transfer that image to the component whenever the Paint() event is triggered. We will look at redrawing the graphics in the Paint() event in this chapter and Using Bitmaps for Persistent Graphics in C# 
Creating a Graphics Object
The first step in this tutorial is to create a new Visual Studio project called CSharpGraphics. With the new project created select the Form in the design area and click on the lightning bolt at the top of the Properties panel to list the events available for the Form. Double click the Paint event to display the code editing page.
Graphics Objects are created by calling the CreateGraphics() method of the component on which the drawing is to performed. For example, a Graphics Object can be created on our Form called Form1 by calling CreateGraphics() method as follows in the Paint() method:
       private void Form1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Graphics graphicsObj;

            graphicsObj = this.CreateGraphics();
        }
Now that we have a Graphic Object we need a Pen with which to draw.
Creating a Pen In C#

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...