1 / 14

CST238 Week 5

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

celina
Download Presentation

CST238 Week 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. Recap • Timer • Tick event • DateTime • Get current date / time • MDI applications • Main form • Child form (set its MDIparent to main form)

  3. 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.

  4. 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

  5. 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

  6. 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;

  7. 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.

  8. Grid System X Y (X, Y)

  9. 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

  10. Methods of the Graphics class • Draw methods • DrawLine, DrawArc, DrawImage, DrawEllipse, DrawRectangle • Fill methods • FillEllipse, FillPolygon, FillRectangle

  11. 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

  12. Form: Size (300, 300) Form’s ClientRectangle (284, 262)

  13. 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.

More Related