What is GDI+ :
This technique is the upgraded version of the GDI are used in the drawing for the making new tools, or for any purpose that needs to draw such a chart ...
Principles in the GDI +:
Create a new project Windows Forms Application, and then place a button on the form and type in the event Click:
This technique is the upgraded version of the GDI are used in the drawing for the making new tools, or for any purpose that needs to draw such a chart ...
Principles in the GDI +:
Create a new project Windows Forms Application, and then place a button on the form and type in the event Click:
Graphics myg = this.CreateGraphics();
Pen myp = new Pen(Brushes.Red, 2);
myg.DrawLine(myp, 0, 0, this.Width, this.Height);
myg.Dispose();The code will draw a red line of the upper-right corner of the form to the lower right corner ...
What happened?
- When we declare the Graphics object to be used, we did so, as shown and as we draw outside Paint event you must use this way ...
- When we declare the object Pen we have specify the red color and width 2 pixel ...
- We draw a line by the variable myg which we declare it as Graphics by the the sub DrawLine
This sub is used as follows:
DrawLine(FirstX, FirstY, SecX, SecY);
Examples:
- Drawing dotted frame:
Graphics myg = this.CreateGraphics();
Pen myp = new Pen(Brushes.Red, 2);
myp.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
myg.DrawRectangle(myp, 5, 5, 100, 100);
myg.Dispose();- Draw a triangle:
Graphics myg = this.CreateGraphics();
Pen myp = new Pen(Brushes.Red, 2);
System.Drawing.Drawing2D.GraphicsPath mypath = new System.Drawing.Drawing2D.GraphicsPath();
mypath.AddLine(new Point(10, 10), new Point(50, 50));
mypath.AddLine(new Point(50, 50), new Point(10, 50));
mypath.AddLine(new Point(10, 50), new Point(10, 10));
myg.DrawPath(myp, mypath);
myg.Dispose(); - Fill a rectangle:
Graphics myg = this.CreateGraphics();
myg.FillRectangle(Brushes.Gray, new Rectangle(50, 50, 400, 400));
myg.Dispose();
This was just a simple introduction to dealing with the 2D graphics library using GDI + ... And there is still more to learn
very good start in gdi+
ReplyDeletethanks
very usefull notes and we need more information on this topic please post updated data . thanks for your post.
ReplyDeleteDot net online tutorials