140 likes | 260 Views
CST238 Week 5. Questions / Concerns? Announcements HW#1 due (Project ideas) Check-off Take Home lab#4 Recap New topics Drawing Coming up: GUI Bloopers presentations start next Monday (#1&#2) Test#1 Take Home Lab#5. Recap. Timer Tick event DateTime Get current date / time
E N D
CST238 Week 5 • Questions / Concerns? • Announcements • HW#1 due (Project ideas) • Check-off Take Home lab#4 • Recap • New topics • Drawing • Coming up: • GUI Bloopers presentations start next Monday (#1) • Test#1 • Take Home Lab#5
Recap • Timer • Tick event • DateTime • Get current date / time • MDI applications • Main form • Child form (set its MDIparent to main form)
GUI Blooper Presentations • Limit your presentation to 30 minutes. Both team members need to present. • Summary the key points in the chapter. • Show examples given in the book. • When possible, show actual GUI examples from applications/websites that you have used.
Drawing • You need the Graphics class from System.Drawing namespace. • Two ways to get a Graphics object • Create a new that’s associated with the form or control • Grab the Graphics object in the Paint event’s PaintEventArgs
Drawing • There are 2 types of draw: • Immediate Draw • Not updated after form resize, covered or uncovered. • Redraw • Updated each time a form is updated. • This is done through Paint event. • This event can be triggered using Invalidate
Drawing • Get Graphics object: • Create a Graphics object for the form or control Graphics g = this.CreateGraphics(); Graphics g = pictureBox1.CreateGraphics(); • void DrawingForm_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics;
Drawing • Classes that you might need: • Color • Brushes • Pens • Read Chapter 5, 6 & 7 in the Chris Sells book as reference on different shapes to draw and different pens and brushes to use.
Grid System X Y (X, Y)
Drawing • Drawing procedure: • Obtain a Graphics object. • Obtain a tool to use on the Graphics object. - pen, brushes, fonts, etc. • Call methods on the Graphics object to draw your picture. • Trigger redraw is necessary by Invalidate the form or control
Methods of the Graphics class • Draw methods • DrawLine, DrawArc, DrawImage, DrawEllipse, DrawRectangle • Fill methods • FillEllipse, FillPolygon, FillRectangle
Drawing • Drawing directly on the form • Know the size of the form • Drawing on one of the controls • Panel • PictureBox • Use the Width and Height for the control
Form: Size (300, 300) Form’s ClientRectangle (284, 262)
Take Home Lab #5 • Draw a static picture. • Try different styles of pens and brushes. • Try different shapes, lines, images, text. • Add some immediately drawn shapes via a button, but keep the main picture updated. • Be creative but it doesn’t have to be very complex or fancy.