KEMBAR78
31c | PPTX
C# Tutorial
Part 32: GDI
www.siri-kt.blogspot.com
• GDI(graphical designing interface):
• The c#.net windows application by default supports only GUI features using GUi
feature we can add all controls on the form container. using GDi we can give 2D & 3D
graphics‘ Microsoft assigned these features in the system.drawing.drawing2d;
• Graphics(class):
• using this class we can convert windows form mode into GDI mode.this class supports
3 predefined methods
• 1.Drawstring()
• 2.DrawImage()
• 3.DrawEllipse()
• 1.Drawstring():
• using this method we can display string value on the form container. this method takes
5 parameters
• 1.string
• 2.font
• 3.brush
• 4.form x-location
• 5.form y-location
• 1.take the form
• 2.add timer control(windows.forms.timer)
• goto-timer-properties-enabled=true interval=10
• source code:
• using System.Drawing.Drawing2D;
• string s = "INDIA";
• Font f = new Font("Ariel", 100);
• Graphics g;
• int i;
• private void timer1_Tick(object sender, EventArgs e)
• { LinearGradientBrush b = new LinearGradientBrush(new PointF(100, 100),
new PointF(200, i), Color.Red, Color.Green);
• g = this.CreateGraphics();
• g.DrawString(s, f, b, 100, 100);
• i++;
• if (i == 100)
• { i = 0; } }
• 2.DrawImage():
• using this method we can display image on the form container this method takes 2
parameters
• 1.image(image.fromfile("path"))
• 2.rectangle class
• Rectangle class:
• using this class we can display rectangle on this form conatiner.
• this class takes 4 constructor parameters
• 1.form x location
• 2.form y location
• 3.Rectangle width
• 4.Rectangle height
• Example on drawimage():
• 1.take the form
• 2.add timer control
• goto-timer-properties-enabled=true interval=10
• goto-solution explorer-add existing item-*.gif images
• source code:
• using System.Drawing.Drawing2D;
• Graphics g;
• int i;
• private void timer1_Tick(object sender, EventArgs e)
• { g = this.CreateGraphics();
• Rectangle r = new Rectangle(i, i, i, i);
g.DrawImage(Image.FromFile("E:7pmonlineDrawInageExampleDrawInageExampl
esmallSuccess.gif"),r);
• i++;
• if (i == 200)
• { i = 0;
• } }
• 3.DrawEllipse():
• using this method we can display ellipse on the from container this method takes
5-parameters
• 1.pen structure
• 2.form x-location
• 3.form y-location
• 4.ellipse height
• 5.ellipse width
• example on drawellipse():
• 1.take the form
• 2.add timer control
• goto-timer-properties-enabled=false,interval=10;
• form1-properties-windowstate=maximized
• form1-events-mousedown(doubleclick)
• form1-events-mouseup(doubleclick)
• source code:
• using System.Drawing.Drawing2D;
• int x, y;
• Graphics g;
• int i;
• private void Form1_MouseDown(object sender,
MouseEventArgs e)
• { x = e.X;
• y = e.Y;
• timer1.Enabled = true; }
• private void Form1_MouseUp(object sender,
MouseEventArgs e)
• { i = 0;
• timer1.Enabled = false; }
• private void timer1_Tick(object sender,
EventArgs e)
• { g = this.CreateGraphics();
• g.DrawEllipse(new Pen(new
SolidBrush(Color.Green), 1), x, y, i, i);
• i++; }
For more visit our website www.siri-kt.blogspot.com
Thanks for
Watching
More Angular JS TutorialsMore C sharp (c#) tutorials

31c

  • 1.
    C# Tutorial Part 32:GDI www.siri-kt.blogspot.com
  • 2.
    • GDI(graphical designinginterface): • The c#.net windows application by default supports only GUI features using GUi feature we can add all controls on the form container. using GDi we can give 2D & 3D graphics‘ Microsoft assigned these features in the system.drawing.drawing2d; • Graphics(class): • using this class we can convert windows form mode into GDI mode.this class supports 3 predefined methods • 1.Drawstring() • 2.DrawImage() • 3.DrawEllipse() • 1.Drawstring(): • using this method we can display string value on the form container. this method takes 5 parameters • 1.string • 2.font • 3.brush • 4.form x-location • 5.form y-location
  • 3.
    • 1.take theform • 2.add timer control(windows.forms.timer) • goto-timer-properties-enabled=true interval=10 • source code: • using System.Drawing.Drawing2D; • string s = "INDIA"; • Font f = new Font("Ariel", 100); • Graphics g; • int i; • private void timer1_Tick(object sender, EventArgs e) • { LinearGradientBrush b = new LinearGradientBrush(new PointF(100, 100), new PointF(200, i), Color.Red, Color.Green); • g = this.CreateGraphics(); • g.DrawString(s, f, b, 100, 100); • i++; • if (i == 100) • { i = 0; } }
  • 4.
    • 2.DrawImage(): • usingthis method we can display image on the form container this method takes 2 parameters • 1.image(image.fromfile("path")) • 2.rectangle class • Rectangle class: • using this class we can display rectangle on this form conatiner. • this class takes 4 constructor parameters • 1.form x location • 2.form y location • 3.Rectangle width • 4.Rectangle height • Example on drawimage(): • 1.take the form • 2.add timer control
  • 5.
    • goto-timer-properties-enabled=true interval=10 •goto-solution explorer-add existing item-*.gif images • source code: • using System.Drawing.Drawing2D; • Graphics g; • int i; • private void timer1_Tick(object sender, EventArgs e) • { g = this.CreateGraphics(); • Rectangle r = new Rectangle(i, i, i, i); g.DrawImage(Image.FromFile("E:7pmonlineDrawInageExampleDrawInageExampl esmallSuccess.gif"),r); • i++; • if (i == 200) • { i = 0; • } }
  • 6.
    • 3.DrawEllipse(): • usingthis method we can display ellipse on the from container this method takes 5-parameters • 1.pen structure • 2.form x-location • 3.form y-location • 4.ellipse height • 5.ellipse width • example on drawellipse(): • 1.take the form • 2.add timer control
  • 7.
    • goto-timer-properties-enabled=false,interval=10; • form1-properties-windowstate=maximized •form1-events-mousedown(doubleclick) • form1-events-mouseup(doubleclick) • source code: • using System.Drawing.Drawing2D; • int x, y; • Graphics g; • int i; • private void Form1_MouseDown(object sender, MouseEventArgs e) • { x = e.X; • y = e.Y; • timer1.Enabled = true; }
  • 8.
    • private voidForm1_MouseUp(object sender, MouseEventArgs e) • { i = 0; • timer1.Enabled = false; } • private void timer1_Tick(object sender, EventArgs e) • { g = this.CreateGraphics(); • g.DrawEllipse(new Pen(new SolidBrush(Color.Green), 1), x, y, i, i); • i++; }
  • 9.
    For more visitour website www.siri-kt.blogspot.com Thanks for Watching More Angular JS TutorialsMore C sharp (c#) tutorials