CST238 Week 5 Questions / Concerns? Announcements – HW#1 due (Project ideas) – Check-off Take...

14
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

Transcript of CST238 Week 5 Questions / Concerns? Announcements – HW#1 due (Project ideas) – Check-off Take...

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

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

Page 2: 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.

Recap• Timer– Tick event

• DateTime– Get current date / time

• MDI applications– Main form– Child form (set its MDIparent to main form)

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

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.

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

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

Page 6: 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.

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

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

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;

Page 8: 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.

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.

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

Grid System XY

(X, Y)

Page 10: 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.

Drawing• Drawing procedure:

1. Obtain a Graphics object.2. Obtain a tool to use on the Graphics object.

- pen, brushes, fonts, etc.

3. Call methods on the Graphics object to draw your picture.

4. Trigger redraw is necessary by Invalidate the form or control

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

Methods of the Graphics class• Draw methods– DrawLine, DrawArc, DrawImage, DrawEllipse,

DrawRectangle• Fill methods– FillEllipse, FillPolygon, FillRectangle

Page 12: 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.

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

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

Form: Size

Form’s ClientRectangle

(284, 262)

(300, 300)

Page 14: 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.

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.