Wednesday, 7 November 2007

Chapter 6, Lesson 1 - Drawing Graphics.

UI - brushes, pens, colours, fonts
lines, circles, shapes.

System.Drawing Namespace
  • circles, lines, create charts, edit/resize pics.
  • Graphics class - most used - mths for drawing to display device.
  • Pen class - draw lines & curves.
  • Brush class (abstract) - fills interiors of shapes.
  • PictureBox class - use in Windows Forms apps to display image as part of UI.
  • System.Drawing structures - Color, Point, Rectangle, Size.
  • Specify location of control - set control's Location property using Point structure - button1.Location = new Point(10,10);
  • Specify size of control - set control's Size property using Size structure - button1.Size = new Size(30,30);
  • Specify colour - Color structure -> ForeColor/BackColor.
  • Specify custom colour - Color.FromArgB() -> ForeColor/BackColor.
  • To draw on form/control - 1) create Graphics obj - System.Windows.Forms.Control.CreateGraphics(), 2) create Pen obj, 3) call member of Graphics class to draw on control. e.g. g.DrawLine(p,1,1,100,100);
  • endcaps - ends of a line.
  • Pens - can customiize Color + Size of Pen, and also Pattern (p.DashStyle = DashStyle.Dot) and Endcaps (StartCap/EndCap).
  • Filling shapes - most Graphics Draw mthds have corresponding Fill mthds, that require Brush instead of Pen.

No comments: